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

Commit d7097e6a authored by Youkichi Hosoi's avatar Youkichi Hosoi
Browse files

Toggle fullscreen state of focused task via fullscreen key

Currently, the fullscreen key is mapped to Ctrl+Action+Up by ag/31495712
and just moves the focused task into fullscreen mode.

However, the key's expected behavior should be to toggle the fullscreen
state of the focused task by moving fullscreen tasks into desktop mode.

With this change, the fullscreen key is mapped (under a flag) to a new
key gesture defined by ag/35177330, which toggles the fullscreen state
of the focused task.

Bug: 396483171
Test: manual
Test: atest InputTests:KeyGestureControllerTests
Flag: com.android.window.flags.toggle_fullscreen_state_via_fullscreen_key

Change-Id: I1d31def5bf01d707c6b01e1f3738d1105c109e6a
parent 4aaebc22
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_CHORD;
import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_OTHER;
import static android.view.WindowManagerPolicyConstants.FLAG_INTERACTIVE;
import static android.window.DesktopExperienceFlags.TOGGLE_FULLSCREEN_STATE_VIA_FULLSCREEN_KEY;

import static com.android.hardware.input.Flags.enableNew25q2Keycodes;
import static com.android.hardware.input.Flags.fixSearchModifierFallbacks;
@@ -818,7 +819,9 @@ final class KeyGestureController {
                    if (firstDown) {
                        handleKeyGesture(deviceId, new int[]{KeyEvent.KEYCODE_FULLSCREEN},
                                /* modifierState = */0,
                                KeyGestureEvent.KEY_GESTURE_TYPE_MULTI_WINDOW_NAVIGATION,
                                TOGGLE_FULLSCREEN_STATE_VIA_FULLSCREEN_KEY.isTrue()
                                        ? KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_FULLSCREEN
                                        : KeyGestureEvent.KEY_GESTURE_TYPE_MULTI_WINDOW_NAVIGATION,
                                KeyGestureEvent.ACTION_GESTURE_COMPLETE, displayId,
                                focusedToken, /* flags = */0, /* appLaunchData = */null);
                    }
+20 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.Process
import android.os.SystemClock
import android.os.SystemProperties
import android.os.test.TestLooper
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.annotations.Presubmit
import android.platform.test.flag.junit.SetFlagsRule
@@ -366,12 +367,14 @@ class KeyGestureControllerTests {

    @Test
    @Parameters(method = "systemGesturesTestArguments")
    @EnableFlags(com.android.window.flags.Flags.FLAG_TOGGLE_FULLSCREEN_STATE_VIA_FULLSCREEN_KEY)
    fun testKeyGestures(test: KeyGestureData) {
        setupKeyGestureController()
        testKeyGestureProduced(test, PASS_THROUGH_APP)
    }

    @Test
    @EnableFlags(com.android.window.flags.Flags.FLAG_TOGGLE_FULLSCREEN_STATE_VIA_FULLSCREEN_KEY)
    fun testCustomKeyGesturesNotAllowedForSystemGestures() {
        setupKeyGestureController()
        for (systemGesture in systemGesturesTestArguments()) {
@@ -454,6 +457,7 @@ class KeyGestureControllerTests {

    @Test
    @Parameters(method = "nonCapturableKeyGestures")
    @EnableFlags(com.android.window.flags.Flags.FLAG_TOGGLE_FULLSCREEN_STATE_VIA_FULLSCREEN_KEY)
    fun testKeyGestures_withKeyCapture_nonCapturableGestures(test: KeyGestureData) {
        setupKeyGestureController()
        enableKeyCaptureForFocussedWindow()
@@ -1401,6 +1405,22 @@ class KeyGestureControllerTests {
        assertEquals(0, callback)
    }

    @Test
    @DisableFlags(com.android.window.flags.Flags.FLAG_TOGGLE_FULLSCREEN_STATE_VIA_FULLSCREEN_KEY)
    fun testKeyGestures_fullscreenKey_toggleFullscreenStateFlagDisabled() {
        val testData =
            KeyGestureData(
                "FULLSCREEN -> Turns a task into fullscreen",
                intArrayOf(KeyEvent.KEYCODE_FULLSCREEN),
                KeyGestureEvent.KEY_GESTURE_TYPE_MULTI_WINDOW_NAVIGATION,
                intArrayOf(KeyEvent.KEYCODE_FULLSCREEN),
                0,
                intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE),
            )
        setupKeyGestureController()
        testKeyGestureProduced(testData, PASS_THROUGH_APP)
    }

    private fun testKeyGestureProduced(test: KeyGestureData, appDelegate: AppDelegate) {
        val events = mutableListOf<KeyGestureEvent>()
        val listener = KeyGestureEventListener { event -> events.add(KeyGestureEvent(event)) }
+2 −2
Original line number Diff line number Diff line
@@ -309,9 +309,9 @@ object KeyGestureTestData {
                intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE),
            ),
            KeyGestureData(
                "FULLSCREEN -> Turns a task into fullscreen",
                "FULLSCREEN -> Toggles the focused task's fullscreen state",
                intArrayOf(KeyEvent.KEYCODE_FULLSCREEN),
                KeyGestureEvent.KEY_GESTURE_TYPE_MULTI_WINDOW_NAVIGATION,
                KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_FULLSCREEN,
                intArrayOf(KeyEvent.KEYCODE_FULLSCREEN),
                0,
                intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE),