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

Commit 571fb2b8 authored by Graciela Wissen Putri's avatar Graciela Wissen Putri
Browse files

Fix letterboxed app input info not added

Launcher remote animation requires permission ACCESS_SURFACE_FLINGER to
set input info. Use pendingTransaction instead of syncTransaction to let
system_server apply input info with permission.

Flag: EXEMPT bugfix
Fix: 352717194
Bug: 345729003
Test: atest LetterboxTest
      atest SizeCompatTests
      atest LetterboxUiControllerTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:4f08ec1ddd88608f09c2c995cfc6e11735d50797)

Merged-In: I66d0b1dbd6aad4639e8e25994577232e388f47bd
Change-Id: I66d0b1dbd6aad4639e8e25994577232e388f47bd
parent 5a8d897c
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;