am: d6b6709
* commit 'd6b6709b21a99797be472a997ebd18d1d1f25c0f':
Fix issue #25817435: Batterystats missing UIDs for secondary users
This commit is contained in:
@@ -30,6 +30,8 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.telephony.SignalStrength;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.MutableBoolean;
|
||||
import android.util.Pair;
|
||||
import android.util.Printer;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
@@ -5317,26 +5319,28 @@ public abstract class BatteryStats implements Parcelable {
|
||||
}
|
||||
|
||||
if (apps != null) {
|
||||
SparseArray<ArrayList<String>> uids = new SparseArray<ArrayList<String>>();
|
||||
SparseArray<Pair<ArrayList<String>, MutableBoolean>> uids = new SparseArray<>();
|
||||
for (int i=0; i<apps.size(); i++) {
|
||||
ApplicationInfo ai = apps.get(i);
|
||||
ArrayList<String> pkgs = uids.get(ai.uid);
|
||||
Pair<ArrayList<String>, MutableBoolean> pkgs = uids.get(
|
||||
UserHandle.getAppId(ai.uid));
|
||||
if (pkgs == null) {
|
||||
pkgs = new ArrayList<String>();
|
||||
uids.put(ai.uid, pkgs);
|
||||
pkgs = new Pair<>(new ArrayList<String>(), new MutableBoolean(false));
|
||||
uids.put(UserHandle.getAppId(ai.uid), pkgs);
|
||||
}
|
||||
pkgs.add(ai.packageName);
|
||||
pkgs.first.add(ai.packageName);
|
||||
}
|
||||
SparseArray<? extends Uid> uidStats = getUidStats();
|
||||
final int NU = uidStats.size();
|
||||
String[] lineArgs = new String[2];
|
||||
for (int i=0; i<NU; i++) {
|
||||
int uid = uidStats.keyAt(i);
|
||||
ArrayList<String> pkgs = uids.get(uid);
|
||||
if (pkgs != null) {
|
||||
for (int j=0; j<pkgs.size(); j++) {
|
||||
int uid = UserHandle.getAppId(uidStats.keyAt(i));
|
||||
Pair<ArrayList<String>, MutableBoolean> pkgs = uids.get(uid);
|
||||
if (pkgs != null && !pkgs.second.value) {
|
||||
pkgs.second.value = true;
|
||||
for (int j=0; j<pkgs.first.size(); j++) {
|
||||
lineArgs[0] = Integer.toString(uid);
|
||||
lineArgs[1] = pkgs.get(j);
|
||||
lineArgs[1] = pkgs.first.get(j);
|
||||
dumpLine(pw, 0 /* uid */, "i" /* category */, UID_DATA,
|
||||
(Object[])lineArgs);
|
||||
}
|
||||
|
||||
@@ -1170,7 +1170,8 @@ public final class BatteryStatsService extends IBatteryStats.Stub
|
||||
}
|
||||
|
||||
if (useCheckinFormat) {
|
||||
List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(0);
|
||||
List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(
|
||||
PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.MATCH_ALL);
|
||||
if (isRealCheckin) {
|
||||
// For a real checkin, first we want to prefer to use the last complete checkin
|
||||
// file if there is one.
|
||||
|
||||
@@ -4456,7 +4456,8 @@ final class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
if ((permissionNames != null || dumpAll) && ps.pkg.requestedPermissions != null
|
||||
if ((permissionNames != null || dumpAll) && ps.pkg != null
|
||||
&& ps.pkg.requestedPermissions != null
|
||||
&& ps.pkg.requestedPermissions.size() > 0) {
|
||||
final ArrayList<String> perms = ps.pkg.requestedPermissions;
|
||||
pw.print(prefix); pw.println(" requested permissions:");
|
||||
|
||||
Reference in New Issue
Block a user