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

Commit c1cbd767 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7040187 from 8119a319 to rvc-qpr2-release

Change-Id: I2eaba7896fed36d1f5b40bed1dab17d18ae2d4eb
parents efc2a26c 8119a319
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.telephony.TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIS
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_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE;
import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_NAMES;
import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_WARNING_TYPE;
@@ -91,7 +92,8 @@ public class MultiSimSettingController extends Handler {
                    PRIMARY_SUB_SWAPPED,
                    PRIMARY_SUB_SWAPPED_IN_GROUP,
                    PRIMARY_SUB_MARKED_OPPT,
                    PRIMARY_SUB_INITIALIZED
                    PRIMARY_SUB_INITIALIZED,
                    PRIMARY_SUB_REMOVED_IN_GROUP
    })
    private @interface PrimarySubChangeType {}

@@ -109,6 +111,9 @@ public class MultiSimSettingController extends Handler {
    private static final int PRIMARY_SUB_MARKED_OPPT            = 5;
    // Subscription information is initially loaded.
    private static final int PRIMARY_SUB_INITIALIZED            = 6;
    // One or more primary subscriptions are deactivated but within the same group as another active
    // sub.
    private static final int PRIMARY_SUB_REMOVED_IN_GROUP       = 7;

    protected final Context mContext;
    protected final SubscriptionController mSubController;
@@ -536,6 +541,7 @@ public class MultiSimSettingController extends Handler {
            mSubController.setDefaultDataSubId(subId);
            mSubController.setDefaultVoiceSubId(subId);
            mSubController.setDefaultSmsSubId(subId);
            sendDefaultSubConfirmedNotification(subId);
            return;
        }

@@ -598,7 +604,14 @@ public class MultiSimSettingController extends Handler {
            // any previous primary subscription becomes inactive, we consider it
            for (int subId : prevPrimarySubList) {
                if (mPrimarySubList.contains(subId)) continue;
                if (!mSubController.isActiveSubId(subId)) return PRIMARY_SUB_REMOVED;
                if (!mSubController.isActiveSubId(subId)) {
                    for (int currentSubId : mPrimarySubList) {
                        if (areSubscriptionsInSameGroup(currentSubId, subId)) {
                            return PRIMARY_SUB_REMOVED_IN_GROUP;
                        }
                    }
                    return PRIMARY_SUB_REMOVED;
                }
                if (!mSubController.isOpportunistic(subId)) {
                    // Should never happen.
                    loge("[updatePrimarySubListAndGetChangeType]: missing active primary subId "
@@ -609,6 +622,19 @@ public class MultiSimSettingController extends Handler {
        }
    }

    private void sendDefaultSubConfirmedNotification(int defaultSubId) {
        Intent intent = new Intent();
        intent.setAction(ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED);
        intent.setClassName("com.android.settings",
                "com.android.settings.sim.SimSelectNotification");

        intent.putExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE,
                EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS);
        intent.putExtra(EXTRA_SUBSCRIPTION_ID, defaultSubId);

        mContext.sendBroadcast(intent);
    }

    private void sendSubChangeNotificationIfNeeded(int change, boolean dataSelected,
            boolean voiceSelected, boolean smsSelected) {
        @TelephonyManager.DefaultSubscriptionSelectType
+17 −7
Original line number Diff line number Diff line
@@ -289,6 +289,16 @@ public class DcTracker extends Handler {
    /* Indicating data service is bound or not */
    private boolean mDataServiceBound = false;

    /* Intent to hide/show the sign-in error notification for provisioning */
    private static final String INTENT_PROVISION = "com.android.internal.telephony.PROVISION";

    /**
     * Extra containing the phone ID for INTENT_PROVISION
     * Must be kept consistent with NetworkNotificationManager#setProvNotificationVisible.
     * TODO: refactor the deprecated API to prevent hardcoding values.
     */
    private static final String EXTRA_PROVISION_PHONE_ID = "provision.phone.id";

    /* Intent for the provisioning apn alarm */
    private static final String INTENT_PROVISIONING_APN_ALARM =
            "com.android.internal.telephony.provisioning_apn_alarm";
@@ -647,7 +657,6 @@ public class DcTracker extends Handler {
    /** Watches for changes to the APN db. */
    private ApnChangeObserver mApnObserver;

    private final String mProvisionActionName;
    private BroadcastReceiver mProvisionBroadcastReceiver;
    private ProgressDialog mProvisioningSpinner;

@@ -729,8 +738,6 @@ public class DcTracker extends Handler {
        initEmergencyApnSetting();
        addEmergencyApnSetting();

        mProvisionActionName = "com.android.internal.telephony.PROVISION" + phone.getPhoneId();

        mSettingsObserver = new SettingsObserver(mPhone.getContext(), this);
        registerSettingsObserver();
    }
@@ -743,7 +750,6 @@ public class DcTracker extends Handler {
        mAlarmManager = null;
        mPhone = null;
        mDataConnectionTracker = null;
        mProvisionActionName = null;
        mSettingsObserver = new SettingsObserver(null, this);
        mDataEnabledSettings = null;
        mTransportType = 0;
@@ -950,6 +956,10 @@ public class DcTracker extends Handler {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (mPhone.getPhoneId() != intent.getIntExtra(EXTRA_PROVISION_PHONE_ID,
                    SubscriptionManager.INVALID_PHONE_INDEX)) {
                return;
            }
            // Turning back on the radio can take time on the order of a minute, so show user a
            // spinner so they know something is going on.
            log("onReceive : ProvisionNotificationBroadcastReceiver");
@@ -2967,7 +2977,7 @@ public class DcTracker extends Handler {
                if ((!isProvApn) || mIsProvisioning) {
                    // Hide any provisioning notification.
                    cm.setProvisioningNotificationVisible(false, ConnectivityManager.TYPE_MOBILE,
                            mProvisionActionName);
                            INTENT_PROVISION + ":" + mPhone.getPhoneId());
                    // Complete the connection normally notifying the world we're connected.
                    // We do this if this isn't a special provisioning apn or if we've been
                    // told its time to provision.
@@ -2990,10 +3000,10 @@ public class DcTracker extends Handler {
                            cm.getMobileProvisioningUrl(),
                            mTelephonyManager.getNetworkOperatorName());
                    mPhone.getContext().registerReceiver(mProvisionBroadcastReceiver,
                            new IntentFilter(mProvisionActionName));
                            new IntentFilter(INTENT_PROVISION));
                    // Put up user notification that sign-in is required.
                    cm.setProvisioningNotificationVisible(true, ConnectivityManager.TYPE_MOBILE,
                            mProvisionActionName);
                            INTENT_PROVISION + ":" + mPhone.getPhoneId());
                    // Turn off radio to save battery and avoid wasting carrier resources.
                    // The network isn't usable and network validation will just fail anyhow.
                    setRadio(false);
+56 −12
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.telephony.TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIS
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;
@@ -190,8 +191,7 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        verify(mSubControllerMock).setDefaultDataSubId(1);
        verify(mSubControllerMock).setDefaultVoiceSubId(1);
        verify(mSubControllerMock).setDefaultSmsSubId(1);
        // No dialog or notification is needed. So no intent is expected to be broadcast.
        verify(mContext, never()).sendBroadcast(any());
        verifyDismissIntentSent();
    }

    @Test
@@ -216,6 +216,8 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        mMultiSimSettingControllerUT.notifyAllSubscriptionLoaded();
        mMultiSimSettingControllerUT.notifyCarrierConfigChanged(0, 1);
        processAllMessages();
        verifyDismissIntentSent();
        clearInvocations(mContext);

        // Sub 1 should be default sub silently.
        // Sub 1 switches to sub 2 in the same slot.
@@ -237,8 +239,7 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        verify(mSubControllerMock).setDefaultDataSubId(2);
        verify(mSubControllerMock).setDefaultVoiceSubId(2);
        verify(mSubControllerMock).setDefaultSmsSubId(2);
        // No dialog or notification is needed. So no intent is expected to be broadcast.
        verify(mContext, never()).sendBroadcast(any());
        verifyDismissIntentSent();
    }

    @Test
@@ -261,11 +262,11 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        verify(mSubControllerMock).setDefaultDataSubId(1);
        verify(mSubControllerMock).setDefaultVoiceSubId(1);
        verify(mSubControllerMock).setDefaultSmsSubId(1);
        // No dialog or notification is needed. So no intent is expected to be broadcast.
        verify(mContext, never()).sendBroadcast(any());
        verifyDismissIntentSent();

        // Mark sub 2 as active in phone[1].
        clearInvocations(mSubControllerMock);
        clearInvocations(mContext);
        doReturn(true).when(mSubControllerMock).isActiveSubId(2);
        doReturn(1).when(mSubControllerMock).getPhoneId(2);
        doReturn(2).when(mPhoneMock2).getSubId();
@@ -445,8 +446,7 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        processAllMessages();
        verify(mSubControllerMock).setDefaultDataSubId(2);
        verify(mDataEnabledSettingsMock1, never()).setUserDataEnabled(anyBoolean());
        // No user selection needed, no intent should be sent.
        verify(mContext, never()).sendBroadcast(any());
        verifyDismissIntentSent();

        clearInvocations(mSubControllerMock);
        clearInvocations(mDataEnabledSettingsMock1);
@@ -465,6 +465,13 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        verify(mDataEnabledSettingsMock2, never()).setUserDataEnabled(anyBoolean());
    }

    private void verifyDismissIntentSent() {
        Intent intentSent = captureBroadcastIntent();
        assertEquals(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS,
                intentSent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE, -1));
        assertEquals(ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED, intentSent.getAction());
    }

    @Test
    @SmallTest
    public void testGroupedCbrs() throws Exception {
@@ -483,8 +490,6 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        mMultiSimSettingControllerUT.notifyCarrierConfigChanged(1, 2);
        processAllMessages();
        verify(mSubControllerMock).setDefaultDataSubId(2);
        // No user selection needed, no intent should be sent.
        verify(mContext, never()).sendBroadcast(any());

        // Mark sub 2 as data off.
        doReturn(false).when(mPhoneMock2).isUserDataEnabled();
@@ -505,8 +510,47 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        mMultiSimSettingControllerUT.notifyUserDataEnabled(2, true);
        processAllMessages();
        verify(mDataEnabledSettingsMock1).setUserDataEnabled(true, false);
        // No user selection needed, no intent should be sent.
        verify(mContext, never()).sendBroadcast(any());
        verifyDismissIntentSent();
    }

    @Test
    @SmallTest
    public void testGroupedPrimaryRemoved() throws Exception {
        // Create subscription grouping of subs 1 and 2.
        replaceInstance(SubscriptionInfo.class, "mGroupUUID", mSubInfo1, mGroupUuid1);
        doReturn(mGroupUuid1).when(mSubControllerMock).getGroupUuid(1);
        doReturn(mGroupUuid1).when(mSubControllerMock).getGroupUuid(2);
        doReturn(Arrays.asList(mSubInfo1, mSubInfo2)).when(mSubControllerMock)
                .getSubscriptionsInGroup(any(), anyString(), nullable(String.class));

        mMultiSimSettingControllerUT.notifyAllSubscriptionLoaded();
        mMultiSimSettingControllerUT.notifySubscriptionGroupChanged(mGroupUuid1);
        mMultiSimSettingControllerUT.notifyCarrierConfigChanged(0, 1);
        mMultiSimSettingControllerUT.notifyCarrierConfigChanged(1, 2);
        processAllMessages();

        // Defaults not touched, sub 1 is already default.
        verify(mSubControllerMock, never()).setDefaultDataSubId(anyInt());

        // Take out SIM 1.
        clearInvocations(mSubControllerMock);
        doReturn(false).when(mSubControllerMock).isActiveSubId(1);
        doReturn(SubscriptionManager.INVALID_PHONE_INDEX).when(mSubControllerMock).getPhoneId(1);
        doReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID).when(mPhoneMock1).getSubId();
        List<SubscriptionInfo> infoList = Arrays.asList(mSubInfo2);
        doReturn(infoList).when(mSubControllerMock).getActiveSubscriptionInfoList(anyString(),
                nullable(String.class));
        doReturn(new int[]{2}).when(mSubControllerMock).getActiveSubIdList(anyBoolean());
        mMultiSimSettingControllerUT.notifySubscriptionInfoChanged();
        mMultiSimSettingControllerUT.notifyCarrierConfigChanged(
                0, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        processAllMessages();

        // Sub 2 should be made the default sub silently.
        verify(mSubControllerMock).setDefaultDataSubId(2);
        verify(mSubControllerMock).setDefaultVoiceSubId(2);
        verify(mSubControllerMock).setDefaultSmsSubId(2);
        verifyDismissIntentSent();
    }

    private Intent captureBroadcastIntent() {
+12 −0
Original line number Diff line number Diff line
@@ -2215,4 +2215,16 @@ public class DcTrackerTest extends TelephonyTest {
                .filter(x -> x.getApnType().equals(type))
                .findFirst().get().getPriority());
    }

    @Test
    public void testProvisionBroadcastReceiver() {
        Intent intent = new Intent("com.android.internal.telephony.PROVISION");
        intent.putExtra("provision.phone.id", mPhone.getPhoneId());
        try {
            mContext.sendBroadcast(intent);
        } catch (SecurityException e) {
            fail();
        }
        waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    }
}