Bug 1069862 - Use serviceClass 0 to query callbarring option. r=hsinyi
authorSzu-Yu Chen [:aknow] <szchen@mozilla.com>
Mon, 06 Oct 2014 03:07:00 -0400
changeset 208978 0c22e43c9e77700b4a65de15bd6125630a8158b0
parent 208977 c5146dfdbbebef530cc590945fdeb025d57a3902
child 208979 464acfebdcd48f4dc958a934465359c60bc6b4e9
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewershsinyi
bugs1069862
milestone35.0a1
Bug 1069862 - Use serviceClass 0 to query callbarring option. r=hsinyi
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -2720,16 +2720,23 @@ RilObject.prototype = {
    * @param program
    *        One of CALL_BARRING_PROGRAM_* constants.
    * @param serviceClass
    *        One of ICC_SERVICE_CLASS_* constants.
    */
   queryCallBarringStatus: function(options) {
     options.facility = CALL_BARRING_PROGRAM_TO_FACILITY[options.program];
     options.password = ""; // For query no need to provide it.
+
+    // For some operators, querying specific serviceClass doesn't work. We use
+    // serviceClass 0 instead, and then process the response to extract the
+    // answer for queryServiceClass.
+    options.queryServiceClass = options.serviceClass;
+    options.serviceClass = 0;
+
     this.queryICCFacilityLock(options);
   },
 
   /**
    * Configures call barring rule.
    *
    * @param program
    *        One of CALL_BARRING_PROGRAM_* constants.
@@ -5925,30 +5932,33 @@ RilObject.prototype[REQUEST_DEACTIVATE_D
 RilObject.prototype[REQUEST_QUERY_FACILITY_LOCK] = function REQUEST_QUERY_FACILITY_LOCK(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
     return;
   }
 
-  let services;
-  if (length) {
-    // Buf.readInt32List()[0] for Call Barring is a bit vector of services.
-    services = this.context.Buf.readInt32List()[0];
-  } else {
+  if (!length) {
     options.success = false;
     options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
     this.sendChromeMessage(options);
     return;
   }
 
-  options.enabled = services === 0 ? false : true;
-
-  if (options.success && (options.rilMessageType === "sendMMI")) {
+  // Buf.readInt32List()[0] for Call Barring is a bit vector of services.
+  let services = this.context.Buf.readInt32List()[0];
+
+  if (options.queryServiceClass) {
+    options.enabled = (services & options.queryServiceClass) ? true : false;
+  } else {
+    options.enabled = services ? true : false;
+  }
+
+  if (options.rilMessageType === "sendMMI") {
     if (!options.enabled) {
       options.statusMessage = MMI_SM_KS_SERVICE_DISABLED;
     } else {
       options.statusMessage = MMI_SM_KS_SERVICE_ENABLED_FOR;
       let serviceClass = [];
       for (let serviceClassMask = 1;
            serviceClassMask <= ICC_SERVICE_CLASS_MAX;
            serviceClassMask <<= 1) {