use of com.android.settings.fuelgauge.PowerUsageAdvanced.PowerUsageData.UsageType in project platform_packages_apps_Settings by BlissRoms.
the class PowerUsageAdvanced method parsePowerUsageData.
@VisibleForTesting
List<PowerUsageData> parsePowerUsageData(BatteryStatsHelper statusHelper) {
final List<BatterySipper> batterySippers = statusHelper.getUsageList();
final Map<Integer, PowerUsageData> batteryDataMap = new HashMap<>();
for (@UsageType final Integer type : mUsageTypes) {
batteryDataMap.put(type, new PowerUsageData(type));
}
// Accumulate power usage based on usage type
for (final BatterySipper sipper : batterySippers) {
sipper.mPackages = mPackageManager.getPackagesForUid(sipper.getUid());
final PowerUsageData usageData = batteryDataMap.get(extractUsageType(sipper));
usageData.totalPowerMah += sipper.totalPowerMah;
if (sipper.drainType == DrainType.APP && sipper.usageTimeMs != 0) {
sipper.usageTimeMs = mBatteryUtils.getProcessTimeMs(BatteryUtils.StatusType.FOREGROUND, sipper.uidObj, STATUS_TYPE);
}
usageData.totalUsageTimeMs += sipper.usageTimeMs;
if (shouldShowBatterySipper(sipper)) {
usageData.usageList.add(sipper);
}
}
final List<PowerUsageData> batteryDataList = new ArrayList<>(batteryDataMap.values());
final int dischargeAmount = statusHelper.getStats().getDischargeAmount(STATUS_TYPE);
final double totalPower = statusHelper.getTotalPower();
final double hiddenPower = calculateHiddenPower(batteryDataList);
for (final PowerUsageData usageData : batteryDataList) {
usageData.percentage = mBatteryUtils.calculateBatteryPercent(usageData.totalPowerMah, totalPower, hiddenPower, dischargeAmount);
updateUsageDataSummary(usageData, totalPower, dischargeAmount);
}
Collections.sort(batteryDataList);
mBatteryDataMap = batteryDataMap;
return batteryDataList;
}
use of com.android.settings.fuelgauge.PowerUsageAdvanced.PowerUsageData.UsageType in project platform_packages_apps_Settings by BlissRoms.
the class PowerUsageAdvanced method extractUsageType.
@VisibleForTesting
@UsageType
int extractUsageType(BatterySipper sipper) {
final DrainType drainType = sipper.drainType;
final int uid = sipper.getUid();
if (drainType == DrainType.WIFI) {
return UsageType.WIFI;
} else if (drainType == DrainType.BLUETOOTH) {
return UsageType.BLUETOOTH;
} else if (drainType == DrainType.IDLE) {
return UsageType.IDLE;
} else if (drainType == DrainType.USER) {
return UsageType.USER;
} else if (drainType == DrainType.CELL) {
return UsageType.CELL;
} else if (drainType == DrainType.UNACCOUNTED) {
return UsageType.UNACCOUNTED;
} else if (drainType == DrainType.OVERCOUNTED) {
return UsageType.OVERCOUNTED;
} else if (mPowerUsageFeatureProvider.isTypeSystem(sipper) || mPowerUsageFeatureProvider.isTypeService(sipper)) {
return UsageType.SYSTEM;
} else {
return UsageType.APP;
}
}
Aggregations