diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5c07d45dcca..6cdbc33b336 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1433,9 +1433,9 @@ found in the list of installed applications.
%1$s: select to manage
- Background procs: %1$d
+ Bg: %2$s (%1$d procs)
- Foreground procs: %1$d
+ Fg: %2$s (%1$d procs)
diff --git a/src/com/android/settings/RunningServices.java b/src/com/android/settings/RunningServices.java
index 5593ce95cd3..03168d07c21 100644
--- a/src/com/android/settings/RunningServices.java
+++ b/src/com/android/settings/RunningServices.java
@@ -90,6 +90,8 @@ public class RunningServices extends ListActivity
int mLastNumBackgroundProcesses = -1;
int mLastNumForegroundProcesses = -1;
+ long mLastBackgroundProcessMemory = -1;
+ long mLastForegroundProcessMemory = -1;
Dialog mCurDialog;
@@ -306,36 +308,20 @@ public class RunningServices extends ListActivity
return changed;
}
- boolean updateSize(Context context) {
- boolean changed = false;
-
- if (mPid != 0 && mSize == 0) {
- final int NP = mDependentProcesses.size();
- for (int i=0; i dest) {
+ void addDependentProcesses(ArrayList dest,
+ ArrayList destProc) {
final int NP = mDependentProcesses.size();
for (int i=0; i 0) {
+ destProc.add(proc);
+ }
}
}
}
@@ -382,11 +371,15 @@ public class RunningServices extends ListActivity
= new SparseArray();
final ArrayList mItems = new ArrayList();
+ final ArrayList mProcessItems = new ArrayList();
+ final ArrayList mAllProcessItems = new ArrayList();
int mSequence = 0;
int mNumBackgroundProcesses;
+ long mBackgroundProcessMemory;
int mNumForegroundProcesses;
+ long mForegroundProcessMemory;
boolean update(Context context, ActivityManager am) {
final PackageManager pm = context.getPackageManager();
@@ -439,7 +432,6 @@ public class RunningServices extends ListActivity
proc.mPid = pid;
}
}
- proc.mSize = 0;
proc.mDependentProcesses.clear();
proc.mCurSeq = mSequence;
}
@@ -465,7 +457,6 @@ public class RunningServices extends ListActivity
mRunningProcesses.put(pi.pid, proc);
}
proc.mDependentProcesses.clear();
- proc.mSize = 0;
}
proc.mRunningSeq = mSequence;
proc.mRunningProcessInfo = pi;
@@ -508,25 +499,6 @@ public class RunningServices extends ListActivity
}
}
- // Count number of interesting other (non-active) processes.
- mNumBackgroundProcesses = 0;
- mNumForegroundProcesses = 0;
- NRP = mRunningProcesses.size();
- for (int i=0; i=
- ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND) {
- mNumBackgroundProcesses++;
- } else if (proc.mRunningProcessInfo.importance <=
- ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE) {
- mNumForegroundProcesses++;
- }
- }
- }
-
// Look for services and their primary processes that no longer exist...
for (int i=0; i procs = mProcesses.valueAt(i);
@@ -535,7 +507,6 @@ public class RunningServices extends ListActivity
ProcessItem pi = pit.next();
if (pi.mCurSeq == mSequence) {
pi.ensureLabel(pm);
- changed |= pi.updateSize(context);
if (pi.mPid == 0) {
// Sanity: a non-process can't be dependent on
// anything.
@@ -565,13 +536,17 @@ public class RunningServices extends ListActivity
if (changed) {
mItems.clear();
+ mProcessItems.clear();
for (int i=0; i 0) {
+ mProcessItems.add(pi);
+ }
// And finally the services running in it.
boolean needDivider = false;
for (ServiceItem si : pi.mServices.values()) {
@@ -583,6 +558,57 @@ public class RunningServices extends ListActivity
}
}
+ // Count number of interesting other (non-active) processes, and
+ // build a list of all processes we will retrieve memory for.
+ mAllProcessItems.clear();
+ mAllProcessItems.addAll(mProcessItems);
+ mNumBackgroundProcesses = 0;
+ mNumForegroundProcesses = 0;
+ NRP = mRunningProcesses.size();
+ for (int i=0; i=
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND) {
+ mNumBackgroundProcesses++;
+ mAllProcessItems.add(proc);
+ } else if (proc.mRunningProcessInfo.importance <=
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE) {
+ mNumForegroundProcesses++;
+ mAllProcessItems.add(proc);
+ }
+ }
+ }
+
+ try {
+ mBackgroundProcessMemory = 0;
+ mForegroundProcessMemory = 0;
+ final int numProc = mAllProcessItems.size();
+ int[] pids = new int[numProc];
+ for (int i=0; i=0; i--) {
+ ProcessItem proc = mAllProcessItems.get(i);
+ changed |= proc.updateSize(context, mem[i], mSequence);
+ if (proc.mCurSeq == mSequence) {
+ continue;
+ }
+ if (proc.mRunningProcessInfo.importance >=
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND) {
+ mBackgroundProcessMemory += proc.mSize;
+ } else if (proc.mRunningProcessInfo.importance <=
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE) {
+ mForegroundProcessMemory += proc.mSize;
+ }
+ }
+ } catch (RemoteException e) {
+ }
+
return changed;
}
}
@@ -734,15 +760,21 @@ public class RunningServices extends ListActivity
if (mState.update(this, mAm)) {
((ServiceListAdapter)(getListView().getAdapter())).notifyDataSetChanged();
}
- if (mLastNumBackgroundProcesses != mState.mNumBackgroundProcesses) {
+ if (mLastNumBackgroundProcesses != mState.mNumBackgroundProcesses
+ || mLastBackgroundProcessMemory != mState.mBackgroundProcessMemory) {
mLastNumBackgroundProcesses = mState.mNumBackgroundProcesses;
+ mLastBackgroundProcessMemory = mState.mBackgroundProcessMemory;
+ String sizeStr = Formatter.formatFileSize(this, mLastBackgroundProcessMemory);
mBackgroundProcessText.setText(getResources().getString(
- R.string.service_background_processes, mLastNumBackgroundProcesses));
+ R.string.service_background_processes, mLastNumBackgroundProcesses, sizeStr));
}
- if (mLastNumForegroundProcesses != mState.mNumForegroundProcesses) {
+ if (mLastNumForegroundProcesses != mState.mNumForegroundProcesses
+ || mLastForegroundProcessMemory != mState.mForegroundProcessMemory) {
mLastNumForegroundProcesses = mState.mNumForegroundProcesses;
+ mLastForegroundProcessMemory = mState.mForegroundProcessMemory;
+ String sizeStr = Formatter.formatFileSize(this, mLastForegroundProcessMemory);
mForegroundProcessText.setText(getResources().getString(
- R.string.service_foreground_processes, mLastNumForegroundProcesses));
+ R.string.service_foreground_processes, mLastNumForegroundProcesses, sizeStr));
}
}