summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values/arrays.xml17
-rw-r--r--res/values/colors.xml5
-rw-r--r--res/values/strings.xml8
-rw-r--r--src/com/android/settings/applications/ProcStatsData.java11
-rw-r--r--src/com/android/settings/applications/ProcessStatsDetail.java40
-rw-r--r--src/com/android/settings/applications/ProcessStatsPreference.java2
-rw-r--r--src/com/android/settings/applications/ProcessStatsUi.java62
7 files changed, 95 insertions, 50 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 3aff578..d556b1b 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -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>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 1fbfc18..3bcf1ae 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -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>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4ff5090..7467248 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -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 -->
@@ -6624,11 +6621,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>
diff --git a/src/com/android/settings/applications/ProcStatsData.java b/src/com/android/settings/applications/ProcStatsData.java
index 1e32cc9..af7d94d 100644
--- a/src/com/android/settings/applications/ProcStatsData.java
+++ b/src/com/android/settings/applications/ProcStatsData.java
@@ -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;
diff --git a/src/com/android/settings/applications/ProcessStatsDetail.java b/src/com/android/settings/applications/ProcessStatsDetail.java
index 55538bc..7035bf0 100644
--- a/src/com/android/settings/applications/ProcessStatsDetail.java
+++ b/src/com/android/settings/applications/ProcessStatsDetail.java
@@ -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 memoryUse = Math.max((long)(entry.mRunWeight * mWeightToRam),
- (long)(entry.mBgWeight * mWeightToRam));
+ 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
diff --git a/src/com/android/settings/applications/ProcessStatsPreference.java b/src/com/android/settings/applications/ProcessStatsPreference.java
index a1725e3..239e0d3 100644
--- a/src/com/android/settings/applications/ProcessStatsPreference.java
+++ b/src/com/android/settings/applications/ProcessStatsPreference.java
@@ -67,7 +67,7 @@ public class ProcessStatsPreference extends Preference {
setIcon(new ColorDrawable(0));
}
boolean statsForeground = entry.mRunWeight > entry.mBgWeight;
- setSummary(statsForeground ? entry.getRunningFrequency(getContext())
+ setSummary(entry.mRunDuration > entry.mBgDuration ? entry.getRunningFrequency(getContext())
: entry.getBackgroundFrequency(getContext()));
mAvgRatio = (statsForeground ? entry.mAvgRunMem : entry.mAvgBgMem) / maxMemory;
mMaxRatio = (statsForeground ? entry.mMaxRunMem : entry.mMaxBgMem) / maxMemory - mAvgRatio;
diff --git a/src/com/android/settings/applications/ProcessStatsUi.java b/src/com/android/settings/applications/ProcessStatsUi.java
index 96f76c0..fee167a 100644
--- a/src/com/android/settings/applications/ProcessStatsUi.java
+++ b/src/com/android/settings/applications/ProcessStatsUi.java
@@ -16,7 +16,9 @@
package com.android.settings.applications;
+import android.app.AlertDialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.preference.Preference;
@@ -28,7 +30,6 @@ import android.util.TimeUtils;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import android.view.SubMenu;
import android.widget.TextView;
import com.android.internal.app.ProcessStats;
@@ -102,8 +103,6 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
private PreferenceGroup mAppListGroup;
private TextView mMemStatus;
- private long mTotalTime;
-
private long[] mMemTimes = new long[ProcessStats.ADJ_MEM_FACTOR_COUNT];
private LinearColorBar mColors;
private TextView mMemUsed;
@@ -200,7 +199,7 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
args.putBoolean(ProcessStatsDetail.EXTRA_USE_USS, mUseUss);
args.putDouble(ProcessStatsDetail.EXTRA_WEIGHT_TO_RAM,
mStatsManager.getMemInfo().weightToRam);
- args.putLong(ProcessStatsDetail.EXTRA_TOTAL_TIME, mTotalTime);
+ args.putLong(ProcessStatsDetail.EXTRA_TOTAL_TIME, memTotalTime);
args.putFloat(ProcessStatsDetail.EXTRA_MAX_MEMORY_USAGE, mMaxMemoryUsage);
args.putDouble(ProcessStatsDetail.EXTRA_TOTAL_SCALE, mStatsManager.getMemInfo().totalScale);
((SettingsActivity) getActivity()).startPreferencePanel(
@@ -216,11 +215,8 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
.setAlphabeticShortcut('r');
refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM |
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
- SubMenu subMenu = menu.addSubMenu(R.string.menu_proc_stats_duration);
- for (int i=0; i<NUM_DURATIONS; i++) {
- mDurationMenus[i] = subMenu.add(0, MENU_DURATION+i, 0, sDurationLabels[i])
- .setCheckable(true);
- }
+ menu.add(0, MENU_DURATION, 0, R.string.menu_proc_stats_duration);
+
// Hide these for now, until their need is determined.
// mShowPercentageMenu = menu.add(0, MENU_SHOW_PERCENTAGE, 0, R.string.menu_show_percentage)
// .setAlphabeticShortcut('p')
@@ -286,8 +282,7 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- final int id = item.getItemId();
- switch (id) {
+ switch (item.getItemId()) {
case MENU_STATS_REFRESH:
mStatsManager.refreshStats(false);
refreshUi();
@@ -318,13 +313,23 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
}
refreshUi();
return true;
- default:
- if (id >= MENU_DURATION && id < (MENU_DURATION + NUM_DURATIONS)) {
- mStatsManager.setDuration(sDurations[id - MENU_DURATION]);
- refreshUi();
+ case MENU_DURATION:
+ CharSequence[] durations = new CharSequence[sDurationLabels.length];
+ for (int i = 0; i < sDurationLabels.length; i++) {
+ durations[i] = getString(sDurationLabels[i]);
}
- return false;
+ new AlertDialog.Builder(getContext())
+ .setTitle(item.getTitle())
+ .setItems(durations, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mStatsManager.setDuration(sDurations[which]);
+ refreshUi();
+ }
+ }).show();
+ return true;
}
+ return false;
}
/**
@@ -360,7 +365,6 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
private void refreshUi() {
updateMenus();
-
mAppListGroup.removeAll();
mAppListGroup.setOrderingAsAdded(false);
mHeader.setOrder(-1);
@@ -368,12 +372,8 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
final long elapsedTime = mStatsManager.getElapsedTime();
- memTotalTime = mTotalTime;
final Context context = getActivity();
// TODO: More Colors.
- mColors.setColors(context.getColor(R.color.running_processes_apps_ram),
- context.getColor(R.color.running_processes_apps_ram),
- context.getColor(R.color.running_processes_free_ram));
// For computing the ratio to show, we want to count the baseline cached RAM we
// need (at which point we start killing processes) as used RAM, so that if we
@@ -383,30 +383,36 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
// match the real physical RAM, scale those to the actual physical RAM. No problem!
MemInfo memInfo = mStatsManager.getMemInfo();
+ memTotalTime = memInfo.memTotalTime;
+ double usedRam = memInfo.realUsedRam;
+ double totalRam = memInfo.realTotalRam;
+ double freeRam = memInfo.realFreeRam;
String durationString = Utils.formatElapsedTime(context, elapsedTime, false);
- String usedString = Formatter.formatShortFileSize(context, (long) memInfo.realUsedRam);
- String totalString = Formatter.formatShortFileSize(context, (long) memInfo.realTotalRam);
+ String usedString = Formatter.formatShortFileSize(context, (long) usedRam);
+ String totalString = Formatter.formatShortFileSize(context, (long) totalRam);
CharSequence memString;
CharSequence[] memStatesStr = getResources().getTextArray(R.array.ram_states);
int memState = mStatsManager.getMemState();
+ int memColor;
if (memState >= 0 && memState < memStatesStr.length) {
memString = memStatesStr[memState];
+ memColor = getResources().getIntArray(R.array.ram_colors)[memState];
} else {
memString = "?";
+ memColor = context.getColor(R.color.running_processes_apps_ram);
}
+ mColors.setColors(memColor, memColor, context.getColor(R.color.running_processes_free_ram));
if (mShowPercentage) {
mMemUsed.setText(context.getString(
R.string.process_stats_total_duration_percentage,
- Utils.formatPercentage((long) memInfo.realUsedRam, (long) memInfo.realTotalRam),
+ Utils.formatPercentage((long) usedRam, (long) totalRam),
durationString));
} else {
mMemUsed.setText(context.getString(R.string.process_stats_total_duration,
usedString, totalString, durationString));
}
- mMemStatus.setText(context.getString(R.string.process_stats_memory_status,
- memString));
- float usedRatio = (float)(memInfo.realUsedRam
- / (memInfo.realFreeRam + memInfo.realUsedRam));
+ mMemStatus.setText(memString);
+ float usedRatio = (float)(usedRam / (freeRam + usedRam));
mColors.setRatios(usedRatio, 0, 1-usedRatio);
List<ProcStatsPackageEntry> pkgEntries = mStatsManager.getEntries();