diff options
Diffstat (limited to 'src/com/android/settings/CryptKeeperSettings.java')
-rw-r--r-- | src/com/android/settings/CryptKeeperSettings.java | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/com/android/settings/CryptKeeperSettings.java b/src/com/android/settings/CryptKeeperSettings.java index 10fa8ac..41a4be5 100644 --- a/src/com/android/settings/CryptKeeperSettings.java +++ b/src/com/android/settings/CryptKeeperSettings.java @@ -37,16 +37,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; -/** - * Confirm and execute a reset of the device to a clean "just out of the box" - * state. Multiple confirmations are required: first, a general "are you sure - * you want to do this?" prompt, followed by a keyguard pattern trace if the user - * has defined one, followed by a final strongly-worded "THIS WILL ERASE EVERYTHING - * ON THE PHONE" prompt. If at any time the phone is allowed to go to sleep, is - * locked, et cetera, then the confirmation sequence is abandoned. - * - * This is the initial screen. - */ public class CryptKeeperSettings extends Fragment { private static final String TAG = "CryptKeeper"; @@ -54,7 +44,7 @@ public class CryptKeeperSettings extends Fragment { // This is the minimum acceptable password quality. If the current password quality is // lower than this, encryption should not be activated. - private static final int MIN_PASSWORD_QUALITY = DevicePolicyManager.PASSWORD_QUALITY_NUMERIC; + static final int MIN_PASSWORD_QUALITY = DevicePolicyManager.PASSWORD_QUALITY_NUMERIC; // Minimum battery charge level (in percent) to launch encryption. If the battery charge is // lower than this, encryption should not be activated. @@ -73,8 +63,14 @@ public class CryptKeeperSettings extends Fragment { if (action.equals(Intent.ACTION_BATTERY_CHANGED)) { int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0); int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0); + int invalidCharger = intent.getIntExtra(BatteryManager.EXTRA_INVALID_CHARGER, 0); + boolean levelOk = level >= MIN_BATTERY_LEVEL; - boolean pluggedOk = plugged == BatteryManager.BATTERY_PLUGGED_AC; + boolean pluggedOk = + (plugged == BatteryManager.BATTERY_PLUGGED_AC || + plugged == BatteryManager.BATTERY_PLUGGED_USB) && + invalidCharger == 0; + // Update UI elements based on power/battery status mInitiateButton.setEnabled(levelOk && pluggedOk); mPowerWarning.setVisibility(pluggedOk ? View.GONE : View.VISIBLE ); @@ -163,7 +159,7 @@ public class CryptKeeperSettings extends Fragment { */ private boolean runKeyguardConfirmation(int request) { // 1. Confirm that we have a sufficient PIN/Password to continue - int quality = new LockPatternUtils(getActivity()).getKeyguardStoredPasswordQuality(); + int quality = new LockPatternUtils(getActivity()).getActivePasswordQuality(); if (quality < MIN_PASSWORD_QUALITY) { return false; } @@ -186,7 +182,7 @@ public class CryptKeeperSettings extends Fragment { // If the user entered a valid keyguard trace, present the final // confirmation prompt; otherwise, go back to the initial state. if (resultCode == Activity.RESULT_OK && data != null) { - String password = data.getStringExtra("password"); + String password = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD); if (!TextUtils.isEmpty(password)) { showFinalConfirmation(password); } |