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

Commit c74948b1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add default IMS DP after sim loaded" am: 994930e9 am: 1913560f am:...

Merge "Add default IMS DP after sim loaded" am: 994930e9 am: 1913560f am: b9faf884 am: 20fddb46 am: 5ba3ce22

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2597461



Change-Id: Ia19426d7951bc050e020dab84dd00d527bc8f497
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 5ca76f9e 5ba3ce22
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -618,6 +618,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) {}
    }

    /**
@@ -3135,6 +3142,8 @@ public class DataNetworkController extends Handler {
                sendMessage(obtainMessage(EVENT_REEVALUATE_UNSATISFIED_NETWORK_REQUESTS,
                        DataEvaluationReason.SIM_LOADED));
            }
            mDataNetworkControllerCallbacks.forEach(callback -> callback.invokeFromExecutor(
                    () -> callback.onSimStateChanged(mSimState)));
        }
    }

+10 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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}.
     */
@@ -170,6 +174,11 @@ public class DataProfileManager extends Handler {
                            @NonNull List<DataNetwork> internetNetworks) {
                        DataProfileManager.this.onInternetDataNetworkConnected(internetNetworks);
                    }

                    @Override
                    public void onSimStateChanged(@SimState int simState) {
                        DataProfileManager.this.mSimState = simState;
                    }
                });
        mDataConfigManager.registerCallback(new DataConfigManagerCallback(this::post) {
            @Override
@@ -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))
+11 −6
Original line number Diff line number Diff line
@@ -912,7 +912,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();

@@ -954,7 +954,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();

@@ -1127,7 +1127,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();

@@ -1196,7 +1196,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();

@@ -1307,7 +1307,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();

@@ -1398,7 +1398,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();

@@ -1528,4 +1528,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);
    }
}