Fix issues in battery usage accounting
1. In High usage dialog, show top apps based on battery usage, not app time. 2. Refactor the check for hidden system modules into ShouldHideSipper, however don't smear it, this is also the current logic before this CL. Bug: 133445008 Test: RunSettingsRoboTests Change-Id: I851a1c9ef9b79a934ba0501cd96001f2e450bda4
This commit is contained in:
@@ -47,6 +47,7 @@ import com.android.settings.fuelgauge.batterytip.AnomalyInfo;
|
||||
import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
|
||||
import com.android.settings.fuelgauge.batterytip.StatsManagerConfig;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.applications.AppUtils;
|
||||
import com.android.settingslib.fuelgauge.Estimate;
|
||||
import com.android.settingslib.fuelgauge.EstimateKt;
|
||||
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
|
||||
@@ -187,8 +188,10 @@ public class BatteryUtils {
|
||||
&& sipper.drainType != BatterySipper.DrainType.UNACCOUNTED
|
||||
&& sipper.drainType != BatterySipper.DrainType.BLUETOOTH
|
||||
&& sipper.drainType != BatterySipper.DrainType.WIFI
|
||||
&& sipper.drainType != BatterySipper.DrainType.IDLE) {
|
||||
// Don't add it if it is overcounted, unaccounted, wifi, bluetooth, or screen
|
||||
&& sipper.drainType != BatterySipper.DrainType.IDLE
|
||||
&& !isHiddenSystemModule(sipper)) {
|
||||
// Don't add it if it is overcounted, unaccounted, wifi, bluetooth, screen
|
||||
// or hidden system modules
|
||||
proportionalSmearPowerMah += sipper.totalPowerMah;
|
||||
}
|
||||
}
|
||||
@@ -251,7 +254,27 @@ public class BatteryUtils {
|
||||
|| drainType == BatterySipper.DrainType.WIFI
|
||||
|| (sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP
|
||||
|| mPowerUsageFeatureProvider.isTypeService(sipper)
|
||||
|| mPowerUsageFeatureProvider.isTypeSystem(sipper);
|
||||
|| mPowerUsageFeatureProvider.isTypeSystem(sipper)
|
||||
|| isHiddenSystemModule(sipper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code true} if one of packages in {@code sipper} is hidden system modules
|
||||
*/
|
||||
public boolean isHiddenSystemModule(BatterySipper sipper) {
|
||||
if (sipper.uidObj == null) {
|
||||
return false;
|
||||
}
|
||||
sipper.mPackages = mPackageManager.getPackagesForUid(sipper.getUid());
|
||||
if (sipper.mPackages != null) {
|
||||
for (int i = 0, length = sipper.mPackages.length; i < length; i++) {
|
||||
if (AppUtils.isHiddenSystemModule(mContext, sipper.mPackages[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user