summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2013-07-18 09:51:30 -0400
committerDaniel Sandler <dsandler@android.com>2013-07-18 10:16:48 -0400
commit074e9acb6fb52ba3d10b79d0caba6aa2c224c34d (patch)
tree262252428a11cc46b3f062f1e254e7505f3c94eb /src
parent181c3dc5829a6da646f193acedf6ff4e447321bb (diff)
downloadandroid_packages_apps_Trebuchet-074e9acb6fb52ba3d10b79d0caba6aa2c224c34d.tar.gz
android_packages_apps_Trebuchet-074e9acb6fb52ba3d10b79d0caba6aa2c224c34d.tar.bz2
android_packages_apps_Trebuchet-074e9acb6fb52ba3d10b79d0caba6aa2c224c34d.zip
Fix crash when processes die.
Bug: 9902561 Change-Id: I83682034095c905171bf284bf7d9fc0860f2b0f9
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/MemoryTracker.java35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/com/android/launcher3/MemoryTracker.java b/src/com/android/launcher3/MemoryTracker.java
index d3bb77c77..0a796a261 100644
--- a/src/com/android/launcher3/MemoryTracker.java
+++ b/src/com/android/launcher3/MemoryTracker.java
@@ -107,24 +107,33 @@ public class MemoryTracker extends Service {
if (mPids.contains(lpid)) return;
mPids.add(lpid);
- final int N = mPids.size();
- mPidsArray = new int[N];
- StringBuffer sb = new StringBuffer("Now tracking processes: ");
- for (int i=0; i<N; i++) {
- final int p = mPids.get(i).intValue();
- mPidsArray[i] = p;
- sb.append(p); sb.append(" ");
- }
+ updatePidsArrayL();
+
mData.put(pid, new ProcessMemInfo(pid, name, start));
- Log.v(TAG, sb.toString());
}
}
+ void updatePidsArrayL() {
+ final int N = mPids.size();
+ mPidsArray = new int[N];
+ StringBuffer sb = new StringBuffer("Now tracking processes: ");
+ for (int i=0; i<N; i++) {
+ final int p = mPids.get(i).intValue();
+ mPidsArray[i] = p;
+ sb.append(p); sb.append(" ");
+ }
+ Log.v(TAG, sb.toString());
+ }
+
void update() {
synchronized (mLock) {
Debug.MemoryInfo[] dinfos = mAm.getProcessMemoryInfo(mPidsArray);
for (int i=0; i<dinfos.length; i++) {
Debug.MemoryInfo dinfo = dinfos[i];
+ if (i > mPids.size()) {
+ Log.e(TAG, "update: unknown process info received: " + dinfo);
+ break;
+ }
final long pid = mPids.get(i).intValue();
final ProcessMemInfo info = mData.get(pid);
info.head = (info.head+1) % info.pss.length;
@@ -142,6 +151,7 @@ public class MemoryTracker extends Service {
final long pid = mPids.get(i).intValue();
if (mData.get(pid) == null) {
mPids.remove(i);
+ updatePidsArrayL();
}
}
}
@@ -155,7 +165,9 @@ public class MemoryTracker extends Service {
List<ActivityManager.RunningServiceInfo> svcs = mAm.getRunningServices(256);
for (ActivityManager.RunningServiceInfo svc : svcs) {
if (svc.service.getPackageName().equals(getPackageName())) {
- startTrackingProcess(svc.pid, svc.process, System.currentTimeMillis() - (SystemClock.elapsedRealtime() - svc.activeSince));
+ Log.v(TAG, "discovered running service: " + svc.process + " (" + svc.pid + ")");
+ startTrackingProcess(svc.pid, svc.process,
+ System.currentTimeMillis() - (SystemClock.elapsedRealtime() - svc.activeSince));
}
}
@@ -163,6 +175,7 @@ public class MemoryTracker extends Service {
for (ActivityManager.RunningAppProcessInfo proc : procs) {
final String pname = proc.processName;
if (pname.startsWith(getPackageName())) {
+ Log.v(TAG, "discovered other running process: " + pname + " (" + proc.pid + ")");
startTrackingProcess(proc.pid, pname, System.currentTimeMillis());
}
}
@@ -175,7 +188,7 @@ public class MemoryTracker extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
- Log.i(TAG, "Received start id " + startId + ": " + intent);
+ Log.v(TAG, "Received start id " + startId + ": " + intent);
if (intent != null) {
if (ACTION_START_TRACKING.equals(intent.getAction())) {