summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-03-19 21:16:25 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-19 21:16:25 -0700
commit85b44c1b4e0de42e762f8606c55554c83c1e890b (patch)
treeea4314a9f614c029ff4a57199efbc29179f302b7 /libs
parentade3b59bc2f84144fefb54b2d3da34304d448589 (diff)
parent33f0ce08a5408ef1bafd0067ffc334ab28d2d2d4 (diff)
Merge "Do not remove decoration surface on DragResizeInputListener#close" into main
Diffstat (limited to 'libs')
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java4
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt22
2 files changed, 24 insertions, 2 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java
index 8a8bdcadd67a..97a47c602bcd 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java
@@ -435,7 +435,9 @@ class DragResizeInputListener implements AutoCloseable {
}
// Removing this surface on the background thread to ensure that mInitInputChannels has
// 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();
});
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt
index 360099777bde..95ae73cde19e 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt
@@ -40,6 +40,7 @@ import com.android.wm.shell.windowdecor.DragResizeInputListener.TaskResizeInputE
import com.google.common.truth.Truth.assertThat
import java.util.function.Consumer
import java.util.function.Supplier
+import kotlin.test.assertNotNull
import org.junit.After
import org.junit.Test
import org.junit.runner.RunWith
@@ -69,9 +70,12 @@ class DragResizeInputListenerTest : ShellTestCase() {
private val sinkInputChannel = mock<InputChannel>()
private val decorationSurface = SurfaceControl.Builder().setName("decoration surface").build()
private val createdSurfaces = ArrayList<SurfaceControl>()
+ private val removedSurfaces = ArrayList<SurfaceControl>()
@After
fun tearDown() {
+ createdSurfaces.clear()
+ removedSurfaces.clear()
decorationSurface.release()
}
@@ -217,6 +221,19 @@ class DragResizeInputListenerTest : ShellTestCase() {
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() {
verify(mockWindowSession, never())
.grantInputChannel(
@@ -258,7 +275,10 @@ class DragResizeInputListenerTest : ShellTestCase() {
{
object : StubTransaction() {
override fun remove(sc: SurfaceControl): SurfaceControl.Transaction {
- return super.remove(sc).also { sc.release() }
+ return super.remove(sc).also {
+ sc.release()
+ removedSurfaces.add(sc)
+ }
}
}
},