Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1de52232 authored by Jason Monk's avatar Jason Monk
Browse files

Updates/fixes to memory settings

 - Update memory states to be Good performance, Ok performance, etc.
 - Update header info to be based on history rather than
   instantaneous
 - Color memory bar differently based on state
 - Fix run frequency bucketing to be correct
 - Show dialog for selecting duration, and fix duration selection
 - Update process naming to:
      - If process name is "anything:xxxx" then show "Xxxx"
      - If process name is "com.app.package.interface" then show "Interface"
      - If process name is the package name then show the app name
      - Otherwise fallback to the process name string

Bug: 20694769
Change-Id: Ic1fab28bfd2422bde84dd10bd305a4cc34be98cf
parent 0d2a8d20
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -1222,18 +1222,25 @@
        <item>Always allow</item>
    </string-array>

    <!-- [CHAR LIMIT=30] Labels for memory states -->
    <!-- [CHAR LIMIT=40] Labels for memory states -->
    <string-array name="ram_states">
        <!-- Normal desired memory state. -->
        <item>normal</item>
        <item>Good performance</item>
        <!-- Moderate memory state, not as good as normal. -->
        <item>moderate</item>
        <item>Ok performance</item>
        <!-- Memory is running low. -->
        <item>low</item>
        <item>Poor performance</item>
        <!-- Memory is critical. -->
        <item>critical</item>
        <item>Very poor performance</item>
    </string-array>

    <array name="ram_colors">
        <item>@color/memory_normal</item>
        <item>@color/memory_moderate</item>
        <item>@color/memory_low</item>
        <item>@color/memory_critical</item>
    </array>

    <!-- Display color space adjustment modes for accessibility -->
    <string-array name="daltonizer_type_entries" translatable="false">
        <item>@string/daltonizer_mode_deuteranomaly</item>
+5 −0
Original line number Diff line number Diff line
@@ -87,6 +87,11 @@

    <drawable name="fp_enrollment_header_landscape">#009688</drawable>

    <color name="memory_normal">#ff009587</color>
    <color name="memory_moderate">#ffF3B300</color>
    <color name="memory_low">#ffff9700</color>
    <color name="memory_critical">#ffff5621</color>

    <color name="memory_avg_use">#ff384248</color>
    <color name="memory_max_use">#ff009587</color>
    <color name="memory_remaining">#ffced7db</color>
+1 −7
Original line number Diff line number Diff line
@@ -4223,9 +4223,6 @@
    <string name="process_stats_type_foreground">Foreground</string>
    <!-- [CHAR LIMIT=NONE] Label for process stats, text for stats type -->
    <string name="process_stats_type_cached">Cached</string>
    <!-- [CHAR LIMIT=NONE] Label for process stats, duration of time the stats are over -->
    <string name="process_stats_memory_status">Memory is
        <xliff:g id="memstate">%1$s</xliff:g></string>
    <!-- [CHAR LIMIT=NONE] Label OS "process" app -->
    <string name="process_stats_os_label">Android OS</string>
    <!-- [CHAR LIMIT=NONE] Name of OS "process" for all native processes -->
@@ -6621,11 +6618,8 @@
    <!-- Formatting for memory description [CHAR LIMIT=25] -->
    <string name="memory_use_running_format"><xliff:g id="memory" example="30MB">%1$s</xliff:g> / <xliff:g id="running" example="Always running">%2$s</xliff:g></string>

    <!-- Label for process (singular) [CHAR LIMIT=25] -->
    <string name="process">Process</string>

    <!-- Label for process [CHAR LIMIT=25] -->
    <string name="process_format">Process <xliff:g id="count" example="3">%1$d</xliff:g></string>
    <string name="process_format"><xliff:g id="app_name" example="Settings">%1$s</xliff:g> (<xliff:g id="count" example="3">%2$d</xliff:g>)</string>

    <!-- Label for whether app is allowed to use a lot ef power [CHAR LIMIT=25]-->
    <string name="high_power" translatable="false">High power</string>
+10 −1
Original line number Diff line number Diff line
@@ -101,7 +101,14 @@ public class ProcStatsData {
    }

    public int getMemState() {
        return mMemState;
        int factor = mStats.mMemFactor;
        if (factor == ProcessStats.ADJ_NOTHING) {
            return ProcessStats.ADJ_MEM_FACTOR_NORMAL;
        }
        if (factor >= ProcessStats.ADJ_SCREEN_ON) {
            factor -= ProcessStats.ADJ_SCREEN_ON;
        }
        return factor;
    }

    public MemInfo getMemInfo() {
@@ -318,9 +325,11 @@ public class ProcStatsData {
        double weightToRam;
        double totalRam;
        double totalScale;
        long memTotalTime;

        private MemInfo(Context context, ProcessStats.TotalMemoryUseCollection totalMem,
                long memTotalTime) {
            this.memTotalTime = memTotalTime;
            calculateWeightInfo(context, totalMem, memTotalTime);

            double usedRam = (usedWeight * 1024) / memTotalTime;
+32 −8
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Process;
import android.preference.PreferenceCategory;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.util.ArrayMap;
import android.util.Log;
@@ -241,11 +242,7 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment
            if (entry.mPackage.equals("os")) {
                entry.mLabel = entry.mName;
            } else {
                if (mApp.mEntries.size() > 1) {
                    entry.mLabel = getString(R.string.process_format, (ie + 1));
                } else {
                    entry.mLabel = getString(R.string.process);
                }
                entry.mLabel = getProcessName(mApp.mUiLabel, entry);
            }
            entries.add(entry);
        }
@@ -256,10 +253,11 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment
            processPref.setLayoutResource(R.layout.process_preference_category);
            processPref.setTitle(entry.mLabel);

            long duration = Math.max(entry.mRunDuration, entry.mBgDuration);
            long memoryUse = Math.max((long) (entry.mRunWeight * mWeightToRam),
                    (long) (entry.mBgWeight * mWeightToRam));
            String memoryString = Formatter.formatShortFileSize(getActivity(), memoryUse);
            CharSequence frequency = ProcStatsPackageEntry.getFrequency(entry.mRunDuration
            CharSequence frequency = ProcStatsPackageEntry.getFrequency(duration
                    / (float)mTotalTime, getActivity());
            processPref.setSummary(
                    getString(R.string.memory_use_running_format, memoryString, frequency));
@@ -268,6 +266,32 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment
        }
    }

    private static String capitalize(String processName) {
        char c = processName.charAt(0);
        if (!Character.isLowerCase(c)) {
            return processName;
        }
        return Character.toUpperCase(c) + processName.substring(1);
    }

    private static String getProcessName(String appLabel, ProcStatsEntry entry) {
        String processName = entry.mName;
        if (processName.contains(":")) {
            return capitalize(processName.substring(processName.lastIndexOf(':') + 1));
        }
        if (processName.startsWith(entry.mPackage)) {
            if (processName.length() == entry.mPackage.length()) {
                return appLabel;
            }
            int start = entry.mPackage.length();
            if (processName.charAt(start) == '.') {
                start++;
            }
            return capitalize(processName.substring(start));
        }
        return processName;
    }

    final static Comparator<ProcStatsEntry.Service> sServiceCompare
            = new Comparator<ProcStatsEntry.Service>() {
        @Override
Loading