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

Commit 8aaccfe3 authored by Maryam Dehaini's avatar Maryam Dehaini Committed by Android (Google) Code Review
Browse files

Merge "Use INPUT_FEATURE_SPY flag to prevent ACTION_CANCEL event during app handle drag" into main

parents 20409bd6 7692d1a5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.view.View.OnLongClickListener
import android.view.View.OnTouchListener
import android.view.ViewConfiguration
import android.view.WindowManager
import android.view.WindowManager.LayoutParams.INPUT_FEATURE_SPY
import android.view.WindowManager.TRANSIT_CHANGE
import android.view.WindowManagerGlobal
import android.window.DesktopExperienceFlags
@@ -469,6 +470,12 @@ constructor(
            }
            inputFeatures =
                inputFeatures or WindowManager.LayoutParams.INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE
        } else if (
            isAppHandle && DesktopExperienceFlags.ENABLE_REMOVE_STATUS_BAR_INPUT_LAYER.isTrue
        ) {
            // Add input feature spy flag if caption is an app handle so that input is not stolen
            // when motion event exits caption view.
            inputFeatures = inputFeatures or INPUT_FEATURE_SPY
        }

        // The configuration used to layout the window decoration. A copy is made instead of using
+8 −7
Original line number Diff line number Diff line
@@ -331,13 +331,8 @@ public class DesktopModeTouchEventListener
                    viewName, mIsCustomHeaderGesture, mIsResizeGesture);
            return false;
        }
        if (mInputManager != null) {
            ViewRootImpl viewRootImpl = v.getViewRootImpl();
            if (viewRootImpl != null) {
        // Pilfer so that windows below receive cancellations for this gesture.
                mInputManager.pilferPointers(viewRootImpl.getInputToken());
            }
        }
        pilferPointers(v);
        if (isUpOrCancel) {
            // Gesture is finished, reset state.
            mIsCustomHeaderGesture = false;
@@ -350,6 +345,12 @@ public class DesktopModeTouchEventListener
        }
    }

    private void pilferPointers(@NonNull View v) {
        final ViewRootImpl viewRootImpl = v.getViewRootImpl();
        if (mInputManager == null || viewRootImpl == null) return;
        mInputManager.pilferPointers(viewRootImpl.getInputToken());
    }

    @Override
    public boolean onLongClick(View v) {
        final String viewName = getResourceName(v);
+15 −7
Original line number Diff line number Diff line
@@ -1206,14 +1206,22 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            }
            relayoutParams.mInputFeatures |=
                        WindowManager.LayoutParams.INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE;
        } else if (isAppHandle && !DesktopModeFlags.ENABLE_HANDLE_INPUT_FIX.isTrue()) {
            // The focused decor (fullscreen/split) does not need to handle input because input in
            // the App Handle is handled by the InputMonitor in DesktopModeWindowDecorViewModel.
            // Note: This does not apply with the above flag enabled as the status bar input layer
            // will forward events to the handle directly.
        } else if (isAppHandle) {
            if (!DesktopModeFlags.ENABLE_HANDLE_INPUT_FIX.isTrue()) {
                // The focused decor (fullscreen/split) does not need to handle input because input
                // in the App Handle is handled by the InputMonitor in
                // DesktopModeWindowDecorViewModel.
                // Note: This does not apply with the above flag enabled as the status bar input
                // layer will forward events to the handle directly.
                relayoutParams.mInputFeatures
                        |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL;
            }
            if (DesktopExperienceFlags.ENABLE_REMOVE_STATUS_BAR_INPUT_LAYER.isTrue()) {
                // Add input feature spy flag if caption is an app handle so that input is not
                // stolen when motion event exits caption view.
                relayoutParams.mInputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_SPY;
            }
        }
        if (isAppHeader
                && desktopConfig.useWindowShadow(/* isFocusedWindow= */ hasGlobalFocus)) {
            if (DesktopExperienceFlags.ENABLE_FREEFORM_BOX_SHADOWS.isTrue()) {
+14 −1
Original line number Diff line number Diff line
@@ -714,7 +714,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    }

    @Test
    public void updateRelayoutParams_fullscreen_disallowsInputFallthrough() {
    @DisableFlags(Flags.FLAG_ENABLE_REMOVE_STATUS_BAR_INPUT_LAYER)
    public void updateRelayoutParams_fullscreenWithStatusBarInputLayer_disallowsInputFallthrough() {
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        final RelayoutParams relayoutParams = new RelayoutParams();
@@ -724,6 +725,18 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
        assertThat(relayoutParams.hasInputFeatureSpy()).isFalse();
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_REMOVE_STATUS_BAR_INPUT_LAYER)
    public void updateRelayoutParams_fullscreenWithoutStatusBarInputLayer_isInputFeatureSpy() {
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        final RelayoutParams relayoutParams = new RelayoutParams();

        updateRelayoutParams(relayoutParams, taskInfo);

        assertThat(relayoutParams.hasInputFeatureSpy()).isTrue();
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_ACCESSIBLE_CUSTOM_HEADERS)
    public void updateRelayoutParams_fullscreen_unlimitedTouchRegion() {