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

Commit 7054a780 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Hold wm lock in ClearOptionsAnimation

The invocation may be from
 PermissionPolicyService.Internal
  mActivityInterceptorCallback#onActivityLaunched
   mHandler.post(() -> showNotificationPromptIfNeeded...
    launchNotificationPermissionRequestDialog
     info.getClearOptionsAnimationRunnable().run();

If wm lock is not held, the field mPendingOptions,
mPendingRemoteAnimation, mPendingRemoteTransition could be null
when other wm operations are executing which may lead to
random NPE.

Bug: 333974740
Test: Launch an old version of API Demo from launcher.
      The notification permission activity can show with
      animation normally.

Change-Id: Iccf5ba19645a97a3f73298cbfc54710c3fcded14
parent 944de4f9
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -389,7 +389,11 @@ public interface ActivityInterceptorCallback {
            return mCheckedOptions;
        }

        /** Returns the {@link Runnable} object to clear options Animation. */
        /**
         * Returns the {@link Runnable} object to clear options Animation. Note that the runnable
         * should not be executed inside a lock because the implementation of runnable holds window
         * manager's lock.
         */
        @Nullable
        public Runnable getClearOptionsAnimationRunnable() {
            return mClearOptionsAnimation;
+5 −2
Original line number Diff line number Diff line
@@ -523,8 +523,11 @@ class ActivityStartInterceptor {
    void onActivityLaunched(TaskInfo taskInfo, ActivityRecord r) {
        final SparseArray<ActivityInterceptorCallback> callbacks =
                mService.getActivityInterceptorCallbacks();
        ActivityInterceptorCallback.ActivityInterceptorInfo info = getInterceptorInfo(
                r::clearOptionsAnimationForSiblings);
        final ActivityInterceptorCallback.ActivityInterceptorInfo info = getInterceptorInfo(() -> {
            synchronized (mService.mGlobalLock) {
                r.clearOptionsAnimationForSiblings();
            }
        });
        for (int i = 0; i < callbacks.size(); i++) {
            final ActivityInterceptorCallback callback = callbacks.valueAt(i);
            callback.onActivityLaunched(taskInfo, r.info, info);