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

Commit abb95e23 authored by Gil Cukierman's avatar Gil Cukierman
Browse files

Split modem cipher transparency flags

Keep the existing flag as an API guard and create a new flag to guard all logic the telephony framework executes on an unsolicited event from the modem.

Bug: 320504773
Change-Id: I8ce4259f7fe208510b3a6a095c02d4ec85a8090e
Test: atest GsmCdmaPhoneTest android.telephony.cts.TelephonyManagerTest
parent 8b760b00
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -31,6 +31,13 @@ flag {
flag {
  name: "enable_modem_cipher_transparency"
  namespace: "telephony"
  description: "Guards APIs for enabling and disabling modem cipher transparency."
  bug: "283336425"
}

flag {
  name: "enable_modem_cipher_transparency_unsol_events"
  namespace: "telephony"
  description: "Allows the framework to register for SecurityAlgorithmChanged events and emit notifications to the user when a device is using null ciphers."
  bug: "283336425"
}
+18 −7
Original line number Diff line number Diff line
@@ -538,9 +538,11 @@ public class GsmCdmaPhone extends Phone {
                    this, EVENT_CELL_IDENTIFIER_DISCLOSURE, null);
        }

        if (mFeatureFlags.enableModemCipherTransparency()) {
            logi("enable_modem_cipher_transparency is on. Registering for security algorithm "
                    + "updates from phone " + getPhoneId());
        if (mFeatureFlags.enableModemCipherTransparencyUnsolEvents()) {
            logi(
                    "enable_modem_cipher_transparency_unsol_events is on. Registering for security "
                            + "algorithm updates from phone "
                            + getPhoneId());
            mNullCipherNotifier =
                    mTelephonyComponentFactory
                            .inject(NullCipherNotifier.class.getName())
@@ -3720,7 +3722,8 @@ public class GsmCdmaPhone extends Phone {

            case EVENT_SECURITY_ALGORITHM_UPDATE:
                logd("EVENT_SECURITY_ALGORITHM_UPDATE phoneId = " + getPhoneId());
                if (mFeatureFlags.enableModemCipherTransparency() && mNullCipherNotifier != null) {
                if (mFeatureFlags.enableModemCipherTransparencyUnsolEvents()
                        && mNullCipherNotifier != null) {
                    ar = (AsyncResult) msg.obj;
                    SecurityAlgorithmUpdate update = (SecurityAlgorithmUpdate) ar.result;
                    mNullCipherNotifier.onSecurityAlgorithmUpdate(getPhoneId(), update);
@@ -5373,11 +5376,19 @@ public class GsmCdmaPhone extends Phone {
        }
        boolean prefEnabled = getNullCipherNotificationsPreferenceEnabled();

        // The notifier is tied to handling unsolicited updates from the modem, not the
        // enable/disable API.
        if (mFeatureFlags.enableModemCipherTransparencyUnsolEvents()) {
            if (prefEnabled) {
                mNullCipherNotifier.enable();
            } else {
                mNullCipherNotifier.disable();
            }
        } else {
            logi(
                    "Not toggling enable state for cipher notifier. Feature flag "
                            + "enable_modem_cipher_transparency_unsol_events is disabled.");
        }

        mCi.setSecurityAlgorithmsUpdatedEnabled(prefEnabled,
                obtainMessage(EVENT_SET_SECURITY_ALGORITHMS_UPDATED_ENABLED_DONE));
+4 −2
Original line number Diff line number Diff line
@@ -2947,7 +2947,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {

    @Test
    public void testSecurityAlgorithmUpdateFlagOn() {
        when(mFeatureFlags.enableModemCipherTransparency()).thenReturn(true);
        when(mFeatureFlags.enableModemCipherTransparencyUnsolEvents()).thenReturn(true);

        Phone phoneUT = makeNewPhoneUT();

@@ -2960,7 +2960,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {

    @Test
    public void testSecurityAlgorithm_updateAddedToNotifier() {
        when(mFeatureFlags.enableModemCipherTransparency()).thenReturn(true);
        when(mFeatureFlags.enableModemCipherTransparencyUnsolEvents()).thenReturn(true);
        Phone phoneUT = makeNewPhoneUT();
        SecurityAlgorithmUpdate update =
                new SecurityAlgorithmUpdate(
@@ -3022,6 +3022,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
    @Test
    public void testNullCipherNotification_preferenceEnabled() {
        when(mFeatureFlags.enableModemCipherTransparency()).thenReturn(true);
        when(mFeatureFlags.enableModemCipherTransparencyUnsolEvents()).thenReturn(true);
        GsmCdmaPhone phoneUT = makeNewPhoneUT();

        setNullCipherNotificationPreferenceEnabled(true);
@@ -3035,6 +3036,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
    @Test
    public void testNullCipherNotification_preferenceDisabled() {
        when(mFeatureFlags.enableModemCipherTransparency()).thenReturn(true);
        when(mFeatureFlags.enableModemCipherTransparencyUnsolEvents()).thenReturn(true);
        GsmCdmaPhone phoneUT = makeNewPhoneUT();

        setNullCipherNotificationPreferenceEnabled(false);