Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 966f1c93 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #25817435: Batterystats missing UIDs for secondary users" into nyc-dev

parents 4ce56535 9cfba350
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -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);
                    }
+2 −1
Original line number Diff line number Diff line
@@ -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.
+2 −1
Original line number Diff line number Diff line
@@ -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:");