Check to see if the power source is a valid charger.

This will allow for devices that can be powered
over USB to be encrypted while plugged into USB.

Bug: 4901080
Change-Id: I7eaa2146c1c4e4dfc9724b11a08ff13a16eda117
This commit is contained in:
Jason parks
2011-06-24 14:05:12 -05:00
parent f54f435f1f
commit 4548cdf3a9

View File

@@ -63,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 );