Bug 783021 - System time: listen to timezone settings changes and update system timezone (part 1). r=cjones
authorGene Lian <clian@mozilla.com>
Thu, 23 Aug 2012 17:00:00 +0800
changeset 111068 1b122d9184be8dfcc575dd24b9daa21078b46b84
parent 111067 ec37fd0db0021e7d86339225b3b27c75001d9450
child 111069 1e7f78ac0e78d617f5926e490607b2de8bc30bf8
push id239
push userakeybl@mozilla.com
push dateThu, 03 Jan 2013 21:54:43 +0000
treeherdermozilla-release@3a7b66445659 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs783021
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 783021 - System time: listen to timezone settings changes and update system timezone (part 1). r=cjones
hal/Hal.cpp
hal/Hal.h
hal/fallback/FallbackTime.cpp
hal/gonk/GonkHal.cpp
hal/sandbox/PHal.ipdl
hal/sandbox/SandboxHal.cpp
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -427,16 +427,23 @@ AdjustSystemClock(int32_t aDeltaMillisec
 
 void 
 SetTimezone(const nsCString& aTimezoneSpec)
 {
   AssertMainThread();
   PROXY_IF_SANDBOXED(SetTimezone(aTimezoneSpec));
 }
 
+nsCString
+GetTimezone()
+{
+  AssertMainThread();
+  RETURN_PROXY_IF_SANDBOXED(GetTimezone());
+}
+
 void
 EnableSensorNotifications(SensorType aSensor) {
   AssertMainThread();
   PROXY_IF_SANDBOXED(EnableSensorNotifications(aSensor));
 }
 
 void
 DisableSensorNotifications(SensorType aSensor) {
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -245,16 +245,22 @@ void AdjustSystemClock(int32_t aDeltaMil
 /**
  * Set timezone
  * @param aTimezoneSpec The definition can be found in 
  * http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  */
 void SetTimezone(const nsCString& aTimezoneSpec);
 
 /**
+ * Get timezone
+ * http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
+ */
+nsCString GetTimezone();
+
+/**
  * Reboot the device.
  */
 void Reboot();
 
 /**
  * Power off the device.
  */
 void PowerOff();
--- a/hal/fallback/FallbackTime.cpp
+++ b/hal/fallback/FallbackTime.cpp
@@ -13,10 +13,16 @@ namespace hal_impl {
 void 
 AdjustSystemClock(int32_t aDeltaMilliseconds)
 {}
 
 void
 SetTimezone(const nsCString& aTimezoneSpec)
 {}
 
+nsCString
+GetTimezone()
+{
+  return EmptyCString();
+}
+
 } // namespace hal_impl
 } // namespace mozilla
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -607,16 +607,24 @@ void
 SetTimezone(const nsCString& aTimezoneSpec)
 { 
   property_set("persist.sys.timezone", aTimezoneSpec.get());
   // this function is automatically called by the other time conversion 
   // functions that depend on the timezone. To be safe, we call it manually.  
   tzset();
 }
 
+nsCString 
+GetTimezone()
+{
+  char timezone[32];
+  property_get("persist.sys.timezone", timezone, "");
+  return nsCString(timezone);
+}
+
 // Nothing to do here.  Gonk widgetry always listens for screen
 // orientation changes.
 void
 EnableScreenConfigurationNotifications()
 {
 }
 
 void
--- a/hal/sandbox/PHal.ipdl
+++ b/hal/sandbox/PHal.ipdl
@@ -104,19 +104,21 @@ parent:
     sync GetScreenEnabled() returns (bool enabled);
     SetScreenEnabled(bool enabled);
 
     sync GetCpuSleepAllowed() returns (bool allowed);
     SetCpuSleepAllowed(bool allowed);
 
     sync GetScreenBrightness() returns (double brightness);
     SetScreenBrightness(double brightness);
-    
+
     AdjustSystemClock(int32 aDeltaMilliseconds);
     SetTimezone(nsCString aTimezoneSpec);
+    sync GetTimezone()
+      returns (nsCString aTimezoneSpec);
 
     sync SetLight(LightType light, LightConfiguration aConfig)
       returns (bool status);
     sync GetLight(LightType light)
       returns (LightConfiguration aConfig, bool status);
 
     Reboot();
     PowerOff();
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -190,16 +190,24 @@ AdjustSystemClock(int32_t aDeltaMillisec
 }
 
 void
 SetTimezone(const nsCString& aTimezoneSpec)
 {
   Hal()->SendSetTimezone(nsCString(aTimezoneSpec));
 } 
 
+nsCString
+GetTimezone()
+{
+  nsCString timezone;
+  Hal()->SendGetTimezone(&timezone);
+  return timezone;
+}
+
 void
 Reboot()
 {
   Hal()->SendReboot();
 }
 
 void
 PowerOff()
@@ -527,16 +535,26 @@ public:
     if (!AppProcessHasPermission(this, "systemclock-write")) {
       return false;
     }
     hal::SetTimezone(aTimezoneSpec);
     return true;  
   }
 
   virtual bool
+  RecvGetTimezone(nsCString *aTimezoneSpec) MOZ_OVERRIDE
+  {
+    if (!AppProcessHasPermission(this, "systemclock-read")) {
+      return false;
+    }
+    *aTimezoneSpec = hal::GetTimezone();
+    return true;
+  }
+
+  virtual bool
   RecvReboot() MOZ_OVERRIDE
   {
     if (!AppProcessHasPermission(this, "power")) {
       return false;
     }
     hal::Reboot();
     return true;
   }