Use primary user's LOCK_SCREEN_SHOW_NOTIFICATIONS.

Only primary user can set LOCK_SCREEN_SHOW_NOTIFICATIONS,
profile can only set notifications to be redacted. When the
user changes notification settings for a work app, this class
is invoked from the profile, meaning it attempts to read
LOCK_SCREEN_SHOW_NOTIFICATIONS for the profile, which is not
there. As a result the function always returs 0 for work apps.

Bug: 111112011
Test: atest packages/apps/Settings/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
Change-Id: Ifb50209ea8ea8fb6639f00ca8b7cf8a4295890ad
Merged-In: Ifb50209ea8ea8fb6639f00ca8b7cf8a4295890ad
(cherry picked from commit f14de789f4)
This commit is contained in:
Pavel Grafov
2018-07-03 20:31:42 +01:00
parent ea97a66383
commit f9429262d2
2 changed files with 29 additions and 2 deletions

View File

@@ -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() {