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();