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

Commit 9986289c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9381392 from 07b3b9a7 to tm-qpr2-release

Change-Id: I7316ea8e9bb9fded391502f05012c4d7969e45f0
parents 1f0f3186 07b3b9a7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1194,7 +1194,8 @@ public class SubscriptionInfoUpdater extends Handler {
            loge("Cannot manage subId=" + currentSubId + ", carrierPackage=" + configPackageName);
        } else {
            boolean isOpportunistic = config.getBoolean(
                    CarrierConfigManager.KEY_IS_OPPORTUNISTIC_SUBSCRIPTION_BOOL, false);
                    CarrierConfigManager.KEY_IS_OPPORTUNISTIC_SUBSCRIPTION_BOOL,
                    currentSubInfo.isOpportunistic());
            if (currentSubInfo.isOpportunistic() != isOpportunistic) {
                if (DBG) logd("Set SubId=" + currentSubId + " isOpportunistic=" + isOpportunistic);
                cv.put(SubscriptionManager.IS_OPPORTUNISTIC, isOpportunistic ? "1" : "0");
+9 −2
Original line number Diff line number Diff line
@@ -1333,8 +1333,8 @@ public final class GsmMmiCode extends Handler implements MmiCode {
        }
    }
    //***** Private instance methods

    private CharSequence getErrorMessage(AsyncResult ar) {
    @VisibleForTesting
    public CharSequence getErrorMessage(AsyncResult ar) {

        if (ar.exception instanceof CommandException) {
            CommandException.Error err = ((CommandException)(ar.exception)).getCommandError();
@@ -1362,6 +1362,13 @@ public final class GsmMmiCode extends Handler implements MmiCode {
            } else if (err == CommandException.Error.OEM_ERROR_1) {
                Rlog.i(LOG_TAG, "OEM_ERROR_1 USSD_MODIFIED_TO_DIAL_VIDEO");
                return mContext.getText(com.android.internal.R.string.stk_cc_ussd_to_dial_video);
            } else if (err == CommandException.Error.REQUEST_NOT_SUPPORTED
                || err == CommandException.Error.OPERATION_NOT_ALLOWED) {
                Rlog.i(LOG_TAG, "REQUEST_NOT_SUPPORTED/OPERATION_NOT_ALLOWED");
                // getResources().getText() is the same as getText(), however getText() is final and
                // cannot be mocked in tests.
                return mContext.getResources().getText(
                        com.android.internal.R.string.mmiErrorNotSupported);
            }
        }

+8 −1
Original line number Diff line number Diff line
@@ -1330,7 +1330,8 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
                mContext.getText(com.android.internal.R.string.mmiError);
    }

    private CharSequence getMmiErrorMessage(AsyncResult ar) {
    @VisibleForTesting
    public CharSequence getMmiErrorMessage(AsyncResult ar) {
        if (ar.exception instanceof ImsException) {
            switch (((ImsException) ar.exception).getCode()) {
                case ImsReasonInfo.CODE_FDN_BLOCKED:
@@ -1360,6 +1361,12 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
                return mContext.getText(com.android.internal.R.string.stk_cc_ss_to_dial_video);
            } else if (err.getCommandError() == CommandException.Error.INTERNAL_ERR) {
                return mContext.getText(com.android.internal.R.string.mmiError);
            } else if (err.getCommandError() == CommandException.Error.REQUEST_NOT_SUPPORTED
                    || err.getCommandError() == CommandException.Error.OPERATION_NOT_ALLOWED) {
                // getResources().getText() is the same as getText(), however getText() is final and
                // cannot be mocked in tests.
                return mContext.getResources().getText(
                        com.android.internal.R.string.mmiErrorNotSupported);
            }
        }
        return null;
+32 −0
Original line number Diff line number Diff line
@@ -792,6 +792,38 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
    }

    @Test
    @SmallTest
    public void testOpportunisticSubscriptionNotUnsetWithEmptyConfigKey() throws Exception {
        final int phoneId = mPhone.getPhoneId();
        PersistableBundle carrierConfig = new PersistableBundle();

        String carrierPackageName = "FakeCarrierPackageName";

        doReturn(FAKE_SUB_ID_1).when(mSubscriptionController).getSubIdUsingPhoneId(phoneId);
        doReturn(mSubInfo).when(mSubscriptionController).getSubscriptionInfo(eq(FAKE_SUB_ID_1));
        doReturn(true).when(mSubInfo).isOpportunistic();
        doReturn(carrierPackageName).when(mTelephonyManager)
                .getCarrierServicePackageNameForLogicalSlot(eq(phoneId));
        ((MockContentResolver) mContext.getContentResolver()).addProvider(
                SubscriptionManager.CONTENT_URI.getAuthority(),
                new FakeSubscriptionContentProvider());

        mUpdater.updateSubscriptionByCarrierConfig(mPhone.getPhoneId(),
                carrierPackageName, carrierConfig);

        ArgumentCaptor<ContentValues> cvCaptor = ArgumentCaptor.forClass(ContentValues.class);
        verify(mContentProvider, times(1)).update(
                eq(SubscriptionManager.getUriForSubscriptionId(FAKE_SUB_ID_1)),
                cvCaptor.capture(), eq(null), eq(null));
        // no key is added for the opportunistic bit
        assertNull(cvCaptor.getValue().getAsInteger(SubscriptionManager.IS_OPPORTUNISTIC));
        // only carrier certs updated
        assertEquals(1, cvCaptor.getValue().size());
        verify(mSubscriptionController, times(1)).refreshCachedActiveSubscriptionInfoList();
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
    }

    @Test
    @SmallTest
    public void testUpdateFromCarrierConfigOpportunisticAddToGroup() throws Exception {
+20 −0
Original line number Diff line number Diff line
@@ -18,15 +18,21 @@ package com.android.internal.telephony.gsm;

import static junit.framework.Assert.fail;

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;

import android.os.AsyncResult;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;

import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.GsmCdmaPhone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyTest;
@@ -102,6 +108,20 @@ public class GsmMmiCodeTest extends TelephonyTest {
        }
    }

    @Test
    public void testOperationNotSupported() {
        // Contrived; this is just to get a simple instance of the class.
        mGsmMmiCode = GsmMmiCode.newNetworkInitiatedUssd(null, true, mGsmCdmaPhoneUT, null);

        assertThat(mGsmMmiCode).isNotNull();
        // Emulate request not supported from the network.
        AsyncResult ar = new AsyncResult(null, null,
                new CommandException(CommandException.Error.REQUEST_NOT_SUPPORTED));
        mGsmMmiCode.getErrorMessage(ar);
        verify(mContext.getResources()).getText(
                eq(com.android.internal.R.string.mmiErrorNotSupported));
    }

    private void setCarrierSupportsCallerIdVerticalServiceCodesCarrierConfig() {
        final PersistableBundle bundle = new PersistableBundle();
        bundle.putBoolean(CarrierConfigManager
Loading