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

Commit ae2fbd47 authored by Ming-Shin Lu's avatar Ming-Shin Lu
Browse files

[Shell-Transition] clean-up some isAnimating call points

..to reflect the app transition animating state when shell-transition
enabled for below cases:

1) ImeInsetsSourceProvider#isReadyToShowIme will use WS#isClosing ->
   AR#isClosingOrEnteringPip to check if the IME layering target window
   is in closing transition. (i.e. It won't be ready to show IME while
   the target is in closing app transition.) Also, given isClosing and
   isClosingOrEnteringPip currently is only used for checking IME target
   validity, wraping those logic into isImeTargetWindowClosing() for
   simplicity.

2) With Shell-Transition, the activity will running a transition when
   it is visible, it won't be included when fromTransition is true means
   the call from finishTransition. As a result, in AR#commitVisibility,
   callback onAppVisibilityChanged(visible, runningAppAnimation) with
   using the above checking logic and adding logs for tracking. In case
   a11y controller will always callback onWindowTransition with
   TRANSIT_EXIT due to runningAppAnimation always being false by
   isAnimating no-op.

Fix: 212570341
Test: No visible change & Pass existing tests.
Change-Id: I9cc77956b3ff61ae83f5bd120c395cc6aca93af9
parent de765a95
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -577,12 +577,6 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-1521427940": {
      "message": "commitVisibility: %s: visible=%b mVisibleRequested=%b",
      "level": "VERBOSE",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-1517908912": {
      "message": "requestScrollCapture: caught exception dispatching to window.token=%s",
      "level": "WARN",
@@ -1513,6 +1507,12 @@
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-636553602": {
      "message": "commitVisibility: %s: visible=%b visibleRequested=%b, isInTransition=%b, runningAnimation=%b, caller=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-635082269": {
      "message": "******** booted=%b msg=%b haveBoot=%b haveApp=%b haveWall=%b wallEnabled=%b haveKeyguard=%b",
      "level": "INFO",
+13 −13
Original line number Diff line number Diff line
@@ -224,6 +224,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WIND
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES;
import static com.android.server.wm.WindowManagerService.sEnableShellTransitions;
import static com.android.server.wm.WindowState.LEGACY_POLICY_VISIBILITY;
import static com.android.server.wm.WindowStateAnimator.HAS_DRAWN;

@@ -3149,15 +3150,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        mWillCloseOrEnterPip = willCloseOrEnterPip;
    }

    /**
     * Returns whether this {@link ActivityRecord} is considered closing. Conditions are either
     * 1. Is this app animating and was requested to be hidden
     * 2. App is delayed closing since it might enter PIP.
     */
    boolean isClosingOrEnteringPip() {
        return (isAnimating(TRANSITION | PARENTS, ANIMATION_TYPE_APP_TRANSITION)
                && !mVisibleRequested) || mWillCloseOrEnterPip;
    boolean willCloseOrEnterPip() {
        return mWillCloseOrEnterPip;
    }

    /**
     * @return Whether AppOps allows this package to enter picture-in-picture.
     */
@@ -5272,12 +5268,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }

        final int windowsCount = mChildren.size();
        // With Shell-Transition, the activity will running a transition when it is visible.
        // It won't be included when fromTransition is true means the call from finishTransition.
        final boolean runningAnimation = sEnableShellTransitions ? visible
                : isAnimating(PARENTS, ANIMATION_TYPE_APP_TRANSITION);
        for (int i = 0; i < windowsCount; i++) {
            mChildren.get(i).onAppVisibilityChanged(visible, isAnimating(PARENTS,
                    ANIMATION_TYPE_APP_TRANSITION));
            mChildren.get(i).onAppVisibilityChanged(visible, runningAnimation);
        }
        setVisible(visible);
        setVisibleRequested(visible);
        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, "commitVisibility: %s: visible=%b"
                        + " visibleRequested=%b, isInTransition=%b, runningAnimation=%b, caller=%s",
                this, isVisible(), mVisibleRequested, isInTransition(), runningAnimation,
                Debug.getCallers(5));
        if (!visible) {
            stopFreezingScreen(true, true);
        } else {
@@ -5300,9 +5303,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            task.dispatchTaskInfoChangedIfNeeded(false /* force */);
            task = task.getParent().asTask();
        }
        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                "commitVisibility: %s: visible=%b mVisibleRequested=%b", this,
                isVisible(), mVisibleRequested);
        final DisplayContent displayContent = getDisplayContent();
        displayContent.getInputMonitor().setUpdateInputWindowsNeededLw();
        if (performLayout) {
+9 −2
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ final class ImeInsetsSourceProvider extends WindowContainerInsetsSourceProvider
    //
    private static boolean isImeLayeringTarget(@NonNull InsetsControlTarget target,
            @NonNull InsetsControlTarget dcTarget) {
        return !dcTarget.getWindow().isClosing() && target == dcTarget;
        return !isImeTargetWindowClosing(dcTarget.getWindow()) && target == dcTarget;
    }

    private static boolean isAboveImeLayeringTarget(@NonNull InsetsControlTarget target,
@@ -256,7 +256,14 @@ final class ImeInsetsSourceProvider extends WindowContainerInsetsSourceProvider
        final InsetsControlTarget target = mDisplayContent.getImeTarget(IME_TARGET_CONTROL);
        return target == mImeRequester
                && (mImeRequester.getWindow() == null
                || !mImeRequester.getWindow().isClosing());
                || !isImeTargetWindowClosing(mImeRequester.getWindow()));
    }

    private static boolean isImeTargetWindowClosing(@NonNull WindowState win) {
        return win.mAnimatingExit || win.mActivityRecord != null
                && (win.mActivityRecord.isInTransition()
                    && !win.mActivityRecord.isVisibleRequested()
                    || win.mActivityRecord.willCloseOrEnterPip());
    }

    private boolean isTargetChangedWithinActivity(InsetsControlTarget target) {
+0 −4
Original line number Diff line number Diff line
@@ -3461,10 +3461,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return mClient.asBinder().isBinderAlive();
    }

    boolean isClosing() {
        return mAnimatingExit || (mActivityRecord != null && mActivityRecord.isClosingOrEnteringPip());
    }

    void sendAppVisibilityToClients() {
        super.sendAppVisibilityToClients();

+0 −1
Original line number Diff line number Diff line
@@ -2118,7 +2118,6 @@ public class DisplayContentTests extends WindowTestsBase {
        final WindowState appWin2 = createWindow(null, TYPE_BASE_APPLICATION, act2, "appWin2");
        appWin2.setHasSurface(true);
        assertTrue(appWin2.canBeImeTarget());
        doReturn(true).when(appWin1).isClosing();
        doReturn(true).when(appWin1).inTransitionSelfOrParent();

        // Test step 3: Verify appWin2 will be the next IME target and the IME snapshot surface will