From 663cc934d993f7621d7fe46d9a85dd8553772612 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 19 May 2020 12:29:24 -0400 Subject: [PATCH] Guard against NPE Test: manual, launching screen from locked lock screen Fixes: 153569405 Change-Id: Idb546f58623792d94a43ca6659f7498de3beec94 --- ...centNotifyingAppsPreferenceController.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java index b4c1815daa7..aaa96bccc7f 100644 --- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java +++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java @@ -31,6 +31,7 @@ import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; import android.util.IconDrawableFactory; +import android.util.Slog; import com.android.settings.R; import com.android.settings.Utils; @@ -294,15 +295,19 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC List displayableApps = new ArrayList<>(SHOW_RECENT_APP_COUNT); int count = 0; for (NotifyingApp app : mApps) { - final ApplicationsState.AppEntry appEntry = mApplicationsState.getEntry( - app.getPackage(), app.getUserId()); - if (appEntry == null) { - continue; - } - displayableApps.add(app); - count++; - if (count >= SHOW_RECENT_APP_COUNT) { - break; + try { + final ApplicationsState.AppEntry appEntry = mApplicationsState.getEntry( + app.getPackage(), app.getUserId()); + if (appEntry == null) { + continue; + } + displayableApps.add(app); + count++; + if (count >= SHOW_RECENT_APP_COUNT) { + break; + } + } catch (Exception e) { + Slog.e(TAG, "Failed to find app " + app.getPackage() + "/" + app.getUserId(), e); } } return displayableApps;