From 8258dc23d3584d8ca2b0ddade6fb84adb86e4866 Mon Sep 17 00:00:00 2001 From: Johannes Carlsson Date: Mon, 20 Dec 2010 13:42:54 +0100 Subject: Fix NPE due to missing ProcessItem.mPackageInfo The reason was that a item was removed from the SparseArray while iterating it causing one ProcessItem to be skipped in the loop which makes sure that mPackageInfo is not null. This happens when all processes for one uid is stopped and a new process is created. This problem was found by running monkey. Change-Id: I5e9a76e8007819d5e6d9ba15af0c2362da193526 --- src/com/android/settings/applications/RunningState.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/com') diff --git a/src/com/android/settings/applications/RunningState.java b/src/com/android/settings/applications/RunningState.java index dbe4a64..4f2c115 100644 --- a/src/com/android/settings/applications/RunningState.java +++ b/src/com/android/settings/applications/RunningState.java @@ -756,6 +756,7 @@ public class RunningState { } // Look for services and their primary processes that no longer exist... + ArrayList uidToDelete = null; for (int i=0; i procs = mServiceProcessesByName.valueAt(i); Iterator pit = procs.values().iterator(); @@ -772,7 +773,10 @@ public class RunningState { changed = true; pit.remove(); if (procs.size() == 0) { - mServiceProcessesByName.remove(mServiceProcessesByName.keyAt(i)); + if (uidToDelete == null) { + uidToDelete = new ArrayList(); + } + uidToDelete.add(mServiceProcessesByName.keyAt(i)); } if (pi.mPid != 0) { mServiceProcessesByPid.remove(pi.mPid); @@ -790,6 +794,13 @@ public class RunningState { } } + if (uidToDelete != null) { + for (int i = 0; i < uidToDelete.size(); i++) { + int uid = uidToDelete.get(i); + mServiceProcessesByName.remove(uid); + } + } + if (changed) { // First determine an order for the services. ArrayList sortedProcesses = new ArrayList(); -- cgit v1.1