Merge "BatteryManager support dock charging 2/2"
This commit is contained in:
committed by
Android (Google) Code Review
commit
92d4b9f795
@@ -30288,6 +30288,7 @@ package android.os {
|
||||
field public static final int BATTERY_HEALTH_UNKNOWN = 1; // 0x1
|
||||
field public static final int BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6; // 0x6
|
||||
field public static final int BATTERY_PLUGGED_AC = 1; // 0x1
|
||||
field public static final int BATTERY_PLUGGED_DOCK = 8; // 0x8
|
||||
field public static final int BATTERY_PLUGGED_USB = 2; // 0x2
|
||||
field public static final int BATTERY_PLUGGED_WIRELESS = 4; // 0x4
|
||||
field public static final int BATTERY_PROPERTY_CAPACITY = 4; // 0x4
|
||||
|
||||
@@ -187,10 +187,13 @@ public class BatteryManager {
|
||||
public static final int BATTERY_PLUGGED_USB = OsProtoEnums.BATTERY_PLUGGED_USB; // = 2
|
||||
/** Power source is wireless. */
|
||||
public static final int BATTERY_PLUGGED_WIRELESS = OsProtoEnums.BATTERY_PLUGGED_WIRELESS; // = 4
|
||||
/** Power source is dock. */
|
||||
public static final int BATTERY_PLUGGED_DOCK = OsProtoEnums.BATTERY_PLUGGED_DOCK; // = 8
|
||||
|
||||
/** @hide */
|
||||
public static final int BATTERY_PLUGGED_ANY =
|
||||
BATTERY_PLUGGED_AC | BATTERY_PLUGGED_USB | BATTERY_PLUGGED_WIRELESS;
|
||||
BATTERY_PLUGGED_AC | BATTERY_PLUGGED_USB | BATTERY_PLUGGED_WIRELESS
|
||||
| BATTERY_PLUGGED_DOCK;
|
||||
|
||||
/**
|
||||
* Sent when the device's battery has started charging (or has reached full charge
|
||||
|
||||
@@ -88,14 +88,15 @@ public class BatteryStatus {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the device is plugged in (USB, power, or wireless).
|
||||
* Determine whether the device is plugged in (USB, power, wireless or dock).
|
||||
*
|
||||
* @return true if the device is plugged in.
|
||||
*/
|
||||
public boolean isPluggedIn() {
|
||||
return plugged == BatteryManager.BATTERY_PLUGGED_AC
|
||||
|| plugged == BatteryManager.BATTERY_PLUGGED_USB
|
||||
|| plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||
|| plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS
|
||||
|| plugged == BatteryManager.BATTERY_PLUGGED_DOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,6 +118,15 @@ public class BatteryStatus {
|
||||
return plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the device is plugged in dock.
|
||||
*
|
||||
* @return true if the device is plugged in dock
|
||||
*/
|
||||
public boolean isPluggedInDock() {
|
||||
return plugged == BatteryManager.BATTERY_PLUGGED_DOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the device is charged. Note that some devices never return 100% for
|
||||
* battery level, so this allows either battery level or status to determine if the
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
<!-- When the lock screen is showing and the phone plugged in, and the battery is not fully charged, say that it's wirelessly charging. [CHAR LIMIT=50] -->
|
||||
<string name="keyguard_plugged_in_wireless"><xliff:g id="percentage" example="20%">%s</xliff:g> • Charging wirelessly</string>
|
||||
|
||||
<!-- When the lock screen is showing and the phone plugged in, and the battery is not fully charged, say that it's dock charging. [CHAR LIMIT=50] -->
|
||||
<string name="keyguard_plugged_in_dock"><xliff:g id="percentage" example="20%">%s</xliff:g> • Charging Dock</string>
|
||||
|
||||
<!-- When the lock screen is showing and the phone plugged in, and the battery
|
||||
is not fully charged, say that it's charging. -->
|
||||
<string name="keyguard_plugged_in"><xliff:g id="percentage">%s</xliff:g> • Charging</string>
|
||||
|
||||
@@ -796,6 +796,9 @@
|
||||
<!-- Indication on the keyguard that is shown when the device is charging slowly. Should match keyguard_plugged_in_charging_slowly [CHAR LIMIT=50]-->
|
||||
<string name="keyguard_indication_charging_time_slowly"><xliff:g id="percentage">%2$s</xliff:g> • Charging slowly • Full in <xliff:g id="charging_time_left" example="4 hr, 2 min">%1$s</xliff:g></string>
|
||||
|
||||
<!-- Indication on the keyguard that is shown when the device is dock charging. [CHAR LIMIT=80]-->
|
||||
<string name="keyguard_indication_charging_time_dock"><xliff:g id="percentage" example="20%">%2$s</xliff:g> • Charging Dock • Full in <xliff:g id="charging_time_left" example="4 hr, 2 min">%1$s</xliff:g></string>
|
||||
|
||||
<!-- Related to user switcher --><skip/>
|
||||
|
||||
<!-- Accessibility label for the button that opens the user switcher. -->
|
||||
|
||||
@@ -151,6 +151,7 @@ public class KeyguardIndicationController {
|
||||
private boolean mPowerPluggedIn;
|
||||
private boolean mPowerPluggedInWired;
|
||||
private boolean mPowerPluggedInWireless;
|
||||
private boolean mPowerPluggedInDock;
|
||||
private boolean mPowerCharged;
|
||||
private boolean mBatteryOverheated;
|
||||
private boolean mEnableBatteryDefender;
|
||||
@@ -786,6 +787,10 @@ public class KeyguardIndicationController {
|
||||
chargingId = hasChargingTime
|
||||
? R.string.keyguard_indication_charging_time_wireless
|
||||
: R.string.keyguard_plugged_in_wireless;
|
||||
} else if (mPowerPluggedInDock) {
|
||||
chargingId = hasChargingTime
|
||||
? R.string.keyguard_indication_charging_time_dock
|
||||
: R.string.keyguard_plugged_in_dock;
|
||||
} else {
|
||||
chargingId = hasChargingTime
|
||||
? R.string.keyguard_indication_charging_time
|
||||
@@ -911,6 +916,7 @@ public class KeyguardIndicationController {
|
||||
boolean wasPluggedIn = mPowerPluggedIn;
|
||||
mPowerPluggedInWired = status.isPluggedInWired() && isChargingOrFull;
|
||||
mPowerPluggedInWireless = status.isPluggedInWireless() && isChargingOrFull;
|
||||
mPowerPluggedInDock = status.isPluggedInDock() && isChargingOrFull;
|
||||
mPowerPluggedIn = status.isPluggedIn() && isChargingOrFull;
|
||||
mPowerCharged = status.isCharged();
|
||||
mChargingWattage = status.maxChargingWattage;
|
||||
|
||||
@@ -323,13 +323,20 @@ public final class BatteryService extends SystemService {
|
||||
if (mHealthInfo.batteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN) {
|
||||
return true;
|
||||
}
|
||||
if ((plugTypeSet & BatteryManager.BATTERY_PLUGGED_AC) != 0 && mHealthInfo.chargerAcOnline) {
|
||||
if ((plugTypeSet & BatteryManager.BATTERY_PLUGGED_AC) != 0
|
||||
&& mHealthInfo.chargerAcOnline) {
|
||||
return true;
|
||||
}
|
||||
if ((plugTypeSet & BatteryManager.BATTERY_PLUGGED_USB) != 0 && mHealthInfo.chargerUsbOnline) {
|
||||
if ((plugTypeSet & BatteryManager.BATTERY_PLUGGED_USB) != 0
|
||||
&& mHealthInfo.chargerUsbOnline) {
|
||||
return true;
|
||||
}
|
||||
if ((plugTypeSet & BatteryManager.BATTERY_PLUGGED_WIRELESS) != 0 && mHealthInfo.chargerWirelessOnline) {
|
||||
if ((plugTypeSet & BatteryManager.BATTERY_PLUGGED_WIRELESS) != 0
|
||||
&& mHealthInfo.chargerWirelessOnline) {
|
||||
return true;
|
||||
}
|
||||
if ((plugTypeSet & BatteryManager.BATTERY_PLUGGED_DOCK) != 0
|
||||
&& mHealthInfo.chargerDockOnline) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -442,6 +449,8 @@ public final class BatteryService extends SystemService {
|
||||
return BatteryManager.BATTERY_PLUGGED_USB;
|
||||
} else if (healthInfo.chargerWirelessOnline) {
|
||||
return BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||
} else if (healthInfo.chargerDockOnline) {
|
||||
return BatteryManager.BATTERY_PLUGGED_DOCK;
|
||||
} else {
|
||||
return BATTERY_PLUGGED_NONE;
|
||||
}
|
||||
@@ -1118,6 +1127,8 @@ public final class BatteryService extends SystemService {
|
||||
batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_USB;
|
||||
} else if (mHealthInfo.chargerWirelessOnline) {
|
||||
batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_WIRELESS;
|
||||
} else if (mHealthInfo.chargerDockOnline) {
|
||||
batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_DOCK;
|
||||
}
|
||||
proto.write(BatteryServiceDumpProto.PLUGGED, batteryPluggedValue);
|
||||
proto.write(
|
||||
|
||||
Reference in New Issue
Block a user