private ProcStatsPackageEntry createOsEntry( ProcessDataCollection bgTotals, ProcessDataCollection runTotals, TotalMemoryUseCollection totalMem, long baseCacheRam) { // Add in fake entry representing the OS itself. ProcStatsPackageEntry osPkg = new ProcStatsPackageEntry("os", memTotalTime); ProcStatsEntry osEntry; if (totalMem.sysMemNativeWeight > 0) { osEntry = new ProcStatsEntry( Utils.OS_PKG, 0, mContext.getString(R.string.process_stats_os_native), memTotalTime, (long) (totalMem.sysMemNativeWeight / memTotalTime)); osEntry.evaluateTargetPackage(mPm, mStats, bgTotals, runTotals, sEntryCompare, mUseUss); osPkg.addEntry(osEntry); } if (totalMem.sysMemKernelWeight > 0) { osEntry = new ProcStatsEntry( Utils.OS_PKG, 0, mContext.getString(R.string.process_stats_os_kernel), memTotalTime, (long) (totalMem.sysMemKernelWeight / memTotalTime)); osEntry.evaluateTargetPackage(mPm, mStats, bgTotals, runTotals, sEntryCompare, mUseUss); osPkg.addEntry(osEntry); } if (totalMem.sysMemZRamWeight > 0) { osEntry = new ProcStatsEntry( Utils.OS_PKG, 0, mContext.getString(R.string.process_stats_os_zram), memTotalTime, (long) (totalMem.sysMemZRamWeight / memTotalTime)); osEntry.evaluateTargetPackage(mPm, mStats, bgTotals, runTotals, sEntryCompare, mUseUss); osPkg.addEntry(osEntry); } if (baseCacheRam > 0) { osEntry = new ProcStatsEntry( Utils.OS_PKG, 0, mContext.getString(R.string.process_stats_os_cache), memTotalTime, baseCacheRam / 1024); osEntry.evaluateTargetPackage(mPm, mStats, bgTotals, runTotals, sEntryCompare, mUseUss); osPkg.addEntry(osEntry); } return osPkg; }
private void createPkgMap( ArrayList<ProcStatsEntry> procEntries, ProcessDataCollection bgTotals, ProcessDataCollection runTotals) { // Combine processes into packages. ArrayMap<String, ProcStatsPackageEntry> pkgMap = new ArrayMap<>(); for (int i = procEntries.size() - 1; i >= 0; i--) { ProcStatsEntry proc = procEntries.get(i); proc.evaluateTargetPackage(mPm, mStats, bgTotals, runTotals, sEntryCompare, mUseUss); ProcStatsPackageEntry pkg = pkgMap.get(proc.mBestTargetPackage); if (pkg == null) { pkg = new ProcStatsPackageEntry(proc.mBestTargetPackage, memTotalTime); pkgMap.put(proc.mBestTargetPackage, pkg); pkgEntries.add(pkg); } pkg.addEntry(proc); } }