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

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

Merge "Allow to show IME snapshot on home when turning off screen" into main

parents a1c72639 ef67dd66
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -4566,7 +4566,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }
        }

        void attachAndShow(Transaction t) {
        /**
         * Attaches the snapshot of IME (a snapshot will be taken if there wasn't one) to the IME
         * target task and shows it. If the given {@param anyTargetTask} is true, the snapshot won't
         * be skipped by the activity type of IME target task.
         */
        void attachAndShow(Transaction t, boolean anyTargetTask) {
            final DisplayContent dc = mImeTarget.getDisplayContent();
            // Prepare IME screenshot for the target if it allows to attach into.
            final Task task = mImeTarget.getTask();
@@ -4574,7 +4579,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            final boolean renewImeSurface = mImeSurface == null
                    || mImeSurface.getWidth() != dc.mInputMethodWindow.getFrame().width()
                    || mImeSurface.getHeight() != dc.mInputMethodWindow.getFrame().height();
            if (task != null && !task.isActivityTypeHomeOrRecents()) {
            // The exclusion of home/recents is an optimization for regular task switch because
            // home/recents won't appear in recents task.
            if (task != null && (anyTargetTask || !task.isActivityTypeHomeOrRecents())) {
                ScreenCapture.ScreenshotHardwareBuffer imeBuffer = renewImeSurface
                        ? dc.mWmService.mTaskSnapshotController.snapshotImeFromAttachedTask(task)
                        : null;
@@ -4642,7 +4649,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        removeImeSurfaceImmediately();
        mImeScreenshot = new ImeScreenshot(
                mWmService.mSurfaceControlFactory.apply(null), imeTarget);
        mImeScreenshot.attachAndShow(t);
        // If the caller requests to hide IME, then allow to show IME snapshot for any target task.
        // So IME won't look like suddenly disappeared. It usually happens when turning off screen.
        mImeScreenshot.attachAndShow(t, hideImeWindow /* anyTargetTask */);
        if (mInputMethodWindow != null && hideImeWindow) {
            // Hide the IME window when deciding to show IME snapshot on demand.
            // InsetsController will make IME visible again before animating it.