Loading src/java/com/android/internal/telephony/data/DataProfileManager.java +6 −3 Original line number Diff line number Diff line Loading @@ -312,14 +312,15 @@ public class DataProfileManager extends Handler { profilesChanged = true; } // Reload the latest preferred data profile from either database or config. profilesChanged |= updatePreferredDataProfile(); int setId = getPreferredDataProfileSetId(); if (setId != mPreferredDataProfileSetId) { logl("Changed preferred data profile set id to " + setId); mPreferredDataProfileSetId = setId; profilesChanged = true; } // Reload the latest preferred data profile from either database or config. profilesChanged |= updatePreferredDataProfile(); updateDataProfilesAtModem(); updateInitialAttachDataProfileAtModem(); Loading Loading @@ -461,6 +462,8 @@ public class DataProfileManager extends Handler { preferredDataProfile = getPreferredDataProfileFromDb(); if (preferredDataProfile == null) { preferredDataProfile = getPreferredDataProfileFromConfig(); // Save the preferred data profile into database. setPreferredDataProfile(preferredDataProfile); } } else { preferredDataProfile = null; Loading Loading @@ -647,7 +650,7 @@ public class DataProfileManager extends Handler { return null; } // Check if the remaining data profiles can used in current data network type. // Check if the remaining data profiles can be used in current data network type. dataProfiles = dataProfiles.stream() .filter(dp -> dp.getApnSetting() != null && dp.getApnSetting().canSupportNetworkType(networkType)) Loading tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java +37 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; Loading Loading @@ -832,7 +833,7 @@ public class DataProfileManagerTest extends TelephonyTest { } @Test public void testResetApn() { public void testResetApnNoPreferredConfig() { mSimInserted = true; mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -863,6 +864,41 @@ public class DataProfileManagerTest extends TelephonyTest { assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isFalse(); } @Test public void testResetApnWithPreferredConfig() { // carrier configured preferred data profile should be picked doReturn(GENERAL_PURPOSE_APN1).when(mDataConfigManager).getDefaultPreferredApn(); clearInvocations(mDataConfigManager); TelephonyNetworkRequest tnr = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .build(), mPhone); mSimInserted = true; mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); // The carrier configured data profile should be the preferred APN after APN reset DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE); verify(mDataConfigManager).getDefaultPreferredApn(); assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN1); assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isTrue(); // APN reset mPreferredApnId = -1; mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); clearInvocations(mDataConfigManager); processAllMessages(); // The carrier configured data profile should be the preferred APN after APN reset dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE); verify(mDataConfigManager).getDefaultPreferredApn(); assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN1); assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isTrue(); } @Test public void testTetheringApnExisting() { assertThat(mDataProfileManagerUT.isTetheringDataProfileExisting( Loading Loading
src/java/com/android/internal/telephony/data/DataProfileManager.java +6 −3 Original line number Diff line number Diff line Loading @@ -312,14 +312,15 @@ public class DataProfileManager extends Handler { profilesChanged = true; } // Reload the latest preferred data profile from either database or config. profilesChanged |= updatePreferredDataProfile(); int setId = getPreferredDataProfileSetId(); if (setId != mPreferredDataProfileSetId) { logl("Changed preferred data profile set id to " + setId); mPreferredDataProfileSetId = setId; profilesChanged = true; } // Reload the latest preferred data profile from either database or config. profilesChanged |= updatePreferredDataProfile(); updateDataProfilesAtModem(); updateInitialAttachDataProfileAtModem(); Loading Loading @@ -461,6 +462,8 @@ public class DataProfileManager extends Handler { preferredDataProfile = getPreferredDataProfileFromDb(); if (preferredDataProfile == null) { preferredDataProfile = getPreferredDataProfileFromConfig(); // Save the preferred data profile into database. setPreferredDataProfile(preferredDataProfile); } } else { preferredDataProfile = null; Loading Loading @@ -647,7 +650,7 @@ public class DataProfileManager extends Handler { return null; } // Check if the remaining data profiles can used in current data network type. // Check if the remaining data profiles can be used in current data network type. dataProfiles = dataProfiles.stream() .filter(dp -> dp.getApnSetting() != null && dp.getApnSetting().canSupportNetworkType(networkType)) Loading
tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java +37 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; Loading Loading @@ -832,7 +833,7 @@ public class DataProfileManagerTest extends TelephonyTest { } @Test public void testResetApn() { public void testResetApnNoPreferredConfig() { mSimInserted = true; mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); Loading Loading @@ -863,6 +864,41 @@ public class DataProfileManagerTest extends TelephonyTest { assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isFalse(); } @Test public void testResetApnWithPreferredConfig() { // carrier configured preferred data profile should be picked doReturn(GENERAL_PURPOSE_APN1).when(mDataConfigManager).getDefaultPreferredApn(); clearInvocations(mDataConfigManager); TelephonyNetworkRequest tnr = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .build(), mPhone); mSimInserted = true; mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); // The carrier configured data profile should be the preferred APN after APN reset DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE); verify(mDataConfigManager).getDefaultPreferredApn(); assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN1); assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isTrue(); // APN reset mPreferredApnId = -1; mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); clearInvocations(mDataConfigManager); processAllMessages(); // The carrier configured data profile should be the preferred APN after APN reset dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE); verify(mDataConfigManager).getDefaultPreferredApn(); assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN1); assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isTrue(); } @Test public void testTetheringApnExisting() { assertThat(mDataProfileManagerUT.isTetheringDataProfileExisting( Loading