Bug 749645 - Use fallback files in hal/ when a backend isn't implemneted instead of having randomly defined methods. r=cjones
authorMounir Lamouri <mounir.lamouri@gmail.com>
Thu, 03 May 2012 12:05:32 +0200
changeset 97030 cda84ca70452c67a0ec6c544f1b1dfaa1f76f2e8
parent 97029 074c8fb332a8bf7642c5a770b01d7dc784404c8f
child 97031 82ad89c00ec6f70d124a8f4dd0d9c1aee513b72a
push id1116
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 19:38:18 +0000
treeherdermozilla-beta@95f959a8b4dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs749645
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 749645 - Use fallback files in hal/ when a backend isn't implemneted instead of having randomly defined methods. r=cjones
hal/Makefile.in
hal/android/AndroidHal.cpp
hal/fallback/FallbackBattery.cpp
hal/fallback/FallbackHal.cpp
hal/fallback/FallbackNetwork.cpp
hal/fallback/FallbackPower.cpp
hal/fallback/FallbackScreenOrientation.cpp
hal/fallback/FallbackScreenPower.cpp
hal/fallback/FallbackVibration.cpp
hal/fallback/ScreenOrientationFallback.cpp
hal/gonk/GonkHal.cpp
hal/linux/LinuxHal.cpp
hal/linux/LinuxPower.cpp
hal/linux/Power.cpp
hal/windows/WindowsHal.cpp
--- a/hal/Makefile.in
+++ b/hal/Makefile.in
@@ -73,67 +73,80 @@ CPPSRCS = \
   WindowIdentifier.cpp \
   HalWakeLock.cpp \
   $(NULL)
 
 ifeq (android,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS += \
   AndroidHal.cpp \
   AndroidSensor.cpp \
+  FallbackPower.cpp \
   $(NULL)
 else ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS += \
   GonkHal.cpp \
-  Power.cpp \
+  LinuxPower.cpp \
   GonkSensor.cpp \
   UeventPoller.cpp \
   GonkSwitch.cpp \
   $(NULL)
 else ifeq (Linux,$(OS_TARGET))
 CPPSRCS += \
-  LinuxHal.cpp \
+  LinuxPower.cpp \
   FallbackSensor.cpp \
-  Power.cpp \
+  FallbackVibration.cpp \
   $(NULL)
 ifdef MOZ_ENABLE_DBUS
 CPPSRCS += UPowerClient.cpp
+else
+CPPSRCS += FallbackBattery.cpp
 endif
 else ifeq (WINNT,$(OS_TARGET))
 CPPSRCS += \
-  WindowsHal.cpp \
   WindowsBattery.cpp \
   WindowsSensor.cpp \
+  FallbackVibration.cpp \
+  FallbackPower.cpp \
   $(NULL)
 else ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS += \
-  FallbackHal.cpp \
+  FallbackBattery.cpp \
+  FallbackVibration.cpp \
+  FallbackPower.cpp \
   $(NULL)
 CMMSRCS += \
   CocoaSensor.mm \
   smslib.mm \
   $(NULL)
 else
 CPPSRCS += \
-  FallbackHal.cpp \
+  FallbackBattery.cpp \
   FallbackSensor.cpp \
+  FallbackVibration.cpp \
+  FallbackPower.cpp \
   $(NULL)
 endif
 
+# Fallbacks for backends implemented on Gonk only.
 ifneq (gonk,$(MOZ_WIDGET_TOOLKIT)) #{
 CPPSRCS += \
   FallbackLights.cpp  \
   FallbackTime.cpp \
   FallbackWakeLocks.cpp \
   FallbackSwitch.cpp \
+  FallbackScreenPower.cpp \
   $(NULL)
 endif #}
 
-# Screen Orientation backend
+# Fallbacks for backends implemented on Android only.
 ifneq (android,$(MOZ_WIDGET_TOOLKIT))
-CPPSRCS += ScreenOrientationFallback.cpp
+CPPSRCS += \
+  FallbackNetwork.cpp \
+  FallbackScreenOrientation.cpp \
+  $(NULL)
 endif
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 CFLAGS          += $(MOZ_DBUS_GLIB_CFLAGS)
 CXXFLAGS        += $(MOZ_DBUS_GLIB_CFLAGS)
--- a/hal/android/AndroidHal.cpp
+++ b/hal/android/AndroidHal.cpp
@@ -116,36 +116,16 @@ GetCurrentBatteryInformation(hal::Batter
   AndroidBridge* bridge = AndroidBridge::Bridge();
   if (!bridge) {
     return;
   }
 
   bridge->GetCurrentBatteryInformation(aBatteryInfo);
 }
 
-bool
-GetScreenEnabled()
-{
-  return true;
-}
-
-void
-SetScreenEnabled(bool enabled)
-{}
-
-double
-GetScreenBrightness()
-{
-  return 1;
-}
-
-void
-SetScreenBrightness(double brightness)
-{}
-
 void
 EnableNetworkNotifications()
 {
   AndroidBridge* bridge = AndroidBridge::Bridge();
   if (!bridge) {
     return;
   }
 
@@ -170,24 +150,16 @@ GetCurrentNetworkInformation(hal::Networ
   if (!bridge) {
     return;
   }
 
   bridge->GetCurrentNetworkInformation(aNetworkInfo);
 }
 
 void
-Reboot()
-{}
-
-void
-PowerOff()
-{}
-
-void
 EnableScreenOrientationNotifications()
 {
   AndroidBridge* bridge = AndroidBridge::Bridge();
   if (!bridge) {
     return;
   }
 
   bridge->EnableScreenOrientationNotifications();
new file mode 100644
--- /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
deleted file mode 100644
--- a/hal/fallback/FallbackHal.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- 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"
-#include "mozilla/dom/network/Constants.h"
-
-using mozilla::hal::WindowIdentifier;
-
-namespace mozilla {
-namespace hal_impl {
-
-void
-Vibrate(const nsTArray<uint32>& pattern, const hal::WindowIdentifier &)
-{}
-
-void
-CancelVibrate(const hal::WindowIdentifier &)
-{}
-
-void
-EnableBatteryNotifications()
-{}
-
-void
-DisableBatteryNotifications()
-{}
-
-void
-GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo)
-{
-  aBatteryInfo->level() = dom::battery::kDefaultLevel;
-  aBatteryInfo->charging() = dom::battery::kDefaultCharging;
-  aBatteryInfo->remainingTime() = dom::battery::kDefaultRemainingTime;
-}
-
-bool
-GetScreenEnabled()
-{
-  return true;
-}
-
-void
-SetScreenEnabled(bool enabled)
-{}
-
-double
-GetScreenBrightness()
-{
-  return 1;
-}
-
-void
-SetScreenBrightness(double brightness)
-{}
-
-void
-EnableNetworkNotifications()
-{}
-
-void
-DisableNetworkNotifications()
-{}
-
-void
-GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
-{
-  aNetworkInfo->bandwidth() = dom::network::kDefaultBandwidth;
-  aNetworkInfo->canBeMetered() = dom::network::kDefaultCanBeMetered;
-}
-
-void
-Reboot()
-{}
-
-void
-PowerOff()
-{}
-
-} // hal_impl
-} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/hal/fallback/FallbackNetwork.cpp
@@ -0,0 +1,30 @@
+/* -*- 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->bandwidth() = dom::network::kDefaultBandwidth;
+  aNetworkInfo->canBeMetered() = dom::network::kDefaultCanBeMetered;
+}
+
+} // namespace hal_impl
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/hal/fallback/FallbackPower.cpp
@@ -0,0 +1,19 @@
+/* -*- 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 {
+
+void
+Reboot()
+{}
+
+void
+PowerOff()
+{}
+
+} // hal_impl
+} // namespace mozilla
rename from hal/fallback/ScreenOrientationFallback.cpp
rename to hal/fallback/FallbackScreenOrientation.cpp
new file mode 100644
--- /dev/null
+++ b/hal/fallback/FallbackScreenPower.cpp
@@ -0,0 +1,31 @@
+/* -*- 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 enabled)
+{}
+
+double
+GetScreenBrightness()
+{
+  return 1;
+}
+
+void
+SetScreenBrightness(double brightness)
+{}
+
+} // hal_impl
+} // namespace mozilla
new file mode 100644
--- /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>& pattern, const hal::WindowIdentifier &)
+{}
+
+void
+CancelVibrate(const hal::WindowIdentifier &)
+{}
+
+} // hal_impl
+} // namespace mozilla
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -27,17 +27,16 @@
 #include "UeventPoller.h"
 #include <stdio.h>
 #include <math.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <time.h>
 #include <sys/syscall.h>
 #include <cutils/properties.h>
-#include "mozilla/dom/network/Constants.h"
 #include <android/log.h>
 
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
 #define NsecPerMsec  1000000
 #define NsecPerSec   1000000000
 
 
 using mozilla::hal::WindowIdentifier;
@@ -588,26 +587,10 @@ void
 SetTimezone(const nsCString& aTimezoneSpec)
 { 
   property_set("persist.sys.timezone", aTimezoneSpec.get());
   // this function is automatically called by the other time conversion 
   // functions that depend on the timezone. To be safe, we call it manually.  
   tzset();
 }
 
-
-void
-EnableNetworkNotifications()
-{}
-
-void
-DisableNetworkNotifications()
-{}
-
-void
-GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
-{
-  aNetworkInfo->bandwidth() = dom::network::kDefaultBandwidth;
-  aNetworkInfo->canBeMetered() = dom::network::kDefaultCanBeMetered;
-}
-
 } // hal_impl
 } // mozilla
deleted file mode 100644
--- a/hal/linux/LinuxHal.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "Hal.h"
-#include "mozilla/dom/network/Constants.h"
-
-#ifndef MOZ_ENABLE_DBUS
-#include <mozilla/dom/battery/Constants.h>
-#endif // !MOZ_ENABLE_DBUS
-
-namespace mozilla {
-namespace hal_impl {
-
-void
-Vibrate(const nsTArray<uint32>& pattern, const hal::WindowIdentifier &)
-{}
-
-void
-CancelVibrate(const hal::WindowIdentifier &)
-{}
-
-#ifndef MOZ_ENABLE_DBUS
-void
-EnableBatteryNotifications()
-{}
-
-void
-DisableBatteryNotifications()
-{}
-
-void
-GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo)
-{
-  aBatteryInfo->level() = dom::battery::kDefaultLevel;
-  aBatteryInfo->charging() = dom::battery::kDefaultCharging;
-  aBatteryInfo->remainingTime() = dom::battery::kDefaultRemainingTime;
-}
-#endif // !MOZ_ENABLE_DBUS
-
-bool
-GetScreenEnabled()
-{
-  return true;
-}
-
-void
-SetScreenEnabled(bool enabled)
-{}
-
-double
-GetScreenBrightness()
-{
-  return 1;
-}
-
-void
-SetScreenBrightness(double brightness)
-{}
-
-void
-EnableNetworkNotifications()
-{}
-
-void
-DisableNetworkNotifications()
-{}
-
-void
-GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
-{
-  aNetworkInfo->bandwidth() = dom::network::kDefaultBandwidth;
-  aNetworkInfo->canBeMetered() = dom::network::kDefaultCanBeMetered;
-}
-
-} // hal_impl
-} // mozilla
-
rename from hal/linux/Power.cpp
rename to hal/linux/LinuxPower.cpp
deleted file mode 100644
--- a/hal/windows/WindowsHal.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is the Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Makoto Kato <m_kato@ga2.so-net.ne.jp> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "Hal.h"
-#include "mozilla/dom/network/Constants.h"
-
-namespace mozilla {
-namespace hal_impl {
-
-void
-Vibrate(const nsTArray<uint32>& pattern, const hal::WindowIdentifier &)
-{}
-
-void
-CancelVibrate(const hal::WindowIdentifier &)
-{}
-
-bool
-GetScreenEnabled()
-{
-  return true;
-}
-
-void
-SetScreenEnabled(bool enabled)
-{}
-
-double
-GetScreenBrightness()
-{
-  return 1;
-}
-
-void
-SetScreenBrightness(double brightness)
-{}
-
-void
-EnableNetworkNotifications()
-{}
-
-void
-DisableNetworkNotifications()
-{}
-
-void
-GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
-{
-  aNetworkInfo->bandwidth() = dom::network::kDefaultBandwidth;
-  aNetworkInfo->canBeMetered() = dom::network::kDefaultCanBeMetered;
-}
-
-void
-Reboot()
-{}
-
-void
-PowerOff()
-{}
-
-} // hal_impl
-} // mozilla