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] -->
|
||||
<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]-->
|
||||
<string name="sort_avg_use">Sort by avg use</string>
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/memory_details_title">
|
||||
android:title="@string/memory_usage">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/average_memory_use" />
|
||||
@@ -36,7 +36,8 @@
|
||||
android:layout="@layout/horizontal_preference"
|
||||
android:title="@string/memory_maximum_usage" />
|
||||
|
||||
<com.android.settings.applications.SpacePreference
|
||||
android:layout_height="15dp" />
|
||||
<PreferenceCategory
|
||||
android:key="processes"
|
||||
android:title="@string/memory_details" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -51,4 +51,10 @@
|
||||
android:title="@string/power_usage_summary_title"
|
||||
android:selectable="true" />
|
||||
|
||||
<Preference
|
||||
android:key="memory"
|
||||
android:title="@string/memory_settings_title"
|
||||
android:enabled="false"
|
||||
android:selectable="true" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -115,6 +115,7 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
private static final String KEY_DATA = "data_settings";
|
||||
private static final String KEY_LAUNCH = "preferred_settings";
|
||||
private static final String KEY_BATTERY = "battery";
|
||||
private static final String KEY_MEMORY = "memory";
|
||||
|
||||
private final HashSet<String> mHomePackages = new HashSet<String>();
|
||||
|
||||
@@ -130,6 +131,7 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
private Preference mPermissionsPreference;
|
||||
private Preference mLaunchPreference;
|
||||
private Preference mDataPreference;
|
||||
private Preference mMemoryPreference;
|
||||
|
||||
private boolean mDisableAfterUninstall;
|
||||
// Used for updating notification preference.
|
||||
@@ -143,6 +145,9 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
private BatteryStatsHelper mBatteryHelper;
|
||||
private BatterySipper mSipper;
|
||||
|
||||
protected ProcStatsData mStatsManager;
|
||||
protected ProcStatsPackageEntry mStats;
|
||||
|
||||
private boolean handleDisableable(Button button) {
|
||||
boolean disableable = false;
|
||||
// Try to prevent the user from bricking their phone
|
||||
@@ -260,6 +265,7 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
mDataCallbacks);
|
||||
}
|
||||
new BatteryUpdater().execute();
|
||||
new MemoryUpdater().execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -295,6 +301,8 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
mBatteryPreference = findPreference(KEY_BATTERY);
|
||||
mBatteryPreference.setEnabled(false);
|
||||
mBatteryPreference.setOnPreferenceClickListener(this);
|
||||
mMemoryPreference = findPreference(KEY_MEMORY);
|
||||
mMemoryPreference.setOnPreferenceClickListener(this);
|
||||
|
||||
mLaunchPreference = findPreference(KEY_LAUNCH);
|
||||
if (mAppEntry.info != null) {
|
||||
@@ -701,6 +709,9 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
startManagePermissionsActivity();
|
||||
} else if (preference == mLaunchPreference) {
|
||||
startAppInfoFragment(AppLaunchSettings.class, mLaunchPreference.getTitle());
|
||||
} else if (preference == mMemoryPreference) {
|
||||
ProcessStatsBase.launchMemoryDetail((SettingsActivity) getActivity(),
|
||||
mStatsManager.getMemInfo(), mStats);
|
||||
} else if (preference == mDataPreference) {
|
||||
Bundle args = new Bundle();
|
||||
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> {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
@@ -787,6 +841,9 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
refreshUi();
|
||||
}
|
||||
}
|
||||
|
@@ -18,14 +18,16 @@ package com.android.settings.applications;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import com.android.internal.app.ProcessStats;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.applications.ProcStatsData.MemInfo;
|
||||
|
||||
public abstract class ProcessStatsBase extends SettingsPreferenceFragment
|
||||
implements OnItemSelectedListener {
|
||||
@@ -124,4 +126,17 @@ public abstract class ProcessStatsBase extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
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_MAX_USAGE = "max_usage";
|
||||
|
||||
private static final String KEY_PROCS = "processes";
|
||||
|
||||
private final ArrayMap<ComponentName, CancellablePreference> mServiceMap = new ArrayMap<>();
|
||||
|
||||
private PackageManager mPm;
|
||||
@@ -92,6 +94,8 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
||||
|
||||
private double mTotalScale;
|
||||
|
||||
private PreferenceCategory mProcGroup;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -172,6 +176,7 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
||||
private void createDetails() {
|
||||
addPreferencesFromResource(R.xml.app_memory_settings);
|
||||
|
||||
mProcGroup = (PreferenceCategory) findPreference(KEY_PROCS);
|
||||
fillProcessesSection();
|
||||
|
||||
LayoutPreference headerLayout = (LayoutPreference) findPreference(KEY_DETAILS_HEADER);
|
||||
@@ -227,6 +232,7 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
||||
};
|
||||
|
||||
private void fillProcessesSection() {
|
||||
mProcGroup.removeAll();
|
||||
final ArrayList<ProcStatsEntry> entries = new ArrayList<>();
|
||||
for (int ie = 0; ie < mApp.mEntries.size(); ie++) {
|
||||
ProcStatsEntry entry = mApp.mEntries.get(ie);
|
||||
@@ -242,6 +248,7 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
||||
ProcStatsEntry entry = entries.get(ie);
|
||||
Preference processPref = new Preference(getActivity());
|
||||
processPref.setTitle(entry.mLabel);
|
||||
processPref.setSelectable(false);
|
||||
|
||||
long duration = Math.max(entry.mRunDuration, entry.mBgDuration);
|
||||
long memoryUse = Math.max((long) (entry.mRunWeight * mWeightToRam),
|
||||
@@ -251,7 +258,10 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment {
|
||||
/ (float) mTotalTime, getActivity());
|
||||
processPref.setSummary(
|
||||
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.putInt(ARG_DURATION_INDEX, mDurationIndex);
|
||||
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 false;
|
||||
|
@@ -106,19 +106,9 @@ public class ProcessStatsUi extends ProcessStatsBase {
|
||||
if (!(preference instanceof ProcessStatsPreference)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessStatsPreference pgp = (ProcessStatsPreference) preference;
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable(ProcessStatsDetail.EXTRA_PACKAGE_ENTRY, pgp.getEntry());
|
||||
MemInfo memInfo = mStatsManager.getMemInfo();
|
||||
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);
|
||||
((SettingsActivity) getActivity()).startPreferencePanel(
|
||||
ProcessStatsDetail.class.getName(), args, R.string.details_title, null, null, 0);
|
||||
launchMemoryDetail((SettingsActivity) getActivity(), memInfo, pgp.getEntry());
|
||||
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
@@ -153,6 +143,7 @@ public class ProcessStatsUi extends ProcessStatsBase {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshUi() {
|
||||
mAppListGroup.removeAll();
|
||||
mAppListGroup.setOrderingAsAdded(false);
|
||||
|
Reference in New Issue
Block a user