dispose uicc card if modem is not available.
Steven Liu [Thu, 11 Sep 2014 16:50:37 +0000 (11:50 -0500)]
Bug: 17786992
Change-Id: Idd36a2afe696789340e0b6cba1d30eeadc378036

src/java/com/android/internal/telephony/uicc/IccCardProxy.java
src/java/com/android/internal/telephony/uicc/UiccController.java

index d932f50..8e8eaec 100644 (file)
@@ -230,6 +230,9 @@ public class IccCardProxy extends Handler implements IccCard {
         switch (msg.what) {
             case EVENT_RADIO_OFF_OR_UNAVAILABLE:
                 mRadioOn = false;
+                if (CommandsInterface.RadioState.RADIO_UNAVAILABLE == mCi.getRadioState()) {
+                    setExternalState(State.NOT_READY);
+                }
                 break;
             case EVENT_RADIO_ON:
                 mRadioOn = true;
index 073103d..c998934 100644 (file)
@@ -82,6 +82,7 @@ public class UiccController extends Handler {
 
     private static final int EVENT_ICC_STATUS_CHANGED = 1;
     private static final int EVENT_GET_ICC_STATUS_DONE = 2;
+    private static final int EVENT_RADIO_UNAVAILABLE = 3;
 
     private CommandsInterface[] mCis;
     private UiccCard[] mUiccCards = new UiccCard[TelephonyManager.getDefault().getPhoneCount()];
@@ -128,6 +129,7 @@ public class UiccController extends Handler {
             mCis[i].registerForIccStatusChanged(this, EVENT_ICC_STATUS_CHANGED, index);
             // TODO remove this once modem correctly notifies the unsols
             mCis[i].registerForAvailable(this, EVENT_ICC_STATUS_CHANGED, index);
+            mCis[i].registerForNotAvailable(this, EVENT_RADIO_UNAVAILABLE, index);
         }
     }
 
@@ -257,6 +259,14 @@ public class UiccController extends Handler {
                     AsyncResult ar = (AsyncResult)msg.obj;
                     onGetIccCardStatusDone(ar, index);
                     break;
+                case EVENT_RADIO_UNAVAILABLE:
+                    if (DBG) log("EVENT_RADIO_UNAVAILABLE, dispose card");
+                    if (mUiccCards[index] != null) {
+                        mUiccCards[index].dispose();
+                    }
+                    mUiccCards[index] = null;
+                    mIccChangedRegistrants.notifyRegistrants(new AsyncResult(null, index, null));
+                    break;
                 default:
                     Rlog.e(LOG_TAG, " Unknown Event " + msg.what);
             }