Telephony: unchange SIM info from CDMAPhone when SIM exists
Wink Saville [Wed, 13 Nov 2013 21:33:43 +0000 (13:33 -0800)]
This change is to prevent for updating the properties of 3GPP SIM
from the CDMAPhone when the 3GPP SIM exists on the card.

Bug: 11189478
Bug: 11360679
Change-Id: If849f8e0d6d6a1750cae045e35f3f92d73db4a20

src/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
src/java/com/android/internal/telephony/cdma/CDMAPhone.java

index c0b7c4a..3b6856d 100644 (file)
@@ -195,6 +195,27 @@ public class CDMALTEPhone extends CDMAPhone {
 
     }
 
+
+    /**
+     * Sets the "current" field in the telephony provider according to the
+     * build-time operator numeric property
+     *
+     * @return true for success; false otherwise.
+     */
+    @Override
+    boolean updateCurrentCarrierInProvider(String operatorNumeric) {
+        boolean retVal;
+        if (mUiccController.getUiccCardApplication(UiccController.APP_FAM_3GPP) == null) {
+            if (DBG) log("updateCurrentCarrierInProvider APP_FAM_3GPP == null");
+            retVal = super.updateCurrentCarrierInProvider(operatorNumeric);
+        } else {
+            if (DBG) log("updateCurrentCarrierInProvider not updated");
+            retVal = true;
+        }
+        if (DBG) log("updateCurrentCarrierInProvider X retVal=" + retVal);
+        return retVal;
+    }
+
     @Override
     public boolean updateCurrentCarrierInProvider() {
         if (mSimRecords != null) {
index 1a27dda..ccffeae 100644 (file)
@@ -195,22 +195,24 @@ public class CDMAPhone extends PhoneBase {
         mCarrierOtaSpNumSchema = SystemProperties.get(
                 TelephonyProperties.PROPERTY_OTASP_NUM_SCHEMA,"");
 
-        // Sets operator alpha property by retrieving from build-time system property
+        // Sets operator properties by retrieving from build-time system property
         String operatorAlpha = SystemProperties.get("ro.cdma.home.operator.alpha");
-        setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, operatorAlpha);
-
-        // Sets operator numeric property by retrieving from build-time system property
         String operatorNumeric = SystemProperties.get(PROPERTY_CDMA_HOME_OPERATOR_NUMERIC);
-        if (!TextUtils.isEmpty(operatorNumeric) &&
-            (mUiccController.getUiccCardApplication(UiccController.APP_FAM_3GPP) == null)) {
-            log("CDMAPhone: init set 'gsm.sim.operator.numeric' to operator='" +
-                    operatorNumeric + "'");
-            setSystemProperty(PROPERTY_ICC_OPERATOR_NUMERIC, operatorNumeric);
+        log("init: operatorAlpha='" + operatorAlpha
+                + "' operatorNumeric='" + operatorNumeric + "'");
+        if (mUiccController.getUiccCardApplication(UiccController.APP_FAM_3GPP) == null) {
+            log("init: APP_FAM_3GPP == NULL");
+            if (!TextUtils.isEmpty(operatorAlpha)) {
+                log("init: set 'gsm.sim.operator.alpha' to operator='" + operatorAlpha + "'");
+                setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, operatorAlpha);
+            }
+            if (!TextUtils.isEmpty(operatorNumeric)) {
+                log("init: set 'gsm.sim.operator.numeric' to operator='" + operatorNumeric + "'");
+                setSystemProperty(PROPERTY_ICC_OPERATOR_NUMERIC, operatorNumeric);
+            }
+            setIsoCountryProperty(operatorNumeric);
         }
 
-        // Sets iso country property by retrieving from build-time system property
-        setIsoCountryProperty(operatorNumeric);
-
         // Sets current entry in the telephony carrier table
         updateCurrentCarrierInProvider(operatorNumeric);
 
@@ -1543,6 +1545,7 @@ public class CDMAPhone extends PhoneBase {
      */
     private void setIsoCountryProperty(String operatorNumeric) {
         if (TextUtils.isEmpty(operatorNumeric)) {
+            log("setIsoCountryProperty: clear 'gsm.sim.operator.iso-country'");
             setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, "");
         } else {
             String iso = "";
@@ -1550,11 +1553,12 @@ public class CDMAPhone extends PhoneBase {
                 iso = MccTable.countryCodeForMcc(Integer.parseInt(
                         operatorNumeric.substring(0,3)));
             } catch (NumberFormatException ex) {
-                Rlog.w(LOG_TAG, "countryCodeForMcc error" + ex);
+                loge("setIsoCountryProperty: countryCodeForMcc error", ex);
             } catch (StringIndexOutOfBoundsException ex) {
-                Rlog.w(LOG_TAG, "countryCodeForMcc error" + ex);
+                loge("setIsoCountryProperty: countryCodeForMcc error", ex);
             }
 
+            log("setIsoCountryProperty: set 'gsm.sim.operator.iso-country' to iso=" + iso);
             setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, iso);
         }
     }
@@ -1566,6 +1570,7 @@ public class CDMAPhone extends PhoneBase {
      * @return true for success; false otherwise.
      */
     boolean updateCurrentCarrierInProvider(String operatorNumeric) {
+        log("CDMAPhone: updateCurrentCarrierInProvider called");
         if (!TextUtils.isEmpty(operatorNumeric)) {
             try {
                 Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
@@ -1631,6 +1636,11 @@ public class CDMAPhone extends PhoneBase {
             Rlog.d(LOG_TAG, s);
     }
 
+    protected void loge(String s, Exception e) {
+        if (DBG)
+            Rlog.e(LOG_TAG, s, e);
+    }
+
     @Override
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
         pw.println("CDMAPhone extends:");