Bug 1026727 - Part 2: Fixing the "Unknown" state is displayed instead of "Connected" during manual network selection. r=hsinyi, a=2.0+
authorEdgar Chen <echen@mozilla.com>
Wed, 18 Jun 2014 17:17:52 +0800
changeset 208351 7a4bbb56e146f341b19841853b4019c6f9d19ae2
parent 208350 d4f56f62327c6b8bed5ba3ba61ceede71d80624a
child 208352 34d3a6ced61d7aa0b0997ee4122e4dda05e74455
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi, 2
bugs1026727
milestone32.0a2
Bug 1026727 - Part 2: Fixing the "Unknown" state is displayed instead of "Connected" during manual network selection. r=hsinyi, a=2.0+
dom/system/gonk/ril_consts.js
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_consts.js
+++ b/dom/system/gonk/ril_consts.js
@@ -359,20 +359,34 @@ this.GECKO_CARD_TYPE = [
   null,
   "sim",
   "usim",
   "ruim",
   "csim",
   "isim"
 ];
 
-this.NETWORK_STATE_UNKNOWN = "unknown";
-this.NETWORK_STATE_AVAILABLE = "available";
-this.NETWORK_STATE_CONNECTED = "connected";
-this.NETWORK_STATE_FORBIDDEN = "forbidden";
+
+// Used for QUERY_AVAILABLE_NETWORKS status.
+this.QAN_STATE_UNKNOWN   = "unknown";
+this.QAN_STATE_AVAILABLE = "available";
+this.QAN_STATE_CURRENT   = "current";
+this.QAN_STATE_FORBIDDEN = "forbidden";
+
+// Must be in sync with MobileNetworkState of MozMobileNetworkInfo.webidl
+this.GECKO_QAN_STATE_UNKNOWN   = null;
+this.GECKO_QAN_STATE_AVAILABLE = "available";
+this.GECKO_QAN_STATE_CONNECTED = "connected";
+this.GECKO_QAN_STATE_FORBIDDEN = "forbidden";
+
+this.RIL_QAN_STATE_TO_GECKO_STATE = {};
+this.RIL_QAN_STATE_TO_GECKO_STATE[this.QAN_STATE_UNKNOWN]   = this.GECKO_QAN_STATE_UNKNOWN;
+this.RIL_QAN_STATE_TO_GECKO_STATE[this.QAN_STATE_AVAILABLE] = this.GECKO_QAN_STATE_AVAILABLE;
+this.RIL_QAN_STATE_TO_GECKO_STATE[this.QAN_STATE_CURRENT]   = this.GECKO_QAN_STATE_CONNECTED;
+this.RIL_QAN_STATE_TO_GECKO_STATE[this.QAN_STATE_FORBIDDEN] = this.GECKO_QAN_STATE_FORBIDDEN;
 
 this.NETWORK_SELECTION_MODE_AUTOMATIC = 0;
 this.NETWORK_SELECTION_MODE_MANUAL = 1;
 
 this.NETWORK_INFO_VOICE_REGISTRATION_STATE = "voiceRegistrationState";
 this.NETWORK_INFO_DATA_REGISTRATION_STATE = "dataRegistrationState";
 this.NETWORK_INFO_OPERATOR = "operator";
 this.NETWORK_INFO_NETWORK_SELECTION_MODE = "networkSelectionMode";
@@ -2390,19 +2404,16 @@ this.DATACALL_FAIL_ERROR_UNSPECIFIED = 0
 
 // Keep consistent with nsINetworkManager.NETWORK_STATE_*.
 this.GECKO_NETWORK_STATE_UNKNOWN = -1;
 this.GECKO_NETWORK_STATE_CONNECTING = 0;
 this.GECKO_NETWORK_STATE_CONNECTED = 1;
 this.GECKO_NETWORK_STATE_DISCONNECTING = 2;
 this.GECKO_NETWORK_STATE_DISCONNECTED = 3;
 
-// Used for QUERY_AVAILABLE_NETWORKS status of "unknown"
-this.GECKO_QAN_STATE_UNKNOWN = null;
-
 this.CALL_FAIL_UNOBTAINABLE_NUMBER = 1;
 this.CALL_FAIL_NORMAL = 16;
 this.CALL_FAIL_BUSY = 17;
 this.CALL_FAIL_NO_USER_RESPONDING = 18;
 this.CALL_FAIL_USER_ALERTING = 19;
 this.CALL_FAIL_CALL_REJECTED = 21;
 this.CALL_FAIL_NUMBER_CHANGED = 22;
 this.CALL_FAIL_CALL_PRE_EMPTION = 25;
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -4440,23 +4440,18 @@ RilObject.prototype = {
       let networkTuple = strings[i + 2];
       try {
         this._processNetworkTuple(networkTuple, network);
       } catch (e) {
         if (DEBUG) this.context.debug("Error processing operator tuple: " + e);
       }
 
       let state = strings[i + 3];
-      if (state === NETWORK_STATE_UNKNOWN) {
-        // TODO: looks like this might conflict in style with
-        // GECKO_NETWORK_STYLE_UNKNOWN / nsINetworkManager
-        state = GECKO_QAN_STATE_UNKNOWN;
-      }
-
-      network.state = state;
+      network.state = RIL_QAN_STATE_TO_GECKO_STATE[state];
+
       networks.push(network);
     }
     return networks;
   },
 
   /**
    * The "numeric" portion of the operator info is a tuple
    * containing MCC (country code) and MNC (network code).