OSDN Git Service

Bring back ERI into CDMA-LTE mode
authorKazuhiro Ondo <kazuhiro.ondo@motorola.com>
Fri, 1 Jul 2011 20:23:37 +0000 (15:23 -0500)
committerWink Saville <wink@google.com>
Thu, 7 Jul 2011 00:30:52 +0000 (17:30 -0700)
Use ERI mechanism for roaming determination in CDMA-LTE mode.
Also display SPN name from CSIM card as "SPN" field in the status bar.
PLMN field will be derived from ERI text as done in original CDMA phone.

Bug: 4970448
Change-Id: I21382b15e148a8451f4c3fcbbb5d1ed296e41b5a

telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
telephony/java/com/android/internal/telephony/cdma/CdmaLteUiccRecords.java
telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java

index a283062..7f6bb45 100755 (executable)
@@ -1030,13 +1030,8 @@ public class CDMAPhone extends PhoneBase {
             case EVENT_NV_READY:{
                 Log.d(LOG_TAG, "Event EVENT_NV_READY Received");
                 //Inform the Service State Tracker
-                mEriManager.loadEriFile();
                 mNvLoadedRegistrants.notifyRegistrants();
-                if(mEriManager.isEriFileLoaded()) {
-                    // when the ERI file is loaded
-                    Log.d(LOG_TAG, "ERI read, notify registrants");
-                    mEriFileLoadedRegistrants.notifyRegistrants();
-                }
+                prepareEri();
             }
             break;
 
@@ -1421,6 +1416,19 @@ public class CDMAPhone extends PhoneBase {
         return false;
     }
 
+    public void prepareEri() {
+        mEriManager.loadEriFile();
+        if(mEriManager.isEriFileLoaded()) {
+            // when the ERI file is loaded
+            log("ERI read, notify registrants");
+            mEriFileLoadedRegistrants.notifyRegistrants();
+        }
+    }
+
+    public boolean isEriFileLoaded() {
+        return mEriManager.isEriFileLoaded();
+    }
+
     protected void log(String s) {
         if (DBG)
             Log.d(LOG_TAG, "[CDMAPhone] " + s);
index 318cf37..459cf87 100644 (file)
@@ -21,13 +21,15 @@ import com.android.internal.telephony.MccTable;
 import com.android.internal.telephony.EventLogTags;
 import com.android.internal.telephony.RILConstants;
 
+import android.content.Intent;
 import android.telephony.SignalStrength;
 import android.telephony.ServiceState;
 import android.telephony.cdma.CdmaCellLocation;
 import android.os.AsyncResult;
 import android.os.Message;
+import android.provider.Telephony.Intents;
 
-
+import android.text.TextUtils;
 import android.util.Log;
 import android.util.EventLog;
 
@@ -37,6 +39,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
     CDMALTEPhone mCdmaLtePhone;
 
     private ServiceState  mLteSS;  // The last LTE state from Voice Registration
+    private String mCurrentSpn = null;
 
     public CdmaLteServiceStateTracker(CDMALTEPhone phone) {
         super(phone);
@@ -73,6 +76,9 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
             pollState();
             // Signal strength polling stops when radio is off.
             queueNextSignalStrengthPoll();
+
+            // load ERI file
+            phone.prepareEri();
             break;
         case EVENT_SIM_RECORDS_LOADED:
             CdmaLteUiccRecords sim = (CdmaLteUiccRecords)phone.mIccRecords;
@@ -84,6 +90,10 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
                 mIsMinInfoReady = true;
                 updateOtaspState();
             }
+            // SID/NID/PRL is loaded. Poll service state
+            // again to update to the roaming state with
+            // the latest variables.
+            pollState();
             break;
         default:
             super.handleMessage(msg);
@@ -319,7 +329,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
         }
 
         if (hasChanged) {
-            if (cm.getNvState().isNVReady()) {
+            if (phone.isEriFileLoaded()) {
                 String eriText;
                 // Now the CDMAPhone sees the new ServiceState so it can get the
                 // new ERI text
@@ -334,13 +344,6 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
                 }
                 ss.setOperatorAlphaLong(eriText);
             }
-            if (cm.getSimState().isSIMReady()) {
-                // SIM is found on the device. Read the operator name from the card.
-                ss.setOperatorAlphaLong(phone.mIccRecords.getServiceProviderName());
-
-                // If SIM card is present, Eri will not be used. Turn it off
-                ss.setCdmaEriIconIndex(EriInfo.ROAMING_INDICATOR_OFF);
-            }
 
             String operatorNumeric;
 
@@ -465,6 +468,43 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
     }
 
     @Override
+    protected void updateSpnDisplay() {
+        // mOperatorAlphaLong contains the ERI text
+        String plmn = ss.getOperatorAlphaLong();
+
+        boolean showSpn = false;
+        String spn = null;
+        if (cm.getSimState().isSIMReady()) {
+            // SIM is found on the device. Read the operator name from the card.
+            showSpn = ((CdmaLteUiccRecords)phone.mIccRecords).getCsimSpnDisplayCondition();
+            spn = phone.mIccRecords.getServiceProviderName();
+
+            // double check we are not printing identicall test
+            if (TextUtils.equals(plmn, spn)) showSpn = false;
+        }
+
+        if (!TextUtils.equals(plmn, mCurPlmn) ||
+            !TextUtils.equals(spn, mCurrentSpn)) {
+            boolean showPlmn = plmn != null;
+            if (DBG) {
+                log(String.format("updateSpnDisplay: changed sending intent" +
+                                  " showPlmn='%b' plmn='%s' showSpn='%b' spn='%s'",
+                                  showPlmn, plmn, showSpn, spn));
+            }
+            Intent intent = new Intent(Intents.SPN_STRINGS_UPDATED_ACTION);
+            intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
+            intent.putExtra(Intents.EXTRA_SHOW_SPN, showSpn);
+            intent.putExtra(Intents.EXTRA_SPN, spn);
+            intent.putExtra(Intents.EXTRA_SHOW_PLMN, showPlmn);
+            intent.putExtra(Intents.EXTRA_PLMN, plmn);
+            phone.getContext().sendStickyBroadcast(intent);
+        }
+
+        mCurPlmn = plmn;
+        mCurrentSpn = spn;
+    }
+
+    @Override
     protected void log(String s) {
         Log.d(LOG_TAG, "[CdmaLteSST] " + s);
     }
index 73b5d97..10515f7 100755 (executable)
@@ -38,7 +38,7 @@ public final class CdmaLteUiccRecords extends SIMRecords {
     // From CSIM application
     private byte[] mEFpl = null;
     private byte[] mEFli = null;
-    boolean csimSpnDisplayCondition = false;
+    boolean mCsimSpnDisplayCondition = false;
     private String mMdn;
     private String mMin;
     private String mPrlVersion;
@@ -235,7 +235,7 @@ public final class CdmaLteUiccRecords extends SIMRecords {
                      IccUtils.bytesToHexString(data));
 
         // C.S0065 for EF_SPN decoding
-        csimSpnDisplayCondition = ((0x02 & data[0]) > 0)?true:false;
+        mCsimSpnDisplayCondition = ((0x01 & data[0]) != 0) ? true : false;
 
         int encoding = data[1];
         int language = data[2];
@@ -272,7 +272,7 @@ public final class CdmaLteUiccRecords extends SIMRecords {
             log("spn decode error: " + e);
         }
         if (DBG) log("spn=" + spn);
-        if (DBG) log("spnCondition=" + csimSpnDisplayCondition);
+        if (DBG) log("spnCondition=" + mCsimSpnDisplayCondition);
         phone.setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, spn);
     }
 
@@ -437,6 +437,10 @@ public final class CdmaLteUiccRecords extends SIMRecords {
         return mPrlVersion;
     }
 
+    public boolean getCsimSpnDisplayCondition() {
+        return mCsimSpnDisplayCondition;
+    }
+
     @Override
     public boolean isProvisioned() {
         // If UICC card has CSIM app, look for MDN and MIN field
index 5ebdd22..24a468a 100755 (executable)
@@ -127,7 +127,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
     private static final String WAKELOCK_TAG = "ServiceStateTracker";
 
     /** Contains the name of the registered network in CDMA (either ONS or ERI text). */
-    private String curPlmn = null;
+    protected String mCurPlmn = null;
 
     protected String mMdn;
     private int mHomeSystemId[] = null;
@@ -484,7 +484,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
 
         // mOperatorAlphaLong contains the ERI text
         String plmn = ss.getOperatorAlphaLong();
-        if (!TextUtils.equals(plmn, curPlmn)) {
+        if (!TextUtils.equals(plmn, mCurPlmn)) {
             // Allow A blank plmn, "" to set showPlmn to true. Previously, we
             // would set showPlmn to true only if plmn was not empty, i.e. was not
             // null and not blank. But this would cause us to incorrectly display
@@ -503,7 +503,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
             phone.getContext().sendStickyBroadcast(intent);
         }
 
-        curPlmn = plmn;
+        mCurPlmn = plmn;
     }
 
     @Override