Loading core/java/android/app/admin/DevicePolicyManager.java +21 −1 Original line number Diff line number Diff line Loading @@ -1732,7 +1732,7 @@ public class DevicePolicyManager { /** * Determine whether the current password the user has set is sufficient * to meet the policy requirements (quality, minimum length) that have been * requested by the admins of this user and its profiles. * requested by the admins of this user and its profiles that don't have a separate challenge. * * <p>The calling device admin must have requested * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call Loading @@ -1751,6 +1751,26 @@ public class DevicePolicyManager { return false; } /** * Determine whether the current profile password the user has set is sufficient * to meet the policy requirements (quality, minimum length) that have been * requested by the admins of the parent user and its profiles. * * @param userHandle the userId of the profile to check the password for. * @return Returns true if the password would meet the current requirements, else false. * @hide */ public boolean isProfileActivePasswordSufficientForParent(int userHandle) { if (mService != null) { try { return mService.isProfileActivePasswordSufficientForParent(userHandle); } catch (RemoteException e) { Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e); } } return false; } /** * Retrieve the number of times the user has failed at entering a * password since that last successful password entry. Loading core/java/android/app/admin/IDevicePolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ interface IDevicePolicyManager { long getPasswordExpiration(in ComponentName who, int userHandle, boolean parent); boolean isActivePasswordSufficient(int userHandle, boolean parent); boolean isProfileActivePasswordSufficientForParent(int userHandle); int getCurrentFailedPasswordAttempts(int userHandle, boolean parent); int getProfileWithMinimumFailedPasswordsForWipe(int userHandle, boolean parent); Loading core/java/com/android/internal/widget/LockPatternUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -935,6 +935,13 @@ public class LockPatternUtils { return getDevicePolicyManager().isSeparateProfileChallengeAllowed(userHandle); } /** * Retrieves whether the current profile and device locks can be unified. */ public boolean isSeparateProfileChallengeAllowedToUnify(int userHandle) { return getDevicePolicyManager().isProfileActivePasswordSufficientForParent(userHandle); } /** * Deserialize a pattern. * @param string The pattern serialized with {@link #patternToString} Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +41 −23 Original line number Diff line number Diff line Loading @@ -3382,10 +3382,29 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (this) { // This API can only be called by an active device admin, // so try to retrieve it to check that the caller is one. getActiveAdminForCallerLocked( null, DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD, parent); getActiveAdminForCallerLocked(null, DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD, parent); DevicePolicyData policy = getUserDataUnchecked(getCredentialOwner(userHandle, parent)); return isActivePasswordSufficientForUserLocked(policy, userHandle, parent); } } @Override public boolean isProfileActivePasswordSufficientForParent(int userHandle) { if (!mHasFeature) { return true; } enforceFullCrossUsersPermission(userHandle); enforceManagedProfile(userHandle, "call APIs refering to the parent profile"); synchronized (this) { int targetUser = getProfileParentId(userHandle); DevicePolicyData policy = getUserDataUnchecked(getCredentialOwner(userHandle, false)); return isActivePasswordSufficientForUserLocked(policy, targetUser, false); } } private boolean isActivePasswordSufficientForUserLocked( DevicePolicyData policy, int userHandle, boolean parent) { if (policy.mActivePasswordQuality < getPasswordQuality(null, userHandle, parent) || policy.mActivePasswordLength < getPasswordMinimumLength( null, userHandle, parent)) { Loading @@ -3407,7 +3426,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { && policy.mActivePasswordNonLetter >= getPasswordMinimumNonLetter( null, userHandle, parent); } } @Override public int getCurrentFailedPasswordAttempts(int userHandle, boolean parent) { Loading Loading
core/java/android/app/admin/DevicePolicyManager.java +21 −1 Original line number Diff line number Diff line Loading @@ -1732,7 +1732,7 @@ public class DevicePolicyManager { /** * Determine whether the current password the user has set is sufficient * to meet the policy requirements (quality, minimum length) that have been * requested by the admins of this user and its profiles. * requested by the admins of this user and its profiles that don't have a separate challenge. * * <p>The calling device admin must have requested * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call Loading @@ -1751,6 +1751,26 @@ public class DevicePolicyManager { return false; } /** * Determine whether the current profile password the user has set is sufficient * to meet the policy requirements (quality, minimum length) that have been * requested by the admins of the parent user and its profiles. * * @param userHandle the userId of the profile to check the password for. * @return Returns true if the password would meet the current requirements, else false. * @hide */ public boolean isProfileActivePasswordSufficientForParent(int userHandle) { if (mService != null) { try { return mService.isProfileActivePasswordSufficientForParent(userHandle); } catch (RemoteException e) { Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e); } } return false; } /** * Retrieve the number of times the user has failed at entering a * password since that last successful password entry. Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ interface IDevicePolicyManager { long getPasswordExpiration(in ComponentName who, int userHandle, boolean parent); boolean isActivePasswordSufficient(int userHandle, boolean parent); boolean isProfileActivePasswordSufficientForParent(int userHandle); int getCurrentFailedPasswordAttempts(int userHandle, boolean parent); int getProfileWithMinimumFailedPasswordsForWipe(int userHandle, boolean parent); Loading
core/java/com/android/internal/widget/LockPatternUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -935,6 +935,13 @@ public class LockPatternUtils { return getDevicePolicyManager().isSeparateProfileChallengeAllowed(userHandle); } /** * Retrieves whether the current profile and device locks can be unified. */ public boolean isSeparateProfileChallengeAllowedToUnify(int userHandle) { return getDevicePolicyManager().isProfileActivePasswordSufficientForParent(userHandle); } /** * Deserialize a pattern. * @param string The pattern serialized with {@link #patternToString} Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +41 −23 Original line number Diff line number Diff line Loading @@ -3382,10 +3382,29 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (this) { // This API can only be called by an active device admin, // so try to retrieve it to check that the caller is one. getActiveAdminForCallerLocked( null, DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD, parent); getActiveAdminForCallerLocked(null, DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD, parent); DevicePolicyData policy = getUserDataUnchecked(getCredentialOwner(userHandle, parent)); return isActivePasswordSufficientForUserLocked(policy, userHandle, parent); } } @Override public boolean isProfileActivePasswordSufficientForParent(int userHandle) { if (!mHasFeature) { return true; } enforceFullCrossUsersPermission(userHandle); enforceManagedProfile(userHandle, "call APIs refering to the parent profile"); synchronized (this) { int targetUser = getProfileParentId(userHandle); DevicePolicyData policy = getUserDataUnchecked(getCredentialOwner(userHandle, false)); return isActivePasswordSufficientForUserLocked(policy, targetUser, false); } } private boolean isActivePasswordSufficientForUserLocked( DevicePolicyData policy, int userHandle, boolean parent) { if (policy.mActivePasswordQuality < getPasswordQuality(null, userHandle, parent) || policy.mActivePasswordLength < getPasswordMinimumLength( null, userHandle, parent)) { Loading @@ -3407,7 +3426,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { && policy.mActivePasswordNonLetter >= getPasswordMinimumNonLetter( null, userHandle, parent); } } @Override public int getCurrentFailedPasswordAttempts(int userHandle, boolean parent) { Loading