Bug 897869 - [b2g-ril] Need to keep CLIR settings across reboots. r=vicamo
authorJose Antonio Olivera Ortega <josea.olivera@gmail.com>
Wed, 31 Jul 2013 09:56:43 +0200
changeset 152998 6adb8b4b733bca29450d147b1a96ae49ee484627
parent 152997 40af0307fc257d83ff2495ddd7a10c8da2d90a5a
child 152999 9fa65f1d3803798fbc0b22a6ccff48631a5feddb
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo
bugs897869
milestone25.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 897869 - [b2g-ril] Need to keep CLIR settings across reboots. r=vicamo
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -61,16 +61,17 @@ const kMozSettingsChangedObserverTopic  
 const kSysMsgListenerReadyObserverTopic  = "system-message-listener-ready";
 const kSysClockChangeObserverTopic       = "system-clock-change";
 const kScreenStateChangedTopic           = "screen-state-changed";
 const kTimeNitzAutomaticUpdateEnabled    = "time.nitz.automatic-update.enabled";
 const kTimeNitzAvailable                 = "time.nitz.available";
 const kCellBroadcastSearchList           = "ril.cellbroadcast.searchlist";
 const kCellBroadcastDisabled             = "ril.cellbroadcast.disabled";
 const kPrefenceChangedObserverTopic      = "nsPref:changed";
+const kClirModePreference                = "ril.clirMode";
 
 const DOM_MOBILE_MESSAGE_DELIVERY_RECEIVED = "received";
 const DOM_MOBILE_MESSAGE_DELIVERY_SENDING  = "sending";
 const DOM_MOBILE_MESSAGE_DELIVERY_SENT     = "sent";
 const DOM_MOBILE_MESSAGE_DELIVERY_ERROR    = "error";
 
 const CALL_WAKELOCK_TIMEOUT              = 5000;
 
@@ -557,24 +558,29 @@ XPCOMUtils.defineLazyGetter(this, "gMess
   };
 });
 
 function RadioInterfaceLayer() {
   gMessageManager.init(this);
 
   let options = {
     debug: debugPref,
-    cellBroadcastDisabled: false
+    cellBroadcastDisabled: false,
+    clirMode: RIL.CLIR_DEFAULT
   };
 
   try {
     options.cellBroadcastDisabled =
       Services.prefs.getBoolPref(kCellBroadcastDisabled);
   } catch(e) {}
 
+  try {
+    options.clirMode = Services.prefs.getIntPref(kClirModePreference);
+  } catch(e) {}
+
   let numIfaces = this.numRadioInterfaces;
   debug(numIfaces + " interfaces");
   this.radioInterfaces = [];
   for (let clientId = 0; clientId < numIfaces; clientId++) {
     options.clientId = clientId;
     this.radioInterfaces.push(new RadioInterface(options));
   }
 }
@@ -2333,18 +2339,33 @@ RadioInterface.prototype = {
   handleGetCLIR: function handleGetCLIR(message) {
     if (DEBUG) this.debug("handleGetCLIR: " + JSON.stringify(message));
     gMessageManager.sendRequestResults("RIL:GetCallingLineIdRestriction",
                                        message);
   },
 
   handleSetCLIR: function handleSetCLIR(message) {
     if (DEBUG) this.debug("handleSetCLIR: " + JSON.stringify(message));
-    gMessageManager.sendRequestResults("RIL:SetCallingLineIdRestriction",
-                                       message);
+    let messageType;
+    if (message.isSendMMI) {
+      messageType = message.success ? "RIL:SendMMI:Return:OK" :
+                                      "RIL:SendMMI:Return:KO";
+    } else {
+      messageType = "RIL:SetCallingLineIdRestriction";
+    }
+    if (message.success) {
+      try {
+        Services.prefs.setIntPref(kClirModePreference, message.clirMode);
+        Services.prefs.savePrefFile(null);
+        if (DEBUG) {
+          this.debug(kClirModePreference + " pref is now " + message.clirMode);
+        }
+      } catch (e) {}
+    }
+    gMessageManager.sendRequestResults(messageType, message);
   },
 
   handleSetRoamingPreference: function handleSetRoamingPreference(message) {
     if (DEBUG) this.debug("handleSetRoamingPreference: " + JSON.stringify(message));
     gMessageManager.sendRequestResults("RIL:SetRoamingPreference", message);
   },
 
   handleQueryRoamingPreference: function handleQueryRoamingPreference(message) {
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -756,16 +756,21 @@ let RIL = {
   preferredNetworkType: null,
 
   /**
    * Global Cell Broadcast switch.
    */
   cellBroadcastDisabled: false,
 
   /**
+   * Global CLIR mode settings.
+   */
+  clirMode: CLIR_DEFAULT,
+
+  /**
    * Parsed Cell Broadcast search lists.
    * cellBroadcastConfigs.MMI should be preserved over rild reset.
    */
   cellBroadcastConfigs: null,
   mergedCellBroadcastConfig: null,
 
   _receivedSmsCbPagesMap: {},
 
@@ -1496,19 +1501,22 @@ let RIL = {
    * Enables or disables the presentation of the calling line identity (CLI) to
    * the called party when originating a call.
    *
    * @param options.clirMode
    *        Is one of the CLIR_* constants in
    *        nsIDOMMozMobileConnection interface.
    */
   setCLIR: function setCLIR(options) {
+    if (options) {
+      this.clirMode = options.clirMode;
+    }
     Buf.newParcel(REQUEST_SET_CLIR, options);
     Buf.writeUint32(1);
-    Buf.writeUint32(options.clirMode);
+    Buf.writeUint32(this.clirMode);
     Buf.sendParcel();
   },
 
   /**
    * Set screen state.
    *
    * @param on
    *        Boolean indicating whether the screen should be on or off.
@@ -2543,16 +2551,18 @@ let RIL = {
             break;
           case MMI_PROCEDURE_DEACTIVATION:
             options.clirMode = CLIR_SUPPRESSION;
             break;
           default:
             _sendMMIError(MMI_ERROR_KS_NOT_SUPPORTED, MMI_KS_SC_CLIR);
             return;
         }
+        options.rilMessageType = "setCLIR";
+        options.isSendMMI = true;
         this.setCLIR(options);
         return;
 
       // Call barring
       case MMI_SC_BAOC:
       case MMI_SC_BAOIC:
       case MMI_SC_BAOICxH:
       case MMI_SC_BAIC:
@@ -4658,16 +4668,17 @@ let RIL = {
       method.call(this, length, options);
     }
   },
 
   setInitialOptions: function setInitialOptions(options) {
     DEBUG = DEBUG_WORKER || options.debug;
     CLIENT_ID = options.clientId;
     this.cellBroadcastDisabled = options.cellBroadcastDisabled;
+    this.clirMode = options.clirMode;
   }
 };
 
 RIL.initRILState();
 
 RIL[REQUEST_GET_SIM_STATUS] = function REQUEST_GET_SIM_STATUS(length, options) {
   if (options.rilRequestError) {
     return;
@@ -5159,21 +5170,25 @@ RIL[REQUEST_GET_CLIR] = function REQUEST
         options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
         break;
     }
   }
 
   this.sendChromeMessage(options);
 };
 RIL[REQUEST_SET_CLIR] = function REQUEST_SET_CLIR(length, options) {
+  if (options.rilMessageType == null) {
+    // The request was made by ril_worker itself automatically. Don't report.
+    return;
+  }
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
   }
-  if (options.success && (options.rilMessageType === "sendMMI")) {
+  if (options.success && options.isSendMMI) {
     switch (options.procedure) {
       case MMI_PROCEDURE_ACTIVATION:
         options.statusMessage = MMI_SM_KS_SERVICE_ENABLED;
         break;
       case MMI_PROCEDURE_DEACTIVATION:
         options.statusMessage = MMI_SM_KS_SERVICE_DISABLED;
         break;
     }
@@ -5820,16 +5835,17 @@ RIL[UNSOLICITED_RESPONSE_RADIO_STATE_CHA
       } else {
         this.getIMEI();
         this.getIMEISV();
       }
     }
     this.getBasebandVersion();
     this.updateCellBroadcastConfig();
     this.setPreferredNetworkType();
+    this.setCLIR();
   }
 
   this.radioState = newState;
   this.sendChromeMessage({
     rilMessageType: "radiostatechange",
     radioState: newState
   });