diff --git a/services/core/java/com/android/server/vr/VrManagerService.java b/services/core/java/com/android/server/vr/VrManagerService.java index e6e5a2db0725f..f004b4592413f 100644 --- a/services/core/java/com/android/server/vr/VrManagerService.java +++ b/services/core/java/com/android/server/vr/VrManagerService.java @@ -490,8 +490,15 @@ public class VrManagerService extends SystemService implements EnabledComponentC private void revokeNotificationPolicyAccess(String pkg) { NotificationManager nm = mContext.getSystemService(NotificationManager.class); if (mPreviousNotificationPolicyAccessPackage != null) { - nm.setNotificationPolicyAccessGranted(mPreviousNotificationPolicyAccessPackage, false); - mPreviousNotificationPolicyAccessPackage = null; + if (mPreviousNotificationPolicyAccessPackage.equals(pkg)) { + // Remove any DND zen rules possibly created by the package. + nm.removeAutomaticZenRules(mPreviousNotificationPolicyAccessPackage); + // Remove Notification Policy Access. + nm.setNotificationPolicyAccessGranted(mPreviousNotificationPolicyAccessPackage, false); + mPreviousNotificationPolicyAccessPackage = null; + } else { + Slog.e(TAG, "Couldn't remove Notification Policy Access for package: " + pkg); + } } }