summaryrefslogtreecommitdiffstats
path: root/hal/fallback
diff options
context:
space:
mode:
Diffstat (limited to 'hal/fallback')
-rw-r--r--hal/fallback/FallbackAlarm.cpp79
-rw-r--r--hal/fallback/FallbackBattery.cpp30
-rw-r--r--hal/fallback/FallbackDiskSpaceWatcher.cpp19
-rw-r--r--hal/fallback/FallbackFactoryReset.cpp18
-rw-r--r--hal/fallback/FallbackMemory.cpp20
-rw-r--r--hal/fallback/FallbackNetwork.cpp31
-rw-r--r--hal/fallback/FallbackPower.cpp25
-rw-r--r--hal/fallback/FallbackProcessPriority.cpp21
-rw-r--r--hal/fallback/FallbackScreenConfiguration.cpp63
-rw-r--r--hal/fallback/FallbackScreenPower.cpp41
-rw-r--r--hal/fallback/FallbackSensor.cpp23
-rw-r--r--hal/fallback/FallbackSwitch.cpp39
-rw-r--r--hal/fallback/FallbackSystemService.cpp35
-rw-r--r--hal/fallback/FallbackThreadPriority.cpp29
-rw-r--r--hal/fallback/FallbackTime.cpp54
-rw-r--r--hal/fallback/FallbackVibration.cpp23
-rw-r--r--hal/fallback/FallbackWakeLocks.cpp23
17 files changed, 573 insertions, 0 deletions
diff --git a/hal/fallback/FallbackAlarm.cpp b/hal/fallback/FallbackAlarm.cpp
new file mode 100644
index 000000000..9ec5c48e1
--- /dev/null
+++ b/hal/fallback/FallbackAlarm.cpp
@@ -0,0 +1,79 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+
+#include <algorithm>
+
+#include "mozilla/ClearOnShutdown.h"
+#include "mozilla/StaticPtr.h"
+#include "nsComponentManagerUtils.h"
+#include "nsITimer.h"
+#include "nsThreadUtils.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+static void
+TimerCallbackFunc(nsITimer *aTimer, void *aClosure)
+{
+ hal::NotifyAlarmFired();
+}
+
+static StaticRefPtr<nsITimer> sTimer;
+
+bool
+EnableAlarm()
+{
+ static bool initialized = false;
+ if (!initialized) {
+ initialized = true;
+ ClearOnShutdown(&sTimer);
+ }
+
+ nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1");
+ sTimer = timer;
+ MOZ_ASSERT(sTimer);
+ return true;
+}
+
+void
+DisableAlarm()
+{
+ /*
+ * DisableAlarm() may be called after sTimer has been set to null by
+ * ClearOnShutdown().
+ */
+ if (sTimer) {
+ sTimer->Cancel();
+ }
+}
+
+bool
+SetAlarm(int32_t aSeconds, int32_t aNanoseconds)
+{
+ if (!sTimer) {
+ MOZ_ASSERT(false, "We should have enabled the alarm");
+ return false;
+ }
+
+ // Do the math to convert aSeconds and aNanoseconds into milliseconds since
+ // the epoch.
+ int64_t milliseconds = static_cast<int64_t>(aSeconds) * 1000 +
+ static_cast<int64_t>(aNanoseconds) / 1000000;
+
+ // nsITimer expects relative milliseconds.
+ int64_t relMilliseconds = milliseconds - PR_Now() / 1000;
+
+ // If the alarm time is in the past relative to PR_Now(),
+ // we choose to immediately fire the alarm. Passing 0 means nsITimer will
+ // queue a timeout event immediately.
+ sTimer->InitWithFuncCallback(TimerCallbackFunc, nullptr,
+ clamped<int64_t>(relMilliseconds, 0, INT32_MAX),
+ nsITimer::TYPE_ONE_SHOT);
+ return true;
+}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackBattery.cpp b/hal/fallback/FallbackBattery.cpp
new file mode 100644
index 000000000..3e5e71574
--- /dev/null
+++ b/hal/fallback/FallbackBattery.cpp
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et ft=cpp : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+#include "mozilla/dom/battery/Constants.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+EnableBatteryNotifications()
+{}
+
+void
+DisableBatteryNotifications()
+{}
+
+void
+GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo)
+{
+ aBatteryInfo->level() = dom::battery::kDefaultLevel;
+ aBatteryInfo->charging() = dom::battery::kDefaultCharging;
+ aBatteryInfo->remainingTime() = dom::battery::kDefaultRemainingTime;
+}
+
+} // hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackDiskSpaceWatcher.cpp b/hal/fallback/FallbackDiskSpaceWatcher.cpp
new file mode 100644
index 000000000..99d144397
--- /dev/null
+++ b/hal/fallback/FallbackDiskSpaceWatcher.cpp
@@ -0,0 +1,19 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+StartDiskSpaceWatcher()
+{
+}
+
+void
+StopDiskSpaceWatcher()
+{
+}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackFactoryReset.cpp b/hal/fallback/FallbackFactoryReset.cpp
new file mode 100644
index 000000000..76a727702
--- /dev/null
+++ b/hal/fallback/FallbackFactoryReset.cpp
@@ -0,0 +1,18 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=8 et :
+ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+FactoryReset(mozilla::dom::FactoryResetReason&)
+{}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackMemory.cpp b/hal/fallback/FallbackMemory.cpp
new file mode 100644
index 000000000..2750eebd8
--- /dev/null
+++ b/hal/fallback/FallbackMemory.cpp
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=8 et :
+ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+uint32_t
+GetTotalSystemMemory()
+{
+ return 0;
+}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackNetwork.cpp b/hal/fallback/FallbackNetwork.cpp
new file mode 100644
index 000000000..d8995bc6d
--- /dev/null
+++ b/hal/fallback/FallbackNetwork.cpp
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=8 et :
+ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+#include "mozilla/dom/network/Constants.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+EnableNetworkNotifications()
+{}
+
+void
+DisableNetworkNotifications()
+{}
+
+void
+GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
+{
+ aNetworkInfo->type() = dom::network::kDefaultType;
+ aNetworkInfo->isWifi() = dom::network::kDefaultIsWifi;
+ aNetworkInfo->dhcpGateway() = dom::network::kDefaultDHCPGateway;
+}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackPower.cpp b/hal/fallback/FallbackPower.cpp
new file mode 100644
index 000000000..0a53e89ad
--- /dev/null
+++ b/hal/fallback/FallbackPower.cpp
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et ft=cpp : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+Reboot()
+{}
+
+void
+PowerOff()
+{}
+
+void
+StartForceQuitWatchdog(hal::ShutdownMode aMode, int32_t aTimeoutSecs)
+{}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackProcessPriority.cpp b/hal/fallback/FallbackProcessPriority.cpp
new file mode 100644
index 000000000..b03b1542e
--- /dev/null
+++ b/hal/fallback/FallbackProcessPriority.cpp
@@ -0,0 +1,21 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+#include "HalLog.h"
+
+using namespace mozilla::hal;
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+SetProcessPriority(int aPid, ProcessPriority aPriority, uint32_t aLRU)
+{
+ HAL_LOG("FallbackProcessPriority - SetProcessPriority(%d, %s, %u)\n",
+ aPid, ProcessPriorityToString(aPriority), aLRU);
+}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackScreenConfiguration.cpp b/hal/fallback/FallbackScreenConfiguration.cpp
new file mode 100644
index 000000000..cbee955fb
--- /dev/null
+++ b/hal/fallback/FallbackScreenConfiguration.cpp
@@ -0,0 +1,63 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+#include "mozilla/dom/ScreenOrientation.h"
+#include "nsIScreenManager.h"
+#include "nsServiceManagerUtils.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+EnableScreenConfigurationNotifications()
+{
+}
+
+void
+DisableScreenConfigurationNotifications()
+{
+}
+
+void
+GetCurrentScreenConfiguration(hal::ScreenConfiguration* aScreenConfiguration)
+{
+ nsresult rv;
+ nsCOMPtr<nsIScreenManager> screenMgr =
+ do_GetService("@mozilla.org/gfx/screenmanager;1", &rv);
+ if (NS_FAILED(rv)) {
+ NS_ERROR("Can't find nsIScreenManager!");
+ return;
+ }
+
+ nsIntRect rect;
+ int32_t colorDepth, pixelDepth;
+ dom::ScreenOrientationInternal orientation;
+ nsCOMPtr<nsIScreen> screen;
+
+ screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
+ screen->GetRect(&rect.x, &rect.y, &rect.width, &rect.height);
+ screen->GetColorDepth(&colorDepth);
+ screen->GetPixelDepth(&pixelDepth);
+ orientation = rect.width >= rect.height
+ ? dom::eScreenOrientation_LandscapePrimary
+ : dom::eScreenOrientation_PortraitPrimary;
+
+ *aScreenConfiguration =
+ hal::ScreenConfiguration(rect, orientation, 0, colorDepth, pixelDepth);
+}
+
+bool
+LockScreenOrientation(const dom::ScreenOrientationInternal& aOrientation)
+{
+ return false;
+}
+
+void
+UnlockScreenOrientation()
+{
+}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackScreenPower.cpp b/hal/fallback/FallbackScreenPower.cpp
new file mode 100644
index 000000000..2a7ad276f
--- /dev/null
+++ b/hal/fallback/FallbackScreenPower.cpp
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et ft=cpp : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+namespace mozilla {
+namespace hal_impl {
+
+bool
+GetScreenEnabled()
+{
+ return true;
+}
+
+void
+SetScreenEnabled(bool aEnabled)
+{}
+
+bool
+GetKeyLightEnabled()
+{
+ return true;
+}
+
+void
+SetKeyLightEnabled(bool aEnabled)
+{}
+
+double
+GetScreenBrightness()
+{
+ return 1;
+}
+
+void
+SetScreenBrightness(double aBrightness)
+{}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackSensor.cpp b/hal/fallback/FallbackSensor.cpp
new file mode 100644
index 000000000..22b1a0436
--- /dev/null
+++ b/hal/fallback/FallbackSensor.cpp
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim: set sw=4 ts=8 et ft=cpp : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Hal.h"
+
+using namespace mozilla::hal;
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+EnableSensorNotifications(SensorType aSensor) {
+}
+
+void
+DisableSensorNotifications(SensorType aSensor) {
+}
+
+}
+}
diff --git a/hal/fallback/FallbackSwitch.cpp b/hal/fallback/FallbackSwitch.cpp
new file mode 100644
index 000000000..e9b7eab0a
--- /dev/null
+++ b/hal/fallback/FallbackSwitch.cpp
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Hal.h"
+
+using namespace mozilla::hal;
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+EnableSwitchNotifications(SwitchDevice aDevice)
+{
+}
+
+void
+DisableSwitchNotifications(SwitchDevice aDevice)
+{
+}
+
+SwitchState
+GetCurrentSwitchState(SwitchDevice aDevice) {
+ return SWITCH_STATE_UNKNOWN;
+}
+
+void
+NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState)
+{
+}
+
+bool IsHeadphoneEventFromInputDev()
+{
+ return false;
+}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackSystemService.cpp b/hal/fallback/FallbackSystemService.cpp
new file mode 100644
index 000000000..93365c47c
--- /dev/null
+++ b/hal/fallback/FallbackSystemService.cpp
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et ft=cpp : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+nsresult
+StartSystemService(const char* aSvcName, const char* aArgs)
+{
+ MOZ_ASSERT(NS_IsMainThread());
+
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+void
+StopSystemService(const char* aSvcName)
+{
+ MOZ_ASSERT(NS_IsMainThread());
+}
+
+bool
+SystemServiceIsRunning(const char* aSvcName)
+{
+ MOZ_ASSERT(NS_IsMainThread());
+
+ return false;
+}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackThreadPriority.cpp b/hal/fallback/FallbackThreadPriority.cpp
new file mode 100644
index 000000000..dce5dfa82
--- /dev/null
+++ b/hal/fallback/FallbackThreadPriority.cpp
@@ -0,0 +1,29 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+#include "HalLog.h"
+
+using namespace mozilla::hal;
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+SetCurrentThreadPriority(ThreadPriority aPriority)
+{
+ HAL_LOG("FallbackThreadPriority - SetCurrentThreadPriority(%d)\n",
+ ThreadPriorityToString(aPriority));
+}
+
+void
+SetThreadPriority(PlatformThreadId aThreadId,
+ ThreadPriority aPriority)
+{
+ HAL_LOG("FallbackThreadPriority - SetThreadPriority(%d, %d)\n",
+ aThreadId, ThreadPriorityToString(aPriority));
+}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackTime.cpp b/hal/fallback/FallbackTime.cpp
new file mode 100644
index 000000000..a2c56e817
--- /dev/null
+++ b/hal/fallback/FallbackTime.cpp
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=8 et :
+ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+AdjustSystemClock(int64_t aDeltaMilliseconds)
+{}
+
+void
+SetTimezone(const nsCString& aTimezoneSpec)
+{}
+
+nsCString
+GetTimezone()
+{
+ return EmptyCString();
+}
+
+int32_t
+GetTimezoneOffset()
+{
+ return 0;
+}
+
+void
+EnableSystemClockChangeNotifications()
+{
+}
+
+void
+DisableSystemClockChangeNotifications()
+{
+}
+
+void
+EnableSystemTimezoneChangeNotifications()
+{
+}
+
+void
+DisableSystemTimezoneChangeNotifications()
+{
+}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackVibration.cpp b/hal/fallback/FallbackVibration.cpp
new file mode 100644
index 000000000..ffabe9efe
--- /dev/null
+++ b/hal/fallback/FallbackVibration.cpp
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et ft=cpp : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+
+using mozilla::hal::WindowIdentifier;
+
+namespace mozilla {
+namespace hal_impl {
+
+void
+Vibrate(const nsTArray<uint32_t>& pattern, const hal::WindowIdentifier &)
+{}
+
+void
+CancelVibrate(const hal::WindowIdentifier &)
+{}
+
+} // namespace hal_impl
+} // namespace mozilla
diff --git a/hal/fallback/FallbackWakeLocks.cpp b/hal/fallback/FallbackWakeLocks.cpp
new file mode 100644
index 000000000..1fd97a2e6
--- /dev/null
+++ b/hal/fallback/FallbackWakeLocks.cpp
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et ft=cpp : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Hal.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+bool
+GetCpuSleepAllowed()
+{
+ return true;
+}
+
+void
+SetCpuSleepAllowed(bool allowed)
+{}
+
+} // namespace hal_impl
+} // namespace mozilla