Commits

Fernando Jiménez  committed d8cf2a3 Draft

Bug 793189 - MMI Codes: get IMEI. Part 1 - RIL; r=marshall_law

  • Participants
  • Parent commits 07ccbbd

Comments (0)

Files changed (2)

File dom/system/gonk/RILContentHelper.js

       case "RIL:CancelMMI:Return:OK":
         request = this.takeRequest(msg.json.requestId);
         if (request) {
-          Services.DOMRequest.fireSuccess(request, msg.json);
+          Services.DOMRequest.fireSuccess(request, msg.json.result);
         }
         break;
       case "RIL:SendMMI:Return:KO":

File dom/system/gonk/ril_worker.js

     Buf.simpleRequest(REQUEST_SIGNAL_STRENGTH);
   },
 
-  getIMEI: function getIMEI() {
-    Buf.simpleRequest(REQUEST_GET_IMEI);
+  getIMEI: function getIMEI(options) {
+    Buf.simpleRequest(REQUEST_GET_IMEI, options);
   },
 
   getIMEISV: function getIMEISV() {
 
       // IMEI
       case MMI_SC_IMEI:
-        // TODO: Bug 793189 - MMI Codes: get IMEI.
-        _sendMMIError("GET_IMEI_NOT_SUPPORTED_VIA_MMI");
+        // A device's IMEI can't change, so we only need to request it once.
+        if (this.IMEI == null) {
+          this.getIMEI({mmi: true});
+          return;
+        }
+        // If we already had the device's IMEI, we just send it to the DOM.
+        options.rilMessageType = "sendMMI";
+        options.success = true;
+        options.result = this.IMEI;
+        this.sendDOMMessage(options);
         return;
 
       // Call barring
 };
 RIL[REQUEST_SMS_ACKNOWLEDGE] = null;
 RIL[REQUEST_GET_IMEI] = function REQUEST_GET_IMEI(length, options) {
-  if (options.rilRequestError) {
+  this.IMEI = Buf.readString();
+  // So far we only send the IMEI back to the DOM if it was requested via MMI.
+  if (!options.mmi) {
     return;
   }
 
-  this.IMEI = Buf.readString();
+  options.rilMessageType = "sendMMI";
+  options.success = options.rilRequestError == 0;
+  options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
+  if ((!options.success || this.IMEI == null) && !options.errorMsg) {
+    options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
+  }
+  options.result = this.IMEI;
+  this.sendDOMMessage(options);
 };
 RIL[REQUEST_GET_IMEISV] = function REQUEST_GET_IMEISV(length, options) {
   if (options.rilRequestError) {