mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1037212 - [Flame] Phone is not completely erased when a ringtone is set from the Music App r=dougt,dhylands,khuey
This commit is contained in:
parent
19b7c834a2
commit
0ff99653bd
@ -1273,7 +1273,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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -48,6 +48,9 @@ let librecovery = (function() {
|
||||
FotaUpdateStatus.ptr)
|
||||
};
|
||||
})();
|
||||
|
||||
const gFactoryResetFile = "/persist/__post_reset_cmd__";
|
||||
|
||||
#endif
|
||||
|
||||
function RecoveryService() {}
|
||||
@ -62,16 +65,44 @@ RecoveryService.prototype = {
|
||||
classDescription: "B2G Recovery Service"
|
||||
}),
|
||||
|
||||
factoryReset: function RS_factoryReset() {
|
||||
factoryReset: function RS_factoryReset(reason) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// 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.");
|
||||
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.");
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
var 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;
|
||||
|
@ -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.
|
||||
|
||||
|
@ -78,9 +78,9 @@ PowerManager::Reboot(ErrorResult& aRv)
|
||||
}
|
||||
|
||||
void
|
||||
PowerManager::FactoryReset()
|
||||
PowerManager::FactoryReset(mozilla::dom::FactoryResetReason& aReason)
|
||||
{
|
||||
hal::FactoryReset();
|
||||
hal::FactoryReset(aReason);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -11,7 +11,7 @@ namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
void
|
||||
FactoryReset()
|
||||
FactoryReset(mozilla::dom::FactoryResetReason&)
|
||||
{}
|
||||
|
||||
} // namespace hal_impl
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -159,7 +159,7 @@ parent:
|
||||
sync GetCurrentSwitchState(SwitchDevice aDevice)
|
||||
returns (SwitchState aState);
|
||||
|
||||
FactoryReset();
|
||||
FactoryReset(nsString aReason);
|
||||
|
||||
child:
|
||||
NotifySensorChange(SensorData aSensorData);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user