From f43aa811b7d29d0af3a3c9c05d581230cd2e831a Mon Sep 17 00:00:00 2001 From: Alexandra Gherghina Date: Tue, 9 Dec 2014 17:06:39 +0000 Subject: [PATCH] Fix NPE in Running Processes view in Apps Settings Bug: 18676587 Change-Id: Ib4b400241f0ebd6dd4aacad4bfdda6dfb75cdfb5 --- src/com/android/settings/applications/RunningState.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/applications/RunningState.java b/src/com/android/settings/applications/RunningState.java index e0ac56ceb65..4b5872995a4 100644 --- a/src/com/android/settings/applications/RunningState.java +++ b/src/com/android/settings/applications/RunningState.java @@ -756,6 +756,8 @@ public class RunningState { synchronized (mLock) { mResumed = true; mRefreshUiListener = listener; + // TODO: The set of users may have changed too, so we should probably recompute it + // each time, but that might be costly. See http://b/18696308 if (mInterestingConfigChanges.applyNewConfig(mApplicationContext.getResources())) { mHaveData = false; mBackgroundHandler.removeMessages(MSG_RESET_CONTENTS); @@ -833,6 +835,10 @@ public class RunningState { UserState userState = mUsers.get(newItem.mUserId); UserInfo info = userState != null ? userState.mInfo : mUm.getUserInfo(newItem.mUserId); + if (info == null) { + // The user no longer exists, skip + return; + } if (mHideManagedProfiles && info.isManagedProfile()) { return; } @@ -856,7 +862,7 @@ public class RunningState { private boolean update(Context context, ActivityManager am) { final PackageManager pm = context.getPackageManager(); - + mSequence++; boolean changed = false; @@ -1146,7 +1152,6 @@ public class RunningState { ArrayList newItems = new ArrayList(); ArrayList newMergedItems = new ArrayList(); - SparseArray otherUsers = null; mProcessItems.clear(); for (int i=0; i