Merge "Fix "max failed login attempts" disclosure" into oc-dr1-dev am: 262aacd353
am: cfc3ccdb82
Change-Id: I2c73cf6895da1188027d0f8704f795490f1e7be1
This commit is contained in:
@@ -45,6 +45,13 @@ public interface DevicePolicyManagerWrapper {
|
|||||||
*/
|
*/
|
||||||
int getMaximumFailedPasswordsForWipe(@Nullable ComponentName admin, int userHandle);
|
int getMaximumFailedPasswordsForWipe(@Nullable ComponentName admin, int userHandle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls {@code DevicePolicyManager.getDeviceOwnerComponentOnCallingUser()}.
|
||||||
|
*
|
||||||
|
* @see android.app.admin.DevicePolicyManager#getDeviceOwnerComponentOnCallingUser
|
||||||
|
*/
|
||||||
|
ComponentName getDeviceOwnerComponentOnCallingUser();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls {@code DevicePolicyManager.getDeviceOwnerComponentOnAnyUser()}.
|
* Calls {@code DevicePolicyManager.getDeviceOwnerComponentOnAnyUser()}.
|
||||||
*
|
*
|
||||||
|
@@ -42,6 +42,11 @@ public class DevicePolicyManagerWrapperImpl implements DevicePolicyManagerWrappe
|
|||||||
return mDpm.getMaximumFailedPasswordsForWipe(admin, userHandle);
|
return mDpm.getMaximumFailedPasswordsForWipe(admin, userHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ComponentName getDeviceOwnerComponentOnCallingUser() {
|
||||||
|
return mDpm.getDeviceOwnerComponentOnCallingUser();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ComponentName getDeviceOwnerComponentOnAnyUser() {
|
public ComponentName getDeviceOwnerComponentOnAnyUser() {
|
||||||
return mDpm.getDeviceOwnerComponentOnAnyUser();
|
return mDpm.getDeviceOwnerComponentOnAnyUser();
|
||||||
|
@@ -158,11 +158,14 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaximumFailedPasswordsBeforeWipeInCurrentUser() {
|
public int getMaximumFailedPasswordsBeforeWipeInCurrentUser() {
|
||||||
final ComponentName profileOwner = mDpm.getProfileOwnerAsUser(MY_USER_ID);
|
ComponentName owner = mDpm.getDeviceOwnerComponentOnCallingUser();
|
||||||
if (profileOwner == null) {
|
if (owner == null) {
|
||||||
|
owner = mDpm.getProfileOwnerAsUser(MY_USER_ID);
|
||||||
|
}
|
||||||
|
if (owner == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return mDpm.getMaximumFailedPasswordsForWipe(profileOwner, MY_USER_ID);
|
return mDpm.getMaximumFailedPasswordsForWipe(owner, MY_USER_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -231,6 +231,7 @@ public final class EnterprisePrivacyFeatureProviderImplTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetMaximumFailedPasswordsForWipeInCurrentUser() {
|
public void testGetMaximumFailedPasswordsForWipeInCurrentUser() {
|
||||||
|
when(mDevicePolicyManager.getDeviceOwnerComponentOnCallingUser()).thenReturn(null);
|
||||||
when(mDevicePolicyManager.getProfileOwnerAsUser(MY_USER_ID)).thenReturn(null);
|
when(mDevicePolicyManager.getProfileOwnerAsUser(MY_USER_ID)).thenReturn(null);
|
||||||
when(mDevicePolicyManager.getMaximumFailedPasswordsForWipe(OWNER, MY_USER_ID))
|
when(mDevicePolicyManager.getMaximumFailedPasswordsForWipe(OWNER, MY_USER_ID))
|
||||||
.thenReturn(10);
|
.thenReturn(10);
|
||||||
@@ -238,6 +239,10 @@ public final class EnterprisePrivacyFeatureProviderImplTest {
|
|||||||
|
|
||||||
when(mDevicePolicyManager.getProfileOwnerAsUser(MY_USER_ID)).thenReturn(OWNER);
|
when(mDevicePolicyManager.getProfileOwnerAsUser(MY_USER_ID)).thenReturn(OWNER);
|
||||||
assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInCurrentUser()).isEqualTo(10);
|
assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInCurrentUser()).isEqualTo(10);
|
||||||
|
|
||||||
|
when(mDevicePolicyManager.getDeviceOwnerComponentOnCallingUser()).thenReturn(OWNER);
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerAsUser(MY_USER_ID)).thenReturn(null);
|
||||||
|
assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInCurrentUser()).isEqualTo(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user