Loading src/com/android/settings/notification/VisibilityPreferenceController.java +4 −2 Original line number Diff line number Diff line Loading @@ -147,8 +147,10 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro } private boolean getLockscreenNotificationsEnabled() { return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0; final UserInfo parentUser = mUm.getProfileParent(UserHandle.myUserId()); final int primaryUserId = parentUser != null ? parentUser.id : UserHandle.myUserId(); return Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, primaryUserId) != 0; } private boolean getLockscreenAllowPrivateNotifications() { Loading tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -208,6 +208,31 @@ public class VisibilityPreferenceControllerTest { .contains(String.valueOf(VISIBILITY_PRIVATE))); } @Test public void testUpdateState_noLockScreenNotificationsGloballyInProfile() { final int primaryUserId = 2; final UserInfo primaryUserInfo = new UserInfo(primaryUserId, "user 2", 0); when(mUm.getProfileParent(anyInt())).thenReturn(primaryUserInfo); Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, primaryUserId); NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); NotificationChannel channel = mock(NotificationChannel.class); mController.onResume(appRow, channel, null, null); RestrictedListPreference pref = mock(RestrictedListPreference.class); mController.updateState(pref); ArgumentCaptor<CharSequence[]> argumentCaptor = ArgumentCaptor.forClass(CharSequence[].class); verify(pref, times(1)).setEntryValues(argumentCaptor.capture()); assertFalse(toStringList(argumentCaptor.getValue()) .contains(String.valueOf(VISIBILITY_NO_OVERRIDE))); assertFalse(toStringList(argumentCaptor.getValue()) .contains(String.valueOf(VISIBILITY_PRIVATE))); } @Test public void testUpdateState_noPrivateLockScreenNotificationsGlobally() { Settings.Secure.putInt(mContext.getContentResolver(), Loading Loading
src/com/android/settings/notification/VisibilityPreferenceController.java +4 −2 Original line number Diff line number Diff line Loading @@ -147,8 +147,10 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro } private boolean getLockscreenNotificationsEnabled() { return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0; final UserInfo parentUser = mUm.getProfileParent(UserHandle.myUserId()); final int primaryUserId = parentUser != null ? parentUser.id : UserHandle.myUserId(); return Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, primaryUserId) != 0; } private boolean getLockscreenAllowPrivateNotifications() { Loading
tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -208,6 +208,31 @@ public class VisibilityPreferenceControllerTest { .contains(String.valueOf(VISIBILITY_PRIVATE))); } @Test public void testUpdateState_noLockScreenNotificationsGloballyInProfile() { final int primaryUserId = 2; final UserInfo primaryUserInfo = new UserInfo(primaryUserId, "user 2", 0); when(mUm.getProfileParent(anyInt())).thenReturn(primaryUserInfo); Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, primaryUserId); NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); NotificationChannel channel = mock(NotificationChannel.class); mController.onResume(appRow, channel, null, null); RestrictedListPreference pref = mock(RestrictedListPreference.class); mController.updateState(pref); ArgumentCaptor<CharSequence[]> argumentCaptor = ArgumentCaptor.forClass(CharSequence[].class); verify(pref, times(1)).setEntryValues(argumentCaptor.capture()); assertFalse(toStringList(argumentCaptor.getValue()) .contains(String.valueOf(VISIBILITY_NO_OVERRIDE))); assertFalse(toStringList(argumentCaptor.getValue()) .contains(String.valueOf(VISIBILITY_PRIVATE))); } @Test public void testUpdateState_noPrivateLockScreenNotificationsGlobally() { Settings.Secure.putInt(mContext.getContentResolver(), Loading