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

Commit d60d9b88 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Consider shell transition to update display mode

This continues the purpose of [1] for shell transition. Because
"isAnimating(TRANSITION | PARENTS)" cannot detect the transition
animation which will run by shell.

Also simplify isObscuringDisplay because the split root task can be
fullscreen, but the window in the child task is not, then the condition
can return earlier.

[1]: I5b3ddbc8278a95b4c5239812b2c4a293775c740a

Fix: 267365057
Test: RefreshRatePolicyTest#testAnimatingAppOverridePreferredModeId
Test: Assume device enables 120Hz, launch an app that requests 60Hz.
      And then swipe-up, the animation should run in 120Hz.
Change-Id: I4baba6441dee0dc26ab35456ab916672d69914d9
parent f558dd2d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4944,7 +4944,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        mInsetsStateController.getImeSourceProvider().checkShowImePostLayout();

        mLastHasContent = mTmpApplySurfaceChangesTransactionState.displayHasContent;
        if (!mWmService.mDisplayFrozen && !mDisplayRotation.isRotatingSeamlessly()) {
        if (!inTransition() && !mDisplayRotation.isRotatingSeamlessly()) {
            mWmService.mDisplayManagerInternal.setDisplayProperties(mDisplayId,
                    mLastHasContent,
                    mTmpApplySurfaceChangesTransactionState.preferredRefreshRate,
+4 −7
Original line number Diff line number Diff line
@@ -19,9 +19,6 @@ package com.android.server.wm;
import static android.hardware.display.DisplayManager.SWITCHING_TYPE_NONE;
import static android.hardware.display.DisplayManager.SWITCHING_TYPE_RENDER_FRAME_RATE_ONLY;

import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;

import android.hardware.display.DisplayManager;
import android.view.Display;
import android.view.Display.Mode;
@@ -140,7 +137,7 @@ class RefreshRatePolicy {
        // to run in default refresh rate. But if the display size of default mode is different
        // from the using preferred mode, then still keep the preferred mode to avoid disturbing
        // the animation.
        if (w.isAnimating(TRANSITION | PARENTS)) {
        if (w.isAnimationRunningSelfOrParent()) {
            Display.Mode preferredMode = null;
            for (Display.Mode mode : mDisplayInfo.supportedModes) {
                if (preferredDisplayModeId == mode.getModeId()) {
@@ -254,7 +251,7 @@ class RefreshRatePolicy {

        // If app is animating, it's not able to control refresh rate because we want the animation
        // to run in default refresh rate.
        if (w.isAnimating(TRANSITION | PARENTS)) {
        if (w.isAnimationRunningSelfOrParent()) {
            return w.mFrameRateVote.reset();
        }

@@ -293,7 +290,7 @@ class RefreshRatePolicy {
    float getPreferredMinRefreshRate(WindowState w) {
        // If app is animating, it's not able to control refresh rate because we want the animation
        // to run in default refresh rate.
        if (w.isAnimating(TRANSITION | PARENTS)) {
        if (w.isAnimationRunningSelfOrParent()) {
            return 0;
        }

@@ -316,7 +313,7 @@ class RefreshRatePolicy {
    float getPreferredMaxRefreshRate(WindowState w) {
        // If app is animating, it's not able to control refresh rate because we want the animation
        // to run in default refresh rate.
        if (w.isAnimating(TRANSITION | PARENTS)) {
        if (w.isAnimationRunningSelfOrParent()) {
            return 0;
        }

+5 −5
Original line number Diff line number Diff line
@@ -2081,7 +2081,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        final ActivityRecord atoken = mActivityRecord;
        return isDrawn() && isVisibleByPolicy()
                && ((!isParentWindowHidden() && (atoken == null || atoken.isVisibleRequested()))
                        || isAnimating(TRANSITION | PARENTS));
                        || isAnimationRunningSelfOrParent());
    }

    /**
@@ -2324,7 +2324,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP

    boolean isObscuringDisplay() {
        Task task = getTask();
        if (task != null && task.getRootTask() != null && !task.getRootTask().fillsParent()) {
        if (task != null && !task.fillsParent()) {
            return false;
        }
        return isOpaqueDrawn() && fillsDisplay();
@@ -2589,7 +2589,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    }
                }
                final boolean isAnimating = allowExitAnimation
                        && (mAnimatingExit || isExitAnimationRunningSelfOrParent());
                        && (mAnimatingExit || isAnimationRunningSelfOrParent());
                final boolean lastWindowIsStartingWindow = startingWindow && mActivityRecord != null
                        && mActivityRecord.isLastWindow(this);
                // We delay the removal of a window if it has a showing surface that can be used to run
@@ -4986,7 +4986,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return false;
    }

    boolean isExitAnimationRunningSelfOrParent() {
    boolean isAnimationRunningSelfOrParent() {
        return inTransitionSelfOrParent()
                || isAnimating(0 /* flags */, ANIMATION_TYPE_WINDOW_ANIMATION);
    }
@@ -5002,7 +5002,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            return true;
        }
        // Exit animation is running.
        if (isExitAnimationRunningSelfOrParent()) {
        if (isAnimationRunningSelfOrParent()) {
            ProtoLog.d(WM_DEBUG_APP_TRANSITIONS, "shouldWaitAnimatingExit: isAnimating: %s",
                    this);
            return false;
+9 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.Parcel;
import android.platform.test.annotations.Presubmit;
import android.view.Display.Mode;
import android.view.Surface;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;

import androidx.test.filters.FlakyTest;
@@ -292,6 +293,14 @@ public class RefreshRatePolicyTest extends WindowTestsBase {
        assertEquals(0, mPolicy.getPreferredMinRefreshRate(overrideWindow), FLOAT_TOLERANCE);
        assertEquals(0, mPolicy.getPreferredMaxRefreshRate(overrideWindow), FLOAT_TOLERANCE);

        // Use default mode if it is animating by shell transition.
        overrideWindow.mActivityRecord.mSurfaceAnimator.cancelAnimation();
        registerTestTransitionPlayer();
        final Transition transition = overrideWindow.mTransitionController.createTransition(
                WindowManager.TRANSIT_OPEN);
        transition.collect(overrideWindow.mActivityRecord);
        assertEquals(0, mPolicy.getPreferredModeId(overrideWindow));

        // If there will be display size change when switching from preferred mode to default mode,
        // then keep the current preferred mode during animating.
        mDisplayInfo = spy(mDisplayInfo);
+1 −1
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ public class WindowManagerServiceTests extends WindowTestsBase {
        final WindowSurfaceController surfaceController = mock(WindowSurfaceController.class);
        doReturn(true).when(surfaceController).hasSurface();
        spyOn(win);
        doReturn(true).when(win).isExitAnimationRunningSelfOrParent();
        doReturn(true).when(win).isAnimationRunningSelfOrParent();
        win.mWinAnimator.mSurfaceController = surfaceController;
        win.mViewVisibility = View.VISIBLE;
        win.mHasSurface = true;