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

Commit 3672fa9f authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Remove unused legacy freeze-screen and rotation animation" into main

parents 176cd8e3 1dff6afd
Loading
Loading
Loading
Loading
+11 −163
Original line number Diff line number Diff line
@@ -406,7 +406,7 @@ import java.util.function.Predicate;
/**
 * An entry in the history task, representing an activity.
 */
final class ActivityRecord extends WindowToken implements WindowManagerService.AppFreezeListener {
final class ActivityRecord extends WindowToken {
    private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityRecord" : TAG_ATM;
    private static final String TAG_ADD_REMOVE = TAG + POSTFIX_ADD_REMOVE;
    private static final String TAG_APP = TAG + POSTFIX_APP;
@@ -736,9 +736,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     */
    boolean mAllowCrossUidActivitySwitchFromBelow;

    /** Have we been asked to have this token keep the screen frozen? */
    private boolean mFreezingScreen;

    // These are used for determining when all windows associated with
    // an activity have been drawn, so they can be made visible together
    // at the same time.
@@ -4511,8 +4508,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            removeIfPossible();
        }

        stopFreezingScreen(true, true);

        final DisplayContent dc = getDisplayContent();
        if (dc.mFocusedApp == this) {
            ProtoLog.v(WM_DEBUG_FOCUS_LIGHT,
@@ -5793,9 +5788,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                        + " visibleRequested=%b, isInTransition=%b, runningAnimation=%b, caller=%s",
                this, isVisible(), mVisibleRequested, isInTransition(), runningAnimation,
                Debug.getCallers(5));
        if (!visible) {
            stopFreezingScreen(true, true);
        } else {
        if (visible) {
            // If we are being set visible, and the starting window is not yet displayed,
            // then make sure it doesn't get displayed.
            if (mStartingWindow != null && !mStartingWindow.isDrawn()
@@ -5803,9 +5796,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                mStartingWindow.clearPolicyVisibilityFlag(LEGACY_POLICY_VISIBILITY);
                mStartingWindow.mLegacyPolicyVisibilityAfterAnim = false;
            }
            // We are becoming visible, so better freeze the screen with the windows that are
            // getting visible so we also wait for them.
            forAllWindows(mWmService::makeWindowFreezingScreenIfNeededLocked, true);
        }
        // dispatchTaskInfoChangedIfNeeded() right after ActivityRecord#setVisibility() can report
        // the stale visible state, because the state will be updated after the app transition.
@@ -6842,123 +6832,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        rootTask.removeLaunchTickMessages();
    }

    boolean mayFreezeScreenLocked() {
        return mayFreezeScreenLocked(app);
    }

    private boolean mayFreezeScreenLocked(WindowProcessController app) {
        // Only freeze the screen if this activity is currently attached to
        // an application, and that application is not blocked or unresponding.
        // In any other case, we can't count on getting the screen unfrozen,
        // so it is best to leave as-is.
        return hasProcess() && !app.isCrashing() && !app.isNotResponding();
    }

    void startFreezingScreenLocked(WindowProcessController app, int configChanges) {
        if (mayFreezeScreenLocked(app)) {
            if (getParent() == null) {
                Slog.w(TAG_WM,
                        "Attempted to freeze screen with non-existing app token: " + token);
                return;
            }

            // Window configuration changes only effect windows, so don't require a screen freeze.
            int freezableConfigChanges = configChanges & ~(CONFIG_WINDOW_CONFIGURATION);
            if (freezableConfigChanges == 0 && okToDisplay()) {
                ProtoLog.v(WM_DEBUG_ORIENTATION, "Skipping set freeze of %s", token);
                return;
            }

            startFreezingScreen();
        }
    }

    void startFreezingScreen() {
        startFreezingScreen(ROTATION_UNDEFINED /* overrideOriginalDisplayRotation */);
    }

    void startFreezingScreen(int overrideOriginalDisplayRotation) {
        if (mTransitionController.isShellTransitionsEnabled()) {
            return;
        }
        ProtoLog.i(WM_DEBUG_ORIENTATION,
                "Set freezing of %s: visible=%b freezing=%b visibleRequested=%b. %s",
                token, isVisible(), mFreezingScreen, mVisibleRequested,
                new RuntimeException().fillInStackTrace());
        if (!mVisibleRequested) {
            return;
        }

        // If the override is given, the rotation of display doesn't change but we still want to
        // cover the activity whose configuration is changing by freezing the display and running
        // the rotation animation.
        final boolean forceRotation = overrideOriginalDisplayRotation != ROTATION_UNDEFINED;
        if (!mFreezingScreen) {
            mFreezingScreen = true;
            mWmService.registerAppFreezeListener(this);
            mWmService.mAppsFreezingScreen++;
            if (mWmService.mAppsFreezingScreen == 1) {
                if (forceRotation) {
                    // Make sure normal rotation animation will be applied.
                    mDisplayContent.getDisplayRotation().cancelSeamlessRotation();
                }
                mWmService.startFreezingDisplay(0 /* exitAnim */, 0 /* enterAnim */,
                        mDisplayContent, overrideOriginalDisplayRotation);
                mWmService.mH.removeMessages(H.APP_FREEZE_TIMEOUT);
                mWmService.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000);
            }
        }
        if (forceRotation) {
            // The rotation of the real display won't change, so in order to unfreeze the screen
            // via {@link #checkAppWindowsReadyToShow}, the windows have to be able to call
            // {@link WindowState#reportResized} (it is skipped if the window is freezing) to update
            // the drawn state.
            return;
        }
        final int count = mChildren.size();
        for (int i = 0; i < count; i++) {
            final WindowState w = mChildren.get(i);
            w.onStartFreezingScreen();
        }
    }

    boolean isFreezingScreen() {
        return mFreezingScreen;
    }

    @Override
    public void onAppFreezeTimeout() {
        Slog.w(TAG_WM, "Force clearing freeze: " + this);
        stopFreezingScreen(true, true);
    }

    void stopFreezingScreen(boolean unfreezeSurfaceNow, boolean force) {
        if (!mFreezingScreen) {
            return;
        }
        ProtoLog.v(WM_DEBUG_ORIENTATION,
                "Clear freezing of %s force=%b", this, force);
        final int count = mChildren.size();
        boolean unfrozeWindows = false;
        for (int i = 0; i < count; i++) {
            final WindowState w = mChildren.get(i);
            unfrozeWindows |= w.onStopFreezingScreen();
        }
        if (force || unfrozeWindows) {
            ProtoLog.v(WM_DEBUG_ORIENTATION, "No longer freezing: %s", this);
            mFreezingScreen = false;
            mWmService.unregisterAppFreezeListener(this);
            mWmService.mAppsFreezingScreen--;
            mWmService.mLastFinishedFreezeSource = this;
        }
        if (unfreezeSurfaceNow) {
            if (unfrozeWindows) {
                mWmService.mWindowPlacerLocked.performSurfacePlacement();
            }
            mWmService.stopFreezingDisplayLocked();
        }
    }

    void onFirstWindowDrawn(WindowState win) {
        firstWindowDrawn = true;
        // stop tracking
@@ -7101,18 +6974,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
        }

        // The token has now changed state to having all windows shown...  what to do, what to do?
        if (mFreezingScreen) {
            showAllWindowsLocked();
            stopFreezingScreen(false, true);
            ProtoLog.i(WM_DEBUG_ORIENTATION,
                    "Setting mOrientationChangeComplete=true because wtoken %s "
                            + "numInteresting=%d numDrawn=%d",
                    this, mNumInterestingWindows, mNumDrawnWindows);
            // This will set mOrientationChangeComplete and cause a pass through layout.
            setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER,
                    "checkAppWindowsReadyToShow: freezingScreen");
        } else {
        setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM, "checkAppWindowsReadyToShow");

        // We can now show all of the drawn windows!
@@ -7120,7 +6981,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            showAllWindowsLocked();
        }
    }
    }

    /**
     * This must be called while inside a transaction.
@@ -7204,10 +7064,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        if (DEBUG_STARTING_WINDOW_VERBOSE && w == mStartingWindow) {
            Slog.d(TAG, "updateWindows: starting " + w + " isOnScreen=" + w.isOnScreen()
                    + " allDrawn=" + allDrawn + " freezingScreen=" + mFreezingScreen);
                    + " allDrawn=" + allDrawn);
        }

        if (allDrawn && !mFreezingScreen) {
        if (allDrawn) {
            return false;
        }

@@ -7248,10 +7108,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                        mNumDrawnWindows++;

                        if (DEBUG_VISIBILITY || WM_DEBUG_ORIENTATION.isLogToLogcat()) {
                            Slog.v(TAG, "tokenMayBeDrawn: "
                                    + this + " w=" + w + " numInteresting=" + mNumInterestingWindows
                                    + " freezingScreen=" + mFreezingScreen
                                    + " mAppFreezing=" + w.mAppFreezing);
                            Slog.v(TAG, "tokenMayBeDrawn: " + this + " w=" + w
                                    + " numInteresting=" + mNumInterestingWindows);
                        }

                        isInterestingAndDrawn = true;
@@ -8199,8 +8057,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }

        mDisplayContent.mPinnedTaskController.onCancelFixedRotationTransform();
        // Perform rotation animation according to the rotation of this activity.
        startFreezingScreen(originalDisplayRotation);
        // This activity may relaunch or perform configuration change so once it has reported drawn,
        // the screen can be unfrozen.
        ensureActivityConfiguration();
@@ -9384,11 +9240,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                mLastReportedConfiguration);

        if (shouldRelaunchLocked(changes, mTmpConfig)) {
            // Aha, the activity isn't handling the change, so DIE DIE DIE.
            if (mVisible && mAtmService.mTmpUpdateConfigurationResult.mIsUpdating
                    && !mTransitionController.isShellTransitionsEnabled()) {
                startFreezingScreenLocked(app, mAtmService.mTmpUpdateConfigurationResult.changes);
            }
            final boolean displayMayChange = mTmpConfig.windowConfiguration.getDisplayRotation()
                    != getWindowConfiguration().getDisplayRotation()
                    || !mTmpConfig.windowConfiguration.getMaxBounds().equals(
@@ -9396,10 +9247,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            final boolean isAppResizeOnly = !displayMayChange
                    && (changes & ~(CONFIG_SCREEN_SIZE | CONFIG_SMALLEST_SCREEN_SIZE
                            | CONFIG_ORIENTATION | CONFIG_SCREEN_LAYOUT)) == 0;
            // Do not preserve window if it is freezing screen because the original window won't be
            // able to update drawn state that causes freeze timeout.
            // TODO(b/258618073): Always preserve if possible.
            final boolean preserveWindow = isAppResizeOnly && !mFreezingScreen;
            final boolean preserveWindow = isAppResizeOnly;
            final boolean hasResizeChange = hasResizeChange(changes & ~info.getRealConfigChanged());
            if (hasResizeChange) {
                final boolean isDragResizing = task.isDragResizing();
@@ -9695,7 +9544,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                scheduleStopForRestartProcess();
            });
        } else {
            startFreezingScreen();
            scheduleStopForRestartProcess();
        }
    }
+0 −3
Original line number Diff line number Diff line
@@ -509,7 +509,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        int changes;
        // If the activity was relaunched to match the new configuration.
        boolean activityRelaunched;
        boolean mIsUpdating;
    }

    /** Current sequencing integer of the configuration, for skipping old configurations. */
@@ -4694,14 +4693,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            if (values != null) {
                changes = updateGlobalConfigurationLocked(values, initLocale, persistent, userId);
                mTmpUpdateConfigurationResult.changes = changes;
                mTmpUpdateConfigurationResult.mIsUpdating = true;
            }

            if (!deferResume) {
                kept = ensureConfigAndVisibilityAfterUpdate(starting, changes);
            }
        } finally {
            mTmpUpdateConfigurationResult.mIsUpdating = false;
            continueWindowLayout();
        }
        mTmpUpdateConfigurationResult.activityRelaunched = !kept;
+3 −18
Original line number Diff line number Diff line
@@ -1195,27 +1195,12 @@ public class AppTransitionController {
    private boolean transitionGoodToGo(ArraySet<? extends WindowContainer> apps,
            ArrayMap<WindowContainer, Integer> outReasons) {
        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                "Checking %d opening apps (frozen=%b timeout=%b)...", apps.size(),
                mService.mDisplayFrozen, mDisplayContent.mAppTransition.isTimeout());
                "Checking %d opening apps (timeout=%b)...", apps.size(),
                mDisplayContent.mAppTransition.isTimeout());
        if (mDisplayContent.mAppTransition.isTimeout()) {
            return true;
        }
        final ScreenRotationAnimation screenRotationAnimation = mService.mRoot.getDisplayContent(
                Display.DEFAULT_DISPLAY).getRotationAnimation();

        // Imagine the case where we are changing orientation due to an app transition, but a
        // previous orientation change is still in progress. We won't process the orientation
        // change for our transition because we need to wait for the rotation animation to
        // finish.
        // If we start the app transition at this point, we will interrupt it halfway with a
        // new rotation animation after the old one finally finishes. It's better to defer the
        // app transition.
        if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()
                && mDisplayContent.getDisplayRotation().needsUpdate()) {
            ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                    "Delaying app transition for screen rotation animation to finish");
            return false;
        }
        for (int i = 0; i < apps.size(); i++) {
            WindowContainer wc = apps.valueAt(i);
            final ActivityRecord activity = getAppFromContainer(wc);
+1 −2
Original line number Diff line number Diff line
@@ -135,8 +135,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume
        // decides not to perform seamless rotation, it only affects whether to use fade animation
        // when the windows are drawn. If the windows are not too slow (after rotation animation is
        // done) to be drawn, the visual result can still look smooth.
        mHasScreenRotationAnimation =
                displayContent.getRotationAnimation() != null || mTransitionOp == OP_CHANGE;
        mHasScreenRotationAnimation = mTransitionOp == OP_CHANGE;
        if (mHasScreenRotationAnimation) {
            // Hide the windows immediately because screen should have been covered by screenshot.
            mHideImmediately = true;
+5 −107

File changed.

Preview size limit exceeded, changes collapsed.

Loading