summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java3
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHandleViewHolder.kt40
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java1
3 files changed, 27 insertions, 17 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java
index 5d16d972a0f2..cb55009061d3 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java
@@ -544,7 +544,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
mResult.mRootView,
mOnCaptionTouchListener,
mOnCaptionButtonClickListener,
- mWindowManagerWrapper
+ mWindowManagerWrapper,
+ mHandler
);
} else if (mRelayoutParams.mLayoutResId
== R.layout.desktop_mode_app_header) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHandleViewHolder.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHandleViewHolder.kt
index 9ef4b8cde8ef..d80461cdded8 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHandleViewHolder.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHandleViewHolder.kt
@@ -22,6 +22,7 @@ import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.Point
import android.hardware.input.InputManager
+import android.os.Handler
import android.view.MotionEvent.ACTION_DOWN
import android.view.SurfaceControl
import android.view.View
@@ -44,7 +45,8 @@ internal class AppHandleViewHolder(
rootView: View,
onCaptionTouchListener: View.OnTouchListener,
onCaptionButtonClickListener: OnClickListener,
- private val windowManagerWrapper: WindowManagerWrapper
+ private val windowManagerWrapper: WindowManagerWrapper,
+ private val handler: Handler
) : WindowDecorationViewHolder(rootView) {
companion object {
@@ -54,6 +56,7 @@ internal class AppHandleViewHolder(
private val captionView: View = rootView.requireViewById(R.id.desktop_mode_caption)
private val captionHandle: ImageButton = rootView.requireViewById(R.id.caption_handle)
private val inputManager = context.getSystemService(InputManager::class.java)
+ private var statusBarInputLayerExists = false
// An invisible View that takes up the same coordinates as captionHandle but is layered
// above the status bar. The purpose of this View is to receive input intended for
@@ -78,14 +81,18 @@ internal class AppHandleViewHolder(
// If handle is not in status bar region(i.e., bottom stage in vertical split),
// do not create an input layer
if (position.y >= SystemBarUtils.getStatusBarHeight(context)) return
- if (!isCaptionVisible && hasStatusBarInputLayer() ) {
+ if (!isCaptionVisible && statusBarInputLayerExists) {
disposeStatusBarInputLayer()
return
}
- if (hasStatusBarInputLayer()) {
- updateStatusBarInputLayer(position)
+ // Input layer view creation / modification takes a significant amount of time;
+ // post them so we don't hold up DesktopModeWindowDecoration#relayout.
+ if (statusBarInputLayerExists) {
+ handler.post { updateStatusBarInputLayer(position) }
} else {
- createStatusBarInputLayer(position, width, height)
+ // Input layer is created on a delay; prevent multiple from being created.
+ statusBarInputLayerExists = true
+ handler.post { createStatusBarInputLayer(position, width, height) }
}
}
@@ -103,9 +110,10 @@ internal class AppHandleViewHolder(
if (!Flags.enableAdditionalWindowsAboveStatusBar()) return
statusBarInputLayer = AdditionalSystemViewContainer(context, windowManagerWrapper,
taskInfo.taskId, handlePosition.x, handlePosition.y, handleWidth, handleHeight,
- WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ )
val view = statusBarInputLayer?.view ?: error("Unable to find statusBarInputLayer View")
- val lp = statusBarInputLayer?.lp ?: error("Unable to find statusBarInputLayer" +
+ val lp = statusBarInputLayer?.lp ?: error("Unable to find statusBarInputLayer " +
"LayoutParams")
lp.title = "Handle Input Layer of task " + taskInfo.taskId
lp.setTrustedOverlay()
@@ -130,12 +138,11 @@ internal class AppHandleViewHolder(
}
private fun updateStatusBarInputLayer(globalPosition: Point) {
- statusBarInputLayer?.setPosition(SurfaceControl.Transaction(), globalPosition.x.toFloat(),
- globalPosition.y.toFloat()) ?: return
- }
-
- private fun hasStatusBarInputLayer(): Boolean {
- return statusBarInputLayer != null
+ statusBarInputLayer?.setPosition(
+ SurfaceControl.Transaction(),
+ globalPosition.x.toFloat(),
+ globalPosition.y.toFloat()
+ ) ?: return
}
/**
@@ -143,8 +150,11 @@ internal class AppHandleViewHolder(
* is not visible.
*/
fun disposeStatusBarInputLayer() {
- statusBarInputLayer?.releaseView()
- statusBarInputLayer = null
+ statusBarInputLayerExists = false
+ handler.post {
+ statusBarInputLayer?.releaseView()
+ statusBarInputLayer = null
+ }
}
private fun getCaptionHandleBarColor(taskInfo: RunningTaskInfo): Int {
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java
index 1741fe447fad..96e0ede1b0b8 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java
@@ -837,7 +837,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
}
private void verifyHandleMenuCreated(@Nullable Uri uri) {
-
verify(mMockHandleMenuFactory).create(any(), any(), anyInt(), any(), any(),
any(), anyBoolean(), anyBoolean(), anyBoolean(), eq(uri), anyInt(),
anyInt(), anyInt());