Bug 790393 - Add MozPower.factoryReset() for factory reset. r=cjones, r=vingtetun, sr=sicking
☠☠ backed out by c2e44ae3a09d ☠ ☠
authorShih-Chiang Chien <schien@mozilla.com>
Thu, 04 Oct 2012 17:28:34 +0800
changeset 110621 0fc318454f2b41430eb7194c1d56239822b34453
parent 110620 74cdc7eda9c51c000914796320c752a535a3746f
child 110622 0fb868c93955e29ccbfa5df29fba4ebdf21d5bf9
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerscjones, vingtetun, sicking
bugs790393
milestone19.0a1
Bug 790393 - Add MozPower.factoryReset() for factory reset. r=cjones, r=vingtetun, sr=sicking
dom/power/PowerManager.cpp
dom/power/nsIDOMPowerManager.idl
toolkit/toolkit-tiers.mk
--- a/dom/power/PowerManager.cpp
+++ b/dom/power/PowerManager.cpp
@@ -11,16 +11,20 @@
 #include "nsIDocument.h"
 #include "nsIPermissionManager.h"
 #include "nsIPowerManagerService.h"
 #include "nsIPrincipal.h"
 #include "nsPIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "nsError.h"
 
+#ifdef MOZ_WIDGET_GONK
+#include "b2g.h"
+#endif
+
 DOMCI_DATA(MozPowerManager, mozilla::dom::power::PowerManager)
 
 namespace mozilla {
 namespace dom {
 namespace power {
 
 NS_INTERFACE_MAP_BEGIN(PowerManager)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMozPowerManager)
@@ -66,16 +70,31 @@ PowerManager::Reboot()
   NS_ENSURE_STATE(pmService);
 
   pmService->Reboot();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
+PowerManager::FactoryReset()
+{
+#ifdef MOZ_WIDGET_GONK
+  nsCOMPtr<nsIRecoveryService> recoveryService =
+    do_GetService("@mozilla.org/recovery-service;1");
+  NS_ENSURE_STATE(recoveryService);
+
+  recoveryService->FactoryReset();
+  return NS_OK;
+#else
+  return NS_ERROR_NOT_IMPLEMENTED;
+#endif
+}
+
+NS_IMETHODIMP
 PowerManager::PowerOff()
 {
   nsCOMPtr<nsIPowerManagerService> pmService =
     do_GetService(POWERMANAGERSERVICE_CONTRACTID);
   NS_ENSURE_STATE(pmService);
 
   pmService->PowerOff();
 
--- a/dom/power/nsIDOMPowerManager.idl
+++ b/dom/power/nsIDOMPowerManager.idl
@@ -5,21 +5,22 @@
 
 #include "nsISupports.idl"
 
 interface nsIDOMMozWakeLockListener;
 
 /**
  * This interface implements navigator.mozPower
  */
-[scriptable, uuid(256a3287-f528-45b5-9ba8-2b3650c056e6)]
+[scriptable, uuid(7b181fef-2757-4198-89a0-8c426b8439ea)]
 interface nsIDOMMozPowerManager : nsISupports
 {
     void    powerOff();
     void    reboot();
+    void    factoryReset();
 
     /**
      * The listeners are notified when a resource changes its lock state to:
      *  - unlocked
      *  - locked but not visible
      *  - locked and visible
      */
     void    addWakeLockListener(in nsIDOMMozWakeLockListener aListener);
--- a/toolkit/toolkit-tiers.mk
+++ b/toolkit/toolkit-tiers.mk
@@ -168,16 +168,21 @@ endif
 ifndef MOZ_NATIVE_PNG
 tier_platform_dirs += media/libpng
 endif
 
 ifdef ENABLE_TESTS
 tier_platform_dirs += testing/specialpowers
 endif
 
+# b2g headers need to be built before dom headers
+ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
+tier_platform_dirs += b2g
+endif
+
 tier_platform_dirs	+= \
 		uriloader \
 		caps \
 		parser \
 		gfx \
 		image \
 		dom \
 		view \