Search in sources :

Example 1 with MemInfo

use of com.android.settings.applications.ProcStatsData.MemInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ProcessStatsSummary method refreshUi.

@Override
public void refreshUi() {
    Context context = getContext();
    MemInfo memInfo = mStatsManager.getMemInfo();
    double usedRam = memInfo.realUsedRam;
    double totalRam = memInfo.realTotalRam;
    double freeRam = memInfo.realFreeRam;
    BytesResult usedResult = Formatter.formatBytes(context.getResources(), (long) usedRam, Formatter.FLAG_SHORTER);
    String totalString = Formatter.formatShortFileSize(context, (long) totalRam);
    String freeString = Formatter.formatShortFileSize(context, (long) freeRam);
    CharSequence memString;
    CharSequence[] memStatesStr = getResources().getTextArray(R.array.ram_states);
    int memState = mStatsManager.getMemState();
    if (memState >= 0 && memState < memStatesStr.length - 1) {
        memString = memStatesStr[memState];
    } else {
        memString = memStatesStr[memStatesStr.length - 1];
    }
    mSummaryPref.setAmount(usedResult.value);
    mSummaryPref.setUnits(usedResult.units);
    float usedRatio = (float) (usedRam / (freeRam + usedRam));
    mSummaryPref.setRatios(usedRatio, 0, 1 - usedRatio);
    mPerformance.setSummary(memString);
    mTotalMemory.setSummary(totalString);
    mAverageUsed.setSummary(Utils.formatPercentage((long) usedRam, (long) totalRam));
    mFree.setSummary(freeString);
    String durationString = getString(sDurationLabels[mDurationIndex]);
    int numApps = mStatsManager.getEntries().size();
    mAppListPreference.setSummary(getResources().getQuantityString(R.plurals.memory_usage_apps_summary, numApps, numApps, durationString));
}
Also used : Context(android.content.Context) BytesResult(android.text.format.Formatter.BytesResult) MemInfo(com.android.settings.applications.ProcStatsData.MemInfo)

Example 2 with MemInfo

use of com.android.settings.applications.ProcStatsData.MemInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ProcessStatsUi method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(Preference preference) {
    if (!(preference instanceof ProcessStatsPreference)) {
        return false;
    }
    ProcessStatsPreference pgp = (ProcessStatsPreference) preference;
    MemInfo memInfo = mStatsManager.getMemInfo();
    launchMemoryDetail((SettingsActivity) getActivity(), memInfo, pgp.getEntry(), true);
    return super.onPreferenceTreeClick(preference);
}
Also used : MemInfo(com.android.settings.applications.ProcStatsData.MemInfo)

Example 3 with MemInfo

use of com.android.settings.applications.ProcStatsData.MemInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ProcessStatsUi method refreshUi.

@Override
public void refreshUi() {
    mAppListGroup.removeAll();
    mAppListGroup.setOrderingAsAdded(false);
    mAppListGroup.setTitle(mShowMax ? R.string.maximum_memory_use : R.string.average_memory_use);
    final Context context = getActivity();
    MemInfo memInfo = mStatsManager.getMemInfo();
    List<ProcStatsPackageEntry> pkgEntries = mStatsManager.getEntries();
    // Update everything and get the absolute maximum of memory usage for scaling.
    for (int i = 0, N = pkgEntries.size(); i < N; i++) {
        ProcStatsPackageEntry pkg = pkgEntries.get(i);
        pkg.updateMetrics();
    }
    Collections.sort(pkgEntries, mShowMax ? sMaxPackageEntryCompare : sPackageEntryCompare);
    if (DEBUG)
        Log.d(TAG, "-------------------- BUILDING UI");
    double maxMemory = mShowMax ? memInfo.realTotalRam : memInfo.usedWeight * memInfo.weightToRam;
    for (int i = 0; i < pkgEntries.size(); i++) {
        ProcStatsPackageEntry pkg = pkgEntries.get(i);
        ProcessStatsPreference pref = new ProcessStatsPreference(getPrefContext());
        pkg.retrieveUiData(context, mPm);
        pref.init(pkg, mPm, maxMemory, memInfo.weightToRam, memInfo.totalScale, !mShowMax);
        pref.setOrder(i);
        mAppListGroup.addPreference(pref);
    }
}
Also used : Context(android.content.Context) MemInfo(com.android.settings.applications.ProcStatsData.MemInfo)

Aggregations

MemInfo (com.android.settings.applications.ProcStatsData.MemInfo)3 Context (android.content.Context)2 BytesResult (android.text.format.Formatter.BytesResult)1