From c5f429f0b67c9057dfa641a5e709fce68a7822dd Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Thu, 13 Apr 2023 15:40:26 +0100 Subject: Headless: fix locking work profile with separate challenge on power button SystemUI is querying the profile of its own running user, but in headless system user mode this should really be the current foreground user. Also fix a bug in DevicePolicyManager where device lock timeout is pushed to the wrong user. Bug: 265021591 Test: manual run of the CtsVerifier test Change-Id: I714cda9040b8712df6753a9d37e8c293fe527ad9 --- .../com/android/systemui/keyguard/KeyguardViewMediator.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'packages/SystemUI/src') diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 7a2013e2c612..93ddfba5b6fc 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -1610,8 +1610,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } private void doKeyguardLaterForChildProfilesLocked() { - UserManager um = UserManager.get(mContext); - for (int profileId : um.getEnabledProfileIds(UserHandle.myUserId())) { + for (UserInfo profile : mUserTracker.getUserProfiles()) { + if (!profile.isEnabled()) continue; + final int profileId = profile.id; if (mLockPatternUtils.isSeparateProfileChallengeEnabled(profileId)) { long userTimeout = getLockTimeout(profileId); if (userTimeout == 0) { @@ -1634,8 +1635,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } private void doKeyguardForChildProfilesLocked() { - UserManager um = UserManager.get(mContext); - for (int profileId : um.getEnabledProfileIds(UserHandle.myUserId())) { + for (UserInfo profile : mUserTracker.getUserProfiles()) { + if (!profile.isEnabled()) continue; + final int profileId = profile.id; if (mLockPatternUtils.isSeparateProfileChallengeEnabled(profileId)) { lockProfile(profileId); } -- cgit v1.2.3-59-g8ed1b