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

Commit 5040f05f authored by Gil Cukierman's avatar Gil Cukierman Committed by Automerger Merge Worker
Browse files

Fix EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE Error Handling am: f76d189a

parents c0b85184 f76d189a
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -3522,13 +3522,14 @@ public class GsmCdmaPhone extends Phone {
            case EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE:
                logd("EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE");
                ar = (AsyncResult) msg.obj;
                // Only test for a success here in order to flip the support flag.
                // Testing for the negative case, e.g. REQUEST_NOT_SUPPORTED, is insufficient
                // because the modem or the RIL could still return exceptions for temporary
                // failures even when the feature is unsupported.
                if (ar == null || ar.exception == null) {
                    mIsNullCipherAndIntegritySupported = true;
                    return;
                }
                CommandException.Error error = ((CommandException) ar.exception).getCommandError();
                mIsNullCipherAndIntegritySupported = !error.equals(
                        CommandException.Error.REQUEST_NOT_SUPPORTED);
                break;

            case EVENT_IMS_DEREGISTRATION_TRIGGERED:
+22 −2
Original line number Diff line number Diff line
@@ -2211,7 +2211,6 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        verify(mMockCi, times(1)).setNullCipherAndIntegrityEnabled(anyBoolean(),
                any(Message.class));

        // Some ephemeral error occurred in the modem, but the feature was supported
        mPhoneUT.sendMessage(mPhoneUT.obtainMessage(EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE,
                new AsyncResult(null, null,
                        new CommandException(CommandException.Error.REQUEST_NOT_SUPPORTED))));
@@ -2219,6 +2218,28 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        assertFalse(mPhoneUT.isNullCipherAndIntegritySupported());
    }

    @Test
    public void testHandleNullCipherAndIntegrityEnabled_radioUnavailable() {
        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_CELLULAR_SECURITY,
                TelephonyManager.PROPERTY_ENABLE_NULL_CIPHER_TOGGLE, Boolean.TRUE.toString(),
                false);
        mPhoneUT.mCi = mMockCi;
        assertFalse(mPhoneUT.isNullCipherAndIntegritySupported());

        mPhoneUT.sendMessage(mPhoneUT.obtainMessage(EVENT_RADIO_AVAILABLE,
                new AsyncResult(null, new int[]{ServiceState.RIL_RADIO_TECHNOLOGY_GSM}, null)));
        processAllMessages();

        verify(mMockCi, times(1)).setNullCipherAndIntegrityEnabled(anyBoolean(),
                any(Message.class));

        mPhoneUT.sendMessage(mPhoneUT.obtainMessage(EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE,
                new AsyncResult(null, null,
                        new CommandException(CommandException.Error.RADIO_NOT_AVAILABLE))));
        processAllMessages();
        assertFalse(mPhoneUT.isNullCipherAndIntegritySupported());
    }

    @Test
    public void testHandleNullCipherAndIntegrityEnabled_radioSupportsFeature() {
        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_CELLULAR_SECURITY,
@@ -2234,7 +2255,6 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        verify(mMockCi, times(1)).setNullCipherAndIntegrityEnabled(anyBoolean(),
                any(Message.class));

        // Some ephemeral error occurred in the modem, but the feature was supported
        mPhoneUT.sendMessage(mPhoneUT.obtainMessage(EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE,
                new AsyncResult(null, null, null)));
        processAllMessages();