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

Commit 956647ec authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Revert "Use configuration delta to determine if still in orientation...

Merge "Revert "Use configuration delta to determine if still in orientation change."" into oc-dr1-dev
parents da075a96 31386ab8
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -1073,7 +1073,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            }
            }
            if (w.mHasSurface && !rotateSeamlessly) {
            if (w.mHasSurface && !rotateSeamlessly) {
                if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Set mOrientationChanging of " + w);
                if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Set mOrientationChanging of " + w);
                w.setOrientationChanging(true);
                w.mOrientationChanging = true;
                mService.mRoot.mOrientationChangeComplete = false;
                mService.mRoot.mOrientationChangeComplete = false;
                w.mLastFreezeDuration = 0;
                w.mLastFreezeDuration = 0;
            }
            }
@@ -2679,10 +2679,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_TIMEOUT;
        mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_TIMEOUT;


        forAllWindows(w -> {
        forAllWindows(w -> {
            if (!w.getOrientationChanging()) {
            if (!w.mOrientationChanging) {
                return;
                return;
            }
            }
            w.setOrientationChanging(false);
            w.mOrientationChanging = false;
            w.mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
            w.mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
                    - mService.mDisplayFreezeTime);
                    - mService.mDisplayFreezeTime);
            Slog.w(TAG_WM, "Force clearing orientation change: " + w);
            Slog.w(TAG_WM, "Force clearing orientation change: " + w);
+1 −1
Original line number Original line Diff line number Diff line
@@ -5789,7 +5789,7 @@ public class WindowManagerService extends IWindowManager.Stub
        // orientation.
        // orientation.
        if (!okToDisplay() && mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_TIMEOUT) {
        if (!okToDisplay() && mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_TIMEOUT) {
            if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Changing surface while display frozen: " + w);
            if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Changing surface while display frozen: " + w);
            w.setOrientationChanging(true);
            w.mOrientationChanging = true;
            w.mLastFreezeDuration = 0;
            w.mLastFreezeDuration = 0;
            mRoot.mOrientationChangeComplete = false;
            mRoot.mOrientationChangeComplete = false;
            if (mWindowsFreezingScreen == WINDOWS_FREEZING_SCREENS_NONE) {
            if (mWindowsFreezingScreen == WINDOWS_FREEZING_SCREENS_NONE) {
+8 −28
Original line number Original line Diff line number Diff line
@@ -441,7 +441,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
     * Set when the orientation is changing and this window has not yet
     * Set when the orientation is changing and this window has not yet
     * been updated for the new orientation.
     * been updated for the new orientation.
     */
     */
    private boolean mOrientationChanging;
    boolean mOrientationChanging;


    /**
    /**
     * The orientation during the last visible call to relayout. If our
     * The orientation during the last visible call to relayout. If our
@@ -1184,8 +1184,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            // then we need to hold off on unfreezing the display until this window has been
            // then we need to hold off on unfreezing the display until this window has been
            // redrawn; to do that, we need to go through the process of getting informed by the
            // redrawn; to do that, we need to go through the process of getting informed by the
            // application when it has finished drawing.
            // application when it has finished drawing.
            if (getOrientationChanging() || dragResizingChanged
            if (mOrientationChanging || dragResizingChanged || isResizedWhileNotDragResizing()) {
                    || isResizedWhileNotDragResizing()) {
                if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || DEBUG_ORIENTATION || DEBUG_RESIZE) {
                if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || DEBUG_ORIENTATION || DEBUG_RESIZE) {
                    Slog.v(TAG_WM, "Orientation or resize start waiting for draw"
                    Slog.v(TAG_WM, "Orientation or resize start waiting for draw"
                            + ", mDrawState=DRAW_PENDING in " + this
                            + ", mDrawState=DRAW_PENDING in " + this
@@ -1200,33 +1199,17 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG_WM, "Resizing window " + this);
                if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG_WM, "Resizing window " + this);
                mService.mResizingWindows.add(this);
                mService.mResizingWindows.add(this);
            }
            }
        } else if (getOrientationChanging()) {
        } else if (mOrientationChanging) {
            if (isDrawnLw()) {
            if (isDrawnLw()) {
                if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Orientation not waiting for draw in "
                if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Orientation not waiting for draw in "
                        + this + ", surfaceController " + winAnimator.mSurfaceController);
                        + this + ", surfaceController " + winAnimator.mSurfaceController);
                setOrientationChanging(false);
                mOrientationChanging = false;
                mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
                mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
                        - mService.mDisplayFreezeTime);
                        - mService.mDisplayFreezeTime);
            }
            }
        }
        }
    }
    }


    boolean getOrientationChanging() {
        // In addition to the local state flag, we must also consider the difference in the last
        // reported configuration vs. the current state. If the client code has not been informed of
        // the change, logic dependent on having finished processing the orientation, such as
        // unfreezing, could be improperly triggered.
        // TODO(b/62846907): Checking against {@link mLastReportedConfiguration} could be flaky as
        //                   this is not necessarily what the client has processed yet. Find a
        //                   better indicator consistent with the client.
        return mOrientationChanging
                || getConfiguration().orientation != mLastReportedConfiguration.orientation;
    }

    void setOrientationChanging(boolean changing) {
        mOrientationChanging = changing;
    }

    DisplayContent getDisplayContent() {
    DisplayContent getDisplayContent() {
        return mToken.getDisplayContent();
        return mToken.getDisplayContent();
    }
    }
@@ -2680,10 +2663,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP


        mAppFreezing = false;
        mAppFreezing = false;


        if (mHasSurface && !getOrientationChanging()
        if (mHasSurface && !mOrientationChanging
                && mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_TIMEOUT) {
                && mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_TIMEOUT) {
            if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "set mOrientationChanging of " + this);
            if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "set mOrientationChanging of " + this);
            setOrientationChanging(true);
            mOrientationChanging = true;
            mService.mRoot.mOrientationChangeComplete = false;
            mService.mRoot.mOrientationChangeComplete = false;
        }
        }
        mLastFreezeDuration = 0;
        mLastFreezeDuration = 0;
@@ -3102,7 +3085,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            mWinAnimator.mSurfaceResized = false;
            mWinAnimator.mSurfaceResized = false;
            mReportOrientationChanged = false;
            mReportOrientationChanged = false;
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            setOrientationChanging(false);
            mOrientationChanging = false;
            mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
            mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
                    - mService.mDisplayFreezeTime);
                    - mService.mDisplayFreezeTime);
            // We are assuming the hosting process is dead or in a zombie state.
            // We are assuming the hosting process is dead or in a zombie state.
@@ -3461,13 +3444,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    pw.print(" mDestroying="); pw.print(mDestroying);
                    pw.print(" mDestroying="); pw.print(mDestroying);
                    pw.print(" mRemoved="); pw.println(mRemoved);
                    pw.print(" mRemoved="); pw.println(mRemoved);
        }
        }
        if (getOrientationChanging() || mAppFreezing || mTurnOnScreen
        if (mOrientationChanging || mAppFreezing || mTurnOnScreen
                || mReportOrientationChanged) {
                || mReportOrientationChanged) {
            pw.print(prefix); pw.print("mOrientationChanging=");
            pw.print(prefix); pw.print("mOrientationChanging=");
                    pw.print(mOrientationChanging);
                    pw.print(mOrientationChanging);
                    pw.print(" configOrientationChanging=");
                    pw.print(mLastReportedConfiguration.orientation
                            != getConfiguration().orientation);
                    pw.print(" mAppFreezing="); pw.print(mAppFreezing);
                    pw.print(" mAppFreezing="); pw.print(mAppFreezing);
                    pw.print(" mTurnOnScreen="); pw.print(mTurnOnScreen);
                    pw.print(" mTurnOnScreen="); pw.print(mTurnOnScreen);
                    pw.print(" mReportOrientationChanged="); pw.println(mReportOrientationChanged);
                    pw.print(" mReportOrientationChanged="); pw.println(mReportOrientationChanged);
+7 −7
Original line number Original line Diff line number Diff line
@@ -1527,11 +1527,11 @@ class WindowStateAnimator {


            // There is no need to wait for an animation change if our window is gone for layout
            // There is no need to wait for an animation change if our window is gone for layout
            // already as we'll never be visible.
            // already as we'll never be visible.
            if (w.getOrientationChanging() && w.isGoneForLayoutLw()) {
            if (w.mOrientationChanging && w.isGoneForLayoutLw()) {
                if (DEBUG_ORIENTATION) {
                if (DEBUG_ORIENTATION) {
                    Slog.v(TAG, "Orientation change skips hidden " + w);
                    Slog.v(TAG, "Orientation change skips hidden " + w);
                }
                }
                w.setOrientationChanging(false);
                w.mOrientationChanging = false;
            }
            }
            return;
            return;
        }
        }
@@ -1564,8 +1564,8 @@ class WindowStateAnimator {
            // really hidden (gone for layout), there is no point in still waiting for it.
            // really hidden (gone for layout), there is no point in still waiting for it.
            // Note that this does introduce a potential glitch if the window becomes unhidden
            // Note that this does introduce a potential glitch if the window becomes unhidden
            // before it has drawn for the new orientation.
            // before it has drawn for the new orientation.
            if (w.getOrientationChanging() && w.isGoneForLayoutLw()) {
            if (w.mOrientationChanging && w.isGoneForLayoutLw()) {
                w.setOrientationChanging(false);
                w.mOrientationChanging = false;
                if (DEBUG_ORIENTATION) Slog.v(TAG,
                if (DEBUG_ORIENTATION) Slog.v(TAG,
                        "Orientation change skips hidden " + w);
                        "Orientation change skips hidden " + w);
            }
            }
@@ -1618,7 +1618,7 @@ class WindowStateAnimator {
                    mAnimator.setPendingLayoutChanges(w.getDisplayId(),
                    mAnimator.setPendingLayoutChanges(w.getDisplayId(),
                            WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
                            WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
                } else {
                } else {
                    w.setOrientationChanging(false);
                    w.mOrientationChanging = false;
                }
                }
            }
            }
            if (hasSurface()) {
            if (hasSurface()) {
@@ -1631,14 +1631,14 @@ class WindowStateAnimator {
            displayed = true;
            displayed = true;
        }
        }


        if (w.getOrientationChanging()) {
        if (w.mOrientationChanging) {
            if (!w.isDrawnLw()) {
            if (!w.isDrawnLw()) {
                mAnimator.mBulkUpdateParams &= ~SET_ORIENTATION_CHANGE_COMPLETE;
                mAnimator.mBulkUpdateParams &= ~SET_ORIENTATION_CHANGE_COMPLETE;
                mAnimator.mLastWindowFreezeSource = w;
                mAnimator.mLastWindowFreezeSource = w;
                if (DEBUG_ORIENTATION) Slog.v(TAG,
                if (DEBUG_ORIENTATION) Slog.v(TAG,
                        "Orientation continue waiting for draw in " + w);
                        "Orientation continue waiting for draw in " + w);
            } else {
            } else {
                w.setOrientationChanging(false);
                w.mOrientationChanging = false;
                if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w);
                if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w);
            }
            }
        }
        }