Loading src/java/com/android/internal/telephony/RILUtils.java +2 −1 Original line number Diff line number Diff line Loading @@ -989,8 +989,9 @@ public class RILUtils { * @param dp Data profile * @return The converted DataProfileInfo */ public static android.hardware.radio.data.DataProfileInfo convertToHalDataProfile( public static android.hardware.radio.data.DataProfileInfo convertToHalDataProfile(@Nullable DataProfile dp) { if (dp == null) return null; android.hardware.radio.data.DataProfileInfo dpi = new android.hardware.radio.data.DataProfileInfo(); Loading src/java/com/android/internal/telephony/data/DataConfigManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -1263,6 +1263,15 @@ public class DataConfigManager extends Handler { com.android.internal.R.bool.config_enhanced_iwlan_handover_check); } /** * @return {@code true} if allow sending null data profile to ask modem to clear the initial * attach data profile. */ public boolean allowClearInitialAttachDataProfile() { return mResources.getBoolean( com.android.internal.R.bool.allow_clear_initial_attach_data_profile); } /** * Log debug messages. * @param s debug messages Loading Loading @@ -1359,6 +1368,7 @@ public class DataConfigManager extends Handler { pw.println("isEnhancedIwlanHandoverCheckEnabled=" + isEnhancedIwlanHandoverCheckEnabled()); pw.println("isTetheringProfileDisabledForRoaming=" + isTetheringProfileDisabledForRoaming()); pw.println("allowClearInitialAttachDataProfile=" + allowClearInitialAttachDataProfile()); pw.decreaseIndent(); } } src/java/com/android/internal/telephony/data/DataProfileManager.java +12 −18 Original line number Diff line number Diff line Loading @@ -77,13 +77,6 @@ public class DataProfileManager extends Handler { private final String mLogTag; private final LocalLog mLocalLog = new LocalLog(128); /** * Should only be used by update updateDataProfiles() to indicate whether resend IA to modem * regardless whether IA changed. **/ private final boolean FORCED_UPDATE_IA = true; private final boolean ONLY_UPDATE_IA_IF_CHANGED = false; /** Data network controller. */ private final @NonNull DataNetworkController mDataNetworkController; Loading Loading @@ -193,11 +186,12 @@ public class DataProfileManager extends Handler { switch (msg.what) { case EVENT_SIM_REFRESH: log("Update data profiles due to SIM refresh."); updateDataProfiles(FORCED_UPDATE_IA); updateDataProfiles(!mDataConfigManager.allowClearInitialAttachDataProfile() /*force update IA*/); break; case EVENT_APN_DATABASE_CHANGED: log("Update data profiles due to APN db updated."); updateDataProfiles(ONLY_UPDATE_IA_IF_CHANGED); updateDataProfiles(false/*force update IA*/); break; default: loge("Unexpected event " + msg); Loading @@ -210,9 +204,8 @@ public class DataProfileManager extends Handler { */ private void onCarrierConfigUpdated() { log("Update data profiles due to carrier config updated."); updateDataProfiles(FORCED_UPDATE_IA); //TODO: more works needed to be done here. updateDataProfiles(!mDataConfigManager.allowClearInitialAttachDataProfile() /*force update IA*/); } /** Loading Loading @@ -249,7 +242,8 @@ public class DataProfileManager extends Handler { * Update all data profiles, including preferred data profile, and initial attach data profile. * Also send those profiles down to the modem if needed. * * @param forceUpdateIa If {@code true}, we should always send IA again to modem. * @param forceUpdateIa If {@code true}, we should always send initial attach data profile again * to modem. */ private void updateDataProfiles(boolean forceUpdateIa) { List<DataProfile> profiles = new ArrayList<>(); Loading Loading @@ -435,7 +429,7 @@ public class DataProfileManager extends Handler { if (defaultProfile == null || defaultProfile.equals(mPreferredDataProfile)) return; // Save the preferred data profile into database. setPreferredDataProfile(defaultProfile); updateDataProfiles(ONLY_UPDATE_IA_IF_CHANGED); updateDataProfiles(false/*force update IA*/); } /** Loading Loading @@ -558,7 +552,8 @@ public class DataProfileManager extends Handler { * attach. In this case, exception can be configured through * {@link CarrierConfigManager#KEY_ALLOWED_INITIAL_ATTACH_APN_TYPES_STRING_ARRAY}. * * @param forceUpdateIa If {@code true}, we should always send IA again to modem. * @param forceUpdateIa If {@code true}, we should always send initial attach data profile again * to modem. */ private void updateInitialAttachDataProfileAtModem(boolean forceUpdateIa) { DataProfile initialAttachDataProfile = null; Loading @@ -580,9 +575,8 @@ public class DataProfileManager extends Handler { mInitialAttachDataProfile = initialAttachDataProfile; logl("Initial attach data profile updated as " + mInitialAttachDataProfile + " or forceUpdateIa= " + forceUpdateIa); // TODO: Push the null data profile to modem on new AIDL HAL. Modem should clear the IA // APN, tracking for U b/227579876, now using forceUpdateIa which always push to modem if (mInitialAttachDataProfile != null) { if (mInitialAttachDataProfile != null || mDataConfigManager .allowClearInitialAttachDataProfile()) { mWwanDataServiceManager.setInitialAttachApn(mInitialAttachDataProfile, mPhone.getServiceState().getDataRoamingFromRegistration(), null); } Loading src/java/com/android/internal/telephony/data/DataServiceManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -809,11 +809,12 @@ public class DataServiceManager extends Handler { * Set an APN to initial attach network. * * @param dataProfile Data profile used for data network setup. See {@link DataProfile}. * {@code null} to clear any previous data profiles. * @param isRoaming True if the device is data roaming. * @param onCompleteMessage The result message for this request. Null if the client does not * care about the result. */ public void setInitialAttachApn(DataProfile dataProfile, boolean isRoaming, public void setInitialAttachApn(@Nullable DataProfile dataProfile, boolean isRoaming, Message onCompleteMessage) { if (DBG) log("setInitialAttachApn"); if (!mBound) { Loading tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java +63 −1 Original line number Diff line number Diff line Loading @@ -873,8 +873,10 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testSetInitialAttachDataProfileMultipleRequests() throws Exception { // This test case only applies to legacy modem, see b/227579876 doReturn(false).when(mDataConfigManager).allowClearInitialAttachDataProfile(); // Test: Modem Cleared IA, should always send IA to modem // TODO(b/237444788): this case should be removed from U mDataProfileManagerUT.obtainMessage(3 /* EVENT_SIM_REFRESH */).sendToTarget(); processAllMessages(); Loading Loading @@ -911,6 +913,14 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testSimRemoval() { // This test case applies to the latest modem, see b/227579876. doReturn(true).when(mDataConfigManager).allowClearInitialAttachDataProfile(); // SIM inserted mDataProfileManagerUT.obtainMessage(3 /* EVENT_SIM_REFRESH */).sendToTarget(); processAllMessages(); // SIM removed Mockito.clearInvocations(mDataProfileManagerCallback); mSimInserted = false; mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); Loading Loading @@ -943,6 +953,58 @@ public class DataProfileManagerTest extends TelephonyTest { dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE, false); assertThat(dataProfile).isEqualTo(null); // Verify null as initial attached data profile is sent to modem verify(mMockedWwanDataServiceManager).setInitialAttachApn(null, false, null); } @Test public void testSimRemovalLegacy() { // This test case only applies to legacy modem, see b/227579876, where null IA won't be // updated to modem doReturn(false).when(mDataConfigManager).allowClearInitialAttachDataProfile(); // SIM inserted mDataProfileManagerUT.obtainMessage(3 /* EVENT_SIM_REFRESH */).sendToTarget(); processAllMessages(); // SIM removed Mockito.clearInvocations(mDataProfileManagerCallback); mSimInserted = false; mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); verify(mDataProfileManagerCallback).onDataProfilesChanged(); TelephonyNetworkRequest tnr = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .build(), mPhone); DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE, false); assertThat(dataProfile).isNull(); // expect default EIMS when SIM absent tnr = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_EIMS) .build(), mPhone); dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE, false); assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo("sos"); // expect no default IMS when SIM absent tnr = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_IMS) .build(), mPhone); dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE, false); assertThat(dataProfile).isEqualTo(null); // Verify in legacy mode, null IA should NOT be sent to modem verify(mMockedWwanDataServiceManager, Mockito.never()) .setInitialAttachApn(null, false, null); } @Test Loading Loading
src/java/com/android/internal/telephony/RILUtils.java +2 −1 Original line number Diff line number Diff line Loading @@ -989,8 +989,9 @@ public class RILUtils { * @param dp Data profile * @return The converted DataProfileInfo */ public static android.hardware.radio.data.DataProfileInfo convertToHalDataProfile( public static android.hardware.radio.data.DataProfileInfo convertToHalDataProfile(@Nullable DataProfile dp) { if (dp == null) return null; android.hardware.radio.data.DataProfileInfo dpi = new android.hardware.radio.data.DataProfileInfo(); Loading
src/java/com/android/internal/telephony/data/DataConfigManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -1263,6 +1263,15 @@ public class DataConfigManager extends Handler { com.android.internal.R.bool.config_enhanced_iwlan_handover_check); } /** * @return {@code true} if allow sending null data profile to ask modem to clear the initial * attach data profile. */ public boolean allowClearInitialAttachDataProfile() { return mResources.getBoolean( com.android.internal.R.bool.allow_clear_initial_attach_data_profile); } /** * Log debug messages. * @param s debug messages Loading Loading @@ -1359,6 +1368,7 @@ public class DataConfigManager extends Handler { pw.println("isEnhancedIwlanHandoverCheckEnabled=" + isEnhancedIwlanHandoverCheckEnabled()); pw.println("isTetheringProfileDisabledForRoaming=" + isTetheringProfileDisabledForRoaming()); pw.println("allowClearInitialAttachDataProfile=" + allowClearInitialAttachDataProfile()); pw.decreaseIndent(); } }
src/java/com/android/internal/telephony/data/DataProfileManager.java +12 −18 Original line number Diff line number Diff line Loading @@ -77,13 +77,6 @@ public class DataProfileManager extends Handler { private final String mLogTag; private final LocalLog mLocalLog = new LocalLog(128); /** * Should only be used by update updateDataProfiles() to indicate whether resend IA to modem * regardless whether IA changed. **/ private final boolean FORCED_UPDATE_IA = true; private final boolean ONLY_UPDATE_IA_IF_CHANGED = false; /** Data network controller. */ private final @NonNull DataNetworkController mDataNetworkController; Loading Loading @@ -193,11 +186,12 @@ public class DataProfileManager extends Handler { switch (msg.what) { case EVENT_SIM_REFRESH: log("Update data profiles due to SIM refresh."); updateDataProfiles(FORCED_UPDATE_IA); updateDataProfiles(!mDataConfigManager.allowClearInitialAttachDataProfile() /*force update IA*/); break; case EVENT_APN_DATABASE_CHANGED: log("Update data profiles due to APN db updated."); updateDataProfiles(ONLY_UPDATE_IA_IF_CHANGED); updateDataProfiles(false/*force update IA*/); break; default: loge("Unexpected event " + msg); Loading @@ -210,9 +204,8 @@ public class DataProfileManager extends Handler { */ private void onCarrierConfigUpdated() { log("Update data profiles due to carrier config updated."); updateDataProfiles(FORCED_UPDATE_IA); //TODO: more works needed to be done here. updateDataProfiles(!mDataConfigManager.allowClearInitialAttachDataProfile() /*force update IA*/); } /** Loading Loading @@ -249,7 +242,8 @@ public class DataProfileManager extends Handler { * Update all data profiles, including preferred data profile, and initial attach data profile. * Also send those profiles down to the modem if needed. * * @param forceUpdateIa If {@code true}, we should always send IA again to modem. * @param forceUpdateIa If {@code true}, we should always send initial attach data profile again * to modem. */ private void updateDataProfiles(boolean forceUpdateIa) { List<DataProfile> profiles = new ArrayList<>(); Loading Loading @@ -435,7 +429,7 @@ public class DataProfileManager extends Handler { if (defaultProfile == null || defaultProfile.equals(mPreferredDataProfile)) return; // Save the preferred data profile into database. setPreferredDataProfile(defaultProfile); updateDataProfiles(ONLY_UPDATE_IA_IF_CHANGED); updateDataProfiles(false/*force update IA*/); } /** Loading Loading @@ -558,7 +552,8 @@ public class DataProfileManager extends Handler { * attach. In this case, exception can be configured through * {@link CarrierConfigManager#KEY_ALLOWED_INITIAL_ATTACH_APN_TYPES_STRING_ARRAY}. * * @param forceUpdateIa If {@code true}, we should always send IA again to modem. * @param forceUpdateIa If {@code true}, we should always send initial attach data profile again * to modem. */ private void updateInitialAttachDataProfileAtModem(boolean forceUpdateIa) { DataProfile initialAttachDataProfile = null; Loading @@ -580,9 +575,8 @@ public class DataProfileManager extends Handler { mInitialAttachDataProfile = initialAttachDataProfile; logl("Initial attach data profile updated as " + mInitialAttachDataProfile + " or forceUpdateIa= " + forceUpdateIa); // TODO: Push the null data profile to modem on new AIDL HAL. Modem should clear the IA // APN, tracking for U b/227579876, now using forceUpdateIa which always push to modem if (mInitialAttachDataProfile != null) { if (mInitialAttachDataProfile != null || mDataConfigManager .allowClearInitialAttachDataProfile()) { mWwanDataServiceManager.setInitialAttachApn(mInitialAttachDataProfile, mPhone.getServiceState().getDataRoamingFromRegistration(), null); } Loading
src/java/com/android/internal/telephony/data/DataServiceManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -809,11 +809,12 @@ public class DataServiceManager extends Handler { * Set an APN to initial attach network. * * @param dataProfile Data profile used for data network setup. See {@link DataProfile}. * {@code null} to clear any previous data profiles. * @param isRoaming True if the device is data roaming. * @param onCompleteMessage The result message for this request. Null if the client does not * care about the result. */ public void setInitialAttachApn(DataProfile dataProfile, boolean isRoaming, public void setInitialAttachApn(@Nullable DataProfile dataProfile, boolean isRoaming, Message onCompleteMessage) { if (DBG) log("setInitialAttachApn"); if (!mBound) { Loading
tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java +63 −1 Original line number Diff line number Diff line Loading @@ -873,8 +873,10 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testSetInitialAttachDataProfileMultipleRequests() throws Exception { // This test case only applies to legacy modem, see b/227579876 doReturn(false).when(mDataConfigManager).allowClearInitialAttachDataProfile(); // Test: Modem Cleared IA, should always send IA to modem // TODO(b/237444788): this case should be removed from U mDataProfileManagerUT.obtainMessage(3 /* EVENT_SIM_REFRESH */).sendToTarget(); processAllMessages(); Loading Loading @@ -911,6 +913,14 @@ public class DataProfileManagerTest extends TelephonyTest { @Test public void testSimRemoval() { // This test case applies to the latest modem, see b/227579876. doReturn(true).when(mDataConfigManager).allowClearInitialAttachDataProfile(); // SIM inserted mDataProfileManagerUT.obtainMessage(3 /* EVENT_SIM_REFRESH */).sendToTarget(); processAllMessages(); // SIM removed Mockito.clearInvocations(mDataProfileManagerCallback); mSimInserted = false; mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); Loading Loading @@ -943,6 +953,58 @@ public class DataProfileManagerTest extends TelephonyTest { dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE, false); assertThat(dataProfile).isEqualTo(null); // Verify null as initial attached data profile is sent to modem verify(mMockedWwanDataServiceManager).setInitialAttachApn(null, false, null); } @Test public void testSimRemovalLegacy() { // This test case only applies to legacy modem, see b/227579876, where null IA won't be // updated to modem doReturn(false).when(mDataConfigManager).allowClearInitialAttachDataProfile(); // SIM inserted mDataProfileManagerUT.obtainMessage(3 /* EVENT_SIM_REFRESH */).sendToTarget(); processAllMessages(); // SIM removed Mockito.clearInvocations(mDataProfileManagerCallback); mSimInserted = false; mDataProfileManagerUT.obtainMessage(2 /*EVENT_APN_DATABASE_CHANGED*/).sendToTarget(); processAllMessages(); verify(mDataProfileManagerCallback).onDataProfilesChanged(); TelephonyNetworkRequest tnr = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .build(), mPhone); DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE, false); assertThat(dataProfile).isNull(); // expect default EIMS when SIM absent tnr = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_EIMS) .build(), mPhone); dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE, false); assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo("sos"); // expect no default IMS when SIM absent tnr = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_IMS) .build(), mPhone); dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest( tnr, TelephonyManager.NETWORK_TYPE_LTE, false); assertThat(dataProfile).isEqualTo(null); // Verify in legacy mode, null IA should NOT be sent to modem verify(mMockedWwanDataServiceManager, Mockito.never()) .setInitialAttachApn(null, false, null); } @Test Loading