merge b2g-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2014-07-18 13:02:11 +02:00
commit a35dfdecd6
26 changed files with 201 additions and 54 deletions

View File

@ -1224,7 +1224,7 @@ window.addEventListener('ContentStart', function update_onContentStart() {
// We must set the size in KB, and keep a bit of free space.
let size = Math.floor(stats.totalBytes / 1024) - 1024;
Services.prefs.setIntPref("browser.cache.disk.capacity", size);
}) ()
})();
#endif
// Calling this observer will cause a shutdown an a profile reset.

View File

@ -33,12 +33,66 @@ function log(msg) {
//dump('ProcessGlobal: ' + msg + '\n');
}
const gFactoryResetFile = "/persist/__post_reset_cmd__";
function ProcessGlobal() {}
ProcessGlobal.prototype = {
classID: Components.ID('{1a94c87a-5ece-4d11-91e1-d29c29f21b28}'),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference]),
wipeDir: function(path) {
log("wipeDir " + path);
let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
dir.initWithPath(path);
if (!dir.exists() || !dir.isDirectory()) {
return;
}
let entries = dir.directoryEntries;
while (entries.hasMoreElements()) {
let file = entries.getNext().QueryInterface(Ci.nsIFile);
log("Deleting " + file.path);
try {
file.remove(true);
} catch(e) {}
}
},
processWipeFile: function(text) {
log("processWipeFile " + text);
let lines = text.split("\n");
lines.forEach((line) => {
log(line);
let params = line.split(" ");
if (params[0] == "wipe") {
this.wipeDir(params[1]);
}
});
},
cleanupAfterFactoryReset: function() {
log("cleanupAfterWipe start");
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
file.initWithPath(gFactoryResetFile);
if (!file.exists()) {
debug("Nothing to wipe.")
return;
}
Cu.import("resource://gre/modules/osfile.jsm");
let promise = OS.File.read(gFactoryResetFile);
promise.then(
(array) => {
file.remove(false);
let decoder = new TextDecoder();
this.processWipeFile(decoder.decode(array));
}
);
log("cleanupAfterWipe end.");
},
observe: function pg_observe(subject, topic, data) {
switch (topic) {
case 'app-startup': {
@ -52,6 +106,8 @@ ProcessGlobal.prototype = {
ppmm.addMessageListener("getProfD", function(message) {
return Services.dirsvc.get("ProfD", Ci.nsIFile).path;
});
this.cleanupAfterFactoryReset();
}
break;
}

View File

@ -48,6 +48,9 @@ let librecovery = (function() {
FotaUpdateStatus.ptr)
};
})();
const gFactoryResetFile = "/persist/__post_reset_cmd__";
#endif
function RecoveryService() {}
@ -62,17 +65,45 @@ RecoveryService.prototype = {
classDescription: "B2G Recovery Service"
}),
factoryReset: function RS_factoryReset() {
factoryReset: function RS_factoryReset(reason) {
#ifdef MOZ_WIDGET_GONK
function doReset() {
// If this succeeds, then the device reboots and this never returns
if (librecovery.factoryReset() != 0) {
log("Error: Factory reset failed. Trying again after clearing cache.");
}
var cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"].getService(Ci.nsICacheStorageService);
let cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
cache.clear();
if (librecovery.factoryReset() != 0) {
log("Error: Factory reset failed again");
}
}
log("factoryReset " + reason);
if (reason == "wipe") {
let volumeService = Cc["@mozilla.org/telephony/volume-service;1"]
.getService(Ci.nsIVolumeService);
let volNames = volumeService.getVolumeNames();
log("Found " + volNames.length + " volumes");
let text = "";
for (let i = 0; i < volNames.length; i++) {
let name = volNames.queryElementAt(i, Ci.nsISupportsString);
let volume = volumeService.getVolumeByName(name.data);
log("Got volume: " + name.data + " at " + volume.mountPoint);
text += "wipe " + volume.mountPoint + "\n";
}
Cu.import("resource://gre/modules/osfile.jsm");
let encoder = new TextEncoder();
let array = encoder.encode(text);
let promise = OS.File.writeAtomic(gFactoryResetFile, array,
{ tmpPath: gFactoryResetFile + ".tmp" });
promise.then(doReset);
} else {
doReset();
}
#endif
throw Cr.NS_ERROR_FAILURE;
},

View File

@ -19,13 +19,13 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="7fbcfbacf286c2a8e41a3a96b6d82f1541880617"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e377ad326832eb945c7f4e9a4e63fd0bff14dc7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="7f792d756385bb894fba7645da59c67fe2c804bf"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="227354333a185180b85471f2cc6abfb029e44718"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="dc5ca96695cab87b4c2fcd7c9f046ae3415a70a5"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="d99553937cc53b82965421da1ca950c17f16a324"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8b04b5aca4b0a894de40f4d53ae9750222d349a8"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
<project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>

View File

@ -17,10 +17,10 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="7fbcfbacf286c2a8e41a3a96b6d82f1541880617"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e377ad326832eb945c7f4e9a4e63fd0bff14dc7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="7f792d756385bb894fba7645da59c67fe2c804bf"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="dc5ca96695cab87b4c2fcd7c9f046ae3415a70a5"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="d99553937cc53b82965421da1ca950c17f16a324"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8b04b5aca4b0a894de40f4d53ae9750222d349a8"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<!-- Stock Android things -->

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="276ce45e78b09c4a4ee643646f691d22804754c1">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="7fbcfbacf286c2a8e41a3a96b6d82f1541880617"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e377ad326832eb945c7f4e9a4e63fd0bff14dc7d"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="7f792d756385bb894fba7645da59c67fe2c804bf"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
@ -23,7 +23,7 @@
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="d99553937cc53b82965421da1ca950c17f16a324"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8b04b5aca4b0a894de40f4d53ae9750222d349a8"/>
<!-- Stock Android things -->
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="6e47ff2790f5656b5b074407829ceecf3e6188c4"/>

View File

@ -19,13 +19,13 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="7fbcfbacf286c2a8e41a3a96b6d82f1541880617"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e377ad326832eb945c7f4e9a4e63fd0bff14dc7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="7f792d756385bb894fba7645da59c67fe2c804bf"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="227354333a185180b85471f2cc6abfb029e44718"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="dc5ca96695cab87b4c2fcd7c9f046ae3415a70a5"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="d99553937cc53b82965421da1ca950c17f16a324"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8b04b5aca4b0a894de40f4d53ae9750222d349a8"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
<project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>

View File

@ -17,10 +17,10 @@
</project>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="7fbcfbacf286c2a8e41a3a96b6d82f1541880617"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e377ad326832eb945c7f4e9a4e63fd0bff14dc7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="7f792d756385bb894fba7645da59c67fe2c804bf"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="dc5ca96695cab87b4c2fcd7c9f046ae3415a70a5"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="d99553937cc53b82965421da1ca950c17f16a324"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8b04b5aca4b0a894de40f4d53ae9750222d349a8"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<!-- Stock Android things -->

View File

@ -4,6 +4,6 @@
"remote": "",
"branch": ""
},
"revision": "4d18ecb3653e80055af734c17f35b2abd8fd2a19",
"revision": "de790a9944e5e0429efbe5c5ff214f64e202b008",
"repo_path": "/integration/gaia-central"
}

View File

@ -17,12 +17,12 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="7fbcfbacf286c2a8e41a3a96b6d82f1541880617"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e377ad326832eb945c7f4e9a4e63fd0bff14dc7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="7f792d756385bb894fba7645da59c67fe2c804bf"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="dc5ca96695cab87b4c2fcd7c9f046ae3415a70a5"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="d99553937cc53b82965421da1ca950c17f16a324"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8b04b5aca4b0a894de40f4d53ae9750222d349a8"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
<project name="platform/bionic" path="bionic" revision="d2eb6c7b6e1bc7643c17df2d9d9bcb1704d0b9ab"/>

View File

@ -15,7 +15,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="7fbcfbacf286c2a8e41a3a96b6d82f1541880617"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e377ad326832eb945c7f4e9a4e63fd0bff14dc7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="7f792d756385bb894fba7645da59c67fe2c804bf"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

View File

@ -17,10 +17,10 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="7fbcfbacf286c2a8e41a3a96b6d82f1541880617"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e377ad326832eb945c7f4e9a4e63fd0bff14dc7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="7f792d756385bb894fba7645da59c67fe2c804bf"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="dc5ca96695cab87b4c2fcd7c9f046ae3415a70a5"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="d99553937cc53b82965421da1ca950c17f16a324"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8b04b5aca4b0a894de40f4d53ae9750222d349a8"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<!-- Stock Android things -->

View File

@ -17,12 +17,12 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="7fbcfbacf286c2a8e41a3a96b6d82f1541880617"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e377ad326832eb945c7f4e9a4e63fd0bff14dc7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="7f792d756385bb894fba7645da59c67fe2c804bf"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="dc5ca96695cab87b4c2fcd7c9f046ae3415a70a5"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="d99553937cc53b82965421da1ca950c17f16a324"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8b04b5aca4b0a894de40f4d53ae9750222d349a8"/>
<project name="gonk-patches" path="patches" remote="b2g" revision="223a2421006e8f5da33f516f6891c87cae86b0f6"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>

View File

@ -29,6 +29,7 @@
#include "mozilla/Scoped.h"
#include "mozilla/Services.h"
#include "nsArrayUtils.h"
#include "nsAutoPtr.h"
#include "nsGlobalWindow.h"
#include "nsServiceManagerUtils.h"
@ -3346,7 +3347,19 @@ nsDOMDeviceStorage::GetOrderedVolumeNames(
#ifdef MOZ_WIDGET_GONK
nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID);
if (vs) {
vs->GetVolumeNames(aVolumeNames);
nsCOMPtr<nsIArray> volNames;
vs->GetVolumeNames(getter_AddRefs(volNames));
uint32_t length = -1;
volNames->GetLength(&length);
for (uint32_t i = 0; i < length; i++) {
nsCOMPtr<nsISupportsString> str = do_QueryElementAt(volNames, i);
if (str) {
nsAutoString s;
if (NS_SUCCEEDED(str->GetData(s)) && !s.IsEmpty()) {
aVolumeNames.AppendElement(s);
}
}
}
// If the volume sdcard exists, then we want it to be first.

View File

@ -78,9 +78,9 @@ PowerManager::Reboot(ErrorResult& aRv)
}
void
PowerManager::FactoryReset()
PowerManager::FactoryReset(mozilla::dom::FactoryResetReason& aReason)
{
hal::FactoryReset();
hal::FactoryReset(aReason);
}
void

View File

@ -12,6 +12,7 @@
#include "nsWeakReference.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "mozilla/dom/MozPowerManagerBinding.h"
class nsPIDOMWindow;
@ -45,7 +46,7 @@ public:
}
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
void Reboot(ErrorResult& aRv);
void FactoryReset();
void FactoryReset(mozilla::dom::FactoryResetReason& aReason);
void PowerOff(ErrorResult& aRv);
void AddWakeLockListener(nsIDOMMozWakeLockListener* aListener);
void RemoveWakeLockListener(nsIDOMMozWakeLockListener* aListener);

View File

@ -6,13 +6,9 @@
#include "nsIVolume.idl"
#include "nsIVolumeMountLock.idl"
%{C++
#include "nsTArray.h"
#include "nsString.h"
%}
[ref] native nsStringTArrayRef(nsTArray<nsString>);
interface nsIArray;
[scriptable, uuid(a3b110cd-74f2-43cb-84c6-2a87713f2774)]
[scriptable, uuid(cab99ab4-542e-4387-bd40-db6ef30e4f5f)]
interface nsIVolumeService : nsISupports
{
nsIVolume getVolumeByName(in DOMString volName);
@ -23,7 +19,7 @@ interface nsIVolumeService : nsISupports
nsIVolumeMountLock createMountLock(in DOMString volName);
[noscript] void getVolumeNames(in nsStringTArrayRef aVolNames);
nsIArray getVolumeNames();
/* for test case only to simulate sdcard insertion/removal */
void createFakeVolume(in DOMString name, in DOMString path);

View File

@ -12,9 +12,11 @@
#include "nsCOMPtr.h"
#include "nsDependentSubstring.h"
#include "nsIDOMWakeLockListener.h"
#include "nsIMutableArray.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsIPowerManagerService.h"
#include "nsISupportsPrimitives.h"
#include "nsISupportsUtils.h"
#include "nsIVolume.h"
#include "nsIVolumeService.h"
@ -256,17 +258,34 @@ nsVolumeService::CreateOrGetVolumeByPath(const nsAString& aPath, nsIVolume** aRe
}
NS_IMETHODIMP
nsVolumeService::GetVolumeNames(nsTArray<nsString>& aVolNames)
nsVolumeService::GetVolumeNames(nsIArray** aVolNames)
{
NS_ENSURE_ARG_POINTER(aVolNames);
MonitorAutoLock autoLock(mArrayMonitor);
*aVolNames = nullptr;
nsresult rv;
nsCOMPtr<nsIMutableArray> volNames =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsVolume::Array::size_type numVolumes = mVolumeArray.Length();
nsVolume::Array::index_type volIndex;
for (volIndex = 0; volIndex < numVolumes; volIndex++) {
nsRefPtr<nsVolume> vol = mVolumeArray[volIndex];
aVolNames.AppendElement(vol->Name());
nsCOMPtr<nsISupportsString> isupportsString =
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = isupportsString->SetData(vol->Name());
NS_ENSURE_SUCCESS(rv, rv);
rv = volNames->AppendElement(isupportsString, false);
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ADDREF(*aVolNames = volNames);
return NS_OK;
}

View File

@ -5,6 +5,16 @@
interface MozWakeLockListener;
/**
* The reason for the factory reset.
* "normal" : simple factory reset.
* "wipe" : will also attempt to wipe all user storage areas.
*/
enum FactoryResetReason {
"normal",
"wipe"
};
/**
* This interface implements navigator.mozPower
*/
@ -14,7 +24,7 @@ interface MozPowerManager
void powerOff();
[Throws]
void reboot();
void factoryReset();
void factoryReset(optional FactoryResetReason reason = "normal");
/**
* The listeners are notified when a resource changes its lock state to:

View File

@ -1205,10 +1205,10 @@ GetFMBandSettings(FMRadioCountry aCountry) {
return settings;
}
void FactoryReset()
void FactoryReset(mozilla::dom::FactoryResetReason& aReason)
{
AssertMainThread();
PROXY_IF_SANDBOXED(FactoryReset());
PROXY_IF_SANDBOXED(FactoryReset(aReason));
}
void

View File

@ -14,6 +14,7 @@
#include "mozilla/Types.h"
#include "nsTArray.h"
#include "prlog.h"
#include "mozilla/dom/MozPowerManagerBinding.h"
#include "mozilla/dom/battery/Types.h"
#include "mozilla/dom/network/Types.h"
#include "mozilla/dom/power/Types.h"
@ -575,7 +576,7 @@ void StartForceQuitWatchdog(hal::ShutdownMode aMode, int32_t aTimeoutSecs);
/**
* Perform Factory Reset to wipe out all user data.
*/
void FactoryReset();
void FactoryReset(mozilla::dom::FactoryResetReason& aReason);
/**
* Start monitoring the status of gamepads attached to the system.

View File

@ -11,7 +11,7 @@ namespace mozilla {
namespace hal_impl {
void
FactoryReset()
FactoryReset(mozilla::dom::FactoryResetReason&)
{}
} // namespace hal_impl

View File

@ -105,6 +105,7 @@
using namespace mozilla;
using namespace mozilla::hal;
using namespace mozilla::dom;
namespace mozilla {
namespace hal_impl {
@ -1691,7 +1692,7 @@ SetCurrentThreadPriority(ThreadPriority aThreadPriority)
}
void
FactoryReset()
FactoryReset(FactoryResetReason& aReason)
{
nsCOMPtr<nsIRecoveryService> recoveryService =
do_GetService("@mozilla.org/recovery-service;1");
@ -1700,7 +1701,11 @@ FactoryReset()
return;
}
recoveryService->FactoryReset();
if (aReason == FactoryResetReason::Wipe) {
recoveryService->FactoryReset("wipe");
} else {
recoveryService->FactoryReset("normal");
}
}
} // hal_impl

View File

@ -4,7 +4,7 @@
#include "nsISupports.idl"
[scriptable, uuid(acb93ff8-aa6d-4bc8-bedd-2a6a3b802a74)]
[scriptable, uuid(bc24fb33-a0c1-49ca-aa43-05f167e02fb6)]
interface nsIRecoveryService : nsISupports
{
/**
@ -21,7 +21,7 @@ interface nsIRecoveryService : nsISupports
*
* @throws NS_ERROR_FAILURE when rebooting into recovery fails for some reason.
*/
void factoryReset();
void factoryReset(in string reason);
/**
* Use recovery to install an OTA update.zip. If this call is

View File

@ -159,7 +159,7 @@ parent:
sync GetCurrentSwitchState(SwitchDevice aDevice)
returns (SwitchState aState);
FactoryReset();
FactoryReset(nsString aReason);
child:
NotifySensorChange(SensorData aSensorData);

View File

@ -426,9 +426,13 @@ CancelFMRadioSeek()
}
void
FactoryReset()
FactoryReset(FactoryResetReason& aReason)
{
Hal()->SendFactoryReset();
if (aReason == FactoryResetReason::Normal) {
Hal()->SendFactoryReset(NS_LITERAL_STRING("normal"));
} else if (aReason == FactoryResetReason::Wipe) {
Hal()->SendFactoryReset(NS_LITERAL_STRING("wipe"));
}
}
void
@ -841,12 +845,23 @@ public:
}
virtual bool
RecvFactoryReset()
RecvFactoryReset(const nsString& aReason) MOZ_OVERRIDE
{
if (!AssertAppProcessPermission(this, "power")) {
return false;
}
hal::FactoryReset();
FactoryResetReason reason = FactoryResetReason::Normal;
if (aReason.EqualsLiteral("normal")) {
reason = FactoryResetReason::Normal;
} else if (aReason.EqualsLiteral("wipe")) {
reason = FactoryResetReason::Wipe;
} else {
// Invalid factory reset reason. That should never happen.
return false;
}
hal::FactoryReset(reason);
return true;
}