Search in sources :

Example 46 with LongSparseArray

use of android.util.LongSparseArray in project android_packages_apps_Settings by omnirom.

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<LongSparseArray<ProcessStats.PackageState>> pkgUids = mStats.mPackages.getMap().valueAt(ipkg);
        for (int iu = 0; iu < pkgUids.size(); iu++) {
            final LongSparseArray<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) {
                        if (DEBUG)
                            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<LongSparseArray<ProcessStats.PackageState>> uids = mStats.mPackages.getMap().valueAt(ip);
        for (int iu = 0; iu < uids.size(); iu++) {
            LongSparseArray<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 : LongSparseArray(android.util.LongSparseArray) 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) ProcessMap(com.android.internal.app.ProcessMap)

Aggregations

LongSparseArray (android.util.LongSparseArray)46 Field (java.lang.reflect.Field)23 ArrayList (java.util.ArrayList)12 Parcelable (android.os.Parcelable)7 Editable (android.text.Editable)7 View (android.view.View)7 PendingHostUpdate (android.appwidget.PendingHostUpdate)5 ParceledListSlice (android.content.pm.ParceledListSlice)5 Point (android.graphics.Point)5 IAppWidgetHost (com.android.internal.appwidget.IAppWidgetHost)5 Resources (android.content.res.Resources)4 SparseArray (android.util.SparseArray)4 Method (java.lang.reflect.Method)4 ContactEntry (com.android.contacts.common.list.ContactEntry)2 ProcessMap (com.android.internal.app.ProcessMap)2 IProcessStats (com.android.internal.app.procstats.IProcessStats)2 ProcessState (com.android.internal.app.procstats.ProcessState)2 ProcessStats (com.android.internal.app.procstats.ProcessStats)2 ServiceState (com.android.internal.app.procstats.ServiceState)2 Element (de.westnordost.osmapi.map.data.Element)2