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

Commit 33f0ce08 authored by Jorge Gil's avatar Jorge Gil
Browse files

Do not remove decoration surface on DragResizeInputListener#close

I37ba7d97d51079ba07148a425826a0cd9b59c3fd made a change to create a copy
of the decoration container surface to allow DRIL to manage its release
in the correct thread. However, it started using SC.T#remove() to
release the surface, which is fine in most cases because closing the
DRIL usually happens when the decoration is also closing. In
desktop-immersive cases though, where we make a desktop task use
fullscreen bounds, we want to dispose of the DRIL because it is no
longer drag-resizable, but we want to keep the decoration surface
because we still show an App Header.

With this change, the copied decoration surface is only release in
close(), and removal continues to be managed by WindowDecoration.

Flag: com.android.window.flags.enable_drag_resize_set_up_in_bg_thread
Fix: 404581880
Test: put immersive-capable app into desktop-immersive, drag down from
status bar - verify App Header becomes visible

Change-Id: I029c56189fc8656789cf0ece2437d8cc16475208
parent c9091359
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -435,7 +435,9 @@ class DragResizeInputListener implements AutoCloseable {
            }
            }
            // Removing this surface on the background thread to ensure that mInitInputChannels has
            // Removing this surface on the background thread to ensure that mInitInputChannels has
            // already been finished.
            // already been finished.
            mSurfaceControlTransactionSupplier.get().remove(mDecorationSurface).apply();
            // Do not |remove| the surface, the decoration might still be needed even if
            // drag-resizing isn't.
            mDecorationSurface.release();
        });
        });
    }
    }


+21 −1
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.wm.shell.windowdecor.DragResizeInputListener.TaskResizeInputE
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertThat
import java.util.function.Consumer
import java.util.function.Consumer
import java.util.function.Supplier
import java.util.function.Supplier
import kotlin.test.assertNotNull
import org.junit.After
import org.junit.After
import org.junit.Test
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runner.RunWith
@@ -69,9 +70,12 @@ class DragResizeInputListenerTest : ShellTestCase() {
    private val sinkInputChannel = mock<InputChannel>()
    private val sinkInputChannel = mock<InputChannel>()
    private val decorationSurface = SurfaceControl.Builder().setName("decoration surface").build()
    private val decorationSurface = SurfaceControl.Builder().setName("decoration surface").build()
    private val createdSurfaces = ArrayList<SurfaceControl>()
    private val createdSurfaces = ArrayList<SurfaceControl>()
    private val removedSurfaces = ArrayList<SurfaceControl>()


    @After
    @After
    fun tearDown() {
    fun tearDown() {
        createdSurfaces.clear()
        removedSurfaces.clear()
        decorationSurface.release()
        decorationSurface.release()
    }
    }


@@ -217,6 +221,19 @@ class DragResizeInputListenerTest : ShellTestCase() {
        assertThat(createdSurfaces[1].isValid).isFalse()
        assertThat(createdSurfaces[1].isValid).isFalse()
    }
    }


    @Test
    fun testClose_releasesDecorationSurfaceWithoutRemoval() {
        val inputListener = create()
        testBgExecutor.flushAll()
        inputListener.close()
        testMainExecutor.flushAll()
        testBgExecutor.flushAll()

        val decorationSurface = assertNotNull(createdSurfaces[0])
        assertThat(decorationSurface.isValid).isFalse()
        assertThat(removedSurfaces.contains(decorationSurface)).isFalse()
    }

    private fun verifyNoInputChannelGrantRequests() {
    private fun verifyNoInputChannelGrantRequests() {
        verify(mockWindowSession, never())
        verify(mockWindowSession, never())
            .grantInputChannel(
            .grantInputChannel(
@@ -258,7 +275,10 @@ class DragResizeInputListenerTest : ShellTestCase() {
            {
            {
                object : StubTransaction() {
                object : StubTransaction() {
                    override fun remove(sc: SurfaceControl): SurfaceControl.Transaction {
                    override fun remove(sc: SurfaceControl): SurfaceControl.Transaction {
                        return super.remove(sc).also { sc.release() }
                        return super.remove(sc).also {
                            sc.release()
                            removedSurfaces.add(sc)
                        }
                    }
                    }
                }
                }
            },
            },