Support default, pattern, pin and password encryption types

Use plumbing provided by dependant change to bring up correct dialog
at boot time.

Needs matching framework changes from
 https://googleplex-android-review.googlesource.com/#/c/412885/

Bug: 8769627
Change-Id: Ib04a2875e051a7cccca035fadb25978dfec22491
This commit is contained in:
Paul Lawrence
2014-02-04 10:22:19 -08:00
parent c94122a199
commit b05f39d186
6 changed files with 241 additions and 44 deletions

View File

@@ -226,20 +226,7 @@ public class ChooseLockGeneric extends SettingsActivity {
private int upgradeQuality(int quality, MutableBoolean allowBiometric) {
quality = upgradeQualityForDPM(quality);
quality = upgradeQualityForKeyStore(quality);
int encryptionQuality = upgradeQualityForEncryption(quality);
if (encryptionQuality > quality) {
//The first case checks whether biometric is allowed, prior to the user making
//their selection from the list
if (allowBiometric != null) {
allowBiometric.value = quality <=
DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK;
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK) {
//When the user has selected biometric we shouldn't change that due to
//encryption
return quality;
}
}
return encryptionQuality;
return quality;
}
private int upgradeQualityForDPM(int quality) {
@@ -251,27 +238,6 @@ public class ChooseLockGeneric extends SettingsActivity {
return quality;
}
/**
* Mix in "encryption minimums" to any given quality value. This prevents users
* from downgrading the pattern/pin/password to a level below the minimums.
*
* ASSUMPTION: Setting quality is sufficient (e.g. minimum lengths will be set
* appropriately.)
*/
private int upgradeQualityForEncryption(int quality) {
// Don't upgrade quality for secondary users. Encryption requirements don't apply.
if (!Process.myUserHandle().equals(UserHandle.OWNER)) return quality;
int encryptionStatus = mDPM.getStorageEncryptionStatus();
boolean encrypted = (encryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE)
|| (encryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING);
if (encrypted) {
if (quality < CryptKeeperSettings.MIN_PASSWORD_QUALITY) {
quality = CryptKeeperSettings.MIN_PASSWORD_QUALITY;
}
}
return quality;
}
private int upgradeQualityForKeyStore(int quality) {
if (!mKeyStore.isEmpty()) {
if (quality < CredentialStorage.MIN_PASSWORD_QUALITY) {