Loading core/java/android/app/admin/DevicePolicyManager.java +17 −0 Original line number Diff line number Diff line Loading @@ -2287,6 +2287,23 @@ public class DevicePolicyManager { return 0; } /** * Returns maximum time to lock that applied by all profiles in this user. We do this because we * do not have a separate timeout to lock for work challenge only. * * @hide */ public long getMaximumTimeToLockForUserAndProfiles(int userHandle) { if (mService != null) { try { return mService.getMaximumTimeToLockForUserAndProfiles(userHandle); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } return 0; } /** * Make the device lock immediately, as if the lock screen timeout has expired at the point of * this call. Loading core/java/android/app/admin/IDevicePolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ interface IDevicePolicyManager { void setMaximumTimeToLock(in ComponentName who, long timeMs, boolean parent); long getMaximumTimeToLock(in ComponentName who, int userHandle, boolean parent); long getMaximumTimeToLockForUserAndProfiles(int userHandle); void lockNow(boolean parent); Loading packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java +25 −43 Original line number Diff line number Diff line Loading @@ -459,35 +459,19 @@ public class RestrictedLockUtils { LockPatternUtils lockPatternUtils = new LockPatternUtils(context); EnforcedAdmin enforcedAdmin = null; final int userId = UserHandle.myUserId(); if (lockPatternUtils.isSeparateProfileChallengeEnabled(userId)) { // userId is managed profile and has a separate challenge, only consider // the admins in that user. final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userId); if (admins == null) { return null; } for (ComponentName admin : admins) { if (dpm.getMaximumTimeToLock(admin, userId) > 0) { if (enforcedAdmin == null) { enforcedAdmin = new EnforcedAdmin(admin, userId); } else { return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN; } } } } else { // Return all admins for this user and the profiles that are visible from this // user that do not use a separate work challenge. final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); for (UserInfo userInfo : um.getProfiles(userId)) { final UserManager um = UserManager.get(context); final List<UserInfo> profiles = um.getProfiles(userId); final int profilesSize = profiles.size(); // As we do not have a separate screen lock timeout settings for work challenge, // we need to combine all profiles maximum time to lock even work challenge is // enabled. for (int i = 0; i < profilesSize; i++) { final UserInfo userInfo = profiles.get(i); final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userInfo.id); if (admins == null) { continue; } final boolean isSeparateProfileChallengeEnabled = lockPatternUtils.isSeparateProfileChallengeEnabled(userInfo.id); for (ComponentName admin : admins) { if (!isSeparateProfileChallengeEnabled) { if (dpm.getMaximumTimeToLock(admin, userInfo.id) > 0) { if (enforcedAdmin == null) { enforcedAdmin = new EnforcedAdmin(admin, userInfo.id); Loading @@ -500,11 +484,10 @@ public class RestrictedLockUtils { // has set policy on the parent admin. continue; } } if (userInfo.isManagedProfile()) { // If userInfo.id is a managed profile, we also need to look at // the policies set on the parent. DevicePolicyManager parentDpm = dpm.getParentProfileInstance(userInfo); final DevicePolicyManager parentDpm = dpm.getParentProfileInstance(userInfo); if (parentDpm.getMaximumTimeToLock(admin, userInfo.id) > 0) { if (enforcedAdmin == null) { enforcedAdmin = new EnforcedAdmin(admin, userInfo.id); Loading @@ -515,7 +498,6 @@ public class RestrictedLockUtils { } } } } return enforcedAdmin; } Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +1 −1 Original line number Diff line number Diff line Loading @@ -804,7 +804,7 @@ public class KeyguardViewMediator extends SystemUI { // From DevicePolicyAdmin final long policyTimeout = mLockPatternUtils.getDevicePolicyManager() .getMaximumTimeToLock(null, userId); .getMaximumTimeToLockForUserAndProfiles(userId); long timeout; Loading services/core/java/com/android/server/trust/TrustAgentWrapper.java +1 −1 Original line number Diff line number Diff line Loading @@ -375,7 +375,7 @@ public class TrustAgentWrapper { } else { mTrustAgentService.onConfigure(Collections.EMPTY_LIST, null); } final long maxTimeToLock = dpm.getMaximumTimeToLock(null); final long maxTimeToLock = dpm.getMaximumTimeToLockForUserAndProfiles(mUserId); if (maxTimeToLock != mMaximumTimeToLock) { // If the timeout changes, cancel the alarm and send a timeout event to have // the agent re-evaluate trust. Loading Loading
core/java/android/app/admin/DevicePolicyManager.java +17 −0 Original line number Diff line number Diff line Loading @@ -2287,6 +2287,23 @@ public class DevicePolicyManager { return 0; } /** * Returns maximum time to lock that applied by all profiles in this user. We do this because we * do not have a separate timeout to lock for work challenge only. * * @hide */ public long getMaximumTimeToLockForUserAndProfiles(int userHandle) { if (mService != null) { try { return mService.getMaximumTimeToLockForUserAndProfiles(userHandle); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } return 0; } /** * Make the device lock immediately, as if the lock screen timeout has expired at the point of * this call. Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ interface IDevicePolicyManager { void setMaximumTimeToLock(in ComponentName who, long timeMs, boolean parent); long getMaximumTimeToLock(in ComponentName who, int userHandle, boolean parent); long getMaximumTimeToLockForUserAndProfiles(int userHandle); void lockNow(boolean parent); Loading
packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java +25 −43 Original line number Diff line number Diff line Loading @@ -459,35 +459,19 @@ public class RestrictedLockUtils { LockPatternUtils lockPatternUtils = new LockPatternUtils(context); EnforcedAdmin enforcedAdmin = null; final int userId = UserHandle.myUserId(); if (lockPatternUtils.isSeparateProfileChallengeEnabled(userId)) { // userId is managed profile and has a separate challenge, only consider // the admins in that user. final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userId); if (admins == null) { return null; } for (ComponentName admin : admins) { if (dpm.getMaximumTimeToLock(admin, userId) > 0) { if (enforcedAdmin == null) { enforcedAdmin = new EnforcedAdmin(admin, userId); } else { return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN; } } } } else { // Return all admins for this user and the profiles that are visible from this // user that do not use a separate work challenge. final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); for (UserInfo userInfo : um.getProfiles(userId)) { final UserManager um = UserManager.get(context); final List<UserInfo> profiles = um.getProfiles(userId); final int profilesSize = profiles.size(); // As we do not have a separate screen lock timeout settings for work challenge, // we need to combine all profiles maximum time to lock even work challenge is // enabled. for (int i = 0; i < profilesSize; i++) { final UserInfo userInfo = profiles.get(i); final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userInfo.id); if (admins == null) { continue; } final boolean isSeparateProfileChallengeEnabled = lockPatternUtils.isSeparateProfileChallengeEnabled(userInfo.id); for (ComponentName admin : admins) { if (!isSeparateProfileChallengeEnabled) { if (dpm.getMaximumTimeToLock(admin, userInfo.id) > 0) { if (enforcedAdmin == null) { enforcedAdmin = new EnforcedAdmin(admin, userInfo.id); Loading @@ -500,11 +484,10 @@ public class RestrictedLockUtils { // has set policy on the parent admin. continue; } } if (userInfo.isManagedProfile()) { // If userInfo.id is a managed profile, we also need to look at // the policies set on the parent. DevicePolicyManager parentDpm = dpm.getParentProfileInstance(userInfo); final DevicePolicyManager parentDpm = dpm.getParentProfileInstance(userInfo); if (parentDpm.getMaximumTimeToLock(admin, userInfo.id) > 0) { if (enforcedAdmin == null) { enforcedAdmin = new EnforcedAdmin(admin, userInfo.id); Loading @@ -515,7 +498,6 @@ public class RestrictedLockUtils { } } } } return enforcedAdmin; } Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +1 −1 Original line number Diff line number Diff line Loading @@ -804,7 +804,7 @@ public class KeyguardViewMediator extends SystemUI { // From DevicePolicyAdmin final long policyTimeout = mLockPatternUtils.getDevicePolicyManager() .getMaximumTimeToLock(null, userId); .getMaximumTimeToLockForUserAndProfiles(userId); long timeout; Loading
services/core/java/com/android/server/trust/TrustAgentWrapper.java +1 −1 Original line number Diff line number Diff line Loading @@ -375,7 +375,7 @@ public class TrustAgentWrapper { } else { mTrustAgentService.onConfigure(Collections.EMPTY_LIST, null); } final long maxTimeToLock = dpm.getMaximumTimeToLock(null); final long maxTimeToLock = dpm.getMaximumTimeToLockForUserAndProfiles(mUserId); if (maxTimeToLock != mMaximumTimeToLock) { // If the timeout changes, cancel the alarm and send a timeout event to have // the agent re-evaluate trust. Loading