Bug 1013847 - Part 1-4: Create IccInfo object even if appType is unknown. r=hsinyi
authorEdgar Chen <echen@mozilla.com>
Mon, 18 Aug 2014 15:15:16 +0800
changeset 224077 164df22f3b0390edf4877399318b2a6e9fdcdfc4
parent 224076 2a8d5eec4c383c0228f5bbbc7f02600814a87758
child 224078 4130d44be0e902fe3df2c3144836382037b9ca4d
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewershsinyi
bugs1013847
milestone34.0a1
Bug 1013847 - Part 1-4: Create IccInfo object even if appType is unknown. r=hsinyi
dom/icc/interfaces/nsIDOMIccInfo.idl
dom/system/gonk/RILContentHelper.js
dom/system/gonk/RadioInterfaceLayer.js
--- a/dom/icc/interfaces/nsIDOMIccInfo.idl
+++ b/dom/icc/interfaces/nsIDOMIccInfo.idl
@@ -5,17 +5,17 @@
 #include "nsISupports.idl"
 
 [scriptable, uuid(dd9f229c-e5a6-453a-8388-950af0ff9918)]
 interface nsIDOMMozIccInfo : nsISupports
 {
   /**
    * Integrated Circuit Card Type.
    *
-   * Possible values: "sim", "usim", "ruim".
+   * Possible values: null(unknown), "sim", "usim", "csim", ruim".
    */
   readonly attribute DOMString iccType;
 
   /**
    * Integrated Circuit Card Identifier.
    */
   readonly attribute DOMString iccid;
 
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -37,16 +37,18 @@ const kPrefVoicemailDefaultServiceId = "
 
 let DEBUG;
 function debug(s) {
   dump("-*- RILContentHelper: " + s + "\n");
 }
 
 const RILCONTENTHELPER_CID =
   Components.ID("{472816e1-1fd6-4405-996c-806f9ea68174}");
+const ICCINFO_CID =
+  Components.ID("{39d64d90-26a6-11e4-8c21-0800200c9a66}");
 const GSMICCINFO_CID =
   Components.ID("{e0fa785b-ad3f-46ed-bc56-fcb0d6fe4fa8}");
 const CDMAICCINFO_CID =
   Components.ID("{3d1f844f-9ec5-48fb-8907-aed2e5421709}");
 const MOBILECONNECTIONINFO_CID =
   Components.ID("{a35cfd39-2d93-4489-ac7d-396475dacb27}");
 const MOBILENETWORKINFO_CID =
   Components.ID("{a6c8416c-09b4-46d1-bf29-6520d677d085}");
@@ -151,16 +153,27 @@ function MobileIccCardLockRetryCount(opt
 MobileIccCardLockRetryCount.prototype = {
   __exposedProps__ : {lockType: 'r',
                       retryCount: 'r',
                       success: 'r'}
 };
 
 function IccInfo() {}
 IccInfo.prototype = {
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozIccInfo]),
+  classID: ICCINFO_CID,
+  classInfo: XPCOMUtils.generateCI({
+    classID:          ICCINFO_CID,
+    classDescription: "MozIccInfo",
+    flags:            Ci.nsIClassInfo.DOM_OBJECT,
+    interfaces:       [Ci.nsIDOMMozIccInfo]
+  }),
+
+  // nsIDOMMozIccInfo
+
   iccType: null,
   iccid: null,
   mcc: null,
   mnc: null,
   spn: null,
   isDisplayNetworkNameRequired: null,
   isDisplaySpnRequired: null
 };
@@ -519,33 +532,35 @@ RILContentHelper.prototype = {
    * We need to consider below cases when update iccInfo:
    * 1. Should clear iccInfo to null if there is no card detected.
    * 2. Need to create corresponding object based on iccType.
    */
   updateIccInfo: function(clientId, newInfo) {
     let rilContext = this.rilContexts[clientId];
 
     // Card is not detected, clear iccInfo to null.
-    if (!newInfo || !newInfo.iccType || !newInfo.iccid) {
+    if (!newInfo || !newInfo.iccid) {
       if (rilContext.iccInfo) {
         rilContext.iccInfo = null;
         this._deliverEvent(clientId,
                            "_mobileConnectionListeners",
                            "notifyIccChanged",
                            null);
       }
       return;
     }
 
     // If iccInfo is null, new corresponding object based on iccType.
     if (!rilContext.iccInfo) {
       if (newInfo.iccType === "ruim" || newInfo.iccType === "csim") {
         rilContext.iccInfo = new CdmaIccInfo();
+      } else if (newInfo.iccType === "sim" || newInfo.iccType === "usim") {
+        rilContext.iccInfo = new GsmIccInfo();
       } else {
-        rilContext.iccInfo = new GsmIccInfo();
+        rilContext.iccInfo = new IccInfo();
       }
     }
     let changed = (rilContext.iccInfo.iccid != newInfo.iccid) ?
       true : false;
 
     this.updateInfo(newInfo, rilContext.iccInfo);
 
     // Deliver event after info is updated.
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -48,30 +48,32 @@ let RILQUIRKS_HAVE_IPV6 =
   libcutils.property_get("ro.moz.ril.ipv6", "false") == "true";
 
 const RADIOINTERFACELAYER_CID =
   Components.ID("{2d831c8d-6017-435b-a80c-e5d422810cea}");
 const RADIOINTERFACE_CID =
   Components.ID("{6a7c91f0-a2b3-4193-8562-8969296c0b54}");
 const RILNETWORKINTERFACE_CID =
   Components.ID("{3bdd52a9-3965-4130-b569-0ac5afed045e}");
+const ICCINFO_CID =
+  Components.ID("{52eec7f0-26a4-11e4-8c21-0800200c9a66}");
 const GSMICCINFO_CID =
   Components.ID("{d90c4261-a99d-47bc-8b05-b057bb7e8f8a}");
 const CDMAICCINFO_CID =
   Components.ID("{39ba3c08-aacc-46d0-8c04-9b619c387061}");
 const NEIGHBORINGCELLINFO_CID =
   Components.ID("{f9dfe26a-851e-4a8b-a769-cbb1baae7ded}");
 const GSMCELLINFO_CID =
-    Components.ID("{41f6201e-7263-42e3-b31f-38a9dc8a280a}");
+  Components.ID("{41f6201e-7263-42e3-b31f-38a9dc8a280a}");
 const WCDMACELLINFO_CID =
-    Components.ID("{eeaaf307-df6e-4c98-b121-e3302b1fc468}");
+  Components.ID("{eeaaf307-df6e-4c98-b121-e3302b1fc468}");
 const CDMACELLINFO_CID =
-    Components.ID("{b497d6e4-4cb8-4d6e-b673-840c7d5ddf25}");
+  Components.ID("{b497d6e4-4cb8-4d6e-b673-840c7d5ddf25}");
 const LTECELLINFO_CID =
-    Components.ID("{c7e0a78a-4e99-42f5-9251-e6172c5ed8d8}");
+  Components.ID("{c7e0a78a-4e99-42f5-9251-e6172c5ed8d8}");
 
 const NS_XPCOM_SHUTDOWN_OBSERVER_ID      = "xpcom-shutdown";
 const kNetworkConnStateChangedTopic      = "network-connection-state-changed";
 const kNetworkActiveChangedTopic         = "network-active-changed";
 const kSmsReceivedObserverTopic          = "sms-received";
 const kSilentSmsReceivedObserverTopic    = "silent-sms-received";
 const kSmsSendingObserverTopic           = "sms-sending";
 const kSmsSentObserverTopic              = "sms-sent";
@@ -1010,16 +1012,27 @@ try {
     } catch (e) {}
 
     return 1;
   })());
 } catch (e) {}
 
 function IccInfo() {}
 IccInfo.prototype = {
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozIccInfo]),
+  classID: ICCINFO_CID,
+  classInfo: XPCOMUtils.generateCI({
+    classID:          ICCINFO_CID,
+    classDescription: "MozIccInfo",
+    flags:            Ci.nsIClassInfo.DOM_OBJECT,
+    interfaces:       [Ci.nsIDOMMozIccInfo]
+  }),
+
+  // nsIDOMMozIccInfo
+
   iccType: null,
   iccid: null,
   mcc: null,
   mnc: null,
   spn: null,
   isDisplayNetworkNameRequired: null,
   isDisplaySpnRequired: null
 };
@@ -3445,40 +3458,42 @@ RadioInterface.prototype = {
 
     gMessageManager.sendVoicemailMessage("RIL:VoicemailInfoChanged",
                                          this.clientId, voicemailInfo);
   },
 
   handleIccInfoChange: function(message) {
     let oldSpn = this.rilContext.iccInfo ? this.rilContext.iccInfo.spn : null;
 
-    if (!message || !message.iccType) {
+    if (!message || !message.iccid) {
       // Card is not detected, clear iccInfo to null.
       this.rilContext.iccInfo = null;
     } else {
       if (!this.rilContext.iccInfo) {
         if (message.iccType === "ruim" || message.iccType === "csim") {
           this.rilContext.iccInfo = new CdmaIccInfo();
+        } else if (message.iccType === "sim" || message.iccType === "usim") {
+          this.rilContext.iccInfo = new GsmIccInfo();
         } else {
-          this.rilContext.iccInfo = new GsmIccInfo();
+          this.rilContext.iccInfo = new IccInfo();
         }
       }
 
       if (!this.isInfoChanged(message, this.rilContext.iccInfo)) {
         return;
       }
 
       this.updateInfo(message, this.rilContext.iccInfo);
     }
 
     // RIL:IccInfoChanged corresponds to a DOM event that gets fired only
     // when iccInfo has changed.
     gMessageManager.sendIccMessage("RIL:IccInfoChanged",
                                    this.clientId,
-                                   message.iccType ? message : null);
+                                   message.iccid ? message : null);
 
     // Update lastKnownSimMcc.
     if (message.mcc) {
       try {
         Services.prefs.setCharPref("ril.lastKnownSimMcc",
                                    message.mcc.toString());
       } catch (e) {}
     }