Use system package name for SYSTEM_UID in the BatteryEntry
Force use the system package for the SYSTEM_UID, since the SYSTEM_UID is used for multiple packages. The getPackageWithHighestDrain() method may get different packages to represent it, since it will use the highest battery drain to represent the SYSTEM_UID if there are multiple packages use the same UID value to make users confuse about the usage data. _ $ adb shell pm list packages --uid 1000 package:android uid:1000 package:com.android.dynsystem uid:1000 package:com.android.frameworks.core.batterystatsviewer uid:1000 package:com.android.inputdevices uid:1000 package:com.android.keychain uid:1000 package:com.android.localtransport uid:1000 package:com.android.location.fused uid:1000 package:com.android.providers.settings uid:1000 package:com.android.server.telecom uid:1000 package:com.android.settings uid:1000 package:com.android.wallpaperbackup uid:1000 Bug: 202682426 Test: make RunSettingsRoboTests -j56 ROBOTEST_FILTER="com.android.settings.fuelgauge" Change-Id: I447bfa1b32037763a2194c0639abcc334c7d8b78
This commit is contained in:
@@ -209,7 +209,8 @@ public class BatteryEntry {
|
||||
if (packages != null && packages.length == 1) {
|
||||
mDefaultPackageName = packages[0];
|
||||
} else {
|
||||
mDefaultPackageName = uidBatteryConsumer.getPackageWithHighestDrain();
|
||||
mDefaultPackageName = isSystemUid(uid)
|
||||
? PACKAGE_SYSTEM : uidBatteryConsumer.getPackageWithHighestDrain();
|
||||
}
|
||||
}
|
||||
if (mDefaultPackageName != null) {
|
||||
@@ -352,13 +353,8 @@ public class BatteryEntry {
|
||||
}
|
||||
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
final String[] packages;
|
||||
if (uid == Process.SYSTEM_UID) {
|
||||
packages = new String[] {PACKAGE_SYSTEM};
|
||||
} else {
|
||||
packages = pm.getPackagesForUid(uid);
|
||||
}
|
||||
|
||||
final String[] packages = isSystemUid(uid)
|
||||
? new String[] {PACKAGE_SYSTEM} : pm.getPackagesForUid(uid);
|
||||
if (packages != null) {
|
||||
final String[] packageLabels = new String[packages.length];
|
||||
System.arraycopy(packages, 0, packageLabels, 0, packages.length);
|
||||
@@ -615,4 +611,8 @@ public class BatteryEntry {
|
||||
}
|
||||
return new NameAndIcon(name, null /* icon */, iconId);
|
||||
}
|
||||
|
||||
private static boolean isSystemUid(int uid) {
|
||||
return uid == Process.SYSTEM_UID;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user