Bug 787380: Initial implementation of B2G updater download mozChromeEvents. r=fabrice

This commit is contained in:
Marshall Culpepper 2012-09-12 11:53:03 -05:00
parent 3a5ad504fc
commit b904b1ca98
2 changed files with 29 additions and 3 deletions

View File

@ -444,8 +444,8 @@ pref("b2g.update.apply-wait-timeout", 1800000); // milliseconds
pref("b2g.update.self-destruct-timeout", 5000); // milliseconds
pref("app.update.enabled", true);
pref("app.update.auto", true);
pref("app.update.silent", true);
pref("app.update.auto", false);
pref("app.update.silent", false);
pref("app.update.mode", 0);
pref("app.update.incompatible.mode", 0);
pref("app.update.staging.enabled", true);

View File

@ -25,6 +25,10 @@ const APPLY_WAIT_TIMEOUT =
const SELF_DESTRUCT_TIMEOUT =
Services.prefs.getIntPref("b2g.update.self-destruct-timeout");
XPCOMUtils.defineLazyServiceGetter(Services, "aus",
"@mozilla.org/updates/update-service;1",
"nsIApplicationUpdateService");
function UpdatePrompt() { }
UpdatePrompt.prototype = {
@ -42,7 +46,15 @@ UpdatePrompt.prototype = {
// updates when on a billed pipe. Initially, opt-in for 3g, but
// that doesn't cover all cases.
checkForUpdates: function UP_checkForUpdates() { },
showUpdateAvailable: function UP_showUpdateAvailable(aUpdate) { },
showUpdateAvailable: function UP_showUpdateAvailable(aUpdate) {
if (!this.sendUpdateEvent("update-available", aUpdate,
this.handleAvailableResult)) {
log("Unable to prompt for available update, forcing download");
this.downloadUpdate(aUpdate);
}
},
showUpdateDownloaded: function UP_showUpdateDownloaded(aUpdate, aBackground) {
if (!this.sendUpdateEvent("update-downloaded", aUpdate,
@ -119,6 +131,16 @@ UpdatePrompt.prototype = {
return true;
},
handleAvailableResult: function UP_handleAvailableResult(aDetail) {
// If the user doesn't choose "download", the updater will implicitly call
// showUpdateAvailable again after a certain period of time
switch (aDetail.result) {
case "download":
this.downloadUpdate(this._update);
break;
}
},
handleDownloadedResult: function UP_handleDownloadedResult(aDetail) {
if (this._applyPromptTimer) {
this._applyPromptTimer.cancel();
@ -137,6 +159,10 @@ UpdatePrompt.prototype = {
}
},
downloadUpdate: function UP_downloadUpdate(aUpdate) {
Services.aus.downloadUpdate(aUpdate, true);
},
restartProcess: function UP_restartProcess() {
log("Update downloaded, restarting to apply it");