mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 801096 - [settings] Set-Automatically for time should take effect *immediately* instead of waiting on next NITZ coming (part 1). r=jlebar
This commit is contained in:
parent
cdb97c6164
commit
49f7f7432c
@ -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> AlarmHalService::sSingleton;
|
||||
|
||||
/* static */ already_AddRefed<nsIAlarmHalService>
|
||||
/* static */ already_AddRefed<AlarmHalService>
|
||||
AlarmHalService::GetInstance()
|
||||
{
|
||||
if (!sSingleton) {
|
||||
@ -41,7 +41,7 @@ AlarmHalService::GetInstance()
|
||||
ClearOnShutdown(&sSingleton);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAlarmHalService> service(do_QueryInterface(sSingleton));
|
||||
nsRefPtr<AlarmHalService> 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
|
||||
|
@ -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<void_t> AlarmObserver;
|
||||
typedef Observer<hal::SystemTimezoneChangeInformation> SystemTimezoneChangeObserver;
|
||||
|
||||
class AlarmHalService : public nsIAlarmHalService,
|
||||
public AlarmObserver,
|
||||
public SystemTimeObserver
|
||||
public SystemTimezoneChangeObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -32,13 +32,13 @@ public:
|
||||
void Init();
|
||||
virtual ~AlarmHalService();
|
||||
|
||||
static already_AddRefed<nsIAlarmHalService> GetInstance();
|
||||
static already_AddRefed<AlarmHalService> 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 @@ private:
|
||||
|
||||
nsCOMPtr<nsIAlarmFiredCb> mAlarmFiredCb;
|
||||
nsCOMPtr<nsITimezoneChangedCb> mTimezoneChangedCb;
|
||||
|
||||
int32_t GetTimezoneOffset(bool aIgnoreDST);
|
||||
};
|
||||
|
||||
} // namespace alarm
|
||||
|
@ -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<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (!stack) {
|
||||
|
@ -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<nsSystemTimeChangeObserver> 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<nsIObserverService> observerService = GetObserverService();
|
||||
if (observerService) {
|
||||
nsString dataStr;
|
||||
dataStr.AppendFloat(static_cast<double>(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;
|
||||
|
@ -12,14 +12,23 @@
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsWeakPtr.h"
|
||||
|
||||
typedef mozilla::Observer<mozilla::hal::SystemTimeChange> SystemTimeChangeObserver;
|
||||
typedef mozilla::Observer<int64_t> SystemClockChangeObserver;
|
||||
typedef mozilla::Observer<mozilla::hal::SystemTimezoneChangeInformation> 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 @@ private:
|
||||
nsresult RemoveWindowListenerImpl(nsIDOMWindow* aWindow);
|
||||
nsSystemTimeChangeObserver() { };
|
||||
nsTArray<nsWeakPtr> mWindowListeners;
|
||||
void FireMozTimeChangeEvent();
|
||||
};
|
||||
|
||||
#endif //_mozilla_time_change_observer_h_
|
||||
|
76
hal/Hal.cpp
76
hal/Hal.cpp
@ -405,50 +405,84 @@ 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<SystemTimeChange>
|
||||
class SystemClockChangeObserversManager : public ObserversManager<int64_t>
|
||||
{
|
||||
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<SystemTimezoneChangeInformation>
|
||||
{
|
||||
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
|
||||
@ -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<SwitchEvent> 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.
|
||||
|
40
hal/Hal.h
40
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<SystemTimeChange> SystemTimeObserver;
|
||||
typedef Observer<int64_t> SystemClockChangeObserver;
|
||||
typedef Observer<SystemTimezoneChangeInformation> 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.
|
||||
|
@ -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
|
||||
|
@ -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<FMRadioOperationInformation> FMRadioObserver;
|
||||
typedef Observer<SystemTimeChange> SystemTimeChangeObserver;
|
||||
} // namespace hal
|
||||
} // namespace mozilla
|
||||
|
||||
@ -250,16 +242,6 @@ struct ParamTraits<mozilla::hal::ProcessPriority>:
|
||||
mozilla::hal::NUM_PROCESS_PRIORITY> {
|
||||
};
|
||||
|
||||
/**
|
||||
* SystemTimeChange serializer.
|
||||
*/
|
||||
template <>
|
||||
struct ParamTraits<mozilla::hal::SystemTimeChange>
|
||||
: public EnumSerializer<mozilla::hal::SystemTimeChange,
|
||||
mozilla::hal::SYS_TIME_CHANGE_UNKNOWN,
|
||||
mozilla::hal::SYS_TIME_CHANGE_GUARD>
|
||||
{};
|
||||
|
||||
/**
|
||||
* Serializer for FMRadioOperation
|
||||
*/
|
||||
|
@ -25,13 +25,24 @@ GetTimezone()
|
||||
}
|
||||
|
||||
void
|
||||
EnableSystemTimeChangeNotifications()
|
||||
EnableSystemClockChangeNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DisableSystemTimeChangeNotifications()
|
||||
DisableSystemClockChangeNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
EnableSystemTimezoneChangeNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DisableSystemTimezoneChangeNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace hal_impl
|
||||
} // namespace mozilla
|
||||
|
@ -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
|
||||
DisableSystemTimeChangeNotifications()
|
||||
DisableSystemClockChangeNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
EnableSystemTimezoneChangeNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DisableSystemTimezoneChangeNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 @@ public:
|
||||
hal::UnregisterSensorObserver(SensorType(sensor), this);
|
||||
}
|
||||
hal::UnregisterWakeLockObserver(this);
|
||||
hal::UnregisterSystemTimeChangeObserver(this);
|
||||
hal::UnregisterSystemClockChangeObserver(this);
|
||||
hal::UnregisterSystemTimezoneChangeObserver(this);
|
||||
}
|
||||
|
||||
virtual bool
|
||||
@ -643,16 +657,30 @@ public:
|
||||
}
|
||||
|
||||
virtual bool
|
||||
RecvEnableSystemTimeChangeNotifications() MOZ_OVERRIDE
|
||||
RecvEnableSystemClockChangeNotifications() MOZ_OVERRIDE
|
||||
{
|
||||
hal::RegisterSystemTimeChangeObserver(this);
|
||||
hal::RegisterSystemClockChangeObserver(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool
|
||||
RecvDisableSystemTimeChangeNotifications() MOZ_OVERRIDE
|
||||
RecvDisableSystemClockChangeNotifications() MOZ_OVERRIDE
|
||||
{
|
||||
hal::UnregisterSystemTimeChangeObserver(this);
|
||||
hal::UnregisterSystemClockChangeObserver(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool
|
||||
RecvEnableSystemTimezoneChangeNotifications() MOZ_OVERRIDE
|
||||
{
|
||||
hal::RegisterSystemTimezoneChangeObserver(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool
|
||||
RecvDisableSystemTimezoneChangeNotifications() MOZ_OVERRIDE
|
||||
{
|
||||
hal::UnregisterSystemTimezoneChangeObserver(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -749,9 +777,14 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void Notify(const SystemTimeChange& aReason)
|
||||
void Notify(const int64_t& aClockDeltaMS)
|
||||
{
|
||||
unused << SendNotifySystemTimeChange(aReason);
|
||||
unused << SendNotifySystemClockChange(aClockDeltaMS);
|
||||
}
|
||||
|
||||
void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
|
||||
{
|
||||
unused << SendNotifySystemTimezoneChange(aSystemTimezoneChangeInfo);
|
||||
}
|
||||
|
||||
virtual bool
|
||||
@ -902,8 +935,15 @@ public:
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user