Loading core/java/android/app/admin/DevicePolicyManager.java +9 −7 Original line number Diff line number Diff line Loading @@ -3499,9 +3499,11 @@ public class DevicePolicyManager { * Returns how complex the current user's screen lock is. * * <p>Note that when called from a profile which uses an unified challenge with its parent, the * screen lock complexity of the parent will be returned. However, this API does not support * explicitly querying the parent profile screen lock complexity via {@link * #getParentProfileInstance}. * screen lock complexity of the parent will be returned. * * <p>This method can be called on the {@link DevicePolicyManager} instance * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve * restrictions on the parent profile. * * @throws IllegalStateException if the user is not unlocked. * @throws SecurityException if the calling application does not have the permission Loading @@ -3510,13 +3512,12 @@ public class DevicePolicyManager { @PasswordComplexity @RequiresPermission(android.Manifest.permission.REQUEST_PASSWORD_COMPLEXITY) public int getPasswordComplexity() { throwIfParentInstance("getPasswordComplexity"); if (mService == null) { return PASSWORD_COMPLEXITY_NONE; } try { return mService.getPasswordComplexity(); return mService.getPasswordComplexity(mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -9254,6 +9255,7 @@ public class DevicePolicyManager { * <li>{@link #setPasswordExpirationTimeout}</li> * <li>{@link #getPasswordExpiration}</li> * <li>{@link #getPasswordMaximumLength}</li> * <li>{@link #getPasswordComplexity}</li> * <li>{@link #isActivePasswordSufficient}</li> * <li>{@link #getCurrentFailedPasswordAttempts}</li> * <li>{@link #getMaximumFailedPasswordsForWipe}</li> Loading core/java/android/app/admin/IDevicePolicyManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ interface IDevicePolicyManager { boolean isActivePasswordSufficient(int userHandle, boolean parent); boolean isProfileActivePasswordSufficientForParent(int userHandle); int getPasswordComplexity(); int getPasswordComplexity(boolean parent); boolean isUsingUnifiedPassword(in ComponentName admin); int getCurrentFailedPasswordAttempts(int userHandle, boolean parent); int getProfileWithMinimumFailedPasswordsForWipe(int userHandle, boolean parent); Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +7 −3 Original line number Diff line number Diff line Loading @@ -4928,21 +4928,25 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { @Override @PasswordComplexity public int getPasswordComplexity() { public int getPasswordComplexity(boolean parent) { DevicePolicyEventLogger .createEvent(DevicePolicyEnums.GET_USER_PASSWORD_COMPLEXITY_LEVEL) .setStrings(mInjector.getPackageManager() .getPackagesForUid(mInjector.binderGetCallingUid())) .write(); final int callingUserId = mInjector.userHandleGetCallingUserId(); if (parent) { enforceProfileOwnerOrSystemUser(); } enforceUserUnlocked(callingUserId); mContext.enforceCallingOrSelfPermission( REQUEST_PASSWORD_COMPLEXITY, "Must have " + REQUEST_PASSWORD_COMPLEXITY + " permission."); synchronized (getLockObject()) { int targetUserId = getCredentialOwner(callingUserId, /* parent= */ false); PasswordMetrics metrics = mLockSettingsInternal.getUserPasswordMetrics(targetUserId); final int credentialOwner = getCredentialOwner(callingUserId, parent); PasswordMetrics metrics = mLockSettingsInternal.getUserPasswordMetrics(credentialOwner); return metrics == null ? PASSWORD_COMPLEXITY_NONE : metrics.determineComplexity(); } } Loading services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +11 −7 Original line number Diff line number Diff line Loading @@ -5295,13 +5295,17 @@ public class DevicePolicyManagerTest extends DpmTestBase { }); } public void testGetPasswordComplexity_securityExceptionIfParentInstance() { assertThrows(SecurityException.class, () -> new DevicePolicyManagerTestable( public void testGetPasswordComplexity_securityExceptionNotThrownForParentInstance() { mServiceContext.permissions.add(permission.REQUEST_PASSWORD_COMPLEXITY); setAsProfileOwner(admin1); new DevicePolicyManagerTestable( mServiceContext, dpms, /* parentInstance= */ true) .getPasswordComplexity()); .getPasswordComplexity(); assertEquals(PASSWORD_COMPLEXITY_NONE, dpm.getPasswordComplexity()); } public void testGetPasswordComplexity_illegalStateExceptionIfLocked() { Loading Loading
core/java/android/app/admin/DevicePolicyManager.java +9 −7 Original line number Diff line number Diff line Loading @@ -3499,9 +3499,11 @@ public class DevicePolicyManager { * Returns how complex the current user's screen lock is. * * <p>Note that when called from a profile which uses an unified challenge with its parent, the * screen lock complexity of the parent will be returned. However, this API does not support * explicitly querying the parent profile screen lock complexity via {@link * #getParentProfileInstance}. * screen lock complexity of the parent will be returned. * * <p>This method can be called on the {@link DevicePolicyManager} instance * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve * restrictions on the parent profile. * * @throws IllegalStateException if the user is not unlocked. * @throws SecurityException if the calling application does not have the permission Loading @@ -3510,13 +3512,12 @@ public class DevicePolicyManager { @PasswordComplexity @RequiresPermission(android.Manifest.permission.REQUEST_PASSWORD_COMPLEXITY) public int getPasswordComplexity() { throwIfParentInstance("getPasswordComplexity"); if (mService == null) { return PASSWORD_COMPLEXITY_NONE; } try { return mService.getPasswordComplexity(); return mService.getPasswordComplexity(mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -9254,6 +9255,7 @@ public class DevicePolicyManager { * <li>{@link #setPasswordExpirationTimeout}</li> * <li>{@link #getPasswordExpiration}</li> * <li>{@link #getPasswordMaximumLength}</li> * <li>{@link #getPasswordComplexity}</li> * <li>{@link #isActivePasswordSufficient}</li> * <li>{@link #getCurrentFailedPasswordAttempts}</li> * <li>{@link #getMaximumFailedPasswordsForWipe}</li> Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ interface IDevicePolicyManager { boolean isActivePasswordSufficient(int userHandle, boolean parent); boolean isProfileActivePasswordSufficientForParent(int userHandle); int getPasswordComplexity(); int getPasswordComplexity(boolean parent); boolean isUsingUnifiedPassword(in ComponentName admin); int getCurrentFailedPasswordAttempts(int userHandle, boolean parent); int getProfileWithMinimumFailedPasswordsForWipe(int userHandle, boolean parent); Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +7 −3 Original line number Diff line number Diff line Loading @@ -4928,21 +4928,25 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { @Override @PasswordComplexity public int getPasswordComplexity() { public int getPasswordComplexity(boolean parent) { DevicePolicyEventLogger .createEvent(DevicePolicyEnums.GET_USER_PASSWORD_COMPLEXITY_LEVEL) .setStrings(mInjector.getPackageManager() .getPackagesForUid(mInjector.binderGetCallingUid())) .write(); final int callingUserId = mInjector.userHandleGetCallingUserId(); if (parent) { enforceProfileOwnerOrSystemUser(); } enforceUserUnlocked(callingUserId); mContext.enforceCallingOrSelfPermission( REQUEST_PASSWORD_COMPLEXITY, "Must have " + REQUEST_PASSWORD_COMPLEXITY + " permission."); synchronized (getLockObject()) { int targetUserId = getCredentialOwner(callingUserId, /* parent= */ false); PasswordMetrics metrics = mLockSettingsInternal.getUserPasswordMetrics(targetUserId); final int credentialOwner = getCredentialOwner(callingUserId, parent); PasswordMetrics metrics = mLockSettingsInternal.getUserPasswordMetrics(credentialOwner); return metrics == null ? PASSWORD_COMPLEXITY_NONE : metrics.determineComplexity(); } } Loading
services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +11 −7 Original line number Diff line number Diff line Loading @@ -5295,13 +5295,17 @@ public class DevicePolicyManagerTest extends DpmTestBase { }); } public void testGetPasswordComplexity_securityExceptionIfParentInstance() { assertThrows(SecurityException.class, () -> new DevicePolicyManagerTestable( public void testGetPasswordComplexity_securityExceptionNotThrownForParentInstance() { mServiceContext.permissions.add(permission.REQUEST_PASSWORD_COMPLEXITY); setAsProfileOwner(admin1); new DevicePolicyManagerTestable( mServiceContext, dpms, /* parentInstance= */ true) .getPasswordComplexity()); .getPasswordComplexity(); assertEquals(PASSWORD_COMPLEXITY_NONE, dpm.getPasswordComplexity()); } public void testGetPasswordComplexity_illegalStateExceptionIfLocked() { Loading