Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2da53c2b authored by Ling Ma's avatar Ling Ma
Browse files

Allow sending null initial attach data profile to modem

Controlled by a allow_clear_initial_attach_data_profile, modem implemented b/227579876 to allow framework clear initial attach data profile by sending null.

Fix: 278702856
Fix: 237444788
Test: voice call + internet browsing + reporter verified
Test: daily test verified on both P22 and P23 by b/283239810 and confirmed by log
Test: daily test related to hot swapping SIM and phone call on Barbet

Change-Id: I77217c7568ee854f145781a4fe7913b608d99681
parent 3a211f46
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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();

+10 −0
Original line number Diff line number Diff line
@@ -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
@@ -1359,6 +1368,7 @@ public class DataConfigManager extends Handler {
        pw.println("isEnhancedIwlanHandoverCheckEnabled=" + isEnhancedIwlanHandoverCheckEnabled());
        pw.println("isTetheringProfileDisabledForRoaming="
                + isTetheringProfileDisabledForRoaming());
        pw.println("allowClearInitialAttachDataProfile=" + allowClearInitialAttachDataProfile());
        pw.decreaseIndent();
    }
}
+12 −18
Original line number Diff line number Diff line
@@ -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);
            }
+2 −1
Original line number Diff line number Diff line
@@ -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) {
+63 −1
Original line number Diff line number Diff line
@@ -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