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

Commit a1e62252 authored by songferngwang's avatar songferngwang
Browse files

Reset the default data/SMS/voice values in one active sim case

To reset the default data/SMS/voice values when device has one active
sim.

Bug: 339394518
Test: atest MultiSimSettingControllerTest
Change-Id: I41b2581512b8575e4e30b69e4b2c80803792c62a
parent dbb96945
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -65,3 +65,15 @@ flag {
    purpose: PURPOSE_BUGFIX
  }
}

# OWNER=songferngwang TARGET=24Q3
flag {
  name: "reset_primary_sim_default_values"
  namespace: "telephony"
  description: "Reset the default values to the remaining sim"
  bug: "339394518"

  metadata {
    purpose: PURPOSE_BUGFIX
  }
}
+5 −2
Original line number Diff line number Diff line
@@ -645,8 +645,11 @@ public class MultiSimSettingController extends Handler {
        // Otherwise, if user just inserted their first SIM, or there's one primary and one
        // opportunistic subscription active (activeSubInfos.size() > 1), we automatically
        // set the primary to be default SIM and return.
        if (mPrimarySubList.size() == 1 && (change != PRIMARY_SUB_REMOVED
                || mActiveModemCount == 1)) {
        boolean conditionForOnePrimarySim =
                mFeatureFlags.resetPrimarySimDefaultValues() ? mPrimarySubList.size() == 1
                        : mPrimarySubList.size() == 1
                        && (change != PRIMARY_SUB_REMOVED || mActiveModemCount == 1);
        if (conditionForOnePrimarySim) {
            int subId = mPrimarySubList.get(0);
            if (DBG) log("updateDefaultValues: to only primary sub " + subId);
            if (hasData()) mSubscriptionManagerService.setDefaultDataSubId(subId);
+6 −16
Original line number Diff line number Diff line
@@ -18,10 +18,8 @@ package com.android.internal.telephony;

import static android.telephony.TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS;
import static android.telephony.TelephonyManager.EXTRA_SUBSCRIPTION_ID;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -251,6 +249,8 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        bundle.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
        doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(anyInt());

        doReturn(true).when(mFeatureFlags).resetPrimarySimDefaultValues();

        replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
        // Capture listener to emulate the carrier config change notification used later
        ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor =
@@ -496,18 +496,9 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        sendCarrierConfigChanged(1, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        processAllMessages();

        verify(mSubscriptionManagerService).setDefaultDataSubId(
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        verify(mSubscriptionManagerService).setDefaultSmsSubId(
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        verify(mSubscriptionManagerService, never()).setDefaultVoiceSubId(anyInt());

        // Verify intent sent to select sub 2 as default for all types.
        Intent intent = captureBroadcastIntent();
        assertEquals(ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED, intent.getAction());
        assertEquals(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL,
                intent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE, -1));
        assertEquals(2, intent.getIntExtra(EXTRA_SUBSCRIPTION_ID, -1));
        verify(mSubscriptionManagerService).setDefaultDataSubId(2);
        verify(mSubscriptionManagerService).setDefaultSmsSubId(2);
        verify(mSubscriptionManagerService).setDefaultVoiceSubId(2);
    }

    @Test
@@ -917,8 +908,7 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        markSubscriptionInactive(1/*subid*/);
        sendCarrierConfigChanged(0/*phoneid*/, SubscriptionManager.INVALID_SUBSCRIPTION_ID);

        verify(mSubscriptionManagerService).setDefaultDataSubId(
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        verify(mSubscriptionManagerService).setDefaultDataSubId(2);

        // insert it back, but carrier config not loaded yet
        clearInvocations(mSubscriptionManagerService);