OSDN Git Service

Further fix for SIM detection.
authorKazuhiro Ondo <kazuhiro.ondo@motorola.com>
Fri, 27 May 2011 22:01:51 +0000 (17:01 -0500)
committerWink Saville <wink@google.com>
Sat, 28 May 2011 01:36:05 +0000 (18:36 -0700)
Refining SIM ready condition on UICC w/ multiple apps.
Also migration for RIL to use SIM_READY indication in case of UICC
presence instead of current NV_READY message.

Change-Id: I3445a628e2d32a24292e6a69785fe72422481221

telephony/java/com/android/internal/telephony/IccCard.java
telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
telephony/java/com/android/internal/telephony/gsm/SIMRecords.java

index f2506da..5d8fc78 100644 (file)
@@ -785,7 +785,18 @@ public abstract class IccCard {
         if (right == IccCard.State.ABSENT) return left;
         if (left == IccCard.State.ABSENT) return right;
 
-        // Disregards if either is NOT_READY
+        // Only if both are ready, return ready
+        if ((left == IccCard.State.READY) && (right == IccCard.State.READY)) {
+            return State.READY;
+        }
+
+        // Case one is ready, but the other is not.
+        if (((right == IccCard.State.NOT_READY) && (left == IccCard.State.READY)) ||
+            ((left == IccCard.State.NOT_READY) && (right == IccCard.State.READY))) {
+            return IccCard.State.NOT_READY;
+        }
+
+        // At this point, the other state is assumed to be one of locked state
         if (right == IccCard.State.NOT_READY) return left;
         if (left == IccCard.State.NOT_READY) return right;
 
index d79f0a1..e593bd0 100644 (file)
@@ -48,22 +48,37 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
 
     public CdmaLteServiceStateTracker(CDMALTEPhone phone) {
         super(phone);
+        cm.registerForSIMReady(this, EVENT_SIM_READY, null);
         mCdmaLtePhone = phone;
 
         mLteSS = new ServiceState();
         if (DBG) log("CdmaLteServiceStateTracker Constructors");
     }
 
+    public void dispose() {
+        cm.unregisterForSIMReady(this);
+        super.dispose();
+    }
+
     @Override
     public void handleMessage(Message msg) {
         AsyncResult ar;
         int[] ints;
         String[] strings;
-        if (msg.what == EVENT_POLL_STATE_GPRS) {
+        switch (msg.what) {
+        case EVENT_POLL_STATE_GPRS:
             if (DBG) log("handleMessage EVENT_POLL_STATE_GPRS");
             ar = (AsyncResult)msg.obj;
             handlePollStateResult(msg.what, ar);
-        } else {
+            break;
+        case EVENT_SIM_READY:
+            isSubscriptionFromRuim = false;
+            cm.getCDMASubscription( obtainMessage(EVENT_POLL_STATE_CDMA_SUBSCRIPTION));
+            pollState();
+            // Signal strength polling stops when radio is off.
+            queueNextSignalStrengthPoll();
+            break;
+        default:
             super.handleMessage(msg);
         }
     }
index 35a98ed..0fd0614 100755 (executable)
@@ -137,7 +137,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
     private boolean mIsMinInfoReady = false;
 
     private boolean isEriTextLoaded = false;
-    private boolean isSubscriptionFromRuim = false;
+    protected boolean isSubscriptionFromRuim = false;
 
     /* Used only for debugging purposes. */
     private String mRegistrationDeniedReason;
@@ -1120,7 +1120,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
      * This code should probably be hoisted to the base class so
      * the fix, when added, works for both.
      */
-    private void
+    protected void
     queueNextSignalStrengthPoll() {
         if (dontPollSignalStrength || (cm.getRadioState().isGsm())) {
             // The radio is telling us about signal strength changes
index 891c7cb..4cd9440 100755 (executable)
@@ -181,8 +181,11 @@ public final class SIMRecords extends IccRecords {
         // recordsToLoad is set to 0 because no requests are made yet
         recordsToLoad = 0;
 
-
-        p.mCM.registerForSIMReady(this, EVENT_SIM_READY, null);
+        // SIMRecord is used by CDMA+LTE mode, and SIM_READY event
+        // will be subscribed by CdmaLteServiceStateTracker.
+        if (phone.getLteOnCdmaMode() != Phone.LTE_ON_CDMA_TRUE) {
+            p.mCM.registerForSIMReady(this, EVENT_SIM_READY, null);
+        }
         p.mCM.registerForOffOrNotAvailable(
                         this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
         p.mCM.setOnSmsOnSim(this, EVENT_SMS_ON_SIM, null);
@@ -196,7 +199,9 @@ public final class SIMRecords extends IccRecords {
     @Override
     public void dispose() {
         //Unregister for all events
-        phone.mCM.unregisterForSIMReady(this);
+        if (phone.getLteOnCdmaMode() != Phone.LTE_ON_CDMA_TRUE) {
+            phone.mCM.unregisterForSIMReady(this);
+        }
         phone.mCM.unregisterForOffOrNotAvailable( this);
         phone.mCM.unregisterForIccRefresh(this);
     }