Bug 1052846 - Part 3: Use enums for MobileNetworkType in nsIMobileConnectionService.idl (gonk). r=echen
authorJessica Jong <jjong@mozilla.com>
Tue, 18 Nov 2014 10:07:02 +0800
changeset 216089 6c0d0fed9ad459b4975c78d740c05494c5cf5789
parent 216088 e04c1126aeb45c6535247638aa8d3a055d443fb9
child 216090 651b972023af60fa603044e72148c2d2177f27f8
push id27840
push usercbook@mozilla.com
push dateTue, 18 Nov 2014 11:52:32 +0000
treeherdermozilla-central@f9975ae1e89f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen
bugs1052846
milestone36.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 1052846 - Part 3: Use enums for MobileNetworkType in nsIMobileConnectionService.idl (gonk). r=echen
dom/mobileconnection/gonk/MobileConnectionService.js
dom/system/gonk/ril_consts.js
--- a/dom/mobileconnection/gonk/MobileConnectionService.js
+++ b/dom/mobileconnection/gonk/MobileConnectionService.js
@@ -393,32 +393,36 @@ MobileConnectionProvider.prototype = {
       if (DEBUG) this._debug("Fallback to " + key + ": " + index);
 
       let networkTypes = RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO[index];
       supportedNetworkTypes = networkTypes ?
         networkTypes.replace("-auto", "", "g").split("/") :
         RIL.GECKO_SUPPORTED_NETWORK_TYPES_DEFAULT.split(",");
     }
 
+    let enumNetworkTypes = [];
     for (let type of supportedNetworkTypes) {
       // If the value in system property is not valid, use the default one which
       // is defined in ril_consts.js.
       if (RIL.GECKO_SUPPORTED_NETWORK_TYPES.indexOf(type) < 0) {
         if (DEBUG) {
           this._debug("Unknown network type: " + type);
         }
-        supportedNetworkTypes =
-          RIL.GECKO_SUPPORTED_NETWORK_TYPES_DEFAULT.split(",");
+        RIL.GECKO_SUPPORTED_NETWORK_TYPES_DEFAULT.split(",").forEach(aType => {
+          enumNetworkTypes.push(RIL.GECKO_SUPPORTED_NETWORK_TYPES.indexOf(aType));
+        });
         break;
       }
+      enumNetworkTypes.push(RIL.GECKO_SUPPORTED_NETWORK_TYPES.indexOf(type));
     }
     if (DEBUG) {
-      this._debug("Supported Network Types: " + supportedNetworkTypes);
+      this._debug("Supported Network Types: " + enumNetworkTypes);
     }
-    return supportedNetworkTypes;
+
+    return enumNetworkTypes;
   },
 
   /**
    * Helper for guarding us against invalid mode for clir.
    */
   _isValidClirMode: function(aMode) {
     switch (aMode) {
       case Ci.nsIMobileConnection.CLIR_DEFAULT:
--- a/dom/system/gonk/ril_consts.js
+++ b/dom/system/gonk/ril_consts.js
@@ -422,16 +422,17 @@ this.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO
   GECKO_PREFERRED_NETWORK_TYPE_WCDMA_GSM_CDMA_EVDO,
   GECKO_PREFERRED_NETWORK_TYPE_LTE_CDMA_EVDO,
   GECKO_PREFERRED_NETWORK_TYPE_LTE_WCDMA_GSM,
   GECKO_PREFERRED_NETWORK_TYPE_LTE_WCDMA_GSM_CDMA_EVDO,
   GECKO_PREFERRED_NETWORK_TYPE_LTE_ONLY
 ];
 
 this.GECKO_SUPPORTED_NETWORK_TYPES_DEFAULT = "gsm,wcdma";
+// Index-item pair must be in sync with nsIMobileConnection.MOBILE_NETWORK_TYPE_*
 this.GECKO_SUPPORTED_NETWORK_TYPES = [
   "gsm",
   "wcdma",
   "cdma",
   "evdo",
   "lte"
 ];