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
diff --git a/src/com/android/settings/CryptKeeperSettings.java b/src/com/android/settings/CryptKeeperSettings.java
index a9002fa..41a4be5 100644
--- a/src/com/android/settings/CryptKeeperSettings.java
+++ b/src/com/android/settings/CryptKeeperSettings.java
@@ -63,8 +63,14 @@
             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 );