From 6fd71484b54767c893abb58e90b6881185aefed1 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Wed, 23 Feb 2022 12:51:45 -0500 Subject: [PATCH] Remove unnecessary async Because if the work wasn't scheduled by the time the main page was shown, the switch would be shown in the wrong state. And these calls are fast, and can be done on the main thread Test: turn off DND access for apps with DND rules Fixes: 207058117 Change-Id: I186413f4237ef754bdfa5cc469e1b7be4ff71f2c --- .../specialaccess/zenaccess/ZenAccessController.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java index 84608794f7a..2c52a8c6d62 100644 --- a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java +++ b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java @@ -97,17 +97,13 @@ public class ZenAccessController extends BasePreferenceController { public static void setAccess(final Context context, final String pkg, final boolean access) { logSpecialPermissionChange(access, pkg, context); - AsyncTask.execute(() -> { - final NotificationManager mgr = context.getSystemService(NotificationManager.class); - mgr.setNotificationPolicyAccessGranted(pkg, access); - }); + final NotificationManager mgr = context.getSystemService(NotificationManager.class); + mgr.setNotificationPolicyAccessGranted(pkg, access); } public static void deleteRules(final Context context, final String pkg) { - AsyncTask.execute(() -> { - final NotificationManager mgr = context.getSystemService(NotificationManager.class); - mgr.removeAutomaticZenRules(pkg); - }); + final NotificationManager mgr = context.getSystemService(NotificationManager.class); + mgr.removeAutomaticZenRules(pkg); } @VisibleForTesting