Merge "Power profile improvement: support ambient display"
This commit is contained in:
committed by
Android (Google) Code Review
commit
1bd402b86d
@@ -113,19 +113,20 @@ public class BatterySipper implements Comparable<BatterySipper> {
|
||||
public double bluetoothPowerMah;
|
||||
|
||||
public enum DrainType {
|
||||
IDLE,
|
||||
CELL,
|
||||
PHONE,
|
||||
WIFI,
|
||||
BLUETOOTH,
|
||||
FLASHLIGHT,
|
||||
SCREEN,
|
||||
AMBIENT_DISPLAY,
|
||||
APP,
|
||||
USER,
|
||||
UNACCOUNTED,
|
||||
OVERCOUNTED,
|
||||
BLUETOOTH,
|
||||
CAMERA,
|
||||
MEMORY
|
||||
CELL,
|
||||
FLASHLIGHT,
|
||||
IDLE,
|
||||
MEMORY,
|
||||
OVERCOUNTED,
|
||||
PHONE,
|
||||
SCREEN,
|
||||
UNACCOUNTED,
|
||||
USER,
|
||||
WIFI,
|
||||
}
|
||||
|
||||
public BatterySipper(DrainType drainType, Uid uid, double value) {
|
||||
|
||||
@@ -643,6 +643,21 @@ public class BatteryStatsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ambient display power is the additional power the screen takes while in ambient display/
|
||||
* screen doze/ always-on display (interchangeable terms) mode. Ambient display power should
|
||||
* be hidden {@link #shouldHideSipper(BatterySipper)}, but should not be included in smearing
|
||||
* {@link #removeHiddenBatterySippers(List)}.
|
||||
*/
|
||||
private void addAmbientDisplayUsage() {
|
||||
long ambientDisplayMs = mStats.getScreenDozeTime(mRawRealtimeUs, mStatsType);
|
||||
double power = mPowerProfile.getAveragePower(PowerProfile.POWER_AMBIENT_DISPLAY)
|
||||
* ambientDisplayMs / (60 * 60 * 1000);
|
||||
if (power > 0) {
|
||||
addEntry(DrainType.AMBIENT_DISPLAY, ambientDisplayMs, power);
|
||||
}
|
||||
}
|
||||
|
||||
private void addRadioUsage() {
|
||||
BatterySipper radio = new BatterySipper(BatterySipper.DrainType.CELL, null, 0);
|
||||
mMobileRadioPowerCalculator.calculateRemaining(radio, mStats, mRawRealtimeUs, mRawUptimeUs,
|
||||
@@ -741,6 +756,7 @@ public class BatteryStatsHelper {
|
||||
addUserUsage();
|
||||
addPhoneUsage();
|
||||
addScreenUsage();
|
||||
addAmbientDisplayUsage();
|
||||
addWiFiUsage();
|
||||
addBluetoothUsage();
|
||||
addMemoryUsage();
|
||||
@@ -841,12 +857,13 @@ public class BatteryStatsHelper {
|
||||
final BatterySipper sipper = sippers.get(i);
|
||||
sipper.shouldHide = shouldHideSipper(sipper);
|
||||
if (sipper.shouldHide) {
|
||||
if (sipper.drainType != BatterySipper.DrainType.OVERCOUNTED
|
||||
&& sipper.drainType != BatterySipper.DrainType.SCREEN
|
||||
&& sipper.drainType != BatterySipper.DrainType.UNACCOUNTED
|
||||
&& sipper.drainType != BatterySipper.DrainType.BLUETOOTH
|
||||
&& sipper.drainType != BatterySipper.DrainType.WIFI
|
||||
&& sipper.drainType != BatterySipper.DrainType.IDLE) {
|
||||
if (sipper.drainType != DrainType.OVERCOUNTED
|
||||
&& sipper.drainType != DrainType.SCREEN
|
||||
&& sipper.drainType != DrainType.AMBIENT_DISPLAY
|
||||
&& sipper.drainType != DrainType.UNACCOUNTED
|
||||
&& sipper.drainType != DrainType.BLUETOOTH
|
||||
&& sipper.drainType != DrainType.WIFI
|
||||
&& sipper.drainType != DrainType.IDLE) {
|
||||
// Don't add it if it is overcounted, unaccounted or screen
|
||||
proportionalSmearPowerMah += sipper.totalPowerMah;
|
||||
}
|
||||
@@ -893,13 +910,14 @@ public class BatteryStatsHelper {
|
||||
* Check whether we should hide the battery sipper.
|
||||
*/
|
||||
public boolean shouldHideSipper(BatterySipper sipper) {
|
||||
final BatterySipper.DrainType drainType = sipper.drainType;
|
||||
final DrainType drainType = sipper.drainType;
|
||||
|
||||
return drainType == BatterySipper.DrainType.IDLE
|
||||
|| drainType == BatterySipper.DrainType.CELL
|
||||
|| drainType == BatterySipper.DrainType.SCREEN
|
||||
|| drainType == BatterySipper.DrainType.UNACCOUNTED
|
||||
|| drainType == BatterySipper.DrainType.OVERCOUNTED
|
||||
return drainType == DrainType.IDLE
|
||||
|| drainType == DrainType.CELL
|
||||
|| drainType == DrainType.SCREEN
|
||||
|| drainType == DrainType.AMBIENT_DISPLAY
|
||||
|| drainType == DrainType.UNACCOUNTED
|
||||
|| drainType == DrainType.OVERCOUNTED
|
||||
|| isTypeService(sipper)
|
||||
|| isTypeSystem(sipper);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class PowerProfile {
|
||||
public static final String POWER_MODEM_CONTROLLER_OPERATING_VOLTAGE =
|
||||
"modem.controller.voltage";
|
||||
|
||||
/**
|
||||
/**
|
||||
* Power consumption when GPS is on.
|
||||
*/
|
||||
public static final String POWER_GPS_ON = "gps.on";
|
||||
@@ -136,6 +136,10 @@ public class PowerProfile {
|
||||
@Deprecated
|
||||
public static final String POWER_BLUETOOTH_AT_CMD = "bluetooth.at";
|
||||
|
||||
/**
|
||||
* Power consumption when screen is in doze/ambient/always-on mode, including backlight power.
|
||||
*/
|
||||
public static final String POWER_AMBIENT_DISPLAY = "ambient.on";
|
||||
|
||||
/**
|
||||
* Power consumption when screen is on, not including the backlight power.
|
||||
|
||||
Reference in New Issue
Block a user