Loading src/java/com/android/internal/telephony/GsmCdmaPhone.java +15 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,8 @@ public class GsmCdmaPhone extends Phone { CellBroadcastConfigTracker mCellBroadcastConfigTracker = CellBroadcastConfigTracker.make(this, null); private boolean mIsNullCipherAndIntegritySupported = false; // Create Cfu (Call forward unconditional) so that dialing number & // mOnComplete (Message object passed by client) can be packed & // given as a single Cfu object as user data to RIL. Loading Loading @@ -3440,6 +3442,14 @@ public class GsmCdmaPhone extends Phone { break; case EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE: logd("EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE"); ar = (AsyncResult) msg.obj; 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: Loading Loading @@ -5034,4 +5044,9 @@ public class GsmCdmaPhone extends Phone { getNullCipherAndIntegrityEnabledPreference(), obtainMessage(EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE)); } @Override public boolean isNullCipherAndIntegritySupported() { return mIsNullCipherAndIntegritySupported; } } src/java/com/android/internal/telephony/Phone.java +8 −0 Original line number Diff line number Diff line Loading @@ -5157,6 +5157,14 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { return sp.getBoolean(PREF_NULL_CIPHER_AND_INTEGRITY_ENABLED, true); } /** * @return whether or not this Phone interacts with a modem that supports the null cipher * and integrity feature. */ public boolean isNullCipherAndIntegritySupported() { return false; } /** * Override to implement handling of an update to the enablement of the null cipher and * integrity preference. Loading tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java +46 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.internal.telephony.CommandsInterface.CF_REASON_UNCONDI import static com.android.internal.telephony.Phone.EVENT_ICC_CHANGED; import static com.android.internal.telephony.Phone.EVENT_IMS_DEREGISTRATION_TRIGGERED; import static com.android.internal.telephony.Phone.EVENT_RADIO_AVAILABLE; import static com.android.internal.telephony.Phone.EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE; import static com.android.internal.telephony.Phone.EVENT_SRVCC_STATE_CHANGED; import static com.android.internal.telephony.Phone.EVENT_UICC_APPS_ENABLEMENT_STATUS_CHANGED; import static com.android.internal.telephony.TelephonyTestUtils.waitForMs; Loading Loading @@ -2109,6 +2110,51 @@ public class GsmCdmaPhoneTest extends TelephonyTest { fdnCheckCleanup(); } @Test public void testHandleNullCipherAndIntegrityEnabled_radioFeatureUnsupported() { 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)); // 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)))); processAllMessages(); assertFalse(mPhoneUT.isNullCipherAndIntegritySupported()); } @Test public void testHandleNullCipherAndIntegrityEnabled_radioSupportsFeature() { 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)); // 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(); assertTrue(mPhoneUT.isNullCipherAndIntegritySupported()); } @Test public void testHandleNullCipherAndIntegrityEnabled_featureFlagOn() { DeviceConfig.setProperty(DeviceConfig.NAMESPACE_CELLULAR_SECURITY, Loading Loading @@ -2137,7 +2183,6 @@ public class GsmCdmaPhoneTest extends TelephonyTest { verify(mMockCi, times(0)).setNullCipherAndIntegrityEnabled(anyBoolean(), any(Message.class)); } public void fdnCheckCleanup() { Loading Loading
src/java/com/android/internal/telephony/GsmCdmaPhone.java +15 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,8 @@ public class GsmCdmaPhone extends Phone { CellBroadcastConfigTracker mCellBroadcastConfigTracker = CellBroadcastConfigTracker.make(this, null); private boolean mIsNullCipherAndIntegritySupported = false; // Create Cfu (Call forward unconditional) so that dialing number & // mOnComplete (Message object passed by client) can be packed & // given as a single Cfu object as user data to RIL. Loading Loading @@ -3440,6 +3442,14 @@ public class GsmCdmaPhone extends Phone { break; case EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE: logd("EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE"); ar = (AsyncResult) msg.obj; 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: Loading Loading @@ -5034,4 +5044,9 @@ public class GsmCdmaPhone extends Phone { getNullCipherAndIntegrityEnabledPreference(), obtainMessage(EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE)); } @Override public boolean isNullCipherAndIntegritySupported() { return mIsNullCipherAndIntegritySupported; } }
src/java/com/android/internal/telephony/Phone.java +8 −0 Original line number Diff line number Diff line Loading @@ -5157,6 +5157,14 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { return sp.getBoolean(PREF_NULL_CIPHER_AND_INTEGRITY_ENABLED, true); } /** * @return whether or not this Phone interacts with a modem that supports the null cipher * and integrity feature. */ public boolean isNullCipherAndIntegritySupported() { return false; } /** * Override to implement handling of an update to the enablement of the null cipher and * integrity preference. Loading
tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java +46 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.internal.telephony.CommandsInterface.CF_REASON_UNCONDI import static com.android.internal.telephony.Phone.EVENT_ICC_CHANGED; import static com.android.internal.telephony.Phone.EVENT_IMS_DEREGISTRATION_TRIGGERED; import static com.android.internal.telephony.Phone.EVENT_RADIO_AVAILABLE; import static com.android.internal.telephony.Phone.EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE; import static com.android.internal.telephony.Phone.EVENT_SRVCC_STATE_CHANGED; import static com.android.internal.telephony.Phone.EVENT_UICC_APPS_ENABLEMENT_STATUS_CHANGED; import static com.android.internal.telephony.TelephonyTestUtils.waitForMs; Loading Loading @@ -2109,6 +2110,51 @@ public class GsmCdmaPhoneTest extends TelephonyTest { fdnCheckCleanup(); } @Test public void testHandleNullCipherAndIntegrityEnabled_radioFeatureUnsupported() { 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)); // 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)))); processAllMessages(); assertFalse(mPhoneUT.isNullCipherAndIntegritySupported()); } @Test public void testHandleNullCipherAndIntegrityEnabled_radioSupportsFeature() { 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)); // 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(); assertTrue(mPhoneUT.isNullCipherAndIntegritySupported()); } @Test public void testHandleNullCipherAndIntegrityEnabled_featureFlagOn() { DeviceConfig.setProperty(DeviceConfig.NAMESPACE_CELLULAR_SECURITY, Loading Loading @@ -2137,7 +2183,6 @@ public class GsmCdmaPhoneTest extends TelephonyTest { verify(mMockCi, times(0)).setNullCipherAndIntegrityEnabled(anyBoolean(), any(Message.class)); } public void fdnCheckCleanup() { Loading