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
This commit is contained in:
Yanting Yang
2023-03-29 17:55:29 +08:00
parent 9890f5e462
commit 3d851e0428

View File

@@ -483,7 +483,10 @@ public class ApplicationsState {
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) {