Bug 912884 - Part 1: Always send out emergencyCbModeChange event when received from ril. r=hsinyi
authorSzu-Yu Chen [:aknow] <szchen@mozilla.com>
Mon, 09 Sep 2013 08:19:49 -0400
changeset 146147 f7ac432b38b5d1d15e58ae41d80fe4d209ac280a
parent 146146 fe975eaab49719076f42d4c6909846f5c40cc75c
child 146148 035ce07737626ce7fa3b5651d0b63b7e30798e05
push id25243
push userryanvm@gmail.com
push dateMon, 09 Sep 2013 19:52:36 +0000
treeherdermozilla-central@9edc229b7d09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs912884
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 912884 - Part 1: Always send out emergencyCbModeChange event when received from ril. r=hsinyi
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -3792,34 +3792,26 @@ let RIL = {
   _cancelEmergencyCbModeTimeout: function _cancelEmergencyCbModeTimeout() {
     if (this._exitEmergencyCbModeTimeoutID) {
       clearTimeout(this._exitEmergencyCbModeTimeoutID);
       this._exitEmergencyCbModeTimeoutID = null;
     }
   },
 
   _handleChangedEmergencyCbMode: function _handleChangedEmergencyCbMode(active) {
-    if (this._isInEmergencyCbMode === active) {
-      return;
-    }
-
+    this._isInEmergencyCbMode = active;
+
+    // Clear the existed timeout event.
+    this._cancelEmergencyCbModeTimeout();
+
+    // Start a new timeout event when entering the mode.
     if (active) {
-      // Start a new timeout event when enter the mode.
-      let ril = this;
-      this._cancelEmergencyCbModeTimeout();
-      this._exitEmergencyCbModeTimeoutID = setTimeout(function() {
-          ril.exitEmergencyCbMode();
-      }, EMERGENCY_CB_MODE_TIMEOUT_MS);
-    } else {
-      // Clear the timeout event when exit mode.
-      this._cancelEmergencyCbModeTimeout();
-    }
-
-    // Keep current mode and write to property.
-    this._isInEmergencyCbMode = active;
+      this._exitEmergencyCbModeTimeoutID = setTimeout(
+          this.exitEmergencyCbMode.bind(this), EMERGENCY_CB_MODE_TIMEOUT_MS);
+    }
 
     let message = {rilMessageType: "emergencyCbModeChange",
                    active: active,
                    timeoutMs: EMERGENCY_CB_MODE_TIMEOUT_MS};
     this.sendChromeMessage(message);
   },
 
   _processNetworks: function _processNetworks() {