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"
|
2012-12-22 15:53:38 +04:00
|
|
|
#include "mozilla/AppProcessChecker.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"
|
|
|
|
#include "mozilla/unused.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
|
|
|
{
|
2011-09-30 11:00:48 +04:00
|
|
|
HAL_LOG(("Vibrate: Sending to parent process."));
|
|
|
|
|
2012-05-25 11:18:30 +04:00
|
|
|
AutoInfallibleTArray<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)
|
|
|
|
{
|
|
|
|
HAL_LOG(("CancelVibrate: Sending to parent process."));
|
|
|
|
|
|
|
|
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
|
|
|
|
LockScreenOrientation(const dom::ScreenOrientation& aOrientation)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-02-17 14:44:00 +04: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));
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2012-09-26 13:12:33 +04:00
|
|
|
NS_RUNTIMEABORT("Reboot() can't be called from sandboxed contexts.");
|
2012-01-31 10:08:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PowerOff()
|
|
|
|
{
|
2012-09-26 13:12:33 +04:00
|
|
|
NS_RUNTIMEABORT("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)
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("StartForceQuitWatchdog() can't be called from sandboxed contexts.");
|
|
|
|
}
|
|
|
|
|
2012-02-05 23:51:06 +04:00
|
|
|
void
|
|
|
|
EnableSensorNotifications(SensorType aSensor) {
|
|
|
|
Hal()->SendEnableSensorNotifications(aSensor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableSensorNotifications(SensorType aSensor) {
|
|
|
|
Hal()->SendDisableSensorNotifications(aSensor);
|
|
|
|
}
|
|
|
|
|
2011-08-03 22:12:08 +04:00
|
|
|
//TODO: bug 852944 - IPC implementations of these
|
|
|
|
void StartMonitoringGamepadStatus()
|
|
|
|
{}
|
|
|
|
|
|
|
|
void StopMonitoringGamepadStatus()
|
|
|
|
{}
|
|
|
|
|
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)
|
|
|
|
{
|
2014-06-03 03:25:00 +04:00
|
|
|
unused << aDevice;
|
|
|
|
unused << aState;
|
|
|
|
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
|
2013-05-10 00:27:06 +04:00
|
|
|
SetProcessPriority(int aPid,
|
|
|
|
ProcessPriority aPriority,
|
2013-10-01 07:54:59 +04:00
|
|
|
ProcessCPUPriority aCPUPriority,
|
|
|
|
uint32_t aBackgroundLRU)
|
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)
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("Setting thread priority cannot be called from sandboxed contexts.");
|
|
|
|
}
|
|
|
|
|
2012-09-19 19:17:13 +04:00
|
|
|
void
|
|
|
|
EnableFMRadio(const hal::FMRadioSettings& aSettings)
|
|
|
|
{
|
2012-12-04 20:57:31 +04:00
|
|
|
NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
|
2012-09-19 19:17:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableFMRadio()
|
|
|
|
{
|
2012-12-04 20:57:31 +04:00
|
|
|
NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
|
2012-09-19 19:17:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FMRadioSeek(const hal::FMRadioSeekDirection& aDirection)
|
|
|
|
{
|
2012-12-04 20:57:31 +04:00
|
|
|
NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
|
2012-09-19 19:17:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetFMRadioSettings(FMRadioSettings* aSettings)
|
|
|
|
{
|
2012-12-04 20:57:31 +04:00
|
|
|
NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
|
2012-09-19 19:17:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetFMRadioFrequency(const uint32_t aFrequency)
|
|
|
|
{
|
2012-12-04 20:57:31 +04:00
|
|
|
NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
|
2012-09-19 19:17:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
GetFMRadioFrequency()
|
|
|
|
{
|
2012-12-04 20:57:31 +04:00
|
|
|
NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
|
|
|
|
return 0;
|
2012-09-19 19:17:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsFMRadioOn()
|
|
|
|
{
|
2012-12-04 20:57:31 +04:00
|
|
|
NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
|
|
|
|
return false;
|
2012-09-19 19:17:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
GetFMRadioSignalStrength()
|
|
|
|
{
|
2012-12-04 20:57:31 +04:00
|
|
|
NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
|
|
|
|
return 0;
|
2012-09-19 19:17:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CancelFMRadioSeek()
|
|
|
|
{
|
2012-12-04 20:57:31 +04:00
|
|
|
NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts.");
|
2012-09-19 19:17:13 +04:00
|
|
|
}
|
|
|
|
|
2012-10-04 13:28:34 +04:00
|
|
|
void
|
|
|
|
FactoryReset()
|
|
|
|
{
|
|
|
|
Hal()->SendFactoryReset();
|
|
|
|
}
|
|
|
|
|
2013-05-10 02:57:31 +04:00
|
|
|
void
|
|
|
|
StartDiskSpaceWatcher()
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("StartDiskSpaceWatcher() can't be called from sandboxed contexts.");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StopDiskSpaceWatcher()
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("StopDiskSpaceWatcher() can't be called from sandboxed contexts.");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
2011-09-30 11:00:48 +04:00
|
|
|
RecvVibrate(const InfallibleTArray<unsigned int>& pattern,
|
2012-05-25 11:18:30 +04:00
|
|
|
const InfallibleTArray<uint64_t> &id,
|
2012-07-06 22:15:45 +04:00
|
|
|
PBrowserParent *browserParent) MOZ_OVERRIDE
|
2011-09-30 11:00:48 +04:00
|
|
|
{
|
2012-08-16 23:34:53 +04:00
|
|
|
// We give all content vibration permission.
|
2011-09-30 11:00:48 +04:00
|
|
|
TabParent *tabParent = static_cast<TabParent*>(browserParent);
|
|
|
|
nsCOMPtr<nsIDOMWindow> window =
|
|
|
|
do_QueryInterface(tabParent->GetBrowserDOMWindow());
|
|
|
|
WindowIdentifier newID(id, window);
|
2012-12-19 05:16:06 +04:00
|
|
|
hal::Vibrate(pattern, newID);
|
2011-09-30 11:00:48 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
2012-05-25 11:18:30 +04:00
|
|
|
RecvCancelVibrate(const InfallibleTArray<uint64_t> &id,
|
2012-07-06 22:15:45 +04:00
|
|
|
PBrowserParent *browserParent) MOZ_OVERRIDE
|
2011-09-30 11:00:48 +04:00
|
|
|
{
|
|
|
|
TabParent *tabParent = static_cast<TabParent*>(browserParent);
|
|
|
|
nsCOMPtr<nsIDOMWindow> window =
|
|
|
|
do_QueryInterface(tabParent->GetBrowserDOMWindow());
|
|
|
|
WindowIdentifier newID(id, window);
|
|
|
|
hal::CancelVibrate(newID);
|
2011-10-06 02:15:45 +04:00
|
|
|
return true;
|
|
|
|
}
|
2011-11-02 19:14:01 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvEnableBatteryNotifications() MOZ_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);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvDisableBatteryNotifications() MOZ_OVERRIDE {
|
2011-11-02 19:14:01 +04:00
|
|
|
hal::UnregisterBatteryObserver(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvGetCurrentBatteryInformation(BatteryInformation* aBatteryInfo) MOZ_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);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
void Notify(const BatteryInformation& aBatteryInfo) MOZ_OVERRIDE {
|
2011-11-02 19:14:01 +04:00
|
|
|
unused << SendNotifyBatteryChange(aBatteryInfo);
|
|
|
|
}
|
2011-12-04 21:07:00 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvEnableNetworkNotifications() MOZ_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);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvDisableNetworkNotifications() MOZ_OVERRIDE {
|
2012-01-16 17:39:57 +04:00
|
|
|
hal::UnregisterNetworkObserver(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvGetCurrentNetworkInformation(NetworkInformation* aNetworkInfo) MOZ_OVERRIDE {
|
2012-01-16 17:39:57 +04:00
|
|
|
hal::GetCurrentNetworkInformation(aNetworkInfo);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Notify(const NetworkInformation& aNetworkInfo) {
|
|
|
|
unused << SendNotifyNetworkChange(aNetworkInfo);
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvEnableScreenConfigurationNotifications() MOZ_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);
|
2012-03-13 20:42:46 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvDisableScreenConfigurationNotifications() MOZ_OVERRIDE {
|
2012-05-09 01:36:07 +04:00
|
|
|
hal::UnregisterScreenConfigurationObserver(this);
|
2012-03-13 20:42:46 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvGetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration) MOZ_OVERRIDE {
|
2012-05-09 01:36:07 +04:00
|
|
|
hal::GetCurrentScreenConfiguration(aScreenConfiguration);
|
2012-03-13 20:42:46 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvLockScreenOrientation(const dom::ScreenOrientation& aOrientation, bool* aAllowed) MOZ_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);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvUnlockScreenOrientation() MOZ_OVERRIDE
|
2012-03-29 23:43:16 +04:00
|
|
|
{
|
|
|
|
hal::UnlockScreenOrientation();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-09 01:36:07 +04:00
|
|
|
void Notify(const ScreenConfiguration& aScreenConfiguration) {
|
|
|
|
unused << SendNotifyScreenConfigurationChange(aScreenConfiguration);
|
2012-03-13 20:42:46 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
2014-05-30 07:11:23 +04:00
|
|
|
RecvGetScreenEnabled(bool* aEnabled) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (!AssertAppProcessPermission(this, "power")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
*aEnabled = hal::GetScreenEnabled();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvSetScreenEnabled(const bool& aEnabled) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (!AssertAppProcessPermission(this, "power")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
hal::SetScreenEnabled(aEnabled);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvGetKeyLightEnabled(bool* aEnabled) MOZ_OVERRIDE
|
2011-12-04 21:07:00 +04:00
|
|
|
{
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "power")) {
|
2012-08-16 23:34:53 +04:00
|
|
|
return false;
|
|
|
|
}
|
2014-05-30 07:11:23 +04:00
|
|
|
*aEnabled = hal::GetKeyLightEnabled();
|
2011-12-04 21:07:00 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
2014-05-30 07:11:23 +04:00
|
|
|
RecvSetKeyLightEnabled(const bool& aEnabled) MOZ_OVERRIDE
|
2011-12-04 21:07:00 +04:00
|
|
|
{
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "power")) {
|
2012-08-16 23:34:53 +04:00
|
|
|
return false;
|
|
|
|
}
|
2014-05-30 07:11:23 +04:00
|
|
|
hal::SetKeyLightEnabled(aEnabled);
|
2011-12-04 21:07:00 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
2014-05-30 07:11:23 +04:00
|
|
|
RecvGetCpuSleepAllowed(bool* aAllowed) MOZ_OVERRIDE
|
2012-04-17 02:35:33 +04:00
|
|
|
{
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "power")) {
|
2012-08-16 23:34:53 +04:00
|
|
|
return false;
|
|
|
|
}
|
2014-05-30 07:11:23 +04:00
|
|
|
*aAllowed = hal::GetCpuSleepAllowed();
|
2012-04-17 02:35:33 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
2014-05-30 07:11:23 +04:00
|
|
|
RecvSetCpuSleepAllowed(const bool& aAllowed) MOZ_OVERRIDE
|
2012-04-17 02:35:33 +04:00
|
|
|
{
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "power")) {
|
2012-08-16 23:34:53 +04:00
|
|
|
return false;
|
|
|
|
}
|
2014-05-30 07:11:23 +04:00
|
|
|
hal::SetCpuSleepAllowed(aAllowed);
|
2012-04-17 02:35:33 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
2014-05-30 07:11:23 +04:00
|
|
|
RecvGetScreenBrightness(double* aBrightness) MOZ_OVERRIDE
|
2011-12-04 21:07:00 +04:00
|
|
|
{
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "power")) {
|
2012-08-16 23:34:53 +04:00
|
|
|
return false;
|
|
|
|
}
|
2014-05-30 07:11:23 +04:00
|
|
|
*aBrightness = hal::GetScreenBrightness();
|
2011-12-04 21:07:00 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
2014-05-30 07:11:23 +04:00
|
|
|
RecvSetScreenBrightness(const double& aBrightness) MOZ_OVERRIDE
|
2011-12-04 21:07:00 +04:00
|
|
|
{
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "power")) {
|
2012-08-16 23:34:53 +04:00
|
|
|
return false;
|
|
|
|
}
|
2014-05-30 07:11:23 +04:00
|
|
|
hal::SetScreenBrightness(aBrightness);
|
2011-12-04 21:07:00 +04:00
|
|
|
return true;
|
|
|
|
}
|
2012-01-31 10:08:00 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
2012-09-26 07:51:29 +04:00
|
|
|
RecvAdjustSystemClock(const int64_t &aDeltaMilliseconds) MOZ_OVERRIDE
|
2012-02-17 14:44:00 +04:00
|
|
|
{
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "time")) {
|
2012-08-16 23:34:53 +04:00
|
|
|
return false;
|
|
|
|
}
|
2012-02-17 14:44:00 +04:00
|
|
|
hal::AdjustSystemClock(aDeltaMilliseconds);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvSetTimezone(const nsCString& aTimezoneSpec) MOZ_OVERRIDE
|
2012-02-17 14:44:00 +04:00
|
|
|
{
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "time")) {
|
2012-08-16 23:34:53 +04:00
|
|
|
return false;
|
|
|
|
}
|
2012-02-17 14:44:00 +04:00
|
|
|
hal::SetTimezone(aTimezoneSpec);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-23 13:00:00 +04:00
|
|
|
virtual bool
|
|
|
|
RecvGetTimezone(nsCString *aTimezoneSpec) MOZ_OVERRIDE
|
|
|
|
{
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "time")) {
|
2012-08-23 13:00:00 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
*aTimezoneSpec = hal::GetTimezone();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-15 12:43:53 +04:00
|
|
|
virtual bool
|
|
|
|
RecvGetTimezoneOffset(int32_t *aTimezoneOffset) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (!AssertAppProcessPermission(this, "time")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
*aTimezoneOffset = hal::GetTimezoneOffset();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-23 21:00:32 +04:00
|
|
|
virtual bool
|
2012-10-23 11:15:43 +04:00
|
|
|
RecvEnableSystemClockChangeNotifications() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
hal::RegisterSystemClockChangeObserver(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvDisableSystemClockChangeNotifications() MOZ_OVERRIDE
|
2012-09-23 21:00:32 +04:00
|
|
|
{
|
2012-10-23 11:15:43 +04:00
|
|
|
hal::UnregisterSystemClockChangeObserver(this);
|
2012-09-23 21:00:32 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
2012-10-23 11:15:43 +04:00
|
|
|
RecvEnableSystemTimezoneChangeNotifications() MOZ_OVERRIDE
|
2012-09-23 21:00:32 +04:00
|
|
|
{
|
2012-10-23 11:15:43 +04:00
|
|
|
hal::RegisterSystemTimezoneChangeObserver(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvDisableSystemTimezoneChangeNotifications() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
hal::UnregisterSystemTimezoneChangeObserver(this);
|
2012-09-23 21:00:32 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvEnableSensorNotifications(const SensorType &aSensor) MOZ_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);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvDisableSensorNotifications(const SensorType &aSensor) MOZ_OVERRIDE {
|
2012-02-05 23:51:06 +04:00
|
|
|
hal::UnregisterSensorObserver(aSensor, this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Notify(const SensorData& aSensorData) {
|
|
|
|
unused << SendNotifySensorChange(aSensorData);
|
|
|
|
}
|
2012-03-07 15:03:25 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
2012-11-17 19:05:18 +04:00
|
|
|
RecvModifyWakeLock(const nsString& aTopic,
|
|
|
|
const WakeLockControl& aLockAdjust,
|
|
|
|
const WakeLockControl& aHiddenAdjust,
|
|
|
|
const uint64_t& aProcessID) MOZ_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);
|
2012-03-07 15:03:25 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvEnableWakeLockNotifications() MOZ_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);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvDisableWakeLockNotifications() MOZ_OVERRIDE
|
2012-03-07 15:03:25 +04:00
|
|
|
{
|
|
|
|
hal::UnregisterWakeLockObserver(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvGetWakeLockInfo(const nsString &aTopic, WakeLockInformation *aWakeLockInfo) MOZ_OVERRIDE
|
2012-03-07 15:03:25 +04:00
|
|
|
{
|
|
|
|
hal::GetWakeLockInfo(aTopic, aWakeLockInfo);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Notify(const WakeLockInformation& aWakeLockInfo)
|
|
|
|
{
|
|
|
|
unused << SendNotifyWakeLockChange(aWakeLockInfo);
|
|
|
|
}
|
2012-04-22 22:09:22 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvEnableSwitchNotifications(const SwitchDevice& aDevice) MOZ_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);
|
|
|
|
return true;
|
2012-04-22 22:09:22 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvDisableSwitchNotifications(const SwitchDevice& aDevice) MOZ_OVERRIDE
|
2012-04-22 22:09:22 +04:00
|
|
|
{
|
|
|
|
hal::UnregisterSwitchObserver(aDevice, this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Notify(const SwitchEvent& aSwitchEvent)
|
|
|
|
{
|
|
|
|
unused << SendNotifySwitchChange(aSwitchEvent);
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvGetCurrentSwitchState(const SwitchDevice& aDevice, hal::SwitchState *aState) MOZ_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);
|
|
|
|
return true;
|
2012-04-22 22:09:22 +04:00
|
|
|
}
|
2012-08-05 09:09:39 +04:00
|
|
|
|
2012-10-23 11:15:43 +04:00
|
|
|
void Notify(const int64_t& aClockDeltaMS)
|
|
|
|
{
|
|
|
|
unused << SendNotifySystemClockChange(aClockDeltaMS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
|
2012-09-11 10:40:00 +04:00
|
|
|
{
|
2012-10-23 11:15:43 +04:00
|
|
|
unused << SendNotifySystemTimezoneChange(aSystemTimezoneChangeInfo);
|
2012-09-11 10:40:00 +04:00
|
|
|
}
|
2012-09-19 19:17:13 +04:00
|
|
|
|
2012-10-04 13:28:34 +04:00
|
|
|
virtual bool
|
|
|
|
RecvFactoryReset()
|
|
|
|
{
|
|
|
|
if (!AssertAppProcessPermission(this, "power")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
hal::FactoryReset();
|
|
|
|
return true;
|
|
|
|
}
|
2013-06-03 14:14:37 +04:00
|
|
|
|
|
|
|
virtual mozilla::ipc::IProtocol*
|
|
|
|
CloneProtocol(Channel* aChannel,
|
|
|
|
mozilla::ipc::ProtocolCloneContext* aCtx) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
ContentParent* contentParent = aCtx->GetContentParent();
|
|
|
|
nsAutoPtr<PHalParent> actor(contentParent->AllocPHalParent());
|
|
|
|
if (!actor || !contentParent->RecvPHalConstructor(actor)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return actor.forget();
|
|
|
|
}
|
2011-10-06 02:15:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class HalChild : public PHalChild {
|
|
|
|
public:
|
2012-10-07 05:53:22 +04:00
|
|
|
virtual void
|
|
|
|
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE
|
|
|
|
{
|
2013-02-12 08:09:25 +04:00
|
|
|
sHalChildDestroyed = true;
|
2012-10-07 05:53:22 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvNotifyBatteryChange(const BatteryInformation& aBatteryInfo) MOZ_OVERRIDE {
|
2011-11-02 19:14:01 +04:00
|
|
|
hal::NotifyBatteryChange(aBatteryInfo);
|
|
|
|
return true;
|
|
|
|
}
|
2012-01-16 17:39:57 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvNotifySensorChange(const hal::SensorData &aSensorData) MOZ_OVERRIDE;
|
2012-02-05 23:51:06 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvNotifyNetworkChange(const NetworkInformation& aNetworkInfo) MOZ_OVERRIDE {
|
2012-01-16 17:39:57 +04:00
|
|
|
hal::NotifyNetworkChange(aNetworkInfo);
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-07 15:03:25 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvNotifyWakeLockChange(const WakeLockInformation& aWakeLockInfo) MOZ_OVERRIDE {
|
2012-03-07 15:03:25 +04:00
|
|
|
hal::NotifyWakeLockChange(aWakeLockInfo);
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-13 20:42:46 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvNotifyScreenConfigurationChange(const ScreenConfiguration& aScreenConfiguration) MOZ_OVERRIDE {
|
2012-05-09 01:36:07 +04:00
|
|
|
hal::NotifyScreenConfigurationChange(aScreenConfiguration);
|
2012-03-13 20:42:46 +04:00
|
|
|
return true;
|
|
|
|
}
|
2012-04-22 22:09:22 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
virtual bool
|
|
|
|
RecvNotifySwitchChange(const mozilla::hal::SwitchEvent& aEvent) MOZ_OVERRIDE {
|
2012-04-22 22:09:22 +04:00
|
|
|
hal::NotifySwitchChange(aEvent);
|
|
|
|
return true;
|
|
|
|
}
|
2012-09-11 10:40:00 +04:00
|
|
|
|
|
|
|
virtual bool
|
2012-10-23 11:15:43 +04:00
|
|
|
RecvNotifySystemClockChange(const int64_t& aClockDeltaMS) {
|
|
|
|
hal::NotifySystemClockChange(aClockDeltaMS);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvNotifySystemTimezoneChange(
|
|
|
|
const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) {
|
|
|
|
hal::NotifySystemTimezoneChange(aSystemTimezoneChangeInfo);
|
2012-09-11 10:40:00 +04:00
|
|
|
return true;
|
|
|
|
}
|
2011-10-06 02:15:45 +04:00
|
|
|
};
|
|
|
|
|
2012-02-05 23:51:06 +04:00
|
|
|
bool
|
|
|
|
HalChild::RecvNotifySensorChange(const hal::SensorData &aSensorData) {
|
|
|
|
hal::NotifySensorChange(aSensorData);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-10-06 02:15:45 +04:00
|
|
|
PHalChild* CreateHalChild() {
|
|
|
|
return new HalChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
PHalParent* CreateHalParent() {
|
|
|
|
return new HalParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace hal_sandbox
|
|
|
|
} // namespace mozilla
|