From e6f31e38a92eaeec2d5656303be9697ef760ef40 Mon Sep 17 00:00:00 2001 From: Gene Lian Date: Tue, 23 Oct 2012 15:15:43 +0800 Subject: [PATCH] Bug 801096 - [settings] Set-Automatically for time should take effect *immediately* instead of waiting on next NITZ coming (part 1). r=jlebar --- dom/alarm/AlarmHalService.cpp | 32 +++++--------- dom/alarm/AlarmHalService.h | 18 ++++---- dom/time/DateCacheCleaner.cpp | 12 ++--- dom/time/TimeChangeObserver.cpp | 37 +++++++++++++--- dom/time/TimeChangeObserver.h | 16 +++++-- hal/Hal.cpp | 78 +++++++++++++++++++++++---------- hal/Hal.h | 40 +++++++++++++---- hal/HalInternal.h | 18 ++++++-- hal/HalTypes.h | 18 -------- hal/fallback/FallbackTime.cpp | 15 ++++++- hal/gonk/GonkHal.cpp | 36 +++++++++++++-- hal/sandbox/PHal.ipdl | 17 +++++-- hal/sandbox/SandboxHal.cpp | 68 ++++++++++++++++++++++------ 13 files changed, 281 insertions(+), 124 deletions(-) diff --git a/dom/alarm/AlarmHalService.cpp b/dom/alarm/AlarmHalService.cpp index 851c1a4f34ff0..e6cc50485f354 100644 --- a/dom/alarm/AlarmHalService.cpp +++ b/dom/alarm/AlarmHalService.cpp @@ -19,20 +19,20 @@ AlarmHalService::Init() if (!mAlarmEnabled) { return; } - RegisterSystemTimeChangeObserver(this); + RegisterSystemTimezoneChangeObserver(this); } /* virtual */ AlarmHalService::~AlarmHalService() { if (mAlarmEnabled) { UnregisterTheOneAlarmObserver(); - UnregisterSystemTimeChangeObserver(this); + UnregisterSystemTimezoneChangeObserver(this); } } /* static */ StaticRefPtr AlarmHalService::sSingleton; -/* static */ already_AddRefed +/* static */ already_AddRefed AlarmHalService::GetInstance() { if (!sSingleton) { @@ -41,7 +41,7 @@ AlarmHalService::GetInstance() ClearOnShutdown(&sSingleton); } - nsCOMPtr service(do_QueryInterface(sSingleton)); + nsRefPtr service = sSingleton.get(); return service.forget(); } @@ -76,7 +76,7 @@ AlarmHalService::SetTimezoneChangedCb(nsITimezoneChangedCb* aTimeZoneChangedCb) } void -AlarmHalService::Notify(const mozilla::void_t& aVoid) +AlarmHalService::Notify(const void_t& aVoid) { if (!mAlarmFiredCb) { return; @@ -85,26 +85,14 @@ AlarmHalService::Notify(const mozilla::void_t& aVoid) } void -AlarmHalService::Notify(const SystemTimeChange& aReason) +AlarmHalService::Notify( + const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) { - if (aReason != SYS_TIME_CHANGE_TZ || !mTimezoneChangedCb) { + if (!mTimezoneChangedCb) { return; } - mTimezoneChangedCb->OnTimezoneChanged(GetTimezoneOffset(false)); -} - -int32_t -AlarmHalService::GetTimezoneOffset(bool aIgnoreDST) -{ - PRExplodedTime prTime; - PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &prTime); - - int32_t offset = prTime.tm_params.tp_gmt_offset; - if (!aIgnoreDST) { - offset += prTime.tm_params.tp_dst_offset; - } - - return -(offset / 60); + mTimezoneChangedCb->OnTimezoneChanged( + aSystemTimezoneChangeInfo.newTimezoneOffsetMinutes()); } } // alarm diff --git a/dom/alarm/AlarmHalService.h b/dom/alarm/AlarmHalService.h index 5bdcb2184456d..4578a86fd12ab 100644 --- a/dom/alarm/AlarmHalService.h +++ b/dom/alarm/AlarmHalService.h @@ -13,17 +13,17 @@ #include "nsIAlarmHalService.h" #include "nsIObserver.h" #include "nsIObserverService.h" -#include "prtime.h" namespace mozilla { namespace dom { namespace alarm { - -using namespace hal; + +typedef Observer AlarmObserver; +typedef Observer SystemTimezoneChangeObserver; class AlarmHalService : public nsIAlarmHalService, public AlarmObserver, - public SystemTimeObserver + public SystemTimezoneChangeObserver { public: NS_DECL_ISUPPORTS @@ -32,13 +32,13 @@ class AlarmHalService : public nsIAlarmHalService, void Init(); virtual ~AlarmHalService(); - static already_AddRefed GetInstance(); + static already_AddRefed GetInstance(); // Implementing hal::AlarmObserver - void Notify(const mozilla::void_t& aVoid); + void Notify(const void_t& aVoid); - // Implementing hal::SystemTimeObserver - void Notify(const SystemTimeChange& aReason); + // Implementing hal::SystemTimezoneChangeObserver + void Notify(const hal::SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo); private: bool mAlarmEnabled; @@ -46,8 +46,6 @@ class AlarmHalService : public nsIAlarmHalService, nsCOMPtr mAlarmFiredCb; nsCOMPtr mTimezoneChangedCb; - - int32_t GetTimezoneOffset(bool aIgnoreDST); }; } // namespace alarm diff --git a/dom/time/DateCacheCleaner.cpp b/dom/time/DateCacheCleaner.cpp index ccba359aa6f75..fbdae8d18def4 100644 --- a/dom/time/DateCacheCleaner.cpp +++ b/dom/time/DateCacheCleaner.cpp @@ -16,24 +16,20 @@ namespace mozilla { namespace dom { namespace time { -class DateCacheCleaner : public SystemTimeChangeObserver +class DateCacheCleaner : public SystemTimezoneChangeObserver { public: DateCacheCleaner() { - RegisterSystemTimeChangeObserver(this); + RegisterSystemTimezoneChangeObserver(this); } ~DateCacheCleaner() { - UnregisterSystemTimeChangeObserver(this); + UnregisterSystemTimezoneChangeObserver(this); } - void Notify(const SystemTimeChange& aReason) + void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) { - if (aReason == SYS_TIME_CHANGE_CLOCK) { - return; - } - nsCOMPtr stack = do_GetService("@mozilla.org/js/xpc/ContextStack;1"); if (!stack) { diff --git a/dom/time/TimeChangeObserver.cpp b/dom/time/TimeChangeObserver.cpp index 27e2478da178b..453dc86854e6f 100644 --- a/dom/time/TimeChangeObserver.cpp +++ b/dom/time/TimeChangeObserver.cpp @@ -9,9 +9,11 @@ #include "nsPIDOMWindow.h" #include "nsDOMEvent.h" #include "nsContentUtils.h" +#include "nsIObserverService.h" -using namespace mozilla::hal; using namespace mozilla; +using namespace mozilla::hal; +using namespace mozilla::services; StaticAutoPtr sObserver; @@ -27,11 +29,12 @@ nsSystemTimeChangeObserver* nsSystemTimeChangeObserver::GetInstance() nsSystemTimeChangeObserver::~nsSystemTimeChangeObserver() { mWindowListeners.Clear(); - UnregisterSystemTimeChangeObserver(this); + UnregisterSystemClockChangeObserver(this); + UnregisterSystemTimezoneChangeObserver(this); } void -nsSystemTimeChangeObserver::Notify(const SystemTimeChange& aReason) +nsSystemTimeChangeObserver::FireMozTimeChangeEvent() { //Copy mWindowListeners and iterate over windowListeners instead because //mWindowListeners may be modified while we loop. @@ -58,6 +61,28 @@ nsSystemTimeChangeObserver::Notify(const SystemTimeChange& aReason) } } +void +nsSystemTimeChangeObserver::Notify(const int64_t& aClockDeltaMS) +{ + // Notify observers that the system clock has been adjusted. + nsCOMPtr observerService = GetObserverService(); + if (observerService) { + nsString dataStr; + dataStr.AppendFloat(static_cast(aClockDeltaMS)); + observerService->NotifyObservers( + nullptr, "system-clock-change", dataStr.get()); + } + + FireMozTimeChangeEvent(); +} + +void +nsSystemTimeChangeObserver::Notify( + const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) +{ + FireMozTimeChangeEvent(); +} + nsresult nsSystemTimeChangeObserver::AddWindowListener(nsIDOMWindow* aWindow) { @@ -80,7 +105,8 @@ nsSystemTimeChangeObserver::AddWindowListenerImpl(nsIDOMWindow* aWindow) } if (mWindowListeners.Length() == 0) { - RegisterSystemTimeChangeObserver(sObserver); + RegisterSystemClockChangeObserver(sObserver); + RegisterSystemTimezoneChangeObserver(sObserver); } mWindowListeners.AppendElement(windowWeakRef); @@ -103,7 +129,8 @@ nsSystemTimeChangeObserver::RemoveWindowListenerImpl(nsIDOMWindow* aWindow) mWindowListeners.RemoveElement(NS_GetWeakReference(aWindow)); if (mWindowListeners.Length() == 0) { - UnregisterSystemTimeChangeObserver(sObserver); + UnregisterSystemClockChangeObserver(sObserver); + UnregisterSystemTimezoneChangeObserver(sObserver); } return NS_OK; diff --git a/dom/time/TimeChangeObserver.h b/dom/time/TimeChangeObserver.h index b94e206443737..91b6a6bc31f32 100644 --- a/dom/time/TimeChangeObserver.h +++ b/dom/time/TimeChangeObserver.h @@ -12,14 +12,23 @@ #include "nsPIDOMWindow.h" #include "nsWeakPtr.h" -typedef mozilla::Observer SystemTimeChangeObserver; +typedef mozilla::Observer SystemClockChangeObserver; +typedef mozilla::Observer SystemTimezoneChangeObserver; -class nsSystemTimeChangeObserver : public SystemTimeChangeObserver +class nsSystemTimeChangeObserver : public SystemClockChangeObserver, + public SystemTimezoneChangeObserver { public: static nsSystemTimeChangeObserver* GetInstance(); virtual ~nsSystemTimeChangeObserver(); - void Notify(const mozilla::hal::SystemTimeChange& aReason); + + // Implementing hal::SystemClockChangeObserver::Notify() + void Notify(const int64_t& aClockDeltaMS); + + // Implementing hal::SystemTimezoneChangeObserver::Notify() + void Notify( + const mozilla::hal::SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo); + static nsresult AddWindowListener(nsIDOMWindow* aWindow); static nsresult RemoveWindowListener(nsIDOMWindow* aWindow); private: @@ -27,6 +36,7 @@ class nsSystemTimeChangeObserver : public SystemTimeChangeObserver nsresult RemoveWindowListenerImpl(nsIDOMWindow* aWindow); nsSystemTimeChangeObserver() { }; nsTArray mWindowListeners; + void FireMozTimeChangeEvent(); }; #endif //_mozilla_time_change_observer_h_ diff --git a/hal/Hal.cpp b/hal/Hal.cpp index e08206a9db7aa..e52104fe5f0fd 100644 --- a/hal/Hal.cpp +++ b/hal/Hal.cpp @@ -405,52 +405,86 @@ void SetScreenBrightness(double brightness) PROXY_IF_SANDBOXED(SetScreenBrightness(clamped(brightness, 0.0, 1.0))); } -bool SetLight(LightType light, const hal::LightConfiguration& aConfig) +bool SetLight(LightType light, const LightConfiguration& aConfig) { AssertMainThread(); RETURN_PROXY_IF_SANDBOXED(SetLight(light, aConfig), false); } -bool GetLight(LightType light, hal::LightConfiguration* aConfig) +bool GetLight(LightType light, LightConfiguration* aConfig) { AssertMainThread(); RETURN_PROXY_IF_SANDBOXED(GetLight(light, aConfig), false); } -class SystemTimeObserversManager : public ObserversManager +class SystemClockChangeObserversManager : public ObserversManager { protected: void EnableNotifications() { - PROXY_IF_SANDBOXED(EnableSystemTimeChangeNotifications()); + PROXY_IF_SANDBOXED(EnableSystemClockChangeNotifications()); } void DisableNotifications() { - PROXY_IF_SANDBOXED(DisableSystemTimeChangeNotifications()); + PROXY_IF_SANDBOXED(DisableSystemClockChangeNotifications()); } }; -static SystemTimeObserversManager sSystemTimeObservers; +static SystemClockChangeObserversManager sSystemClockChangeObservers; void -RegisterSystemTimeChangeObserver(SystemTimeObserver *aObserver) +RegisterSystemClockChangeObserver(SystemClockChangeObserver* aObserver) { AssertMainThread(); - sSystemTimeObservers.AddObserver(aObserver); + sSystemClockChangeObservers.AddObserver(aObserver); } void -UnregisterSystemTimeChangeObserver(SystemTimeObserver *aObserver) +UnregisterSystemClockChangeObserver(SystemClockChangeObserver* aObserver) { AssertMainThread(); - sSystemTimeObservers.RemoveObserver(aObserver); + sSystemClockChangeObservers.RemoveObserver(aObserver); } void -NotifySystemTimeChange(const hal::SystemTimeChange& aReason) +NotifySystemClockChange(const int64_t& aClockDeltaMS) { - sSystemTimeObservers.BroadcastInformation(aReason); + sSystemClockChangeObservers.BroadcastInformation(aClockDeltaMS); } - + +class SystemTimezoneChangeObserversManager : public ObserversManager +{ +protected: + void EnableNotifications() { + PROXY_IF_SANDBOXED(EnableSystemTimezoneChangeNotifications()); + } + + void DisableNotifications() { + PROXY_IF_SANDBOXED(DisableSystemTimezoneChangeNotifications()); + } +}; + +static SystemTimezoneChangeObserversManager sSystemTimezoneChangeObservers; + +void +RegisterSystemTimezoneChangeObserver(SystemTimezoneChangeObserver* aObserver) +{ + AssertMainThread(); + sSystemTimezoneChangeObservers.AddObserver(aObserver); +} + +void +UnregisterSystemTimezoneChangeObserver(SystemTimezoneChangeObserver* aObserver) +{ + AssertMainThread(); + sSystemTimezoneChangeObservers.RemoveObserver(aObserver); +} + +void +NotifySystemTimezoneChange(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) +{ + sSystemTimezoneChangeObservers.BroadcastInformation(aSystemTimezoneChangeInfo); +} + void AdjustSystemClock(int64_t aDeltaMilliseconds) { @@ -607,8 +641,8 @@ UnregisterWakeLockObserver(WakeLockObserver* aObserver) void ModifyWakeLock(const nsAString &aTopic, - hal::WakeLockControl aLockAdjust, - hal::WakeLockControl aHiddenAdjust) + WakeLockControl aLockAdjust, + WakeLockControl aHiddenAdjust) { AssertMainThread(); PROXY_IF_SANDBOXED(ModifyWakeLock(aTopic, aLockAdjust, aHiddenAdjust)); @@ -671,18 +705,18 @@ UnlockScreenOrientation() } void -EnableSwitchNotifications(hal::SwitchDevice aDevice) { +EnableSwitchNotifications(SwitchDevice aDevice) { AssertMainThread(); PROXY_IF_SANDBOXED(EnableSwitchNotifications(aDevice)); } void -DisableSwitchNotifications(hal::SwitchDevice aDevice) { +DisableSwitchNotifications(SwitchDevice aDevice) { AssertMainThread(); PROXY_IF_SANDBOXED(DisableSwitchNotifications(aDevice)); } -hal::SwitchState GetCurrentSwitchState(hal::SwitchDevice aDevice) +SwitchState GetCurrentSwitchState(SwitchDevice aDevice) { AssertMainThread(); RETURN_PROXY_IF_SANDBOXED(GetCurrentSwitchState(aDevice), SWITCH_STATE_UNKNOWN); @@ -693,7 +727,7 @@ typedef mozilla::ObserverList SwitchObserverList; static SwitchObserverList *sSwitchObserverLists = NULL; static SwitchObserverList& -GetSwitchObserverList(hal::SwitchDevice aDevice) { +GetSwitchObserverList(SwitchDevice aDevice) { MOZ_ASSERT(0 <= aDevice && aDevice < NUM_SWITCH_DEVICE); if (sSwitchObserverLists == NULL) { sSwitchObserverLists = new SwitchObserverList[NUM_SWITCH_DEVICE]; @@ -714,7 +748,7 @@ ReleaseObserversIfNeeded() { } void -RegisterSwitchObserver(hal::SwitchDevice aDevice, hal::SwitchObserver *aObserver) +RegisterSwitchObserver(SwitchDevice aDevice, SwitchObserver *aObserver) { AssertMainThread(); SwitchObserverList& observer = GetSwitchObserverList(aDevice); @@ -725,7 +759,7 @@ RegisterSwitchObserver(hal::SwitchDevice aDevice, hal::SwitchObserver *aObserver } void -UnregisterSwitchObserver(hal::SwitchDevice aDevice, hal::SwitchObserver *aObserver) +UnregisterSwitchObserver(SwitchDevice aDevice, SwitchObserver *aObserver) { AssertMainThread(); @@ -743,7 +777,7 @@ UnregisterSwitchObserver(hal::SwitchDevice aDevice, hal::SwitchObserver *aObserv } void -NotifySwitchChange(const hal::SwitchEvent& aEvent) +NotifySwitchChange(const SwitchEvent& aEvent) { // When callback this notification, main thread may call unregister function // first. We should check if this pointer is valid. diff --git a/hal/Hal.h b/hal/Hal.h index 2dd7ca7286b6d..103ee5b94113c 100644 --- a/hal/Hal.h +++ b/hal/Hal.h @@ -50,7 +50,8 @@ class WindowIdentifier; extern PRLogModuleInfo *sHalLog; #define HAL_LOG(msg) PR_LOG(mozilla::hal::sHalLog, PR_LOG_DEBUG, msg) -typedef Observer SystemTimeObserver; +typedef Observer SystemClockChangeObserver; +typedef Observer SystemTimezoneChangeObserver; } // namespace hal @@ -258,22 +259,45 @@ void SetTimezone(const nsCString& aTimezoneSpec); nsCString GetTimezone(); /** - * Register observer for system time changed notification. + * Register observer for system clock changed notification. * @param aObserver The observer that should be added. */ -void RegisterSystemTimeChangeObserver(hal::SystemTimeObserver* aObserver); +void RegisterSystemClockChangeObserver( + hal::SystemClockChangeObserver* aObserver); /** - * Unregister the observer for system time changed. + * Unregister the observer for system clock changed. * @param aObserver The observer that should be removed. */ -void UnregisterSystemTimeChangeObserver(hal::SystemTimeObserver* aObserver); +void UnregisterSystemClockChangeObserver( + hal::SystemClockChangeObserver* aObserver); /** - * Notify of a change in the system cloeck or time zone. - * @param aReason + * Notify of a change in the system clock. + * @param aClockDeltaMS */ -void NotifySystemTimeChange(const hal::SystemTimeChange& aReason); +void NotifySystemClockChange(const int64_t& aClockDeltaMS); + +/** + * Register observer for system timezone changed notification. + * @param aObserver The observer that should be added. + */ +void RegisterSystemTimezoneChangeObserver( + hal::SystemTimezoneChangeObserver* aObserver); + +/** + * Unregister the observer for system timezone changed. + * @param aObserver The observer that should be removed. + */ +void UnregisterSystemTimezoneChangeObserver( + hal::SystemTimezoneChangeObserver* aObserver); + +/** + * Notify of a change in the system timezone. + * @param aSystemTimezoneChangeInfo + */ +void NotifySystemTimezoneChange( + const hal::SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo); /** * Reboot the device. diff --git a/hal/HalInternal.h b/hal/HalInternal.h index 71a1315f01ad2..e42672e0e08ee 100644 --- a/hal/HalInternal.h +++ b/hal/HalInternal.h @@ -75,14 +75,24 @@ bool EnableAlarm(); void DisableAlarm(); /** - * Enable system time change notifications from the backend. + * Enable system clock change notifications from the backend. */ -void EnableSystemTimeChangeNotifications(); +void EnableSystemClockChangeNotifications(); /** - * Disable system time change notifications from the backend. + * Disable system clock change notifications from the backend. */ -void DisableSystemTimeChangeNotifications(); +void DisableSystemClockChangeNotifications(); + +/** + * Enable system timezone change notifications from the backend. + */ +void EnableSystemTimezoneChangeNotifications(); + +/** + * Disable system timezone change notifications from the backend. + */ +void DisableSystemTimezoneChangeNotifications(); bool IsHalChildLive(); } // namespace MOZ_HAL_NAMESPACE diff --git a/hal/HalTypes.h b/hal/HalTypes.h index 70368cb4092e8..0a3d25293fe2e 100644 --- a/hal/HalTypes.h +++ b/hal/HalTypes.h @@ -84,13 +84,6 @@ enum WakeLockControl { NUM_WAKE_LOCK }; -enum SystemTimeChange { - SYS_TIME_CHANGE_UNKNOWN = -1, - SYS_TIME_CHANGE_CLOCK, - SYS_TIME_CHANGE_TZ, - SYS_TIME_CHANGE_GUARD -}; - class FMRadioOperationInformation; enum FMRadioOperation { @@ -167,7 +160,6 @@ enum FMRadioCountry { }; typedef Observer FMRadioObserver; -typedef Observer SystemTimeChangeObserver; } // namespace hal } // namespace mozilla @@ -250,16 +242,6 @@ struct ParamTraits: mozilla::hal::NUM_PROCESS_PRIORITY> { }; -/** - * SystemTimeChange serializer. - */ -template <> -struct ParamTraits - : public EnumSerializer -{}; - /** * Serializer for FMRadioOperation */ diff --git a/hal/fallback/FallbackTime.cpp b/hal/fallback/FallbackTime.cpp index 8f65d6680aba9..ac9d8eb24dd2f 100644 --- a/hal/fallback/FallbackTime.cpp +++ b/hal/fallback/FallbackTime.cpp @@ -25,13 +25,24 @@ GetTimezone() } void -EnableSystemTimeChangeNotifications() +EnableSystemClockChangeNotifications() { } void -DisableSystemTimeChangeNotifications() +DisableSystemClockChangeNotifications() { } + +void +EnableSystemTimezoneChangeNotifications() +{ +} + +void +DisableSystemTimezoneChangeNotifications() +{ +} + } // namespace hal_impl } // namespace mozilla diff --git a/hal/gonk/GonkHal.cpp b/hal/gonk/GonkHal.cpp index 12a333f61ae53..e558be95fd7ed 100644 --- a/hal/gonk/GonkHal.cpp +++ b/hal/gonk/GonkHal.cpp @@ -643,7 +643,21 @@ AdjustSystemClock(int64_t aDeltaMilliseconds) return; } - hal::NotifySystemTimeChange(hal::SYS_TIME_CHANGE_CLOCK); + hal::NotifySystemClockChange(aDeltaMilliseconds); +} + +static int32_t +GetTimezoneOffset() +{ + PRExplodedTime prTime; + PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &prTime); + + // Daylight saving time (DST) will be taken into account. + int32_t offset = prTime.tm_params.tp_gmt_offset; + offset += prTime.tm_params.tp_dst_offset; + + // Returns the timezone offset relative to UTC in minutes. + return -(offset / 60); } void @@ -653,11 +667,15 @@ SetTimezone(const nsCString& aTimezoneSpec) return; } + int32_t oldTimezoneOffsetMinutes = GetTimezoneOffset(); 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(); - hal::NotifySystemTimeChange(hal::SYS_TIME_CHANGE_TZ); + int32_t newTimezoneOffsetMinutes = GetTimezoneOffset(); + hal::NotifySystemTimezoneChange( + hal::SystemTimezoneChangeInformation( + oldTimezoneOffsetMinutes, newTimezoneOffsetMinutes)); } nsCString @@ -669,12 +687,22 @@ GetTimezone() } void -EnableSystemTimeChangeNotifications() +EnableSystemClockChangeNotifications() +{ +} + +void +DisableSystemClockChangeNotifications() +{ +} + +void +EnableSystemTimezoneChangeNotifications() { } void -DisableSystemTimeChangeNotifications() +DisableSystemTimezoneChangeNotifications() { } diff --git a/hal/sandbox/PHal.ipdl b/hal/sandbox/PHal.ipdl index 3c8bfbf4b9b82..3c8dd12159d44 100644 --- a/hal/sandbox/PHal.ipdl +++ b/hal/sandbox/PHal.ipdl @@ -24,7 +24,6 @@ using mozilla::hal::SwitchDevice; using mozilla::hal::ProcessPriority; using nsIntRect; using PRTime; -using mozilla::hal::SystemTimeChange; using mozilla::hal::FMRadioCountry; using mozilla::hal::FMRadioOperation; using mozilla::hal::FMRadioOperationStatus; @@ -92,6 +91,13 @@ struct FMRadioSettings { uint32_t preEmphasis; }; +struct SystemTimezoneChangeInformation { + // These timezone offsets are relative to UTC in minutes and + // have already taken daylight saving time (DST) into account. + int32_t oldTimezoneOffsetMinutes; + int32_t newTimezoneOffsetMinutes; +}; + } // namespace hal namespace hal_sandbox { @@ -105,7 +111,8 @@ child: NotifyWakeLockChange(WakeLockInformation aWakeLockInfo); NotifyScreenConfigurationChange(ScreenConfiguration aScreenOrientation); NotifySwitchChange(SwitchEvent aEvent); - NotifySystemTimeChange(SystemTimeChange aReason); + NotifySystemClockChange(int64_t aClockDeltaMS); + NotifySystemTimezoneChange(SystemTimezoneChangeInformation aSystemTimezoneChangeInfo); NotifyFMRadioStatus(FMRadioOperationInformation aInfo); parent: @@ -135,8 +142,10 @@ parent: SetTimezone(nsCString aTimezoneSpec); sync GetTimezone() returns (nsCString aTimezoneSpec); - EnableSystemTimeChangeNotifications(); - DisableSystemTimeChangeNotifications(); + EnableSystemClockChangeNotifications(); + DisableSystemClockChangeNotifications(); + EnableSystemTimezoneChangeNotifications(); + DisableSystemTimezoneChangeNotifications(); sync SetLight(LightType light, LightConfiguration aConfig) returns (bool status); diff --git a/hal/sandbox/SandboxHal.cpp b/hal/sandbox/SandboxHal.cpp index 8276c26ce7b30..fa2adaa9f40bc 100644 --- a/hal/sandbox/SandboxHal.cpp +++ b/hal/sandbox/SandboxHal.cpp @@ -212,15 +212,27 @@ GetTimezone() } void -EnableSystemTimeChangeNotifications() +EnableSystemClockChangeNotifications() { - Hal()->SendEnableSystemTimeChangeNotifications(); + Hal()->SendEnableSystemClockChangeNotifications(); } void -DisableSystemTimeChangeNotifications() +DisableSystemClockChangeNotifications() { - Hal()->SendDisableSystemTimeChangeNotifications(); + Hal()->SendDisableSystemClockChangeNotifications(); +} + +void +EnableSystemTimezoneChangeNotifications() +{ + Hal()->SendEnableSystemTimezoneChangeNotifications(); +} + +void +DisableSystemTimezoneChangeNotifications() +{ + Hal()->SendDisableSystemTimezoneChangeNotifications(); } void @@ -394,7 +406,8 @@ class HalParent : public PHalParent , public WakeLockObserver , public ScreenConfigurationObserver , public SwitchObserver - , public SystemTimeObserver + , public SystemClockChangeObserver + , public SystemTimezoneChangeObserver { public: virtual void @@ -410,7 +423,8 @@ class HalParent : public PHalParent hal::UnregisterSensorObserver(SensorType(sensor), this); } hal::UnregisterWakeLockObserver(this); - hal::UnregisterSystemTimeChangeObserver(this); + hal::UnregisterSystemClockChangeObserver(this); + hal::UnregisterSystemTimezoneChangeObserver(this); } virtual bool @@ -643,16 +657,30 @@ class HalParent : public PHalParent } virtual bool - RecvEnableSystemTimeChangeNotifications() MOZ_OVERRIDE + RecvEnableSystemClockChangeNotifications() MOZ_OVERRIDE + { + hal::RegisterSystemClockChangeObserver(this); + return true; + } + + virtual bool + RecvDisableSystemClockChangeNotifications() MOZ_OVERRIDE { - hal::RegisterSystemTimeChangeObserver(this); + hal::UnregisterSystemClockChangeObserver(this); return true; } virtual bool - RecvDisableSystemTimeChangeNotifications() MOZ_OVERRIDE + RecvEnableSystemTimezoneChangeNotifications() MOZ_OVERRIDE { - hal::UnregisterSystemTimeChangeObserver(this); + hal::RegisterSystemTimezoneChangeObserver(this); + return true; + } + + virtual bool + RecvDisableSystemTimezoneChangeNotifications() MOZ_OVERRIDE + { + hal::UnregisterSystemTimezoneChangeObserver(this); return true; } @@ -749,9 +777,14 @@ class HalParent : public PHalParent return true; } - void Notify(const SystemTimeChange& aReason) + void Notify(const int64_t& aClockDeltaMS) + { + unused << SendNotifySystemClockChange(aClockDeltaMS); + } + + void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) { - unused << SendNotifySystemTimeChange(aReason); + unused << SendNotifySystemTimezoneChange(aSystemTimezoneChangeInfo); } virtual bool @@ -902,8 +935,15 @@ class HalChild : public PHalChild { } virtual bool - RecvNotifySystemTimeChange(const SystemTimeChange& aReason) { - hal::NotifySystemTimeChange(aReason); + RecvNotifySystemClockChange(const int64_t& aClockDeltaMS) { + hal::NotifySystemClockChange(aClockDeltaMS); + return true; + } + + virtual bool + RecvNotifySystemTimezoneChange( + const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) { + hal::NotifySystemTimezoneChange(aSystemTimezoneChangeInfo); return true; }