diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-06-05 23:16:13 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-06-05 23:16:13 +0000 |
commit | 1d92d1a4a7527ae2b62b5b585446479dbf78c91c (patch) | |
tree | 48c09d3770193c29a2a60a333a95e4f540ff4c47 | |
parent | 99d06cb6333428a1f38b94f077a615d74bac3c9d (diff) | |
parent | 57b7718736c88cad98a669b86b8c957e866d654a (diff) | |
download | telephony-1d92d1a4a7527ae2b62b5b585446479dbf78c91c.tar.gz |
Snap for 10262653 from 57b7718736c88cad98a669b86b8c957e866d654a to udc-d1-release
Change-Id: Idb4815e5a09dbc4b8d4b5b8f985b37f88097718b
5 files changed, 89 insertions, 21 deletions
diff --git a/src/java/com/android/internal/telephony/RILUtils.java b/src/java/com/android/internal/telephony/RILUtils.java index 9db186fbf8..3cec2be458 100644 --- a/src/java/com/android/internal/telephony/RILUtils.java +++ b/src/java/com/android/internal/telephony/RILUtils.java @@ -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(); diff --git a/src/java/com/android/internal/telephony/data/DataConfigManager.java b/src/java/com/android/internal/telephony/data/DataConfigManager.java index 78450a81ed..8dea0c246a 100644 --- a/src/java/com/android/internal/telephony/data/DataConfigManager.java +++ b/src/java/com/android/internal/telephony/data/DataConfigManager.java @@ -1264,6 +1264,15 @@ public class DataConfigManager extends Handler { } /** + * @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 */ @@ -1359,6 +1368,7 @@ public class DataConfigManager extends Handler { pw.println("isEnhancedIwlanHandoverCheckEnabled=" + isEnhancedIwlanHandoverCheckEnabled()); pw.println("isTetheringProfileDisabledForRoaming=" + isTetheringProfileDisabledForRoaming()); + pw.println("allowClearInitialAttachDataProfile=" + allowClearInitialAttachDataProfile()); pw.decreaseIndent(); } } diff --git a/src/java/com/android/internal/telephony/data/DataProfileManager.java b/src/java/com/android/internal/telephony/data/DataProfileManager.java index 37f0de0a8a..e7e92042e9 100644 --- a/src/java/com/android/internal/telephony/data/DataProfileManager.java +++ b/src/java/com/android/internal/telephony/data/DataProfileManager.java @@ -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; @@ -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); @@ -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*/); } /** @@ -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<>(); @@ -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*/); } /** @@ -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; @@ -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); } diff --git a/src/java/com/android/internal/telephony/data/DataServiceManager.java b/src/java/com/android/internal/telephony/data/DataServiceManager.java index 2733aff3ae..bb0e8c3cb2 100644 --- a/src/java/com/android/internal/telephony/data/DataServiceManager.java +++ b/src/java/com/android/internal/telephony/data/DataServiceManager.java @@ -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) { diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java index 43f65e21c4..feb51d0ca9 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java @@ -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(); @@ -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(); @@ -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 |