From 5d8680e1937cd028f701194fa1412adbf8502470 Mon Sep 17 00:00:00 2001 From: yomna Date: Thu, 21 Nov 2024 05:07:58 +0000 Subject: [PATCH] Fix redirect to Mobile security page When the user first access the Mobile network security settings, they should not open in Safety Center even if Safety Center is supported. Until notifications are enabled for hardware security APIs, they should open in Settings. This is because the Safety Center redirect will fail if the Safety Source has not begun providing data to Safety Center. Also update the relevant unit test. Flag: EXEMPT bugfix Bug: 373942609 Test: m & atest CellularSecurityNotificationsDividerControllerTest CellularSecurityNotificationsPreferenceControllerTest CellularSecurityEncryptionDividerControllerTest CellularSecurityPreferenceControllerTest Change-Id: Ica87be4f1567541a6e3ccbe5dd5b674224aa1d8e --- .../network/CellularSecurityPreferenceController.java | 2 +- .../network/CellularSecurityPreferenceControllerTest.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/network/CellularSecurityPreferenceController.java b/src/com/android/settings/network/CellularSecurityPreferenceController.java index 0b0c2a7e948..e515339c68c 100644 --- a/src/com/android/settings/network/CellularSecurityPreferenceController.java +++ b/src/com/android/settings/network/CellularSecurityPreferenceController.java @@ -125,7 +125,7 @@ public class CellularSecurityPreferenceController extends BasePreferenceControll return super.handlePreferenceTreeClick(preference); } boolean isSafetyCenterSupported = isSafetyCenterSupported(); - if (isSafetyCenterSupported) { + if (isSafetyCenterSupported && areNotificationsEnabled()) { Intent safetyCenterIntent = new Intent(Intent.ACTION_SAFETY_CENTER); safetyCenterIntent.putExtra(SafetyCenterManager.EXTRA_SAFETY_SOURCES_GROUP_ID, "AndroidCellularNetworkSecuritySources"); diff --git a/tests/unit/src/com/android/settings/network/CellularSecurityPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/CellularSecurityPreferenceControllerTest.java index 59e10c36ec7..7f05913cd82 100644 --- a/tests/unit/src/com/android/settings/network/CellularSecurityPreferenceControllerTest.java +++ b/tests/unit/src/com/android/settings/network/CellularSecurityPreferenceControllerTest.java @@ -152,6 +152,10 @@ public final class CellularSecurityPreferenceControllerTest { public void handlePreferenceTreeClick_safetyCenterSupported_shouldRedirectToSafetyCenter() { final ArgumentCaptor intentCaptor = ArgumentCaptor.forClass(Intent.class); + doReturn(true).when(mTelephonyManager).isNullCipherNotificationsEnabled(); + doReturn(true).when(mTelephonyManager) + .isCellularIdentifierDisclosureNotificationsEnabled(); + doReturn(true).when(mTelephonyManager).isNullCipherAndIntegrityPreferenceEnabled(); boolean prefHandled = mController.handlePreferenceTreeClick(mPreference); assertThat(prefHandled).isTrue();