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:
@@ -63,8 +63,14 @@ public class CryptKeeperSettings extends Fragment {
|
|||||||
if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
|
if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
|
||||||
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||||
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 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 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
|
// Update UI elements based on power/battery status
|
||||||
mInitiateButton.setEnabled(levelOk && pluggedOk);
|
mInitiateButton.setEnabled(levelOk && pluggedOk);
|
||||||
mPowerWarning.setVisibility(pluggedOk ? View.GONE : View.VISIBLE );
|
mPowerWarning.setVisibility(pluggedOk ? View.GONE : View.VISIBLE );
|
||||||
|
Reference in New Issue
Block a user