diff --git a/src/com/android/settings/notification/RedactNotificationPreferenceController.java b/src/com/android/settings/notification/RedactNotificationPreferenceController.java index db34e5e960a..2d2718478c2 100644 --- a/src/com/android/settings/notification/RedactNotificationPreferenceController.java +++ b/src/com/android/settings/notification/RedactNotificationPreferenceController.java @@ -178,7 +178,8 @@ public class RedactNotificationPreferenceController extends TogglePreferenceCont private boolean getAllowPrivateNotifications(int userId) { return Settings.Secure.getIntForUser(mContext.getContentResolver(), - LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, userId) != 0; + LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, userId) != 0 + && getEnforcedAdmin(userId) == null; } private boolean getLockscreenNotificationsEnabled(int userId) { diff --git a/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java index ae25474f81b..72a2c2451ee 100644 --- a/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java @@ -292,6 +292,18 @@ public class RedactNotificationPreferenceControllerTest { assertThat(mWorkController.isChecked()).isFalse(); } + @Test + public void isChecked_admin() { + Settings.Secure.putIntForUser(mContext.getContentResolver(), + LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, + 1, 0); + + ShadowRestrictedLockUtilsInternal.setKeyguardDisabledFeatures( + KEYGUARD_DISABLE_SECURE_NOTIFICATIONS); + + assertThat(mController.isChecked()).isFalse(); + } + @Test public void setChecked_false() throws Exception { Settings.Secure.putIntForUser(mContext.getContentResolver(),