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

Commit 1153d4ed authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Ensure window is attached before adding a child SC

buildReparentTransaction can't be called before the window is attached
or it will return null.

Bug: 291053162
Test: ScreenshotTests
Change-Id: I5391acbc6d2a7677e282acaed0a78901e1a1457c
parent e69e71a5
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ public class ScreenshotTests {
    }

    @Test
    public void testScreenshotSecureLayers() {
    public void testScreenshotSecureLayers() throws InterruptedException {
        SurfaceControl secureSC = new SurfaceControl.Builder()
                .setName("SecureChildSurfaceControl")
                .setBLASTLayer()
@@ -197,6 +197,8 @@ public class ScreenshotTests {
        private static final long WAIT_TIMEOUT_S = 5;
        private final Handler mHandler = new Handler(Looper.getMainLooper());

        private final CountDownLatch mAttachedLatch = new CountDownLatch(1);

        @Override
        protected void onCreate(@Nullable Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
@@ -204,7 +206,16 @@ public class ScreenshotTests {
                    PointerIcon.getSystemIcon(this, PointerIcon.TYPE_NULL));
        }

        SurfaceControl.Transaction addChildSc(SurfaceControl surfaceControl) {
        @Override
        public void onAttachedToWindow() {
            super.onAttachedToWindow();
            mAttachedLatch.countDown();
        }

        SurfaceControl.Transaction addChildSc(SurfaceControl surfaceControl)
                throws InterruptedException {
            assertTrue("Failed to wait for onAttachedToWindow",
                    mAttachedLatch.await(WAIT_TIMEOUT_S, TimeUnit.SECONDS));
            SurfaceControl.Transaction t = new SurfaceControl.Transaction();
            CountDownLatch countDownLatch = new CountDownLatch(1);
            mHandler.post(() -> {