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

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

Merge "Associate freezing display with a target display id." into oc-dev

parents 229119e0 8f85358f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1107,7 +1107,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
                mAppAnimator.lastFreezeDuration = 0;
                mAppAnimator.lastFreezeDuration = 0;
                mService.mAppsFreezingScreen++;
                mService.mAppsFreezingScreen++;
                if (mService.mAppsFreezingScreen == 1) {
                if (mService.mAppsFreezingScreen == 1) {
                    mService.startFreezingDisplayLocked(false, 0, 0);
                    mService.startFreezingDisplayLocked(false, 0, 0, getDisplayContent());
                    mService.mH.removeMessages(H.APP_FREEZE_TIMEOUT);
                    mService.mH.removeMessages(H.APP_FREEZE_TIMEOUT);
                    mService.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000);
                    mService.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000);
                }
                }
+1 −1
Original line number Original line Diff line number Diff line
@@ -987,7 +987,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }
        }


        if (!rotateSeamlessly) {
        if (!rotateSeamlessly) {
            mService.startFreezingDisplayLocked(inTransaction, anim[0], anim[1]);
            mService.startFreezingDisplayLocked(inTransaction, anim[0], anim[1], this);
            // startFreezingDisplayLocked can reset the ScreenRotationAnimation.
            // startFreezingDisplayLocked can reset the ScreenRotationAnimation.
            screenRotationAnimation = mService.mAnimator.getScreenRotationAnimationLocked(
            screenRotationAnimation = mService.mAnimator.getScreenRotationAnimationLocked(
                    mDisplayId);
                    mDisplayId);
+28 −10
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.Manifest.permission.MANAGE_APP_TOKENS;
import static android.Manifest.permission.READ_FRAME_BUFFER;
import static android.Manifest.permission.READ_FRAME_BUFFER;
import static android.Manifest.permission.REGISTER_WINDOW_MANAGER_LISTENERS;
import static android.Manifest.permission.REGISTER_WINDOW_MANAGER_LISTENERS;
import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
import static android.app.StatusBarManager.DISABLE_MASK;
import static android.app.StatusBarManager.DISABLE_MASK;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED;
@@ -33,6 +32,7 @@ import static android.os.Process.THREAD_PRIORITY_DISPLAY;
import static android.os.Process.myPid;
import static android.os.Process.myPid;
import static android.os.UserHandle.USER_NULL;
import static android.os.UserHandle.USER_NULL;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
@@ -724,6 +724,9 @@ public class WindowManagerService extends IWindowManager.Stub
    // For frozen screen animations.
    // For frozen screen animations.
    private int mExitAnimId, mEnterAnimId;
    private int mExitAnimId, mEnterAnimId;


    // The display that the rotation animation is applying to.
    private int mFrozenDisplayId;

    /** Skip repeated AppWindowTokens initialization. Note that AppWindowsToken's version of this
    /** Skip repeated AppWindowTokens initialization. Note that AppWindowsToken's version of this
     * is a long initialized to Long.MIN_VALUE so that it doesn't match this value on startup. */
     * is a long initialized to Long.MIN_VALUE so that it doesn't match this value on startup. */
    int mTransactionSequence;
    int mTransactionSequence;
@@ -2449,7 +2452,7 @@ public class WindowManagerService extends IWindowManager.Stub
                } else {
                } else {
                    mPolicy.selectRotationAnimationLw(anim);
                    mPolicy.selectRotationAnimationLw(anim);
                }
                }
                startFreezingDisplayLocked(false, anim[0], anim[1]);
                startFreezingDisplayLocked(false, anim[0], anim[1], displayContent);
                config = new Configuration(mTempConfiguration);
                config = new Configuration(mTempConfiguration);
            }
            }
        }
        }
@@ -5555,7 +5558,7 @@ public class WindowManagerService extends IWindowManager.Stub
        if (configChanged) {
        if (configChanged) {
            mWaitingForConfig = true;
            mWaitingForConfig = true;
            startFreezingDisplayLocked(false /* inTransaction */, 0 /* exitAnim */,
            startFreezingDisplayLocked(false /* inTransaction */, 0 /* exitAnim */,
                    0 /* enterAnim */);
                    0 /* enterAnim */, displayContent);
            mH.obtainMessage(H.SEND_NEW_CONFIGURATION, displayId).sendToTarget();
            mH.obtainMessage(H.SEND_NEW_CONFIGURATION, displayId).sendToTarget();
        }
        }


@@ -5862,6 +5865,12 @@ public class WindowManagerService extends IWindowManager.Stub
    }
    }


    void startFreezingDisplayLocked(boolean inTransaction, int exitAnim, int enterAnim) {
    void startFreezingDisplayLocked(boolean inTransaction, int exitAnim, int enterAnim) {
        startFreezingDisplayLocked(inTransaction, exitAnim, enterAnim,
                getDefaultDisplayContentLocked());
    }

    void startFreezingDisplayLocked(boolean inTransaction, int exitAnim, int enterAnim,
            DisplayContent displayContent) {
        if (mDisplayFrozen) {
        if (mDisplayFrozen) {
            return;
            return;
        }
        }
@@ -5882,6 +5891,10 @@ public class WindowManagerService extends IWindowManager.Stub
        mDisplayFreezeTime = SystemClock.elapsedRealtime();
        mDisplayFreezeTime = SystemClock.elapsedRealtime();
        mLastFinishedFreezeSource = null;
        mLastFinishedFreezeSource = null;


        // {@link mDisplayFrozen} prevents us from freezing on multiple displays at the same time.
        // As a result, we only track the display that has initially froze the screen.
        mFrozenDisplayId = displayContent.getDisplayId();

        mInputMonitor.freezeInputDispatchingLw();
        mInputMonitor.freezeInputDispatchingLw();


        // Clear the last input window -- that is just used for
        // Clear the last input window -- that is just used for
@@ -5901,10 +5914,8 @@ public class WindowManagerService extends IWindowManager.Stub
        if (CUSTOM_SCREEN_ROTATION) {
        if (CUSTOM_SCREEN_ROTATION) {
            mExitAnimId = exitAnim;
            mExitAnimId = exitAnim;
            mEnterAnimId = enterAnim;
            mEnterAnimId = enterAnim;
            final DisplayContent displayContent = getDefaultDisplayContentLocked();
            final int displayId = displayContent.getDisplayId();
            ScreenRotationAnimation screenRotationAnimation =
            ScreenRotationAnimation screenRotationAnimation =
                    mAnimator.getScreenRotationAnimationLocked(displayId);
                    mAnimator.getScreenRotationAnimationLocked(mFrozenDisplayId);
            if (screenRotationAnimation != null) {
            if (screenRotationAnimation != null) {
                screenRotationAnimation.kill();
                screenRotationAnimation.kill();
            }
            }
@@ -5915,8 +5926,10 @@ public class WindowManagerService extends IWindowManager.Stub
            // TODO(multidisplay): rotation on main screen only.
            // TODO(multidisplay): rotation on main screen only.
            displayContent.updateDisplayInfo();
            displayContent.updateDisplayInfo();
            screenRotationAnimation = new ScreenRotationAnimation(mContext, displayContent,
            screenRotationAnimation = new ScreenRotationAnimation(mContext, displayContent,
                    mFxSession, inTransaction, mPolicy.isDefaultOrientationForced(), isSecure, this);
                    mFxSession, inTransaction, mPolicy.isDefaultOrientationForced(), isSecure,
            mAnimator.setScreenRotationAnimationLocked(displayId, screenRotationAnimation);
                    this);
            mAnimator.setScreenRotationAnimationLocked(mFrozenDisplayId,
                    screenRotationAnimation);
        }
        }
    }
    }


@@ -5940,6 +5953,13 @@ public class WindowManagerService extends IWindowManager.Stub
        if (DEBUG_ORIENTATION) Slog.d(TAG_WM,
        if (DEBUG_ORIENTATION) Slog.d(TAG_WM,
                "stopFreezingDisplayLocked: Unfreezing now");
                "stopFreezingDisplayLocked: Unfreezing now");


        final DisplayContent displayContent = mRoot.getDisplayContent(mFrozenDisplayId);

        // We must make a local copy of the displayId as it can be potentially overwritten later on
        // in this method. For example, {@link startFreezingDisplayLocked} may be called as a result
        // of update rotation, but we reference the frozen display after that call in this method.
        final int displayId = mFrozenDisplayId;
        mFrozenDisplayId = INVALID_DISPLAY;
        mDisplayFrozen = false;
        mDisplayFrozen = false;
        mLastDisplayFreezeDuration = (int)(SystemClock.elapsedRealtime() - mDisplayFreezeTime);
        mLastDisplayFreezeDuration = (int)(SystemClock.elapsedRealtime() - mDisplayFreezeTime);
        StringBuilder sb = new StringBuilder(128);
        StringBuilder sb = new StringBuilder(128);
@@ -5958,8 +5978,6 @@ public class WindowManagerService extends IWindowManager.Stub


        boolean updateRotation = false;
        boolean updateRotation = false;


        final DisplayContent displayContent = getDefaultDisplayContentLocked();
        final int displayId = displayContent.getDisplayId();
        ScreenRotationAnimation screenRotationAnimation =
        ScreenRotationAnimation screenRotationAnimation =
                mAnimator.getScreenRotationAnimationLocked(displayId);
                mAnimator.getScreenRotationAnimationLocked(displayId);
        if (CUSTOM_SCREEN_ROTATION && screenRotationAnimation != null
        if (CUSTOM_SCREEN_ROTATION && screenRotationAnimation != null