Loading src/java/com/android/internal/telephony/uicc/IccRecords.java +13 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,7 @@ public abstract class IccRecords extends Handler implements IccConstants { protected static final int EVENT_APP_READY = 1 + SYSTEM_EVENT_BASE; protected static final int EVENT_APP_LOCKED = 2 + SYSTEM_EVENT_BASE; protected static final int EVENT_APP_NETWORK_LOCKED = 3 + SYSTEM_EVENT_BASE; protected static final int EVENT_APP_DETECTED = 4 + SYSTEM_EVENT_BASE; public static final int CALL_FORWARDING_STATUS_DISABLED = 0; public static final int CALL_FORWARDING_STATUS_ENABLED = 1; Loading Loading @@ -285,6 +286,7 @@ public abstract class IccRecords extends Handler implements IccConstants { mCi.registerForIccRefresh(this, EVENT_REFRESH, null); mParentApp.registerForReady(this, EVENT_APP_READY, null); mParentApp.registerForDetected(this, EVENT_APP_DETECTED, null); mParentApp.registerForLocked(this, EVENT_APP_LOCKED, null); mParentApp.registerForNetworkLocked(this, EVENT_APP_NETWORK_LOCKED, null); } Loading @@ -306,6 +308,7 @@ public abstract class IccRecords extends Handler implements IccConstants { mCi.unregisterForIccRefresh(this); mParentApp.unregisterForReady(this); mParentApp.unregisterForDetected(this); mParentApp.unregisterForLocked(this); mParentApp.unregisterForNetworkLocked(this); Loading @@ -321,6 +324,11 @@ public abstract class IccRecords extends Handler implements IccConstants { protected abstract void onReady(); protected void onDetected() { mRecordsRequested = false; mLoaded.set(false); } protected void onLocked() { // The LOADED state should not be indicated while the lock is effective. mRecordsRequested = false; Loading Loading @@ -822,6 +830,11 @@ public abstract class IccRecords extends Handler implements IccConstants { onReady(); break; case EVENT_APP_DETECTED: mLockedRecordsReqReason = LOCKED_RECORDS_REQ_REASON_NONE; onDetected(); break; case EVENT_APP_LOCKED: mLockedRecordsReqReason = LOCKED_RECORDS_REQ_REASON_LOCKED; onLocked(); Loading src/java/com/android/internal/telephony/uicc/UiccCardApplication.java +36 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ public class UiccCardApplication { private boolean mDestroyed;//set to true once this App is commanded to be disposed of. private RegistrantList mReadyRegistrants = new RegistrantList(); private RegistrantList mDetectedRegistrants = new RegistrantList(); private RegistrantList mPinLockedRegistrants = new RegistrantList(); private RegistrantList mNetworkLockedRegistrants = new RegistrantList(); Loading Loading @@ -174,6 +175,7 @@ public class UiccCardApplication { } notifyPinLockedRegistrantsIfNeeded(null); notifyReadyRegistrantsIfNeeded(null); notifyDetectedRegistrantsIfNeeded(null); } else { if (mPin1State != oldPin1State) queryPin1State(); Loading Loading @@ -445,6 +447,20 @@ public class UiccCardApplication { } } public void registerForDetected(Handler h, int what, Object obj) { synchronized (mLock) { Registrant r = new Registrant(h, what, obj); mDetectedRegistrants.add(r); notifyDetectedRegistrantsIfNeeded(r); } } public void unregisterForDetected(Handler h) { synchronized (mLock) { mDetectedRegistrants.remove(h); } } /** * Notifies handler of any transition into State.isPinLocked() */ Loading Loading @@ -506,6 +522,26 @@ public class UiccCardApplication { } } /** * Notifies specified registrant, assume mLock is held. * * @param r Registrant to be notified. If null - all registrants will be notified */ private void notifyDetectedRegistrantsIfNeeded(Registrant r) { if (mDestroyed) { return; } if (mAppState == AppState.APPSTATE_DETECTED) { if (r == null) { if (DBG) log("Notifying registrants: DETECTED"); mDetectedRegistrants.notifyRegistrants(); } else { if (DBG) log("Notifying 1 registrant: DETECTED"); r.notifyRegistrant(new AsyncResult(null, null, null)); } } } /** * Notifies specified registrant, assume mLock is held. * Loading tests/telephonytests/src/com/android/internal/telephony/uicc/IccRecordsTest.java +28 −1 Original line number Diff line number Diff line Loading @@ -29,10 +29,16 @@ package com.android.internal.telephony.uicc; import static com.android.internal.telephony.uicc.IccRecords.EVENT_APP_DETECTED; import static com.android.internal.telephony.uicc.IccRecords.EVENT_APP_READY; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.*; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.isNull; import static org.mockito.Mockito.verify; import android.os.AsyncResult; import android.os.HandlerThread; Loading Loading @@ -68,6 +74,10 @@ public class IccRecordsTest extends TelephonyTest { super.setUp(this.getClass().getSimpleName()); new IccRecordsTestHandler(TAG).start(); waitUntilReady(); verify(mUiccCardApplication3gpp).registerForReady( mIccRecords, EVENT_APP_READY, null); verify(mUiccCardApplication3gpp).registerForDetected( mIccRecords, EVENT_APP_DETECTED, null); } @After Loading Loading @@ -168,6 +178,23 @@ public class IccRecordsTest extends TelephonyTest { timeSpent >= mSimulatedCommands.ICC_SIM_CHALLENGE_TIMEOUT_MILLIS); } @Test public void testAppStateChange() { assertFalse(mIccRecords.isLoaded()); mIccRecords.obtainMessage(EVENT_APP_READY).sendToTarget(); waitForLastHandlerAction(mIccRecords); assertTrue(mIccRecords.isLoaded()); mIccRecords.obtainMessage(EVENT_APP_DETECTED).sendToTarget(); waitForLastHandlerAction(mIccRecords); assertFalse(mIccRecords.isLoaded()); mIccRecords.obtainMessage(EVENT_APP_READY).sendToTarget(); waitForLastHandlerAction(mIccRecords); assertTrue(mIccRecords.isLoaded()); } @Test public void testGetIccSimChallengeResponseDefault() { long startTime; Loading tests/telephonytests/src/com/android/internal/telephony/uicc/UiccCardApplicationTest.java +35 −0 Original line number Diff line number Diff line Loading @@ -52,10 +52,13 @@ public class UiccCardApplicationTest extends TelephonyTest { private Handler mHandler; private int mAttemptsRemaining = -1; private CommandException mException = null; private IccCardApplicationStatus.AppState mAppState; private static final int UICCCARDAPP_ENABLE_FDN_EVENT = 1; private static final int UICCCARDAPP_ENABLE_LOCK_EVENT = 2; private static final int UICCCARDAPP_CHANGE_PSW_EVENT = 3; private static final int UICCCARDAPP_SUPPLY_PIN_EVENT = 4; private static final int EVENT_APP_STATE_DETECTED = 5; private static final int EVENT_APP_STATE_READY = 6; @Before public void setUp() throws Exception { Loading Loading @@ -83,6 +86,12 @@ public class UiccCardApplicationTest extends TelephonyTest { logd("remaining Attempt:" + mAttemptsRemaining); } break; case EVENT_APP_STATE_DETECTED: mAppState = IccCardApplicationStatus.AppState.APPSTATE_DETECTED; break; case EVENT_APP_STATE_READY: mAppState = IccCardApplicationStatus.AppState.APPSTATE_READY; break; default: logd("Unknown Event " + msg.what); } Loading Loading @@ -192,4 +201,30 @@ public class UiccCardApplicationTest extends TelephonyTest { processAllMessages(); assertEquals(-1, mAttemptsRemaining); } @Test @SmallTest public void testAppStateChangeNotification() { mUiccCardApplication.registerForDetected(mHandler, EVENT_APP_STATE_DETECTED, null); mUiccCardApplication.registerForReady(mHandler, EVENT_APP_STATE_READY, null); processAllMessages(); assertEquals(null, mAppState); // Change to DETECTED state. mUiccCardAppStatus.app_state = IccCardApplicationStatus.AppState.APPSTATE_DETECTED; mUiccCardApplication.update(mUiccCardAppStatus, mContext, mSimulatedCommands); processAllMessages(); assertEquals(IccCardApplicationStatus.AppState.APPSTATE_DETECTED, mAppState); assertEquals(IccCardApplicationStatus.AppState.APPSTATE_DETECTED, mUiccCardApplication.getState()); // Change to READY state. mUiccCardAppStatus.app_state = IccCardApplicationStatus.AppState.APPSTATE_READY; mUiccCardAppStatus.pin1 = IccCardStatus.PinState.PINSTATE_ENABLED_VERIFIED; mUiccCardApplication.update(mUiccCardAppStatus, mContext, mSimulatedCommands); processAllMessages(); assertEquals(IccCardApplicationStatus.AppState.APPSTATE_READY, mAppState); assertEquals(IccCardApplicationStatus.AppState.APPSTATE_READY, mUiccCardApplication.getState()); } } Loading
src/java/com/android/internal/telephony/uicc/IccRecords.java +13 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,7 @@ public abstract class IccRecords extends Handler implements IccConstants { protected static final int EVENT_APP_READY = 1 + SYSTEM_EVENT_BASE; protected static final int EVENT_APP_LOCKED = 2 + SYSTEM_EVENT_BASE; protected static final int EVENT_APP_NETWORK_LOCKED = 3 + SYSTEM_EVENT_BASE; protected static final int EVENT_APP_DETECTED = 4 + SYSTEM_EVENT_BASE; public static final int CALL_FORWARDING_STATUS_DISABLED = 0; public static final int CALL_FORWARDING_STATUS_ENABLED = 1; Loading Loading @@ -285,6 +286,7 @@ public abstract class IccRecords extends Handler implements IccConstants { mCi.registerForIccRefresh(this, EVENT_REFRESH, null); mParentApp.registerForReady(this, EVENT_APP_READY, null); mParentApp.registerForDetected(this, EVENT_APP_DETECTED, null); mParentApp.registerForLocked(this, EVENT_APP_LOCKED, null); mParentApp.registerForNetworkLocked(this, EVENT_APP_NETWORK_LOCKED, null); } Loading @@ -306,6 +308,7 @@ public abstract class IccRecords extends Handler implements IccConstants { mCi.unregisterForIccRefresh(this); mParentApp.unregisterForReady(this); mParentApp.unregisterForDetected(this); mParentApp.unregisterForLocked(this); mParentApp.unregisterForNetworkLocked(this); Loading @@ -321,6 +324,11 @@ public abstract class IccRecords extends Handler implements IccConstants { protected abstract void onReady(); protected void onDetected() { mRecordsRequested = false; mLoaded.set(false); } protected void onLocked() { // The LOADED state should not be indicated while the lock is effective. mRecordsRequested = false; Loading Loading @@ -822,6 +830,11 @@ public abstract class IccRecords extends Handler implements IccConstants { onReady(); break; case EVENT_APP_DETECTED: mLockedRecordsReqReason = LOCKED_RECORDS_REQ_REASON_NONE; onDetected(); break; case EVENT_APP_LOCKED: mLockedRecordsReqReason = LOCKED_RECORDS_REQ_REASON_LOCKED; onLocked(); Loading
src/java/com/android/internal/telephony/uicc/UiccCardApplication.java +36 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ public class UiccCardApplication { private boolean mDestroyed;//set to true once this App is commanded to be disposed of. private RegistrantList mReadyRegistrants = new RegistrantList(); private RegistrantList mDetectedRegistrants = new RegistrantList(); private RegistrantList mPinLockedRegistrants = new RegistrantList(); private RegistrantList mNetworkLockedRegistrants = new RegistrantList(); Loading Loading @@ -174,6 +175,7 @@ public class UiccCardApplication { } notifyPinLockedRegistrantsIfNeeded(null); notifyReadyRegistrantsIfNeeded(null); notifyDetectedRegistrantsIfNeeded(null); } else { if (mPin1State != oldPin1State) queryPin1State(); Loading Loading @@ -445,6 +447,20 @@ public class UiccCardApplication { } } public void registerForDetected(Handler h, int what, Object obj) { synchronized (mLock) { Registrant r = new Registrant(h, what, obj); mDetectedRegistrants.add(r); notifyDetectedRegistrantsIfNeeded(r); } } public void unregisterForDetected(Handler h) { synchronized (mLock) { mDetectedRegistrants.remove(h); } } /** * Notifies handler of any transition into State.isPinLocked() */ Loading Loading @@ -506,6 +522,26 @@ public class UiccCardApplication { } } /** * Notifies specified registrant, assume mLock is held. * * @param r Registrant to be notified. If null - all registrants will be notified */ private void notifyDetectedRegistrantsIfNeeded(Registrant r) { if (mDestroyed) { return; } if (mAppState == AppState.APPSTATE_DETECTED) { if (r == null) { if (DBG) log("Notifying registrants: DETECTED"); mDetectedRegistrants.notifyRegistrants(); } else { if (DBG) log("Notifying 1 registrant: DETECTED"); r.notifyRegistrant(new AsyncResult(null, null, null)); } } } /** * Notifies specified registrant, assume mLock is held. * Loading
tests/telephonytests/src/com/android/internal/telephony/uicc/IccRecordsTest.java +28 −1 Original line number Diff line number Diff line Loading @@ -29,10 +29,16 @@ package com.android.internal.telephony.uicc; import static com.android.internal.telephony.uicc.IccRecords.EVENT_APP_DETECTED; import static com.android.internal.telephony.uicc.IccRecords.EVENT_APP_READY; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.*; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.isNull; import static org.mockito.Mockito.verify; import android.os.AsyncResult; import android.os.HandlerThread; Loading Loading @@ -68,6 +74,10 @@ public class IccRecordsTest extends TelephonyTest { super.setUp(this.getClass().getSimpleName()); new IccRecordsTestHandler(TAG).start(); waitUntilReady(); verify(mUiccCardApplication3gpp).registerForReady( mIccRecords, EVENT_APP_READY, null); verify(mUiccCardApplication3gpp).registerForDetected( mIccRecords, EVENT_APP_DETECTED, null); } @After Loading Loading @@ -168,6 +178,23 @@ public class IccRecordsTest extends TelephonyTest { timeSpent >= mSimulatedCommands.ICC_SIM_CHALLENGE_TIMEOUT_MILLIS); } @Test public void testAppStateChange() { assertFalse(mIccRecords.isLoaded()); mIccRecords.obtainMessage(EVENT_APP_READY).sendToTarget(); waitForLastHandlerAction(mIccRecords); assertTrue(mIccRecords.isLoaded()); mIccRecords.obtainMessage(EVENT_APP_DETECTED).sendToTarget(); waitForLastHandlerAction(mIccRecords); assertFalse(mIccRecords.isLoaded()); mIccRecords.obtainMessage(EVENT_APP_READY).sendToTarget(); waitForLastHandlerAction(mIccRecords); assertTrue(mIccRecords.isLoaded()); } @Test public void testGetIccSimChallengeResponseDefault() { long startTime; Loading
tests/telephonytests/src/com/android/internal/telephony/uicc/UiccCardApplicationTest.java +35 −0 Original line number Diff line number Diff line Loading @@ -52,10 +52,13 @@ public class UiccCardApplicationTest extends TelephonyTest { private Handler mHandler; private int mAttemptsRemaining = -1; private CommandException mException = null; private IccCardApplicationStatus.AppState mAppState; private static final int UICCCARDAPP_ENABLE_FDN_EVENT = 1; private static final int UICCCARDAPP_ENABLE_LOCK_EVENT = 2; private static final int UICCCARDAPP_CHANGE_PSW_EVENT = 3; private static final int UICCCARDAPP_SUPPLY_PIN_EVENT = 4; private static final int EVENT_APP_STATE_DETECTED = 5; private static final int EVENT_APP_STATE_READY = 6; @Before public void setUp() throws Exception { Loading Loading @@ -83,6 +86,12 @@ public class UiccCardApplicationTest extends TelephonyTest { logd("remaining Attempt:" + mAttemptsRemaining); } break; case EVENT_APP_STATE_DETECTED: mAppState = IccCardApplicationStatus.AppState.APPSTATE_DETECTED; break; case EVENT_APP_STATE_READY: mAppState = IccCardApplicationStatus.AppState.APPSTATE_READY; break; default: logd("Unknown Event " + msg.what); } Loading Loading @@ -192,4 +201,30 @@ public class UiccCardApplicationTest extends TelephonyTest { processAllMessages(); assertEquals(-1, mAttemptsRemaining); } @Test @SmallTest public void testAppStateChangeNotification() { mUiccCardApplication.registerForDetected(mHandler, EVENT_APP_STATE_DETECTED, null); mUiccCardApplication.registerForReady(mHandler, EVENT_APP_STATE_READY, null); processAllMessages(); assertEquals(null, mAppState); // Change to DETECTED state. mUiccCardAppStatus.app_state = IccCardApplicationStatus.AppState.APPSTATE_DETECTED; mUiccCardApplication.update(mUiccCardAppStatus, mContext, mSimulatedCommands); processAllMessages(); assertEquals(IccCardApplicationStatus.AppState.APPSTATE_DETECTED, mAppState); assertEquals(IccCardApplicationStatus.AppState.APPSTATE_DETECTED, mUiccCardApplication.getState()); // Change to READY state. mUiccCardAppStatus.app_state = IccCardApplicationStatus.AppState.APPSTATE_READY; mUiccCardAppStatus.pin1 = IccCardStatus.PinState.PINSTATE_ENABLED_VERIFIED; mUiccCardApplication.update(mUiccCardAppStatus, mContext, mSimulatedCommands); processAllMessages(); assertEquals(IccCardApplicationStatus.AppState.APPSTATE_READY, mAppState); assertEquals(IccCardApplicationStatus.AppState.APPSTATE_READY, mUiccCardApplication.getState()); } }