package com.android.internal.os;
import android.os.BatteryStats.Uid;
import java.util.List;
public class BatterySipper implements Comparable<BatterySipper> {
public int userId;
public Uid uidObj;
public DrainType drainType;
public double screenPowerMah;
public double proportionalSmearMah;
public double totalSmearedPowerMah;
public double totalPowerMah;
public boolean shouldHide;
public long usageTimeMs;
public double usagePowerMah;
public long audioTimeMs;
public long bluetoothRunningTimeMs;
public long cameraTimeMs;
public long cpuFgTimeMs;
public long cpuTimeMs;
public long flashlightTimeMs;
public long gpsTimeMs;
public long videoTimeMs;
public long wakeLockTimeMs;
public long wifiRunningTimeMs;
public long mobileRxPackets;
public long mobileTxPackets;
public long mobileActive;
public int mobileActiveCount;
public double mobilemspp;
public long wifiRxPackets;
public long wifiTxPackets;
public long mobileRxBytes;
public long mobileTxBytes;
public long wifiRxBytes;
public long wifiTxBytes;
public long btRxBytes;
public long btTxBytes;
public double percent;
public double noCoveragePercent;
public String[] mPackages;
public String packageWithHighestDrain;
public double audioPowerMah;
public double bluetoothPowerMah;
public double cameraPowerMah;
public double cpuPowerMah;
public double flashlightPowerMah;
public double gpsPowerMah;
public double mobileRadioPowerMah;
public double sensorPowerMah;
public double videoPowerMah;
public double wakeLockPowerMah;
public double wifiPowerMah;
public enum DrainType {
AMBIENT_DISPLAY,
APP,
BLUETOOTH,
CAMERA,
CELL,
FLASHLIGHT,
IDLE,
MEMORY,
OVERCOUNTED,
PHONE,
SCREEN,
UNACCOUNTED,
USER,
WIFI,
}
public BatterySipper(DrainType drainType, Uid uid, double value) {
this.totalPowerMah = value;
this.drainType = drainType;
uidObj = uid;
}
public void computeMobilemspp() {
long packets = mobileRxPackets + mobileTxPackets;
mobilemspp = packets > 0 ? (mobileActive / (double) packets) : 0;
}
@Override
public int compareTo(BatterySipper other) {
if (drainType != other.drainType) {
if (drainType == DrainType.OVERCOUNTED) {
return 1;
} else if (other.drainType == DrainType.OVERCOUNTED) {
return -1;
}
}
return Double.compare(other.totalPowerMah, totalPowerMah);
}
public String[] getPackages() {
return mPackages;
}
public int getUid() {
if (uidObj == null) {
return 0;
}
return uidObj.getUid();
}
public void add(BatterySipper other) {
totalPowerMah += other.totalPowerMah;
usageTimeMs += other.usageTimeMs;
usagePowerMah += other.usagePowerMah;
audioTimeMs += other.audioTimeMs;
cpuTimeMs += other.cpuTimeMs;
gpsTimeMs += other.gpsTimeMs;
wifiRunningTimeMs += other.wifiRunningTimeMs;
cpuFgTimeMs += other.cpuFgTimeMs;
videoTimeMs += other.videoTimeMs;
wakeLockTimeMs += other.wakeLockTimeMs;
cameraTimeMs += other.cameraTimeMs;
flashlightTimeMs += other.flashlightTimeMs;
bluetoothRunningTimeMs += other.bluetoothRunningTimeMs;
mobileRxPackets += other.mobileRxPackets;
mobileTxPackets += other.mobileTxPackets;
mobileActive += other.mobileActive;
mobileActiveCount += other.mobileActiveCount;
wifiRxPackets += other.wifiRxPackets;
wifiTxPackets += other.wifiTxPackets;
mobileRxBytes += other.mobileRxBytes;
mobileTxBytes += other.mobileTxBytes;
wifiRxBytes += other.wifiRxBytes;
wifiTxBytes += other.wifiTxBytes;
btRxBytes += other.btRxBytes;
btTxBytes += other.btTxBytes;
audioPowerMah += other.audioPowerMah;
wifiPowerMah += other.wifiPowerMah;
gpsPowerMah += other.gpsPowerMah;
cpuPowerMah += other.cpuPowerMah;
sensorPowerMah += other.sensorPowerMah;
mobileRadioPowerMah += other.mobileRadioPowerMah;
wakeLockPowerMah += other.wakeLockPowerMah;
cameraPowerMah += other.cameraPowerMah;
flashlightPowerMah += other.flashlightPowerMah;
bluetoothPowerMah += other.bluetoothPowerMah;
screenPowerMah += other.screenPowerMah;
videoPowerMah += other.videoPowerMah;
proportionalSmearMah += other.proportionalSmearMah;
totalSmearedPowerMah += other.totalSmearedPowerMah;
}
public double sumPower() {
totalPowerMah = usagePowerMah + wifiPowerMah + gpsPowerMah + cpuPowerMah +
sensorPowerMah + mobileRadioPowerMah + wakeLockPowerMah + cameraPowerMah +
flashlightPowerMah + bluetoothPowerMah + audioPowerMah + videoPowerMah;
totalSmearedPowerMah = totalPowerMah + screenPowerMah + proportionalSmearMah;
return totalPowerMah;
}
}