From 540ad99d88c902a5b5238dec7a3cf1eb9c9713af Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Fri, 7 May 2021 15:01:58 -0400 Subject: [PATCH] Fix work profile setting appearing too often That is, when the user didn't have work profile Test: robotests, manual Fixes: 187520760 Change-Id: I9394359a6bc278d58ef13b30f8ce99cbaa595c25 --- .../notification/RedactNotificationPreferenceController.java | 2 +- .../RedactNotificationPreferenceControllerTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/notification/RedactNotificationPreferenceController.java b/src/com/android/settings/notification/RedactNotificationPreferenceController.java index 622b366a970..d0326bb5c6a 100644 --- a/src/com/android/settings/notification/RedactNotificationPreferenceController.java +++ b/src/com/android/settings/notification/RedactNotificationPreferenceController.java @@ -116,7 +116,7 @@ public class RedactNotificationPreferenceController extends TogglePreferenceCont public int getAvailabilityStatus() { // hide work profile setting if no work profile if (KEY_LOCKSCREEN_WORK_PROFILE_REDACT.equals(getPreferenceKey()) - && mProfileUserId == UserHandle.USER_NULL) { + && mProfileUserId == UserHandle.myUserId()) { return CONDITIONALLY_UNAVAILABLE; } diff --git a/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java index febda108526..ae25474f81b 100644 --- a/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java @@ -137,7 +137,7 @@ public class RedactNotificationPreferenceControllerTest { @Test public void getAvailabilityStatus_noWorkProfile() { // reset controllers with no work profile - when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {UserHandle.USER_NULL}); + when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {UserHandle.myUserId()}); mWorkController = new RedactNotificationPreferenceController(mMockContext, RedactNotificationPreferenceController.KEY_LOCKSCREEN_WORK_PROFILE_REDACT); mController = new RedactNotificationPreferenceController(mMockContext,