Skip to content

Commit a4db731

Browse files
Julia Reynoldsofficialputuid
authored andcommitted
Fix NPE when deleting old zen rules
Test: manually revoke access for a DND app that has rules created before and after b/189332346 Bug: 191773100 Bug: 189332346 Bug: 235823407 Change-Id: I069fcc124af24227fa50b61d4fc55d6dadc7a20b Merged-In: I069fcc124af24227fa50b61d4fc55d6dadc7a20b (cherry picked from commit b4fe101) (cherry picked from commit 66896a0) Merged-In: I069fcc124af24227fa50b61d4fc55d6dadc7a20b
1 parent ed29c2b commit a4db731

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

services/core/java/com/android/server/notification/ZenModeHelper.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,14 @@ public boolean removeAutomaticZenRules(String packageName, String reason) {
405405
newConfig = mConfig.copy();
406406
for (int i = newConfig.automaticRules.size() - 1; i >= 0; i--) {
407407
ZenRule rule = newConfig.automaticRules.get(newConfig.automaticRules.keyAt(i));
408-
if (rule.pkg.equals(packageName) && canManageAutomaticZenRule(rule)) {
408+
String pkg = rule.pkg != null
409+
? rule.pkg
410+
: (rule.component != null)
411+
? rule.component.getPackageName()
412+
: (rule.configurationActivity != null)
413+
? rule.configurationActivity.getPackageName()
414+
: null;
415+
if (Objects.equals(pkg, packageName) && canManageAutomaticZenRule(rule)) {
409416
newConfig.automaticRules.removeAt(i);
410417
}
411418
}

0 commit comments

Comments
 (0)