More memory updates
- Some string changes - Make processes in memory details not clickable - Put processes in a 'detail' category - Hide processes when an app only has 1 - Add memory item to bottom of app info page Bug: 20694769 Change-Id: Ifbe2205aeef230e44752d075578524249b30bdf8
This commit is contained in:
@@ -6664,6 +6664,21 @@
|
|||||||
<!-- Label for maximum memory use section [CHAR LIMIT=30] -->
|
<!-- Label for maximum memory use section [CHAR LIMIT=30] -->
|
||||||
<string name="maximum_memory_use">Maximum memory use</string>
|
<string name="maximum_memory_use">Maximum memory use</string>
|
||||||
|
|
||||||
|
<!-- Label for app list of memory use [CHAR LIMIT=30] -->
|
||||||
|
<string name="memory_usage">Memory usage</string>
|
||||||
|
|
||||||
|
<!-- Label for app list of memory use [CHAR LIMIT=30] -->
|
||||||
|
<string name="app_list_memory_use">App usage</string>
|
||||||
|
|
||||||
|
<!-- Label for details about an app's memory use [CHAR LIMIT=30] -->
|
||||||
|
<string name="memory_details">Details</string>
|
||||||
|
|
||||||
|
<!-- Summary for how much memory an app has used [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="memory_use_summary"><xliff:g id="size" example="30MB">%1$s</xliff:g> avg memory used in last 3 hours</string>
|
||||||
|
|
||||||
|
<!-- Summary for no memory use for an app [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="no_memory_use_summary">No memory used in last 3 hours</string>
|
||||||
|
|
||||||
<!-- Menu item for Sorting list by average memory use [CHAR LIMIT=NONE]-->
|
<!-- Menu item for Sorting list by average memory use [CHAR LIMIT=NONE]-->
|
||||||
<string name="sort_avg_use">Sort by avg use</string>
|
<string name="sort_avg_use">Sort by avg use</string>
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:title="@string/memory_details_title">
|
android:title="@string/memory_usage">
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/average_memory_use" />
|
android:title="@string/average_memory_use" />
|
||||||
@@ -36,7 +36,8 @@
|
|||||||
android:layout="@layout/horizontal_preference"
|
android:layout="@layout/horizontal_preference"
|
||||||
android:title="@string/memory_maximum_usage" />
|
android:title="@string/memory_maximum_usage" />
|
||||||
|
|
||||||
<com.android.settings.applications.SpacePreference
|
<PreferenceCategory
|
||||||
android:layout_height="15dp" />
|
android:key="processes"
|
||||||
|
android:title="@string/memory_details" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -51,4 +51,10 @@
|
|||||||
android:title="@string/power_usage_summary_title"
|
android:title="@string/power_usage_summary_title"
|
||||||
android:selectable="true" />
|
android:selectable="true" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="memory"
|
||||||
|
android:title="@string/memory_settings_title"
|
||||||
|
android:enabled="false"
|
||||||
|
android:selectable="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -115,6 +115,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
private static final String KEY_DATA = "data_settings";
|
private static final String KEY_DATA = "data_settings";
|
||||||
private static final String KEY_LAUNCH = "preferred_settings";
|
private static final String KEY_LAUNCH = "preferred_settings";
|
||||||
private static final String KEY_BATTERY = "battery";
|
private static final String KEY_BATTERY = "battery";
|
||||||
|
private static final String KEY_MEMORY = "memory";
|
||||||
|
|
||||||
private final HashSet<String> mHomePackages = new HashSet<String>();
|
private final HashSet<String> mHomePackages = new HashSet<String>();
|
||||||
|
|
||||||
@@ -130,6 +131,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
private Preference mPermissionsPreference;
|
private Preference mPermissionsPreference;
|
||||||
private Preference mLaunchPreference;
|
private Preference mLaunchPreference;
|
||||||
private Preference mDataPreference;
|
private Preference mDataPreference;
|
||||||
|
private Preference mMemoryPreference;
|
||||||
|
|
||||||
private boolean mDisableAfterUninstall;
|
private boolean mDisableAfterUninstall;
|
||||||
// Used for updating notification preference.
|
// Used for updating notification preference.
|
||||||
@@ -143,6 +145,9 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
private BatteryStatsHelper mBatteryHelper;
|
private BatteryStatsHelper mBatteryHelper;
|
||||||
private BatterySipper mSipper;
|
private BatterySipper mSipper;
|
||||||
|
|
||||||
|
protected ProcStatsData mStatsManager;
|
||||||
|
protected ProcStatsPackageEntry mStats;
|
||||||
|
|
||||||
private boolean handleDisableable(Button button) {
|
private boolean handleDisableable(Button button) {
|
||||||
boolean disableable = false;
|
boolean disableable = false;
|
||||||
// Try to prevent the user from bricking their phone
|
// Try to prevent the user from bricking their phone
|
||||||
@@ -260,6 +265,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
mDataCallbacks);
|
mDataCallbacks);
|
||||||
}
|
}
|
||||||
new BatteryUpdater().execute();
|
new BatteryUpdater().execute();
|
||||||
|
new MemoryUpdater().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -295,6 +301,8 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
mBatteryPreference = findPreference(KEY_BATTERY);
|
mBatteryPreference = findPreference(KEY_BATTERY);
|
||||||
mBatteryPreference.setEnabled(false);
|
mBatteryPreference.setEnabled(false);
|
||||||
mBatteryPreference.setOnPreferenceClickListener(this);
|
mBatteryPreference.setOnPreferenceClickListener(this);
|
||||||
|
mMemoryPreference = findPreference(KEY_MEMORY);
|
||||||
|
mMemoryPreference.setOnPreferenceClickListener(this);
|
||||||
|
|
||||||
mLaunchPreference = findPreference(KEY_LAUNCH);
|
mLaunchPreference = findPreference(KEY_LAUNCH);
|
||||||
if (mAppEntry.info != null) {
|
if (mAppEntry.info != null) {
|
||||||
@@ -701,6 +709,9 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
startManagePermissionsActivity();
|
startManagePermissionsActivity();
|
||||||
} else if (preference == mLaunchPreference) {
|
} else if (preference == mLaunchPreference) {
|
||||||
startAppInfoFragment(AppLaunchSettings.class, mLaunchPreference.getTitle());
|
startAppInfoFragment(AppLaunchSettings.class, mLaunchPreference.getTitle());
|
||||||
|
} else if (preference == mMemoryPreference) {
|
||||||
|
ProcessStatsBase.launchMemoryDetail((SettingsActivity) getActivity(),
|
||||||
|
mStatsManager.getMemInfo(), mStats);
|
||||||
} else if (preference == mDataPreference) {
|
} else if (preference == mDataPreference) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(DataUsageSummary.EXTRA_SHOW_APP_IMMEDIATE_PKG,
|
args.putString(DataUsageSummary.EXTRA_SHOW_APP_IMMEDIATE_PKG,
|
||||||
@@ -767,6 +778,49 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class MemoryUpdater extends AsyncTask<Void, Void, ProcStatsPackageEntry> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ProcStatsPackageEntry doInBackground(Void... params) {
|
||||||
|
if (mPackageInfo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (mStatsManager == null) {
|
||||||
|
mStatsManager = new ProcStatsData(getActivity(), false);
|
||||||
|
mStatsManager.setDuration(ProcessStatsBase.sDurations[0]);
|
||||||
|
}
|
||||||
|
mStatsManager.refreshStats(true);
|
||||||
|
for (ProcStatsPackageEntry pkgEntry : mStatsManager.getEntries()) {
|
||||||
|
for (ProcStatsEntry entry : pkgEntry.mEntries) {
|
||||||
|
if (entry.mUid == mPackageInfo.applicationInfo.uid) {
|
||||||
|
pkgEntry.updateMetrics();
|
||||||
|
return pkgEntry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(ProcStatsPackageEntry entry) {
|
||||||
|
if (getActivity() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (entry != null) {
|
||||||
|
mStats = entry;
|
||||||
|
mMemoryPreference.setEnabled(true);
|
||||||
|
double amount = Math.max(entry.mRunWeight, entry.mBgWeight)
|
||||||
|
* mStatsManager.getMemInfo().weightToRam;
|
||||||
|
mMemoryPreference.setSummary(getString(R.string.memory_use_summary,
|
||||||
|
Formatter.formatShortFileSize(getContext(), (long) amount)));
|
||||||
|
} else {
|
||||||
|
mMemoryPreference.setEnabled(false);
|
||||||
|
mMemoryPreference.setSummary(getString(R.string.no_memory_use_summary));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private class BatteryUpdater extends AsyncTask<Void, Void, Void> {
|
private class BatteryUpdater extends AsyncTask<Void, Void, Void> {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
@@ -787,6 +841,9 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void result) {
|
protected void onPostExecute(Void result) {
|
||||||
|
if (getActivity() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
refreshUi();
|
refreshUi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,14 +18,16 @@ package com.android.settings.applications;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
import com.android.internal.app.ProcessStats;
|
import com.android.internal.app.ProcessStats;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
import com.android.settings.applications.ProcStatsData.MemInfo;
|
||||||
|
|
||||||
public abstract class ProcessStatsBase extends SettingsPreferenceFragment
|
public abstract class ProcessStatsBase extends SettingsPreferenceFragment
|
||||||
implements OnItemSelectedListener {
|
implements OnItemSelectedListener {
|
||||||
@@ -124,4 +126,17 @@ public abstract class ProcessStatsBase extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract void refreshUi();
|
public abstract void refreshUi();
|
||||||
|
|
||||||
|
public static void launchMemoryDetail(SettingsActivity activity, MemInfo memInfo,
|
||||||
|
ProcStatsPackageEntry entry) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putParcelable(ProcessStatsDetail.EXTRA_PACKAGE_ENTRY, entry);
|
||||||
|
args.putDouble(ProcessStatsDetail.EXTRA_WEIGHT_TO_RAM, memInfo.weightToRam);
|
||||||
|
args.putLong(ProcessStatsDetail.EXTRA_TOTAL_TIME, memInfo.memTotalTime);
|
||||||
|
args.putDouble(ProcessStatsDetail.EXTRA_MAX_MEMORY_USAGE,
|
||||||
|
memInfo.usedWeight * memInfo.weightToRam);
|
||||||
|
args.putDouble(ProcessStatsDetail.EXTRA_TOTAL_SCALE, memInfo.totalScale);
|
||||||
|
activity.startPreferencePanel(ProcessStatsDetail.class.getName(), args,
|
||||||
|
R.string.memory_usage, null, null, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -74,6 +74,8 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
|||||||
private static final String KEY_FREQUENCY = "frequency";
|
private static final String KEY_FREQUENCY = "frequency";
|
||||||
private static final String KEY_MAX_USAGE = "max_usage";
|
private static final String KEY_MAX_USAGE = "max_usage";
|
||||||
|
|
||||||
|
private static final String KEY_PROCS = "processes";
|
||||||
|
|
||||||
private final ArrayMap<ComponentName, CancellablePreference> mServiceMap = new ArrayMap<>();
|
private final ArrayMap<ComponentName, CancellablePreference> mServiceMap = new ArrayMap<>();
|
||||||
|
|
||||||
private PackageManager mPm;
|
private PackageManager mPm;
|
||||||
@@ -92,6 +94,8 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
private double mTotalScale;
|
private double mTotalScale;
|
||||||
|
|
||||||
|
private PreferenceCategory mProcGroup;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
@@ -172,6 +176,7 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
|||||||
private void createDetails() {
|
private void createDetails() {
|
||||||
addPreferencesFromResource(R.xml.app_memory_settings);
|
addPreferencesFromResource(R.xml.app_memory_settings);
|
||||||
|
|
||||||
|
mProcGroup = (PreferenceCategory) findPreference(KEY_PROCS);
|
||||||
fillProcessesSection();
|
fillProcessesSection();
|
||||||
|
|
||||||
LayoutPreference headerLayout = (LayoutPreference) findPreference(KEY_DETAILS_HEADER);
|
LayoutPreference headerLayout = (LayoutPreference) findPreference(KEY_DETAILS_HEADER);
|
||||||
@@ -227,6 +232,7 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void fillProcessesSection() {
|
private void fillProcessesSection() {
|
||||||
|
mProcGroup.removeAll();
|
||||||
final ArrayList<ProcStatsEntry> entries = new ArrayList<>();
|
final ArrayList<ProcStatsEntry> entries = new ArrayList<>();
|
||||||
for (int ie = 0; ie < mApp.mEntries.size(); ie++) {
|
for (int ie = 0; ie < mApp.mEntries.size(); ie++) {
|
||||||
ProcStatsEntry entry = mApp.mEntries.get(ie);
|
ProcStatsEntry entry = mApp.mEntries.get(ie);
|
||||||
@@ -242,6 +248,7 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
|||||||
ProcStatsEntry entry = entries.get(ie);
|
ProcStatsEntry entry = entries.get(ie);
|
||||||
Preference processPref = new Preference(getActivity());
|
Preference processPref = new Preference(getActivity());
|
||||||
processPref.setTitle(entry.mLabel);
|
processPref.setTitle(entry.mLabel);
|
||||||
|
processPref.setSelectable(false);
|
||||||
|
|
||||||
long duration = Math.max(entry.mRunDuration, entry.mBgDuration);
|
long duration = Math.max(entry.mRunDuration, entry.mBgDuration);
|
||||||
long memoryUse = Math.max((long) (entry.mRunWeight * mWeightToRam),
|
long memoryUse = Math.max((long) (entry.mRunWeight * mWeightToRam),
|
||||||
@@ -251,7 +258,10 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
|||||||
/ (float) mTotalTime, getActivity());
|
/ (float) mTotalTime, getActivity());
|
||||||
processPref.setSummary(
|
processPref.setSummary(
|
||||||
getString(R.string.memory_use_running_format, memoryString, frequency));
|
getString(R.string.memory_use_running_format, memoryString, frequency));
|
||||||
getPreferenceScreen().addPreference(processPref);
|
mProcGroup.addPreference(processPref);
|
||||||
|
}
|
||||||
|
if (mProcGroup.getPreferenceCount() < 2) {
|
||||||
|
getPreferenceScreen().removePreference(mProcGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,7 +112,8 @@ public class ProcessStatsSummary extends ProcessStatsBase implements OnPreferenc
|
|||||||
args.putBoolean(ARG_TRANSFER_STATS, true);
|
args.putBoolean(ARG_TRANSFER_STATS, true);
|
||||||
args.putInt(ARG_DURATION_INDEX, mDurationIndex);
|
args.putInt(ARG_DURATION_INDEX, mDurationIndex);
|
||||||
mStatsManager.xferStats();
|
mStatsManager.xferStats();
|
||||||
startFragment(this, ProcessStatsUi.class.getName(), R.string.app_memory_use, 0, args);
|
startFragment(this, ProcessStatsUi.class.getName(), R.string.app_list_memory_use, 0,
|
||||||
|
args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -106,19 +106,9 @@ public class ProcessStatsUi extends ProcessStatsBase {
|
|||||||
if (!(preference instanceof ProcessStatsPreference)) {
|
if (!(preference instanceof ProcessStatsPreference)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessStatsPreference pgp = (ProcessStatsPreference) preference;
|
ProcessStatsPreference pgp = (ProcessStatsPreference) preference;
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putParcelable(ProcessStatsDetail.EXTRA_PACKAGE_ENTRY, pgp.getEntry());
|
|
||||||
MemInfo memInfo = mStatsManager.getMemInfo();
|
MemInfo memInfo = mStatsManager.getMemInfo();
|
||||||
args.putDouble(ProcessStatsDetail.EXTRA_WEIGHT_TO_RAM,
|
launchMemoryDetail((SettingsActivity) getActivity(), memInfo, pgp.getEntry());
|
||||||
memInfo.weightToRam);
|
|
||||||
args.putLong(ProcessStatsDetail.EXTRA_TOTAL_TIME, memInfo.memTotalTime);
|
|
||||||
args.putDouble(ProcessStatsDetail.EXTRA_MAX_MEMORY_USAGE,
|
|
||||||
memInfo.usedWeight * memInfo.weightToRam);
|
|
||||||
args.putDouble(ProcessStatsDetail.EXTRA_TOTAL_SCALE, memInfo.totalScale);
|
|
||||||
((SettingsActivity) getActivity()).startPreferencePanel(
|
|
||||||
ProcessStatsDetail.class.getName(), args, R.string.details_title, null, null, 0);
|
|
||||||
|
|
||||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||||
}
|
}
|
||||||
@@ -153,6 +143,7 @@ public class ProcessStatsUi extends ProcessStatsBase {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void refreshUi() {
|
public void refreshUi() {
|
||||||
mAppListGroup.removeAll();
|
mAppListGroup.removeAll();
|
||||||
mAppListGroup.setOrderingAsAdded(false);
|
mAppListGroup.setOrderingAsAdded(false);
|
||||||
|
Reference in New Issue
Block a user