Fix NPE of ApplicationsState
Check userId before getting the entry from mEntriesMap to avoid NPE,
since the caller from RecentAppStatsMixin may query the entry for
uncached userId.
Bug: 275123723
Test: manual
Change-Id: I369081ebf179c267fb9ecd1a359ba1ed4e308540
diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
index 6b9daa3..6404d5e 100644
--- a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
+++ b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
@@ -462,7 +462,10 @@
public AppEntry getEntry(String packageName, int userId) {
if (DEBUG_LOCKING) Log.v(TAG, "getEntry about to acquire lock...");
synchronized (mEntriesMap) {
- AppEntry entry = mEntriesMap.get(userId).get(packageName);
+ AppEntry entry = null;
+ if (mEntriesMap.contains(userId)) {
+ entry = mEntriesMap.get(userId).get(packageName);
+ }
if (entry == null) {
ApplicationInfo info = getAppInfoLocked(packageName, userId);
if (info == null) {