Add wipe on login failure to Privacy Settings page

This CL adds information to the Enterprise Privacy Setting page that
tells the user how many times the password can be mistyped before
the device (or the work profile) is forcefully wiped.

Test: make RunSettingsRoboTests
Bug: 32692748

Change-Id: I4ae316802dbf5853ab4eacb0787647372d5e26c2
This commit is contained in:
Bartosz Fabianowski
2017-02-14 11:45:20 +01:00
parent c1a7723c17
commit 8903f66662
20 changed files with 542 additions and 21 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings.enterprise;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -70,12 +71,12 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
return userInfo.id;
}
}
return -1;
return UserHandle.USER_NULL;
}
@Override
public boolean isInCompMode() {
return hasDeviceOwner() && getManagedProfileUserId() != -1;
return hasDeviceOwner() && getManagedProfileUserId() != UserHandle.USER_NULL;
}
@Override
@@ -124,7 +125,7 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
@Override
public boolean isAlwaysOnVpnSetInManagedProfile() {
final int managedProfileUserId = getManagedProfileUserId();
return managedProfileUserId != -1 &&
return managedProfileUserId != UserHandle.USER_NULL &&
VpnUtils.isAlwaysOnVpnSet(mCm, managedProfileUserId);
}
@@ -133,6 +134,28 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
return mCm.getGlobalProxy() != null;
}
@Override
public int getMaximumFailedPasswordsBeforeWipeInPrimaryUser() {
final ComponentName deviceOwner = mDpm.getDeviceOwnerComponentOnAnyUser();
if (deviceOwner == null) {
return 0;
}
return mDpm.getMaximumFailedPasswordsForWipe(deviceOwner, mDpm.getDeviceOwnerUserId());
}
@Override
public int getMaximumFailedPasswordsBeforeWipeInManagedProfile() {
final int userId = getManagedProfileUserId();
if (userId == UserHandle.USER_NULL) {
return 0;
}
final ComponentName profileOwner = mDpm.getProfileOwnerAsUser(userId);
if (profileOwner == null) {
return 0;
}
return mDpm.getMaximumFailedPasswordsForWipe(profileOwner, userId);
}
protected static class EnterprisePrivacySpan extends ClickableSpan {
private final Context mContext;