Bug 739137: Try harder to ensure that b2g shuts down when we ask it to. r=fabrice

This commit is contained in:
Chris Jones 2012-03-26 00:46:21 -07:00
Родитель 1efacca656
Коммит d3ef250e1c
2 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -24,6 +24,8 @@ UpdatePrompt.prototype = {
classID: Components.ID("{88b3eb21-d072-4e3b-886d-f89d8c49fe59}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIUpdatePrompt]),
_selfDestructTimer: null,
// nsIUpdatePrompt
// FIXME/bug 737601: we should have users opt-in to downloading
@ -39,6 +41,10 @@ UpdatePrompt.prototype = {
log("Update downloaded, restarting to apply it");
// If not cleanly shut down within 5 seconds, this process will
// explode.
this._setSelfDestructTimer(5000);
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
// NB: on Gonk, we rely on the system process manager to restart
// us. Trying to restart here would conflict with the process
@ -51,6 +57,24 @@ UpdatePrompt.prototype = {
);
},
_setSelfDestructTimer: function UP__setSelfDestructTimer(timeoutMs) {
#ifdef ANDROID
Cu.import("resource://gre/modules/ctypes.jsm");
let libc = ctypes.open("libc.so");
let _exit = libc.declare("_exit", ctypes.default_abi,
ctypes.void_t, // [return]
ctypes.int); // status
this.notify = function UP_notify(_) {
log("Self-destruct timer fired; didn't cleanly shut down. BOOM");
_exit(0);
}
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.initWithCallback(this, timeoutMs, timer.TYPE_ONE_SHOT);
this._selfDestructTimer = timer;
#endif
},
showUpdateInstalled: function UP_showUpdateInstalled() { },
showUpdateError: function UP_showUpdateError(aUpdate) {

Просмотреть файл

@ -1500,6 +1500,7 @@ WifiWorker.prototype = {
get worker() { throw "Not implemented"; },
shutdown: function() {
debug("shutting down ...");
this.setWifiEnabled(false);
}
};