Search in sources :

Example 1 with Service

use of com.android.settings.applications.ProcStatsEntry.Service in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ProcessStatsDetail method fillServicesSection.

private void fillServicesSection(ProcStatsEntry entry, PreferenceCategory processPref) {
    final HashMap<String, PkgService> pkgServices = new HashMap<>();
    final ArrayList<PkgService> pkgList = new ArrayList<>();
    for (int ip = 0; ip < entry.mServices.size(); ip++) {
        String pkg = entry.mServices.keyAt(ip);
        PkgService psvc = null;
        ArrayList<ProcStatsEntry.Service> services = entry.mServices.valueAt(ip);
        for (int is = services.size() - 1; is >= 0; is--) {
            ProcStatsEntry.Service pent = services.get(is);
            if (pent.mDuration >= mOnePercentTime) {
                if (psvc == null) {
                    psvc = pkgServices.get(pkg);
                    if (psvc == null) {
                        psvc = new PkgService();
                        pkgServices.put(pkg, psvc);
                        pkgList.add(psvc);
                    }
                }
                psvc.mServices.add(pent);
                psvc.mDuration += pent.mDuration;
            }
        }
    }
    Collections.sort(pkgList, sServicePkgCompare);
    for (int ip = 0; ip < pkgList.size(); ip++) {
        ArrayList<ProcStatsEntry.Service> services = pkgList.get(ip).mServices;
        Collections.sort(services, sServiceCompare);
        for (int is = 0; is < services.size(); is++) {
            final ProcStatsEntry.Service service = services.get(is);
            CharSequence label = getLabel(service);
            CancellablePreference servicePref = new CancellablePreference(getPrefContext());
            servicePref.setSelectable(false);
            servicePref.setTitle(label);
            servicePref.setSummary(ProcStatsPackageEntry.getFrequency(service.mDuration / (float) mTotalTime, getActivity()));
            processPref.addPreference(servicePref);
            mServiceMap.put(new ComponentName(service.mPackage, service.mName), servicePref);
        }
    }
}
Also used : CancellablePreference(com.android.settings.CancellablePreference) HashMap(java.util.HashMap) Service(com.android.settings.applications.ProcStatsEntry.Service) ArrayList(java.util.ArrayList) Service(com.android.settings.applications.ProcStatsEntry.Service) ComponentName(android.content.ComponentName)

Aggregations

ComponentName (android.content.ComponentName)1 CancellablePreference (com.android.settings.CancellablePreference)1 Service (com.android.settings.applications.ProcStatsEntry.Service)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1