Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bb9cd92 authored by Julia Reynolds's avatar Julia Reynolds Committed by Yuri Lin
Browse files

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 b4fe101e)
parent eda171cf
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -383,7 +383,14 @@ public class ZenModeHelper {
            newConfig = mConfig.copy();
            for (int i = newConfig.automaticRules.size() - 1; i >= 0; i--) {
                ZenRule rule = newConfig.automaticRules.get(newConfig.automaticRules.keyAt(i));
                if (rule.pkg.equals(packageName) && canManageAutomaticZenRule(rule)) {
                String pkg = rule.pkg != null
                        ? rule.pkg
                        : (rule.component != null)
                                ? rule.component.getPackageName()
                                : (rule.configurationActivity != null)
                                        ? rule.configurationActivity.getPackageName()
                                        : null;
                if (Objects.equals(pkg, packageName) && canManageAutomaticZenRule(rule)) {
                    newConfig.automaticRules.removeAt(i);
                }
            }