From a866e54d14cda717c0dd7a2eea8e425a5c2eff80 Mon Sep 17 00:00:00 2001 From: Nate Myren Date: Fri, 8 Apr 2022 10:53:45 -0700 Subject: [PATCH] Post the starting of the Notification dialog This ensures the checks for notification channels happen outside the WindowManagerGlobalLock-held callback methods Fixes: 228153810 Test: manual Change-Id: Ie6a77b81afae36437e1410ba157c9e4359f9031d --- .../server/policy/PermissionPolicyService.java | 11 +++++++++-- .../server/wm/ActivityInterceptorCallback.java | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/policy/PermissionPolicyService.java b/services/core/java/com/android/server/policy/PermissionPolicyService.java index e8546a7684298..32e7a6a810969 100644 --- a/services/core/java/com/android/server/policy/PermissionPolicyService.java +++ b/services/core/java/com/android/server/policy/PermissionPolicyService.java @@ -59,6 +59,8 @@ import android.content.pm.PackageManagerInternal.PackageListObserver; import android.content.pm.PermissionInfo; import android.os.Build; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; @@ -160,11 +162,13 @@ public final class PermissionPolicyService extends SystemService { private NotificationManagerInternal mNotificationManager; private final KeyguardManager mKeyguardManager; private final PackageManager mPackageManager; + private final Handler mHandler; public PermissionPolicyService(@NonNull Context context) { super(context); mContext = context; + mHandler = new Handler(Looper.getMainLooper()); mPackageManager = context.getPackageManager(); mKeyguardManager = context.getSystemService(KeyguardManager.class); LocalServices.addService(PermissionPolicyInternal.class, new Internal()); @@ -1068,8 +1072,11 @@ public final class PermissionPolicyService extends SystemService { activityInfo.packageName, user)) { clearNotificationReviewFlagsIfNeeded(activityInfo.packageName, user); } else { - showNotificationPromptIfNeeded(activityInfo.packageName, - taskInfo.userId, taskInfo.taskId, info); + // Post the activity start checks to ensure the notification channel + // checks happen outside the WindowManager global lock. + mHandler.post(() -> showNotificationPromptIfNeeded( + activityInfo.packageName, taskInfo.userId, taskInfo.taskId, + info)); } } }; diff --git a/services/core/java/com/android/server/wm/ActivityInterceptorCallback.java b/services/core/java/com/android/server/wm/ActivityInterceptorCallback.java index d2053fa25ad89..400460a1e656d 100644 --- a/services/core/java/com/android/server/wm/ActivityInterceptorCallback.java +++ b/services/core/java/com/android/server/wm/ActivityInterceptorCallback.java @@ -29,7 +29,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** - * Callback to intercept activity starts and possibly block/redirect them. + * Callback to intercept activity starts and possibly block/redirect them. The callback methods will + * be called with the WindowManagerGlobalLock held. */ public abstract class ActivityInterceptorCallback { /**