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

Commit 5f885936 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add "not supported" string for MMI codes not supported by network."...

Merge "Add "not supported" string for MMI codes not supported by network." into tm-qpr-dev am: 07b3b9a7

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



Change-Id: I274dc892510eaee6319ef1906eb01ea8fe5216f8
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 1dca86ec 07b3b9a7
Loading
Loading
Loading
Loading
+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;
+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
+19 −0
Original line number Diff line number Diff line
@@ -20,15 +20,19 @@ import static junit.framework.Assert.fail;

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

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

import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.TelephonyTest;

import org.junit.After;
@@ -117,4 +121,19 @@ public class ImsPhoneMmiCodeTest extends TelephonyTest {
                .KEY_CARRIER_SUPPORTS_CALLER_ID_VERTICAL_SERVICE_CODES_BOOL, true);
        doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(anyInt());
    }

    /**
     * Ensure that when an operation is not supported that the correct message is returned.
     */
    @Test
    public void testOperationNotSupported() {
        mImsPhoneMmiCode = ImsPhoneMmiCode.newNetworkInitiatedUssd(null, true, mImsPhoneUT);

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