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

Commit 15845fa1 authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Fix potential crash when displaying MMI error result." into sc-dev

parents 5e7fc264 cb95ea88
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1228,7 +1228,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
    onUssdFinishedError() {
        if (mState == State.PENDING) {
            mState = State.FAILED;
            if (mMessage.length() == 0) {
            if (TextUtils.isEmpty(mMessage)) {
                mMessage = mContext.getText(com.android.internal.R.string.mmiError);
            }
            Rlog.d(LOG_TAG, "onUssdFinishedError");
+4 −6
Original line number Diff line number Diff line
@@ -346,8 +346,8 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
        return dialString;
    }

    static ImsPhoneMmiCode
    newNetworkInitiatedUssd(String ussdMessage, boolean isUssdRequest, ImsPhone phone) {
    public static ImsPhoneMmiCode newNetworkInitiatedUssd(String ussdMessage,
            boolean isUssdRequest, ImsPhone phone) {
        ImsPhoneMmiCode ret;

        ret = new ImsPhoneMmiCode(phone);
@@ -1194,12 +1194,10 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
     *
     * The radio has reset, and this is still pending
     */

    void
    onUssdFinishedError() {
    public void onUssdFinishedError() {
        if (mState == State.PENDING) {
            mState = State.FAILED;
            if (mMessage.length() == 0) {
            if (TextUtils.isEmpty(mMessage)) {
                mMessage = mContext.getText(com.android.internal.R.string.mmiError);
            }
            Rlog.d(LOG_TAG, "onUssdFinishedError: mmi=" + this);
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.telephony.gsm;

import static junit.framework.Assert.fail;

import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
@@ -95,6 +97,16 @@ public class GsmMmiCodeTest extends TelephonyTest {
        assertTrue(mGsmMmiCode == null);
    }

    @Test
    public void testNoCrashOnEmptyMessage() {
        GsmMmiCode mmi = GsmMmiCode.newNetworkInitiatedUssd(null, true, mGsmCdmaPhoneUT, null);
        try {
            mmi.onUssdFinishedError();
        } catch (Exception e) {
            fail("Shouldn't crash!!!");
        }
    }

    private void setCarrierSupportsCallerIdVerticalServiceCodesCarrierConfig() {
        final PersistableBundle bundle = new PersistableBundle();
        bundle.putBoolean(CarrierConfigManager
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.telephony.imsphone;

import static junit.framework.Assert.fail;

import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
@@ -101,6 +103,16 @@ public class ImsPhoneMmiCodeTest extends TelephonyTest {
        assertTrue(mImsPhoneMmiCode == null);
    }

    @Test
    public void testNoCrashOnEmptyMessage() {
        ImsPhoneMmiCode mmi = ImsPhoneMmiCode.newNetworkInitiatedUssd(null, true, mImsPhoneUT);
        try {
            mmi.onUssdFinishedError();
        } catch (Exception e) {
            fail("Shouldn't crash!!!");
        }
    }

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