Bug 883768 - Don't auto reboot when a pin-lock is active for a sim card. r=fabrice
authorDave Hylands <dhylands@mozilla.com>
Tue, 10 Sep 2013 17:12:34 +0200
changeset 146369 b952c1662ddc8531cbe1cf9bd243b8fc8c7fe9ae
parent 146368 c8c2895284fe43a6a5dd0c8dd6ebb0ca64d9a641
child 146370 f304249f2cb2503d6932bf7b78fde007f14f3f43
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersfabrice
bugs883768
milestone26.0a1
Bug 883768 - Don't auto reboot when a pin-lock is active for a sim card. r=fabrice
b2g/components/UpdatePrompt.js
--- a/b2g/components/UpdatePrompt.js
+++ b/b2g/components/UpdatePrompt.js
@@ -207,19 +207,40 @@ UpdatePrompt.prototype = {
 
   showApplyPrompt: function UP_showApplyPrompt(aUpdate) {
     if (!this.sendUpdateEvent("update-prompt-apply", aUpdate)) {
       log("Unable to prompt, forcing restart");
       this.restartProcess();
       return;
     }
 
+#ifdef MOZ_B2G_RIL
+    let window = Services.wm.getMostRecentWindow("navigator:browser");
+    let pinReq = window.navigator.mozIccManager.getCardLock("pin");
+    pinReq.onsuccess = function(e) {
+      if (e.target.result.enabled) {
+        // The SIM is pin locked. Don't use a fallback timer. This means that
+        // the user has to press Install to apply the update. If we use the
+        // timer, and the timer reboots the phone, then the phone will be
+        // unusable until the SIM is unlocked.
+        log("SIM is pin locked. Not starting fallback timer.");
+      } else {
+        // This means that no pin lock is enabled, so we go ahead and start
+        // the fallback timer.
+        this._applyPromptTimer = this.createTimer(this.applyPromptTimeout);
+      }
+    }.bind(this);
+    pinReq.onerror = function(e) {
+      this._applyPromptTimer = this.createTimer(this.applyPromptTimeout);
+    }.bind(this);
+#else
     // Schedule a fallback timeout in case the UI is unable to respond or show
     // a prompt for some reason.
     this._applyPromptTimer = this.createTimer(this.applyPromptTimeout);
+#endif
   },
 
   _copyProperties: ["appVersion", "buildID", "detailsURL", "displayVersion",
                     "errorCode", "isOSUpdate", "platformVersion",
                     "previousAppVersion", "state", "statusText"],
 
   sendUpdateEvent: function UP_sendUpdateEvent(aType, aUpdate) {
     let detail = {};