Search in sources :

Example 1 with ProcessMap

use of com.android.internal.app.ProcessMap in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ProcStatsData method getProcs.

private ArrayList<ProcStatsEntry> getProcs(ProcessDataCollection bgTotals, ProcessDataCollection runTotals) {
    final ArrayList<ProcStatsEntry> procEntries = new ArrayList<>();
    if (DEBUG)
        Log.d(TAG, "-------------------- PULLING PROCESSES");
    final ProcessMap<ProcStatsEntry> entriesMap = new ProcessMap<ProcStatsEntry>();
    for (int ipkg = 0, N = mStats.mPackages.getMap().size(); ipkg < N; ipkg++) {
        final SparseArray<SparseArray<ProcessStats.PackageState>> pkgUids = mStats.mPackages.getMap().valueAt(ipkg);
        for (int iu = 0; iu < pkgUids.size(); iu++) {
            final SparseArray<ProcessStats.PackageState> vpkgs = pkgUids.valueAt(iu);
            for (int iv = 0; iv < vpkgs.size(); iv++) {
                final ProcessStats.PackageState st = vpkgs.valueAt(iv);
                for (int iproc = 0; iproc < st.mProcesses.size(); iproc++) {
                    final ProcessState pkgProc = st.mProcesses.valueAt(iproc);
                    final ProcessState proc = mStats.mProcesses.get(pkgProc.getName(), pkgProc.getUid());
                    if (proc == null) {
                        Log.w(TAG, "No process found for pkg " + st.mPackageName + "/" + st.mUid + " proc name " + pkgProc.getName());
                        continue;
                    }
                    ProcStatsEntry ent = entriesMap.get(proc.getName(), proc.getUid());
                    if (ent == null) {
                        ent = new ProcStatsEntry(proc, st.mPackageName, bgTotals, runTotals, mUseUss);
                        if (ent.mRunWeight > 0) {
                            if (DEBUG)
                                Log.d(TAG, "Adding proc " + proc.getName() + "/" + proc.getUid() + ": time=" + ProcessStatsUi.makeDuration(ent.mRunDuration) + " (" + ((((double) ent.mRunDuration) / memTotalTime) * 100) + "%)" + " pss=" + ent.mAvgRunMem);
                            entriesMap.put(proc.getName(), proc.getUid(), ent);
                            procEntries.add(ent);
                        }
                    } else {
                        ent.addPackage(st.mPackageName);
                    }
                }
            }
        }
    }
    if (DEBUG)
        Log.d(TAG, "-------------------- MAPPING SERVICES");
    // Add in service info.
    for (int ip = 0, N = mStats.mPackages.getMap().size(); ip < N; ip++) {
        SparseArray<SparseArray<ProcessStats.PackageState>> uids = mStats.mPackages.getMap().valueAt(ip);
        for (int iu = 0; iu < uids.size(); iu++) {
            SparseArray<ProcessStats.PackageState> vpkgs = uids.valueAt(iu);
            for (int iv = 0; iv < vpkgs.size(); iv++) {
                ProcessStats.PackageState ps = vpkgs.valueAt(iv);
                for (int is = 0, NS = ps.mServices.size(); is < NS; is++) {
                    ServiceState ss = ps.mServices.valueAt(is);
                    if (ss.getProcessName() != null) {
                        ProcStatsEntry ent = entriesMap.get(ss.getProcessName(), uids.keyAt(iu));
                        if (ent != null) {
                            if (DEBUG)
                                Log.d(TAG, "Adding service " + ps.mPackageName + "/" + ss.getName() + "/" + uids.keyAt(iu) + " to proc " + ss.getProcessName());
                            ent.addService(ss);
                        } else {
                            Log.w(TAG, "No process " + ss.getProcessName() + "/" + uids.keyAt(iu) + " for service " + ss.getName());
                        }
                    }
                }
            }
        }
    }
    return procEntries;
}
Also used : IProcessStats(com.android.internal.app.procstats.IProcessStats) ProcessStats(com.android.internal.app.procstats.ProcessStats) ServiceState(com.android.internal.app.procstats.ServiceState) ArrayList(java.util.ArrayList) ProcessState(com.android.internal.app.procstats.ProcessState) SparseArray(android.util.SparseArray) ProcessMap(com.android.internal.app.ProcessMap)

Aggregations

SparseArray (android.util.SparseArray)1 ProcessMap (com.android.internal.app.ProcessMap)1 IProcessStats (com.android.internal.app.procstats.IProcessStats)1 ProcessState (com.android.internal.app.procstats.ProcessState)1 ProcessStats (com.android.internal.app.procstats.ProcessStats)1 ServiceState (com.android.internal.app.procstats.ServiceState)1 ArrayList (java.util.ArrayList)1