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

Commit 6458202a authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "Suppress orientation changes during drag operations" into honeycomb

parents a6cbd728 ccd24de8
Loading
Loading
Loading
Loading
+54 −15
Original line number Diff line number Diff line
@@ -505,6 +505,10 @@ public class WindowManagerService extends IWindowManager.Stub
        ArrayList<WindowState> mNotifiedWindows;
        boolean mDragInProgress;

        boolean mPerformDeferredRotation;
        int mRotation;
        int mAnimFlags;

        private final Rect tmpRect = new Rect();

        DragState(IBinder token, Surface surface, int flags, IBinder localWin) {
@@ -526,6 +530,7 @@ public class WindowManagerService extends IWindowManager.Stub
            mData = null;
            mThumbOffsetX = mThumbOffsetY = 0;
            mNotifiedWindows = null;
            mPerformDeferredRotation = false;
        }

        void register() {
@@ -666,9 +671,25 @@ public class WindowManagerService extends IWindowManager.Stub
            mDragState.unregister();
            mInputMonitor.updateInputWindowsLw();

            // Retain the parameters of any deferred rotation operation so
            // that we can perform it after the reset / unref of the drag state
            final boolean performRotation = mPerformDeferredRotation;
            final int rotation = mRotation;
            final int animFlags = mAnimFlags;

            // free our resources and drop all the object references
            mDragState.reset();
            mDragState = null;

            // Now that we've officially ended the drag, execute any
            // deferred rotation
            if (performRotation) {
                if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-drag rotation");
                boolean changed = setRotationUncheckedLocked(rotation, animFlags);
                if (changed) {
                    sendNewConfiguration();
                }
            }
        }

        void notifyMoveLw(float x, float y) {
@@ -812,6 +833,12 @@ public class WindowManagerService extends IWindowManager.Stub

            return touchedWin;
        }

        void setDeferredRotation(int rotation, int animFlags) {
            mRotation = rotation;
            mAnimFlags = animFlags;
            mPerformDeferredRotation = true;
        }
    }

    DragState mDragState = null;
@@ -5076,6 +5103,14 @@ public class WindowManagerService extends IWindowManager.Stub
     * MUST CALL setNewConfiguration() TO UNFREEZE THE SCREEN.
     */
    public boolean setRotationUncheckedLocked(int rotation, int animFlags) {
        if (mDragState != null) {
            // Potential rotation during a drag.  Don't do the rotation now, but make
            // a note to perform the rotation later.
            if (DEBUG_ORIENTATION) Slog.v(TAG, "Deferring rotation during drag");
            mDragState.setDeferredRotation(rotation, animFlags);
            return false;
        }

        boolean changed;
        if (rotation == WindowManagerPolicy.USE_LAST_ROTATION) {
            rotation = mRequestedRotation;
@@ -6496,6 +6531,8 @@ public class WindowManagerService extends IWindowManager.Stub
            }

            synchronized (mWindowMap) {
                long ident = Binder.clearCallingIdentity();
                try {
                    if (mDragState.mToken != token) {
                        Slog.w(TAG, "Invalid drop-result claim by " + window);
                        throw new IllegalStateException("reportDropResult() by non-recipient");
@@ -6505,7 +6542,6 @@ public class WindowManagerService extends IWindowManager.Stub
                    // so be sure to halt the timeout even if the later WindowState
                    // lookup fails.
                    mH.removeMessages(H.DRAG_END_TIMEOUT, window.asBinder());

                    WindowState callingWin = windowForClientLocked(null, window, false);
                    if (callingWin == null) {
                        Slog.w(TAG, "Bad result-reporting window " + window);
@@ -6514,6 +6550,9 @@ public class WindowManagerService extends IWindowManager.Stub

                    mDragState.mDragResult = consumed;
                    mDragState.endDragLw();
                } finally {
                    Binder.restoreCallingIdentity(ident);
                }
            }
        }