Loading src/java/com/android/internal/telephony/data/DataNetworkController.java +9 −0 Original line number Diff line number Diff line Loading @@ -614,6 +614,13 @@ public class DataNetworkController extends Handler { * @param transport The transport of the data service. */ public void onDataServiceBound(@TransportType int transport) {} /** * Called when SIM load state changed. * * @param simState The current SIM state */ public void onSimStateChanged(@SimState int simState) {} } /** Loading Loading @@ -3082,6 +3089,8 @@ public class DataNetworkController extends Handler { sendMessage(obtainMessage(EVENT_REEVALUATE_UNSATISFIED_NETWORK_REQUESTS, DataEvaluationReason.SIM_LOADED)); } mDataNetworkControllerCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onSimStateChanged(mSimState))); } } Loading src/java/com/android/internal/telephony/data/DataProfileManager.java +10 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.telephony.AnomalyReporter; import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager.SimState; import android.telephony.data.ApnSetting; import android.telephony.data.DataProfile; import android.telephony.data.TrafficDescriptor; Loading Loading @@ -116,6 +117,9 @@ public class DataProfileManager extends Handler { private final @NonNull Set<DataProfileManagerCallback> mDataProfileManagerCallbacks = new ArraySet<>(); /** SIM state. */ private @SimState int mSimState = TelephonyManager.SIM_STATE_UNKNOWN; /** * Data profile manager callback. This should be only used by {@link DataNetworkController}. */ Loading Loading @@ -170,6 +174,11 @@ public class DataProfileManager extends Handler { @NonNull List<DataProfile> dataProfiles) { DataProfileManager.this.onInternetDataNetworkConnected(dataProfiles); } @Override public void onSimStateChanged(@SimState int simState) { DataProfileManager.this.mSimState = simState; } }); mDataConfigManager.registerCallback(new DataConfigManagerCallback(this::post) { @Override Loading Loading @@ -291,7 +300,7 @@ public class DataProfileManager extends Handler { DataProfile dataProfile; if (!profiles.isEmpty()) { // APN database has been read successfully after SIM loaded if (mSimState == TelephonyManager.SIM_STATE_LOADED) { // Check if any of the profile already supports IMS, if not, add the default one. dataProfile = profiles.stream() .filter(dp -> dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_IMS)) Loading tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java +11 −6 Original line number Diff line number Diff line Loading @@ -838,7 +838,7 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testSimRemoval() { Mockito.clearInvocations(mDataProfileManagerCallback); mSimInserted = false; changeSimStateTo(TelephonyManager.SIM_STATE_ABSENT); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -880,7 +880,7 @@ public class DataProfileManagerTest extends TelephonyTest { doReturn(List.of(ApnSetting.TYPE_IMS)) .when(mDataConfigManager).getAllowedInitialAttachApnTypes(); mSimInserted = true; changeSimStateTo(TelephonyManager.SIM_STATE_LOADED); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -1053,7 +1053,7 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testResetApn() { mSimInserted = true; changeSimStateTo(TelephonyManager.SIM_STATE_LOADED); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -1125,7 +1125,7 @@ public class DataProfileManagerTest extends TelephonyTest { new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .build(), mPhone); mSimInserted = true; changeSimStateTo(TelephonyManager.SIM_STATE_LOADED); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -1236,7 +1236,7 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testDataProfileCompatibility_FilteringWithPreferredApnSetIdAsDefault() { mApnSettingContentProvider.setPreferredApn(GENERAL_PURPOSE_APN); mSimInserted = true; changeSimStateTo(TelephonyManager.SIM_STATE_LOADED); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -1327,7 +1327,7 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testDataProfileCompatibility_FilteringWithPreferredApnSetIdAs1() { mApnSettingContentProvider.setPreferredApn(APN_SET_ID_1_APN); mSimInserted = true; changeSimStateTo(TelephonyManager.SIM_STATE_LOADED); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -1457,4 +1457,9 @@ public class DataProfileManagerTest extends TelephonyTest { assertThat(mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr, TelephonyManager.NETWORK_TYPE_LTE, false)).isNull(); } private void changeSimStateTo(@TelephonyManager.SimState int simState) { mSimInserted = simState == TelephonyManager.SIM_STATE_LOADED; mDataNetworkControllerCallback.onSimStateChanged(simState); } } Loading
src/java/com/android/internal/telephony/data/DataNetworkController.java +9 −0 Original line number Diff line number Diff line Loading @@ -614,6 +614,13 @@ public class DataNetworkController extends Handler { * @param transport The transport of the data service. */ public void onDataServiceBound(@TransportType int transport) {} /** * Called when SIM load state changed. * * @param simState The current SIM state */ public void onSimStateChanged(@SimState int simState) {} } /** Loading Loading @@ -3082,6 +3089,8 @@ public class DataNetworkController extends Handler { sendMessage(obtainMessage(EVENT_REEVALUATE_UNSATISFIED_NETWORK_REQUESTS, DataEvaluationReason.SIM_LOADED)); } mDataNetworkControllerCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onSimStateChanged(mSimState))); } } Loading
src/java/com/android/internal/telephony/data/DataProfileManager.java +10 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.telephony.AnomalyReporter; import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager.SimState; import android.telephony.data.ApnSetting; import android.telephony.data.DataProfile; import android.telephony.data.TrafficDescriptor; Loading Loading @@ -116,6 +117,9 @@ public class DataProfileManager extends Handler { private final @NonNull Set<DataProfileManagerCallback> mDataProfileManagerCallbacks = new ArraySet<>(); /** SIM state. */ private @SimState int mSimState = TelephonyManager.SIM_STATE_UNKNOWN; /** * Data profile manager callback. This should be only used by {@link DataNetworkController}. */ Loading Loading @@ -170,6 +174,11 @@ public class DataProfileManager extends Handler { @NonNull List<DataProfile> dataProfiles) { DataProfileManager.this.onInternetDataNetworkConnected(dataProfiles); } @Override public void onSimStateChanged(@SimState int simState) { DataProfileManager.this.mSimState = simState; } }); mDataConfigManager.registerCallback(new DataConfigManagerCallback(this::post) { @Override Loading Loading @@ -291,7 +300,7 @@ public class DataProfileManager extends Handler { DataProfile dataProfile; if (!profiles.isEmpty()) { // APN database has been read successfully after SIM loaded if (mSimState == TelephonyManager.SIM_STATE_LOADED) { // Check if any of the profile already supports IMS, if not, add the default one. dataProfile = profiles.stream() .filter(dp -> dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_IMS)) Loading
tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java +11 −6 Original line number Diff line number Diff line Loading @@ -838,7 +838,7 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testSimRemoval() { Mockito.clearInvocations(mDataProfileManagerCallback); mSimInserted = false; changeSimStateTo(TelephonyManager.SIM_STATE_ABSENT); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -880,7 +880,7 @@ public class DataProfileManagerTest extends TelephonyTest { doReturn(List.of(ApnSetting.TYPE_IMS)) .when(mDataConfigManager).getAllowedInitialAttachApnTypes(); mSimInserted = true; changeSimStateTo(TelephonyManager.SIM_STATE_LOADED); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -1053,7 +1053,7 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testResetApn() { mSimInserted = true; changeSimStateTo(TelephonyManager.SIM_STATE_LOADED); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -1125,7 +1125,7 @@ public class DataProfileManagerTest extends TelephonyTest { new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .build(), mPhone); mSimInserted = true; changeSimStateTo(TelephonyManager.SIM_STATE_LOADED); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -1236,7 +1236,7 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testDataProfileCompatibility_FilteringWithPreferredApnSetIdAsDefault() { mApnSettingContentProvider.setPreferredApn(GENERAL_PURPOSE_APN); mSimInserted = true; changeSimStateTo(TelephonyManager.SIM_STATE_LOADED); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -1327,7 +1327,7 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testDataProfileCompatibility_FilteringWithPreferredApnSetIdAs1() { mApnSettingContentProvider.setPreferredApn(APN_SET_ID_1_APN); mSimInserted = true; changeSimStateTo(TelephonyManager.SIM_STATE_LOADED); mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -1457,4 +1457,9 @@ public class DataProfileManagerTest extends TelephonyTest { assertThat(mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr, TelephonyManager.NETWORK_TYPE_LTE, false)).isNull(); } private void changeSimStateTo(@TelephonyManager.SimState int simState) { mSimInserted = simState == TelephonyManager.SIM_STATE_LOADED; mDataNetworkControllerCallback.onSimStateChanged(simState); } }