Bug 939174 - [User Story] Edge Gesture Tutorial Outside of FTE. r=bent
authorSam Joch <samuel@guiora.com>
Fri, 07 Feb 2014 11:28:25 +0100
changeset 169333 f646b79cf1e056160619d2f9d987bc91783c829d
parent 169332 bcdefa1ccd8b220f3087be7910d41ab2b5721a51
child 169334 b53ca595416891ccac061d9e88522a171341f38c
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersbent
bugs939174
milestone30.0a1
Bug 939174 - [User Story] Edge Gesture Tutorial Outside of FTE. r=bent
b2g/components/UpdatePrompt.js
--- a/b2g/components/UpdatePrompt.js
+++ b/b2g/components/UpdatePrompt.js
@@ -361,26 +361,43 @@ UpdatePrompt.prototype = {
       this._update.errorCode = Cr.NS_ERROR_FAILURE;
       this.showUpdateError(this._update);
     }
   },
 
   restartProcess: function UP_restartProcess() {
     log("Update downloaded, restarting to apply it");
 
+    let callbackAfterSet = function() {
 #ifndef MOZ_WIDGET_GONK
-    let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
-                     .getService(Ci.nsIAppStartup);
-    appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
+      let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
+                       .getService(Ci.nsIAppStartup);
+      appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
 #else
-    // NB: on Gonk, we rely on the system process manager to restart us.
-    let pmService = Cc["@mozilla.org/power/powermanagerservice;1"]
-                    .getService(Ci.nsIPowerManagerService);
-    pmService.restart();
+      // NB: on Gonk, we rely on the system process manager to restart us.
+      let pmService = Cc["@mozilla.org/power/powermanagerservice;1"]
+                      .getService(Ci.nsIPowerManagerService);
+      pmService.restart();
 #endif
+    }
+
+    // Save current os version in deviceinfo.previous_os
+    let lock = Services.settings.createLock({
+      handle: callbackAfterSet,
+      handleAbort: function(error) {
+        log("Abort callback when trying to set previous_os: " + error);
+        callbackAfterSet();
+      }
+    });
+    lock.get("deviceinfo.os", {
+      handle: function(name, value) {
+        log("Set previous_os to: " + value);
+        lock.set("deviceinfo.previous_os", value, null, null);
+      }
+    });
   },
 
   forceUpdateCheck: function UP_forceUpdateCheck() {
     log("Forcing update check");
 
     let checker = Cc["@mozilla.org/updates/update-checker;1"]
                     .createInstance(Ci.nsIUpdateChecker);
     checker.checkForUpdates(this._updateCheckListener, true);