Bug 783021 - System time: listen to timezone settings changes and update system timezone (part 1). r=cjones

This commit is contained in:
Gene Lian 2012-08-23 17:00:00 +08:00
parent ad2138e8cd
commit 468c7c6ef3
6 changed files with 48 additions and 1 deletions

View File

@ -432,6 +432,13 @@ SetTimezone(const nsCString& aTimezoneSpec)
PROXY_IF_SANDBOXED(SetTimezone(aTimezoneSpec));
}
nsCString
GetTimezone()
{
AssertMainThread();
RETURN_PROXY_IF_SANDBOXED(GetTimezone());
}
void
EnableSensorNotifications(SensorType aSensor) {
AssertMainThread();

View File

@ -249,6 +249,12 @@ void AdjustSystemClock(int32_t aDeltaMilliseconds);
*/
void SetTimezone(const nsCString& aTimezoneSpec);
/**
* Get timezone
* http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
*/
nsCString GetTimezone();
/**
* Reboot the device.
*/

View File

@ -18,5 +18,11 @@ void
SetTimezone(const nsCString& aTimezoneSpec)
{}
nsCString
GetTimezone()
{
return EmptyCString();
}
} // namespace hal_impl
} // namespace mozilla

View File

@ -612,6 +612,14 @@ SetTimezone(const nsCString& aTimezoneSpec)
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

View File

@ -109,9 +109,11 @@ parent:
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);

View File

@ -195,6 +195,14 @@ SetTimezone(const nsCString& aTimezoneSpec)
Hal()->SendSetTimezone(nsCString(aTimezoneSpec));
}
nsCString
GetTimezone()
{
nsCString timezone;
Hal()->SendGetTimezone(&timezone);
return timezone;
}
void
Reboot()
{
@ -531,6 +539,16 @@ public:
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
{