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

Commit 4862ad2e authored by David Lin's avatar David Lin Committed by Android (Google) Code Review
Browse files

Merge "Fix letterboxed app input info not added" into 24D1-dev

parents fdedd17d 571fb2b8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1882,7 +1882,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }
    void updateLetterboxSurfaceIfNeeded(WindowState winHint, Transaction t) {
        mLetterboxUiController.updateLetterboxSurfaceIfNeeded(winHint, t);
        mLetterboxUiController.updateLetterboxSurfaceIfNeeded(winHint, t, getPendingTransaction());
    }
    void updateLetterboxSurfaceIfNeeded(WindowState winHint) {
+9 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
import static android.view.SurfaceControl.HIDDEN;
import static android.window.TaskConstants.TASK_CHILD_LAYER_LETTERBOX_BACKGROUND;

import android.annotation.NonNull;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
@@ -209,16 +210,18 @@ public class Letterbox {
        return false;
    }

    public void applySurfaceChanges(SurfaceControl.Transaction t) {
    /** Applies surface changes such as colour, window crop, position and input info. */
    public void applySurfaceChanges(@NonNull SurfaceControl.Transaction t,
            @NonNull SurfaceControl.Transaction inputT) {
        if (useFullWindowSurface()) {
            mFullWindowSurface.applySurfaceChanges(t);
            mFullWindowSurface.applySurfaceChanges(t, inputT);

            for (LetterboxSurface surface : mSurfaces) {
                surface.remove();
            }
        } else {
            for (LetterboxSurface surface : mSurfaces) {
                surface.applySurfaceChanges(t);
                surface.applySurfaceChanges(t, inputT);
            }

            mFullWindowSurface.remove();
@@ -418,7 +421,8 @@ public class Letterbox {
            return Math.max(0, mLayoutFrameGlobal.height());
        }

        public void applySurfaceChanges(SurfaceControl.Transaction t) {
        public void applySurfaceChanges(@NonNull SurfaceControl.Transaction t,
                @NonNull SurfaceControl.Transaction inputT) {
            if (!needsApplySurfaceChanges()) {
                // Nothing changed.
                return;
@@ -446,7 +450,7 @@ public class Letterbox {
            }
            if (mSurface != null && mInputInterceptor != null) {
                mInputInterceptor.updateTouchableRegion(mSurfaceFrameRelative);
                t.setInputWindowInfo(mSurface, mInputInterceptor.mWindowHandle);
                inputT.setInputWindowInfo(mSurface, mInputInterceptor.mWindowHandle);
            }
        }

+5 −3
Original line number Diff line number Diff line
@@ -806,16 +806,18 @@ final class LetterboxUiController {
    }

    void updateLetterboxSurfaceIfNeeded(WindowState winHint) {
        updateLetterboxSurfaceIfNeeded(winHint, mActivityRecord.getSyncTransaction());
        updateLetterboxSurfaceIfNeeded(winHint, mActivityRecord.getSyncTransaction(),
                mActivityRecord.getPendingTransaction());
    }

    void updateLetterboxSurfaceIfNeeded(WindowState winHint, Transaction t) {
    void updateLetterboxSurfaceIfNeeded(WindowState winHint, @NonNull Transaction t,
            @NonNull Transaction inputT) {
        if (shouldNotLayoutLetterbox(winHint)) {
            return;
        }
        layoutLetterboxIfNeeded(winHint);
        if (mLetterbox != null && mLetterbox.needsApplySurfaceChanges()) {
            mLetterbox.applySurfaceChanges(t);
            mLetterbox.applySurfaceChanges(t, inputT);
        }
    }

+18 −13
Original line number Diff line number Diff line
@@ -172,14 +172,14 @@ public class LetterboxTest {
    @Test
    public void testSurfaceOrigin_applied() {
        mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();
        verify(mTransaction).setPosition(mSurfaces.top, -1000, -2000);
    }

    @Test
    public void testApplySurfaceChanges_setColor() {
        mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();

        verify(mTransaction).setColor(mSurfaces.top, new float[]{0, 0, 0});

@@ -187,7 +187,7 @@ public class LetterboxTest {

        assertTrue(mLetterbox.needsApplySurfaceChanges());

        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();

        verify(mTransaction).setColor(mSurfaces.top, new float[]{0, 1, 0});
    }
@@ -195,7 +195,7 @@ public class LetterboxTest {
    @Test
    public void testNeedsApplySurfaceChanges_wallpaperBackgroundRequested() {
        mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();

        verify(mTransaction).setAlpha(mSurfaces.top, 1.0f);
        assertFalse(mLetterbox.needsApplySurfaceChanges());
@@ -204,14 +204,14 @@ public class LetterboxTest {

        assertTrue(mLetterbox.needsApplySurfaceChanges());

        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();
        verify(mTransaction).setAlpha(mSurfaces.fullWindowSurface, mDarkScrimAlpha);
    }

    @Test
    public void testNeedsApplySurfaceChanges_setParentSurface() {
        mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();

        verify(mTransaction).reparent(mSurfaces.top, mParentSurface);
        assertFalse(mLetterbox.needsApplySurfaceChanges());
@@ -220,14 +220,14 @@ public class LetterboxTest {

        assertTrue(mLetterbox.needsApplySurfaceChanges());

        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();
        verify(mTransaction).reparent(mSurfaces.top, mParentSurface);
    }

    @Test
    public void testApplySurfaceChanges_cornersNotRounded_surfaceFullWindowSurfaceNotCreated() {
        mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();

        assertNull(mSurfaces.fullWindowSurface);
    }
@@ -236,7 +236,7 @@ public class LetterboxTest {
    public void testApplySurfaceChanges_cornersRounded_surfaceFullWindowSurfaceCreated() {
        mAreCornersRounded = true;
        mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();

        assertNotNull(mSurfaces.fullWindowSurface);
    }
@@ -245,7 +245,7 @@ public class LetterboxTest {
    public void testApplySurfaceChanges_wallpaperBackground_surfaceFullWindowSurfaceCreated() {
        mHasWallpaperBackground = true;
        mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();

        assertNotNull(mSurfaces.fullWindowSurface);
    }
@@ -254,7 +254,7 @@ public class LetterboxTest {
    public void testNotIntersectsOrFullyContains_cornersRounded() {
        mAreCornersRounded = true;
        mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(0, 0));
        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();

        assertTrue(mLetterbox.notIntersectsOrFullyContains(new Rect(1, 2, 9, 9)));
    }
@@ -262,14 +262,19 @@ public class LetterboxTest {
    @Test
    public void testSurfaceOrigin_changeCausesReapply() {
        mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();
        clearInvocations(mTransaction);
        mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(0, 0));
        assertTrue(mLetterbox.needsApplySurfaceChanges());
        mLetterbox.applySurfaceChanges(mTransaction);
        applySurfaceChanges();
        verify(mTransaction).setPosition(mSurfaces.top, 0, 0);
    }

    private void applySurfaceChanges() {
        mLetterbox.applySurfaceChanges(/* syncTransaction */ mTransaction,
                /* pendingTransaction */ mTransaction);
    }

    class SurfaceControlMocker implements Supplier<SurfaceControl.Builder> {
        private SurfaceControl.Builder mLeftBuilder;
        public SurfaceControl left;