2011-10-06 02:15:45 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2011-10-21 01:38:39 +04:00
|
|
|
/* vim: set sw=2 ts=8 et ft=cpp : */
|
2012-02-10 14:04:44 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-02-02 10:09:00 +04:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
2012-02-10 14:04:44 +04:00
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-10-06 02:15:45 +04:00
|
|
|
|
|
|
|
#include "Hal.h"
|
2014-09-24 17:23:18 +04:00
|
|
|
#include "HalLog.h"
|
2011-10-06 02:15:45 +04:00
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2013-06-03 14:14:37 +04:00
|
|
|
#include "mozilla/dom/ContentParent.h"
|
2011-10-06 02:15:45 +04:00
|
|
|
#include "mozilla/hal_sandbox/PHalChild.h"
|
|
|
|
#include "mozilla/hal_sandbox/PHalParent.h"
|
2011-09-30 11:00:48 +04:00
|
|
|
#include "mozilla/dom/TabParent.h"
|
|
|
|
#include "mozilla/dom/TabChild.h"
|
2011-11-02 19:14:01 +04:00
|
|
|
#include "mozilla/dom/battery/Types.h"
|
2012-01-16 17:39:57 +04:00
|
|
|
#include "mozilla/dom/network/Types.h"
|
2012-03-13 20:42:46 +04:00
|
|
|
#include "mozilla/dom/ScreenOrientation.h"
|
2011-11-02 19:14:01 +04:00
|
|
|
#include "mozilla/Observer.h"
|
2016-08-23 07:09:32 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2016-06-07 23:10:18 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2011-12-18 01:04:26 +04:00
|
|
|
#include "WindowIdentifier.h"
|
2011-10-06 02:15:45 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
using namespace mozilla::hal;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace hal_sandbox {
|
|
|
|
|
2013-02-12 08:09:25 +04:00
|
|
|
static bool sHalChildDestroyed = false;
|
2012-10-07 05:53:22 +04:00
|
|
|
|
|
|
|
bool
|
2013-02-12 08:09:25 +04:00
|
|
|
HalChildDestroyed()
|
2012-10-07 05:53:22 +04:00
|
|
|
{
|
2013-02-12 08:09:25 +04:00
|
|
|
return sHalChildDestroyed;
|
2012-10-07 05:53:22 +04:00
|
|
|
}
|
|
|
|
|
2011-10-06 02:15:45 +04:00
|
|
|
static PHalChild* sHal;
|
|
|
|
static PHalChild*
|
|
|
|
Hal()
|
|
|
|
{
|
|
|
|
if (!sHal) {
|
|
|
|
sHal = ContentChild::GetSingleton()->SendPHalConstructor();
|
|
|
|
}
|
|
|
|
return sHal;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-25 11:18:30 +04:00
|
|
|
Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id)
|
2011-10-06 02:15:45 +04:00
|
|
|
{
|
2014-09-24 17:23:18 +04:00
|
|
|
HAL_LOG("Vibrate: Sending to parent process.");
|
2011-09-30 11:00:48 +04:00
|
|
|
|
2016-02-02 18:36:31 +03:00
|
|
|
AutoTArray<uint32_t, 8> p(pattern);
|
2011-09-30 11:00:48 +04:00
|
|
|
|
|
|
|
WindowIdentifier newID(id);
|
|
|
|
newID.AppendProcessID();
|
2013-09-12 23:24:11 +04:00
|
|
|
Hal()->SendVibrate(p, newID.AsArray(), TabChild::GetFrom(newID.GetWindow()));
|
2011-09-30 11:00:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CancelVibrate(const WindowIdentifier &id)
|
|
|
|
{
|
2014-09-24 17:23:18 +04:00
|
|
|
HAL_LOG("CancelVibrate: Sending to parent process.");
|
2011-09-30 11:00:48 +04:00
|
|
|
|
|
|
|
WindowIdentifier newID(id);
|
|
|
|
newID.AppendProcessID();
|
2013-09-12 23:24:11 +04:00
|
|
|
Hal()->SendCancelVibrate(newID.AsArray(), TabChild::GetFrom(newID.GetWindow()));
|
2011-10-06 02:15:45 +04:00
|
|
|
}
|
|
|
|
|
2011-11-02 19:14:01 +04:00
|
|
|
void
|
|
|
|
EnableBatteryNotifications()
|
|
|
|
{
|
|
|
|
Hal()->SendEnableBatteryNotifications();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableBatteryNotifications()
|
|
|
|
{
|
|
|
|
Hal()->SendDisableBatteryNotifications();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetCurrentBatteryInformation(BatteryInformation* aBatteryInfo)
|
|
|
|
{
|
|
|
|
Hal()->SendGetCurrentBatteryInformation(aBatteryInfo);
|
|
|
|
}
|
|
|
|
|
2012-01-16 17:39:57 +04:00
|
|
|
void
|
|
|
|
EnableNetworkNotifications()
|
|
|
|
{
|
|
|
|
Hal()->SendEnableNetworkNotifications();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableNetworkNotifications()
|
|
|
|
{
|
|
|
|
Hal()->SendDisableNetworkNotifications();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetCurrentNetworkInformation(NetworkInformation* aNetworkInfo)
|
|
|
|
{
|
|
|
|
Hal()->SendGetCurrentNetworkInformation(aNetworkInfo);
|
|
|
|
}
|
|
|
|
|
2012-03-13 20:42:46 +04:00
|
|
|
void
|
2012-05-09 01:36:07 +04:00
|
|
|
EnableScreenConfigurationNotifications()
|
2012-03-13 20:42:46 +04:00
|
|
|
{
|
2012-05-09 01:36:07 +04:00
|
|
|
Hal()->SendEnableScreenConfigurationNotifications();
|
2012-03-13 20:42:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-09 01:36:07 +04:00
|
|
|
DisableScreenConfigurationNotifications()
|
2012-03-13 20:42:46 +04:00
|
|
|
{
|
2012-05-09 01:36:07 +04:00
|
|
|
Hal()->SendDisableScreenConfigurationNotifications();
|
2012-03-13 20:42:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-09 01:36:07 +04:00
|
|
|
GetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration)
|
2012-03-13 20:42:46 +04:00
|
|
|
{
|
2012-05-09 01:36:07 +04:00
|
|
|
Hal()->SendGetCurrentScreenConfiguration(aScreenConfiguration);
|
2012-03-13 20:42:46 +04:00
|
|
|
}
|
|
|
|
|
2012-03-29 23:43:16 +04:00
|
|
|
bool
|
2015-08-19 00:55:09 +03:00
|
|
|
LockScreenOrientation(const dom::ScreenOrientationInternal& aOrientation)
|
2012-03-29 23:43:16 +04:00
|
|
|
{
|
|
|
|
bool allowed;
|
|
|
|
Hal()->SendLockScreenOrientation(aOrientation, &allowed);
|
|
|
|
return allowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UnlockScreenOrientation()
|
|
|
|
{
|
|
|
|
Hal()->SendUnlockScreenOrientation();
|
|
|
|
}
|
|
|
|
|
2011-12-04 21:07:00 +04:00
|
|
|
bool
|
|
|
|
GetScreenEnabled()
|
|
|
|
{
|
|
|
|
bool enabled = false;
|
|
|
|
Hal()->SendGetScreenEnabled(&enabled);
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-30 07:11:23 +04:00
|
|
|
SetScreenEnabled(bool aEnabled)
|
2011-12-04 21:07:00 +04:00
|
|
|
{
|
2014-05-30 07:11:23 +04:00
|
|
|
Hal()->SendSetScreenEnabled(aEnabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GetKeyLightEnabled()
|
|
|
|
{
|
|
|
|
bool enabled = false;
|
|
|
|
Hal()->SendGetKeyLightEnabled(&enabled);
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetKeyLightEnabled(bool aEnabled)
|
|
|
|
{
|
|
|
|
Hal()->SendSetKeyLightEnabled(aEnabled);
|
2011-12-04 21:07:00 +04:00
|
|
|
}
|
|
|
|
|
2012-04-17 02:35:33 +04:00
|
|
|
bool
|
|
|
|
GetCpuSleepAllowed()
|
|
|
|
{
|
|
|
|
bool allowed = true;
|
|
|
|
Hal()->SendGetCpuSleepAllowed(&allowed);
|
|
|
|
return allowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-30 07:11:23 +04:00
|
|
|
SetCpuSleepAllowed(bool aAllowed)
|
2012-04-17 02:35:33 +04:00
|
|
|
{
|
2014-05-30 07:11:23 +04:00
|
|
|
Hal()->SendSetCpuSleepAllowed(aAllowed);
|
2012-04-17 02:35:33 +04:00
|
|
|
}
|
|
|
|
|
2011-12-04 21:07:00 +04:00
|
|
|
double
|
|
|
|
GetScreenBrightness()
|
|
|
|
{
|
|
|
|
double brightness = 0;
|
|
|
|
Hal()->SendGetScreenBrightness(&brightness);
|
|
|
|
return brightness;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-30 07:11:23 +04:00
|
|
|
SetScreenBrightness(double aBrightness)
|
2011-12-04 21:07:00 +04:00
|
|
|
{
|
2014-05-30 07:11:23 +04:00
|
|
|
Hal()->SendSetScreenBrightness(aBrightness);
|
2011-12-04 21:07:00 +04:00
|
|
|
}
|
|
|
|
|
2016-01-04 18:08:21 +03:00
|
|
|
void
|
2012-09-26 07:51:29 +04:00
|
|
|
AdjustSystemClock(int64_t aDeltaMilliseconds)
|
2012-02-17 14:44:00 +04:00
|
|
|
{
|
|
|
|
Hal()->SendAdjustSystemClock(aDeltaMilliseconds);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetTimezone(const nsCString& aTimezoneSpec)
|
|
|
|
{
|
|
|
|
Hal()->SendSetTimezone(nsCString(aTimezoneSpec));
|
2016-01-04 18:08:21 +03:00
|
|
|
}
|
2012-02-17 14:44:00 +04:00
|
|
|
|
2012-08-23 13:00:00 +04:00
|
|
|
nsCString
|
|
|
|
GetTimezone()
|
|
|
|
{
|
|
|
|
nsCString timezone;
|
|
|
|
Hal()->SendGetTimezone(&timezone);
|
|
|
|
return timezone;
|
|
|
|
}
|
|
|
|
|
2013-10-15 12:43:53 +04:00
|
|
|
int32_t
|
|
|
|
GetTimezoneOffset()
|
|
|
|
{
|
|
|
|
int32_t timezoneOffset;
|
|
|
|
Hal()->SendGetTimezoneOffset(&timezoneOffset);
|
|
|
|
return timezoneOffset;
|
|
|
|
}
|
|
|
|
|
2012-09-23 21:00:32 +04:00
|
|
|
void
|
2012-10-23 11:15:43 +04:00
|
|
|
EnableSystemClockChangeNotifications()
|
2012-09-23 21:00:32 +04:00
|
|
|
{
|
2012-10-23 11:15:43 +04:00
|
|
|
Hal()->SendEnableSystemClockChangeNotifications();
|
2012-09-23 21:00:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-10-23 11:15:43 +04:00
|
|
|
DisableSystemClockChangeNotifications()
|
2012-09-23 21:00:32 +04:00
|
|
|
{
|
2012-10-23 11:15:43 +04:00
|
|
|
Hal()->SendDisableSystemClockChangeNotifications();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EnableSystemTimezoneChangeNotifications()
|
|
|
|
{
|
|
|
|
Hal()->SendEnableSystemTimezoneChangeNotifications();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableSystemTimezoneChangeNotifications()
|
|
|
|
{
|
|
|
|
Hal()->SendDisableSystemTimezoneChangeNotifications();
|
2012-09-23 21:00:32 +04:00
|
|
|
}
|
|
|
|
|
2012-01-31 10:08:00 +04:00
|
|
|
void
|
|
|
|
Reboot()
|
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("Reboot() can't be called from sandboxed contexts.");
|
2012-01-31 10:08:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PowerOff()
|
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("PowerOff() can't be called from sandboxed contexts.");
|
2012-01-31 10:08:00 +04:00
|
|
|
}
|
|
|
|
|
2012-10-02 11:26:32 +04:00
|
|
|
void
|
|
|
|
StartForceQuitWatchdog(ShutdownMode aMode, int32_t aTimeoutSecs)
|
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("StartForceQuitWatchdog() can't be called from sandboxed contexts.");
|
2012-10-02 11:26:32 +04:00
|
|
|
}
|
|
|
|
|
2012-02-05 23:51:06 +04:00
|
|
|
void
|
|
|
|
EnableSensorNotifications(SensorType aSensor) {
|
|
|
|
Hal()->SendEnableSensorNotifications(aSensor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableSensorNotifications(SensorType aSensor) {
|
|
|
|
Hal()->SendDisableSensorNotifications(aSensor);
|
|
|
|
}
|
|
|
|
|
2012-03-07 15:03:25 +04:00
|
|
|
void
|
|
|
|
EnableWakeLockNotifications()
|
|
|
|
{
|
|
|
|
Hal()->SendEnableWakeLockNotifications();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableWakeLockNotifications()
|
|
|
|
{
|
|
|
|
Hal()->SendDisableWakeLockNotifications();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-02-15 00:41:30 +04:00
|
|
|
ModifyWakeLock(const nsAString &aTopic,
|
|
|
|
WakeLockControl aLockAdjust,
|
|
|
|
WakeLockControl aHiddenAdjust,
|
|
|
|
uint64_t aProcessID)
|
2012-03-07 15:03:25 +04:00
|
|
|
{
|
2013-02-15 00:41:30 +04:00
|
|
|
MOZ_ASSERT(aProcessID != CONTENT_PROCESS_ID_UNKNOWN);
|
2012-11-17 19:05:18 +04:00
|
|
|
Hal()->SendModifyWakeLock(nsString(aTopic), aLockAdjust, aHiddenAdjust, aProcessID);
|
2012-03-07 15:03:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetWakeLockInfo(const nsAString &aTopic, WakeLockInformation *aWakeLockInfo)
|
|
|
|
{
|
|
|
|
Hal()->SendGetWakeLockInfo(nsString(aTopic), aWakeLockInfo);
|
|
|
|
}
|
|
|
|
|
2012-04-22 22:09:22 +04:00
|
|
|
void
|
|
|
|
EnableSwitchNotifications(SwitchDevice aDevice)
|
|
|
|
{
|
|
|
|
Hal()->SendEnableSwitchNotifications(aDevice);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableSwitchNotifications(SwitchDevice aDevice)
|
|
|
|
{
|
|
|
|
Hal()->SendDisableSwitchNotifications(aDevice);
|
|
|
|
}
|
|
|
|
|
|
|
|
SwitchState
|
|
|
|
GetCurrentSwitchState(SwitchDevice aDevice)
|
|
|
|
{
|
|
|
|
SwitchState state;
|
|
|
|
Hal()->SendGetCurrentSwitchState(aDevice, &state);
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2014-01-20 13:35:24 +04:00
|
|
|
void
|
|
|
|
NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState)
|
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << aDevice;
|
|
|
|
Unused << aState;
|
2014-06-03 03:25:00 +04:00
|
|
|
NS_RUNTIMEABORT("Only the main process may notify switch state change.");
|
2014-01-20 13:35:24 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 14:42:10 +04:00
|
|
|
bool
|
|
|
|
EnableAlarm()
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("Alarms can't be programmed from sandboxed contexts. Yet.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableAlarm()
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("Alarms can't be programmed from sandboxed contexts. Yet.");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
SetAlarm(int32_t aSeconds, int32_t aNanoseconds)
|
2012-07-06 14:42:10 +04:00
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("Alarms can't be programmed from sandboxed contexts. Yet.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-05 09:09:39 +04:00
|
|
|
void
|
2015-02-25 11:37:38 +03:00
|
|
|
SetProcessPriority(int aPid, ProcessPriority aPriority, uint32_t aLRU)
|
2012-08-05 09:09:39 +04:00
|
|
|
{
|
2013-05-10 00:27:06 +04:00
|
|
|
NS_RUNTIMEABORT("Only the main process may set processes' priorities.");
|
2012-08-05 09:09:39 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 19:37:00 +04:00
|
|
|
void
|
|
|
|
SetCurrentThreadPriority(ThreadPriority aThreadPriority)
|
2015-05-07 16:53:47 +03:00
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("Setting current thread priority cannot be called from sandboxed contexts.");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetThreadPriority(PlatformThreadId aThreadId,
|
|
|
|
ThreadPriority aThreadPriority)
|
2014-05-05 19:37:00 +04:00
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("Setting thread priority cannot be called from sandboxed contexts.");
|
|
|
|
}
|
|
|
|
|
2012-10-04 13:28:34 +04:00
|
|
|
void
|
2014-07-18 05:30:47 +04:00
|
|
|
FactoryReset(FactoryResetReason& aReason)
|
2012-10-04 13:28:34 +04:00
|
|
|
{
|
2014-07-18 05:30:47 +04:00
|
|
|
if (aReason == FactoryResetReason::Normal) {
|
|
|
|
Hal()->SendFactoryReset(NS_LITERAL_STRING("normal"));
|
|
|
|
} else if (aReason == FactoryResetReason::Wipe) {
|
|
|
|
Hal()->SendFactoryReset(NS_LITERAL_STRING("wipe"));
|
2014-11-26 14:46:00 +03:00
|
|
|
} else if (aReason == FactoryResetReason::Root) {
|
|
|
|
Hal()->SendFactoryReset(NS_LITERAL_STRING("root"));
|
2014-07-18 05:30:47 +04:00
|
|
|
}
|
2012-10-04 13:28:34 +04:00
|
|
|
}
|
|
|
|
|
2013-05-10 02:57:31 +04:00
|
|
|
void
|
|
|
|
StartDiskSpaceWatcher()
|
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("StartDiskSpaceWatcher() can't be called from sandboxed contexts.");
|
2013-05-10 02:57:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StopDiskSpaceWatcher()
|
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("StopDiskSpaceWatcher() can't be called from sandboxed contexts.");
|
2013-05-10 02:57:31 +04:00
|
|
|
}
|
|
|
|
|
2014-07-01 21:52:00 +04:00
|
|
|
bool IsHeadphoneEventFromInputDev()
|
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("IsHeadphoneEventFromInputDev() cannot be called from sandboxed contexts.");
|
2014-07-01 21:52:00 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-04 18:08:21 +03:00
|
|
|
nsresult StartSystemService(const char* aSvcName, const char* aArgs)
|
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("System services cannot be controlled from sandboxed contexts.");
|
2016-01-04 18:08:21 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StopSystemService(const char* aSvcName)
|
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("System services cannot be controlled from sandboxed contexts.");
|
2016-01-04 18:08:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SystemServiceIsRunning(const char* aSvcName)
|
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("System services cannot be controlled from sandboxed contexts.");
|
2016-01-04 18:08:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-11-02 19:14:01 +04:00
|
|
|
class HalParent : public PHalParent
|
2012-01-16 17:39:57 +04:00
|
|
|
, public BatteryObserver
|
|
|
|
, public NetworkObserver
|
2012-02-05 23:51:06 +04:00
|
|
|
, public ISensorObserver
|
2012-03-07 15:03:25 +04:00
|
|
|
, public WakeLockObserver
|
2012-05-09 01:36:07 +04:00
|
|
|
, public ScreenConfigurationObserver
|
2012-04-22 22:09:22 +04:00
|
|
|
, public SwitchObserver
|
2012-10-23 11:15:43 +04:00
|
|
|
, public SystemClockChangeObserver
|
|
|
|
, public SystemTimezoneChangeObserver
|
2012-01-16 17:39:57 +04:00
|
|
|
{
|
2011-10-06 02:15:45 +04:00
|
|
|
public:
|
2012-09-07 01:58:36 +04:00
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
ActorDestroy(ActorDestroyReason aWhy) override
|
2012-09-07 01:58:36 +04:00
|
|
|
{
|
|
|
|
// NB: you *must* unconditionally unregister your observer here,
|
|
|
|
// if it *may* be registered below.
|
|
|
|
hal::UnregisterBatteryObserver(this);
|
|
|
|
hal::UnregisterNetworkObserver(this);
|
|
|
|
hal::UnregisterScreenConfigurationObserver(this);
|
|
|
|
for (int32_t sensor = SENSOR_UNKNOWN + 1;
|
|
|
|
sensor < NUM_SENSOR_TYPE; ++sensor) {
|
|
|
|
hal::UnregisterSensorObserver(SensorType(sensor), this);
|
|
|
|
}
|
|
|
|
hal::UnregisterWakeLockObserver(this);
|
2012-10-23 11:15:43 +04:00
|
|
|
hal::UnregisterSystemClockChangeObserver(this);
|
|
|
|
hal::UnregisterSystemTimezoneChangeObserver(this);
|
2012-12-21 12:37:58 +04:00
|
|
|
for (int32_t switchDevice = SWITCH_DEVICE_UNKNOWN + 1;
|
|
|
|
switchDevice < NUM_SWITCH_DEVICE; ++switchDevice) {
|
|
|
|
hal::UnregisterSwitchObserver(SwitchDevice(switchDevice), this);
|
|
|
|
}
|
2012-09-07 01:58:36 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-01-16 22:58:52 +03:00
|
|
|
RecvVibrate(InfallibleTArray<unsigned int>&& pattern,
|
|
|
|
InfallibleTArray<uint64_t>&& id,
|
2015-03-21 19:28:04 +03:00
|
|
|
PBrowserParent *browserParent) override
|
2011-09-30 11:00:48 +04:00
|
|
|
{
|
2012-08-16 23:34:53 +04:00
|
|
|
// We give all content vibration permission.
|
2016-01-30 20:05:36 +03:00
|
|
|
// TabParent *tabParent = TabParent::GetFrom(browserParent);
|
|
|
|
/* xxxkhuey wtf
|
2011-09-30 11:00:48 +04:00
|
|
|
nsCOMPtr<nsIDOMWindow> window =
|
|
|
|
do_QueryInterface(tabParent->GetBrowserDOMWindow());
|
2016-01-30 20:05:36 +03:00
|
|
|
*/
|
|
|
|
WindowIdentifier newID(id, nullptr);
|
2012-12-19 05:16:06 +04:00
|
|
|
hal::Vibrate(pattern, newID);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-09-30 11:00:48 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-01-16 22:58:52 +03:00
|
|
|
RecvCancelVibrate(InfallibleTArray<uint64_t> &&id,
|
2015-03-21 19:28:04 +03:00
|
|
|
PBrowserParent *browserParent) override
|
2011-09-30 11:00:48 +04:00
|
|
|
{
|
2016-01-30 20:05:36 +03:00
|
|
|
//TabParent *tabParent = TabParent::GetFrom(browserParent);
|
|
|
|
/* XXXkhuey wtf
|
2011-09-30 11:00:48 +04:00
|
|
|
nsCOMPtr<nsIDOMWindow> window =
|
2016-01-30 20:05:36 +03:00
|
|
|
tabParent->GetBrowserDOMWindow();
|
|
|
|
*/
|
|
|
|
WindowIdentifier newID(id, nullptr);
|
2011-09-30 11:00:48 +04:00
|
|
|
hal::CancelVibrate(newID);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-10-06 02:15:45 +04:00
|
|
|
}
|
2011-11-02 19:14:01 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvEnableBatteryNotifications() override {
|
2012-08-16 23:34:53 +04:00
|
|
|
// We give all content battery-status permission.
|
2011-11-02 19:14:01 +04:00
|
|
|
hal::RegisterBatteryObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-11-02 19:14:01 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvDisableBatteryNotifications() override {
|
2011-11-02 19:14:01 +04:00
|
|
|
hal::UnregisterBatteryObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-11-02 19:14:01 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetCurrentBatteryInformation(BatteryInformation* aBatteryInfo) override {
|
2012-08-16 23:34:53 +04:00
|
|
|
// We give all content battery-status permission.
|
2011-11-02 19:14:01 +04:00
|
|
|
hal::GetCurrentBatteryInformation(aBatteryInfo);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-11-02 19:14:01 +04:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void Notify(const BatteryInformation& aBatteryInfo) override {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNotifyBatteryChange(aBatteryInfo);
|
2011-11-02 19:14:01 +04:00
|
|
|
}
|
2011-12-04 21:07:00 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvEnableNetworkNotifications() override {
|
2012-08-16 23:34:53 +04:00
|
|
|
// We give all content access to this network-status information.
|
2012-01-16 17:39:57 +04:00
|
|
|
hal::RegisterNetworkObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-01-16 17:39:57 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvDisableNetworkNotifications() override {
|
2012-01-16 17:39:57 +04:00
|
|
|
hal::UnregisterNetworkObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-01-16 17:39:57 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetCurrentNetworkInformation(NetworkInformation* aNetworkInfo) override {
|
2012-01-16 17:39:57 +04:00
|
|
|
hal::GetCurrentNetworkInformation(aNetworkInfo);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-01-16 17:39:57 +04:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void Notify(const NetworkInformation& aNetworkInfo) override {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNotifyNetworkChange(aNetworkInfo);
|
2012-01-16 17:39:57 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvEnableScreenConfigurationNotifications() override {
|
2012-08-16 23:34:53 +04:00
|
|
|
// Screen configuration is used to implement CSS and DOM
|
|
|
|
// properties, so all content already has access to this.
|
2012-05-09 01:36:07 +04:00
|
|
|
hal::RegisterScreenConfigurationObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-13 20:42:46 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvDisableScreenConfigurationNotifications() override {
|
2012-05-09 01:36:07 +04:00
|
|
|
hal::UnregisterScreenConfigurationObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-13 20:42:46 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration) override {
|
2012-05-09 01:36:07 +04:00
|
|
|
hal::GetCurrentScreenConfiguration(aScreenConfiguration);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-13 20:42:46 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-08-19 00:55:09 +03:00
|
|
|
RecvLockScreenOrientation(const dom::ScreenOrientationInternal& aOrientation, bool* aAllowed) override
|
2012-03-29 23:43:16 +04:00
|
|
|
{
|
2012-08-16 23:34:53 +04:00
|
|
|
// FIXME/bug 777980: unprivileged content may only lock
|
|
|
|
// orientation while fullscreen. We should check whether the
|
|
|
|
// request comes from an actor in a process that might be
|
|
|
|
// fullscreen. We don't have that information currently.
|
2012-03-29 23:43:16 +04:00
|
|
|
*aAllowed = hal::LockScreenOrientation(aOrientation);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-29 23:43:16 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvUnlockScreenOrientation() override
|
2012-03-29 23:43:16 +04:00
|
|
|
{
|
|
|
|
hal::UnlockScreenOrientation();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-29 23:43:16 +04:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void Notify(const ScreenConfiguration& aScreenConfiguration) override {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNotifyScreenConfigurationChange(aScreenConfiguration);
|
2012-03-13 20:42:46 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetScreenEnabled(bool* aEnabled) override
|
2014-05-30 07:11:23 +04:00
|
|
|
{
|
|
|
|
*aEnabled = hal::GetScreenEnabled();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-05-30 07:11:23 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvSetScreenEnabled(const bool& aEnabled) override
|
2014-05-30 07:11:23 +04:00
|
|
|
{
|
|
|
|
hal::SetScreenEnabled(aEnabled);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-05-30 07:11:23 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetKeyLightEnabled(bool* aEnabled) override
|
2011-12-04 21:07:00 +04:00
|
|
|
{
|
2014-05-30 07:11:23 +04:00
|
|
|
*aEnabled = hal::GetKeyLightEnabled();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-12-04 21:07:00 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvSetKeyLightEnabled(const bool& aEnabled) override
|
2011-12-04 21:07:00 +04:00
|
|
|
{
|
2014-05-30 07:11:23 +04:00
|
|
|
hal::SetKeyLightEnabled(aEnabled);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-12-04 21:07:00 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetCpuSleepAllowed(bool* aAllowed) override
|
2012-04-17 02:35:33 +04:00
|
|
|
{
|
2014-05-30 07:11:23 +04:00
|
|
|
*aAllowed = hal::GetCpuSleepAllowed();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-04-17 02:35:33 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvSetCpuSleepAllowed(const bool& aAllowed) override
|
2012-04-17 02:35:33 +04:00
|
|
|
{
|
2014-05-30 07:11:23 +04:00
|
|
|
hal::SetCpuSleepAllowed(aAllowed);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-04-17 02:35:33 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetScreenBrightness(double* aBrightness) override
|
2011-12-04 21:07:00 +04:00
|
|
|
{
|
2014-05-30 07:11:23 +04:00
|
|
|
*aBrightness = hal::GetScreenBrightness();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-12-04 21:07:00 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvSetScreenBrightness(const double& aBrightness) override
|
2011-12-04 21:07:00 +04:00
|
|
|
{
|
2014-05-30 07:11:23 +04:00
|
|
|
hal::SetScreenBrightness(aBrightness);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-12-04 21:07:00 +04:00
|
|
|
}
|
2012-01-31 10:08:00 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvAdjustSystemClock(const int64_t &aDeltaMilliseconds) override
|
2012-02-17 14:44:00 +04:00
|
|
|
{
|
|
|
|
hal::AdjustSystemClock(aDeltaMilliseconds);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-02-17 14:44:00 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvSetTimezone(const nsCString& aTimezoneSpec) override
|
2012-02-17 14:44:00 +04:00
|
|
|
{
|
|
|
|
hal::SetTimezone(aTimezoneSpec);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-02-17 14:44:00 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetTimezone(nsCString *aTimezoneSpec) override
|
2012-08-23 13:00:00 +04:00
|
|
|
{
|
|
|
|
*aTimezoneSpec = hal::GetTimezone();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-08-23 13:00:00 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetTimezoneOffset(int32_t *aTimezoneOffset) override
|
2013-10-15 12:43:53 +04:00
|
|
|
{
|
|
|
|
*aTimezoneOffset = hal::GetTimezoneOffset();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-10-15 12:43:53 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvEnableSystemClockChangeNotifications() override
|
2012-10-23 11:15:43 +04:00
|
|
|
{
|
|
|
|
hal::RegisterSystemClockChangeObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-10-23 11:15:43 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvDisableSystemClockChangeNotifications() override
|
2012-09-23 21:00:32 +04:00
|
|
|
{
|
2012-10-23 11:15:43 +04:00
|
|
|
hal::UnregisterSystemClockChangeObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-09-23 21:00:32 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvEnableSystemTimezoneChangeNotifications() override
|
2012-09-23 21:00:32 +04:00
|
|
|
{
|
2012-10-23 11:15:43 +04:00
|
|
|
hal::RegisterSystemTimezoneChangeObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-10-23 11:15:43 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvDisableSystemTimezoneChangeNotifications() override
|
2012-10-23 11:15:43 +04:00
|
|
|
{
|
|
|
|
hal::UnregisterSystemTimezoneChangeObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-09-23 21:00:32 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvEnableSensorNotifications(const SensorType &aSensor) override {
|
2012-08-16 23:34:53 +04:00
|
|
|
// We currently allow any content to register device-sensor
|
|
|
|
// listeners.
|
2012-02-05 23:51:06 +04:00
|
|
|
hal::RegisterSensorObserver(aSensor, this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-02-05 23:51:06 +04:00
|
|
|
}
|
2016-01-04 18:08:21 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvDisableSensorNotifications(const SensorType &aSensor) override {
|
2012-02-05 23:51:06 +04:00
|
|
|
hal::UnregisterSensorObserver(aSensor, this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-02-05 23:51:06 +04:00
|
|
|
}
|
2016-01-04 18:08:21 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void Notify(const SensorData& aSensorData) override {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNotifySensorChange(aSensorData);
|
2012-02-05 23:51:06 +04:00
|
|
|
}
|
2012-03-07 15:03:25 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2012-11-17 19:05:18 +04:00
|
|
|
RecvModifyWakeLock(const nsString& aTopic,
|
|
|
|
const WakeLockControl& aLockAdjust,
|
|
|
|
const WakeLockControl& aHiddenAdjust,
|
2015-03-21 19:28:04 +03:00
|
|
|
const uint64_t& aProcessID) override
|
2012-03-07 15:03:25 +04:00
|
|
|
{
|
2013-02-15 00:41:30 +04:00
|
|
|
MOZ_ASSERT(aProcessID != CONTENT_PROCESS_ID_UNKNOWN);
|
|
|
|
|
2012-08-26 02:38:04 +04:00
|
|
|
// We allow arbitrary content to use wake locks.
|
2013-02-15 00:41:30 +04:00
|
|
|
hal::ModifyWakeLock(aTopic, aLockAdjust, aHiddenAdjust, aProcessID);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-07 15:03:25 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvEnableWakeLockNotifications() override
|
2012-03-07 15:03:25 +04:00
|
|
|
{
|
2012-08-26 02:38:04 +04:00
|
|
|
// We allow arbitrary content to use wake locks.
|
2012-03-07 15:03:25 +04:00
|
|
|
hal::RegisterWakeLockObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-07 15:03:25 +04:00
|
|
|
}
|
2016-01-04 18:08:21 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvDisableWakeLockNotifications() override
|
2012-03-07 15:03:25 +04:00
|
|
|
{
|
|
|
|
hal::UnregisterWakeLockObserver(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-07 15:03:25 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetWakeLockInfo(const nsString &aTopic, WakeLockInformation *aWakeLockInfo) override
|
2012-03-07 15:03:25 +04:00
|
|
|
{
|
|
|
|
hal::GetWakeLockInfo(aTopic, aWakeLockInfo);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-07 15:03:25 +04:00
|
|
|
}
|
2016-01-04 18:08:21 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void Notify(const WakeLockInformation& aWakeLockInfo) override
|
2012-03-07 15:03:25 +04:00
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNotifyWakeLockChange(aWakeLockInfo);
|
2012-03-07 15:03:25 +04:00
|
|
|
}
|
2012-04-22 22:09:22 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvEnableSwitchNotifications(const SwitchDevice& aDevice) override
|
2012-04-22 22:09:22 +04:00
|
|
|
{
|
2012-08-16 23:34:53 +04:00
|
|
|
// Content has no reason to listen to switch events currently.
|
2012-11-30 02:52:02 +04:00
|
|
|
hal::RegisterSwitchObserver(aDevice, this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-04-22 22:09:22 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvDisableSwitchNotifications(const SwitchDevice& aDevice) override
|
2012-04-22 22:09:22 +04:00
|
|
|
{
|
|
|
|
hal::UnregisterSwitchObserver(aDevice, this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-04-22 22:09:22 +04:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void Notify(const SwitchEvent& aSwitchEvent) override
|
2012-04-22 22:09:22 +04:00
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNotifySwitchChange(aSwitchEvent);
|
2012-04-22 22:09:22 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvGetCurrentSwitchState(const SwitchDevice& aDevice, hal::SwitchState *aState) override
|
2012-04-22 22:09:22 +04:00
|
|
|
{
|
2012-08-16 23:34:53 +04:00
|
|
|
// Content has no reason to listen to switch events currently.
|
2012-11-30 02:52:02 +04:00
|
|
|
*aState = hal::GetCurrentSwitchState(aDevice);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-04-22 22:09:22 +04:00
|
|
|
}
|
2012-08-05 09:09:39 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void Notify(const int64_t& aClockDeltaMS) override
|
2012-10-23 11:15:43 +04:00
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNotifySystemClockChange(aClockDeltaMS);
|
2012-10-23 11:15:43 +04:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) override
|
2012-09-11 10:40:00 +04:00
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNotifySystemTimezoneChange(aSystemTimezoneChangeInfo);
|
2012-09-11 10:40:00 +04:00
|
|
|
}
|
2012-09-19 19:17:13 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvFactoryReset(const nsString& aReason) override
|
2012-10-04 13:28:34 +04:00
|
|
|
{
|
2014-07-18 05:30:47 +04:00
|
|
|
FactoryResetReason reason = FactoryResetReason::Normal;
|
|
|
|
if (aReason.EqualsLiteral("normal")) {
|
|
|
|
reason = FactoryResetReason::Normal;
|
|
|
|
} else if (aReason.EqualsLiteral("wipe")) {
|
|
|
|
reason = FactoryResetReason::Wipe;
|
2014-11-26 14:46:00 +03:00
|
|
|
} else if (aReason.EqualsLiteral("root")) {
|
|
|
|
reason = FactoryResetReason::Root;
|
2014-07-18 05:30:47 +04:00
|
|
|
} else {
|
|
|
|
// Invalid factory reset reason. That should never happen.
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2014-07-18 05:30:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
hal::FactoryReset(reason);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-10-04 13:28:34 +04:00
|
|
|
}
|
2011-10-06 02:15:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class HalChild : public PHalChild {
|
|
|
|
public:
|
2012-10-07 05:53:22 +04:00
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
ActorDestroy(ActorDestroyReason aWhy) override
|
2012-10-07 05:53:22 +04:00
|
|
|
{
|
2013-02-12 08:09:25 +04:00
|
|
|
sHalChildDestroyed = true;
|
2012-10-07 05:53:22 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvNotifyBatteryChange(const BatteryInformation& aBatteryInfo) override {
|
2011-11-02 19:14:01 +04:00
|
|
|
hal::NotifyBatteryChange(aBatteryInfo);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-11-02 19:14:01 +04:00
|
|
|
}
|
2012-01-16 17:39:57 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvNotifySensorChange(const hal::SensorData &aSensorData) override;
|
2012-02-05 23:51:06 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvNotifyNetworkChange(const NetworkInformation& aNetworkInfo) override {
|
2012-01-16 17:39:57 +04:00
|
|
|
hal::NotifyNetworkChange(aNetworkInfo);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-01-16 17:39:57 +04:00
|
|
|
}
|
2012-03-07 15:03:25 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvNotifyWakeLockChange(const WakeLockInformation& aWakeLockInfo) override {
|
2012-03-07 15:03:25 +04:00
|
|
|
hal::NotifyWakeLockChange(aWakeLockInfo);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-07 15:03:25 +04:00
|
|
|
}
|
2012-03-13 20:42:46 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvNotifyScreenConfigurationChange(const ScreenConfiguration& aScreenConfiguration) override {
|
2012-05-09 01:36:07 +04:00
|
|
|
hal::NotifyScreenConfigurationChange(aScreenConfiguration);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-03-13 20:42:46 +04:00
|
|
|
}
|
2012-04-22 22:09:22 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvNotifySwitchChange(const mozilla::hal::SwitchEvent& aEvent) override {
|
2012-04-22 22:09:22 +04:00
|
|
|
hal::NotifySwitchChange(aEvent);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-04-22 22:09:22 +04:00
|
|
|
}
|
2012-09-11 10:40:00 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2015-03-21 19:28:04 +03:00
|
|
|
RecvNotifySystemClockChange(const int64_t& aClockDeltaMS) override {
|
2012-10-23 11:15:43 +04:00
|
|
|
hal::NotifySystemClockChange(aClockDeltaMS);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-10-23 11:15:43 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2012-10-23 11:15:43 +04:00
|
|
|
RecvNotifySystemTimezoneChange(
|
2015-03-21 19:28:04 +03:00
|
|
|
const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) override {
|
2012-10-23 11:15:43 +04:00
|
|
|
hal::NotifySystemTimezoneChange(aSystemTimezoneChangeInfo);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-09-11 10:40:00 +04:00
|
|
|
}
|
2011-10-06 02:15:45 +04:00
|
|
|
};
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-02-05 23:51:06 +04:00
|
|
|
HalChild::RecvNotifySensorChange(const hal::SensorData &aSensorData) {
|
|
|
|
hal::NotifySensorChange(aSensorData);
|
2016-01-04 18:08:21 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-02-05 23:51:06 +04:00
|
|
|
}
|
|
|
|
|
2011-10-06 02:15:45 +04:00
|
|
|
PHalChild* CreateHalChild() {
|
|
|
|
return new HalChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
PHalParent* CreateHalParent() {
|
|
|
|
return new HalParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace hal_sandbox
|
|
|
|
} // namespace mozilla
|