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

Commit 41862f6a authored by Matt Sziklay's avatar Matt Sziklay Committed by Android (Google) Code Review
Browse files

Merge "Let handler perform input layer creation." into main

parents 4fff1aef 930bee1a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -548,7 +548,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                    mResult.mRootView,
                    mOnCaptionTouchListener,
                    mOnCaptionButtonClickListener,
                    mWindowManagerWrapper
                    mWindowManagerWrapper,
                    mHandler
            );
        } else if (mRelayoutParams.mLayoutResId
                == R.layout.desktop_mode_app_header) {
+25 −15
Original line number Diff line number Diff line
@@ -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,7 +110,8 @@ internal class AppHandleViewHolder(
        if (!Flags.enableHandleInputFix()) 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 " +
                "LayoutParams")
@@ -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,9 +150,12 @@ internal class AppHandleViewHolder(
     * is not visible.
     */
    fun disposeStatusBarInputLayer() {
        statusBarInputLayerExists = false
        handler.post {
            statusBarInputLayer?.releaseView()
            statusBarInputLayer = null
        }
    }

    private fun getCaptionHandleBarColor(taskInfo: RunningTaskInfo): Int {
        return if (shouldUseLightCaptionColors(taskInfo)) {
+0 −1
Original line number Diff line number Diff line
@@ -839,7 +839,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());