From 0c9ac648190a3f0e850d4fe376002f7a11654a87 Mon Sep 17 00:00:00 2001 From: Ariana Mott Date: Thu, 7 Apr 2016 12:33:11 -0700 Subject: [PATCH] Remove package AutomaticZenRules for revoked Notification Policy Access Bug=28043240 Change-Id: If59fc043470a6dfe6b2426cd80ef53473ba8be42 --- .../java/com/android/server/vr/VrManagerService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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); + } } }