diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-08-11 01:22:43 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-08-11 01:22:43 +0000 |
commit | 9484051dc3b9dac7b9609306c5b6d4a119fcf9cf (patch) | |
tree | 015d5e94e1fb7a81ec3f04e332d520ac19aa8c7e | |
parent | c0b62b615e8869f35d5e00876d0d498e082844e2 (diff) | |
parent | a1a2e09697e669b434ab54391594bf0f36b15f64 (diff) | |
download | telephony-9484051dc3b9dac7b9609306c5b6d4a119fcf9cf.tar.gz |
Snap for 10643491 from a1a2e09697e669b434ab54391594bf0f36b15f64 to udc-qpr1-release
Change-Id: I3bb2430e5ffc25e93a0aa6e071554fc72f5a56cf
-rw-r--r-- | src/java/com/android/internal/telephony/GsmCdmaPhone.java | 7 | ||||
-rw-r--r-- | tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java | 24 |
2 files changed, 26 insertions, 5 deletions
diff --git a/src/java/com/android/internal/telephony/GsmCdmaPhone.java b/src/java/com/android/internal/telephony/GsmCdmaPhone.java index f2a4fdc99f..62c1dfbe17 100644 --- a/src/java/com/android/internal/telephony/GsmCdmaPhone.java +++ b/src/java/com/android/internal/telephony/GsmCdmaPhone.java @@ -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: diff --git a/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java b/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java index c5f20e39a4..465880aa7d 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java @@ -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)))); @@ -2220,6 +2219,28 @@ public class GsmCdmaPhoneTest extends TelephonyTest { } @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, TelephonyManager.PROPERTY_ENABLE_NULL_CIPHER_TOGGLE, Boolean.TRUE.toString(), @@ -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(); |