From 0a8a686f1c38944c45fbbbd5dcea335ae86feec7 Mon Sep 17 00:00:00 2001 From: Kazuki Takise Date: Fri, 18 Mar 2022 19:13:23 +0900 Subject: [PATCH] Add null check for notification preference helper Not sure about the exact situation, but depending on timing or vendor implementation, this NPE could happen and at least we should avoid this as it's system_server process. We observed this when running WM CTS for ARC. Bug: 225309857 Test: Run WM CTS Change-Id: I095b0f51d8a0d436cca5072073032b26ddd11a90 --- .../com/android/server/notification/PreferencesHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java index 1f7d65e6c6041..75d7a1f510b96 100644 --- a/services/core/java/com/android/server/notification/PreferencesHelper.java +++ b/services/core/java/com/android/server/notification/PreferencesHelper.java @@ -601,8 +601,10 @@ public class PreferencesHelper implements RankingConfig { out.attribute(null, ATT_NAME, r.pkg); if (!notifPermissions.isEmpty()) { Pair app = new Pair(r.uid, r.pkg); + final Pair permission = notifPermissions.get(app); out.attributeInt(null, ATT_IMPORTANCE, - notifPermissions.get(app).first ? IMPORTANCE_DEFAULT : IMPORTANCE_NONE); + permission != null && permission.first ? IMPORTANCE_DEFAULT + : IMPORTANCE_NONE); notifPermissions.remove(app); } else { if (r.importance != DEFAULT_IMPORTANCE) {