Loading src/java/com/android/internal/telephony/gsm/GsmMmiCode.java +9 −2 Original line number Diff line number Diff line Loading @@ -1432,8 +1432,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 @@ -1461,6 +1461,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 @@ -1364,7 +1364,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 @@ -1394,6 +1395,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 +18 −0 Original line number Diff line number Diff line Loading @@ -23,12 +23,16 @@ import static junit.framework.Assert.fail; 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 @@ -308,6 +312,20 @@ public class GsmMmiCodeTest extends TelephonyTest { assertThat(controlStrings).containsExactly("**03*330"); } @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 +20 −0 Original line number Diff line number Diff line Loading @@ -21,9 +21,12 @@ import static junit.framework.Assert.fail; import static org.junit.Assert.assertNull; 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; Loading @@ -31,6 +34,7 @@ import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import com.android.internal.telephony.CommandException; import com.android.internal.telephony.SsDomainController; import com.android.internal.telephony.TelephonyTest; Loading Loading @@ -149,4 +153,20 @@ public class ImsPhoneMmiCodeTest extends TelephonyTest { (SsDomainController) null); assertNull(ssInfo); } /** * Ensure that when an operation is not supported that the correct message is returned. */ @Test @SmallTest 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 @@ -1432,8 +1432,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 @@ -1461,6 +1461,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 @@ -1364,7 +1364,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 @@ -1394,6 +1395,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 +18 −0 Original line number Diff line number Diff line Loading @@ -23,12 +23,16 @@ import static junit.framework.Assert.fail; 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 @@ -308,6 +312,20 @@ public class GsmMmiCodeTest extends TelephonyTest { assertThat(controlStrings).containsExactly("**03*330"); } @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 +20 −0 Original line number Diff line number Diff line Loading @@ -21,9 +21,12 @@ import static junit.framework.Assert.fail; import static org.junit.Assert.assertNull; 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; Loading @@ -31,6 +34,7 @@ import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import com.android.internal.telephony.CommandException; import com.android.internal.telephony.SsDomainController; import com.android.internal.telephony.TelephonyTest; Loading Loading @@ -149,4 +153,20 @@ public class ImsPhoneMmiCodeTest extends TelephonyTest { (SsDomainController) null); assertNull(ssInfo); } /** * Ensure that when an operation is not supported that the correct message is returned. */ @Test @SmallTest 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)); } }