aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-08-10 04:00:48 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-08-10 04:00:48 +0000
commitc15d2681da4bf09ec815d202878af8723ffeb87a (patch)
tree694ec9a77da23680b5c42485e9b137a364627383
parent45fa81f8775bf134a86db73944f1f60bdce55c2c (diff)
parentb24edc20ae50e9e5acbba75f64eecf146415be5b (diff)
downloadtelephony-android14-d1-s4-release.tar.gz
Change-Id: I1e9e0f7b5fdad67b002eb46052c9bd4631135643
-rw-r--r--src/java/com/android/internal/telephony/GsmCdmaPhone.java7
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java24
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 5eae06112c..cd0062ae7e 100644
--- a/src/java/com/android/internal/telephony/GsmCdmaPhone.java
+++ b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
@@ -3521,13 +3521,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();