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

Commit f29ffc29 authored by William Loh's avatar William Loh Committed by Android (Google) Code Review
Browse files

Merge "Add multiuser support to StatsPullAtomService" into tm-dev

parents 6e086786 f587ce8d
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@ import com.android.server.SystemServiceManager;
import com.android.server.am.MemoryStatUtil.MemoryStat;
import com.android.server.health.HealthServiceWrapper;
import com.android.server.notification.NotificationManagerService;
import com.android.server.pm.UserManagerInternal;
import com.android.server.stats.pull.IonMemoryUtil.IonAllocations;
import com.android.server.stats.pull.ProcfsMemoryUtil.MemorySnapshot;
import com.android.server.stats.pull.netstats.NetworkStatsExt;
@@ -4106,11 +4107,24 @@ public class StatsPullAtomService extends SystemService {
            // Incremental is not enabled on this device. The result list will be empty.
            return StatsManager.PULL_SUCCESS;
        }
        List<PackageInfo> installedPackages = pm.getInstalledPackages(0);
        final long token = Binder.clearCallingIdentity();
        try {
            int[] userIds = LocalServices.getService(UserManagerInternal.class).getUserIds();
            for (int userId : userIds) {
                List<PackageInfo> installedPackages = pm.getInstalledPackagesAsUser(0, userId);
                for (PackageInfo pi : installedPackages) {
            if (IncrementalManager.isIncrementalPath(pi.applicationInfo.getBaseCodePath())) {
                pulledData.add(FrameworkStatsLog.buildStatsEvent(atomTag, pi.applicationInfo.uid));
                    if (IncrementalManager.isIncrementalPath(
                            pi.applicationInfo.getBaseCodePath())) {
                        pulledData.add(
                                FrameworkStatsLog.buildStatsEvent(atomTag, pi.applicationInfo.uid));
                    }
                }
            }
        } catch (Exception e) {
            Slog.e(TAG, "failed to pullInstalledIncrementalPackagesLocked", e);
            return StatsManager.PULL_SKIP;
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        return StatsManager.PULL_SUCCESS;
    }