Loading src/java/com/android/internal/telephony/gsm/GsmMmiCode.java +9 −2 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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); } } Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneMmiCode.java +8 −1 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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; Loading tests/telephonytests/src/com/android/internal/telephony/gsm/GsmMmiCodeTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneMmiCodeTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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)); } } Loading
src/java/com/android/internal/telephony/gsm/GsmMmiCode.java +9 −2 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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); } } Loading
src/java/com/android/internal/telephony/imsphone/ImsPhoneMmiCode.java +8 −1 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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; Loading
tests/telephonytests/src/com/android/internal/telephony/gsm/GsmMmiCodeTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneMmiCodeTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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)); } }