Loading services/core/java/com/android/server/wm/ActivityRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading services/core/java/com/android/server/wm/Letterbox.java +9 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -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; Loading Loading @@ -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); } } Loading services/core/java/com/android/server/wm/LetterboxUiController.java +5 −3 Original line number Diff line number Diff line Loading @@ -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); } } Loading services/tests/wmtests/src/com/android/server/wm/LetterboxTest.java +18 −13 Original line number Diff line number Diff line Loading @@ -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}); Loading @@ -187,7 +187,7 @@ public class LetterboxTest { assertTrue(mLetterbox.needsApplySurfaceChanges()); mLetterbox.applySurfaceChanges(mTransaction); applySurfaceChanges(); verify(mTransaction).setColor(mSurfaces.top, new float[]{0, 1, 0}); } Loading @@ -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()); Loading @@ -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()); Loading @@ -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); } Loading @@ -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); } Loading @@ -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); } Loading @@ -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))); } Loading @@ -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; Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading
services/core/java/com/android/server/wm/Letterbox.java +9 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -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; Loading Loading @@ -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); } } Loading
services/core/java/com/android/server/wm/LetterboxUiController.java +5 −3 Original line number Diff line number Diff line Loading @@ -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); } } Loading
services/tests/wmtests/src/com/android/server/wm/LetterboxTest.java +18 −13 Original line number Diff line number Diff line Loading @@ -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}); Loading @@ -187,7 +187,7 @@ public class LetterboxTest { assertTrue(mLetterbox.needsApplySurfaceChanges()); mLetterbox.applySurfaceChanges(mTransaction); applySurfaceChanges(); verify(mTransaction).setColor(mSurfaces.top, new float[]{0, 1, 0}); } Loading @@ -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()); Loading @@ -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()); Loading @@ -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); } Loading @@ -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); } Loading @@ -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); } Loading @@ -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))); } Loading @@ -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; Loading