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

Commit 70227558 authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Add a display flag for maintaining its own focus and touch mode.

This basically duplicates the behavior of config_perDisplayFocusEnabled
but via a display flag instead of globally for all displays. The display
must be trusted for the new flag to be set.

This is particularly needed for virtual devices and displays with
navigation-type inputs, for which touching the default display will
cause everything to enter touch mode and therefore the currently focused
view would lose focus.

Bug: 233911853
Bug: 256810557
Test: atest DisplayManagerServiceTest
Test: atest WindowManagerServiceTests
Change-Id: Ie1c3b8a42f512530bf0ce3fabc56f0da236a311c
parent cd8f2047
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1238,6 +1238,7 @@ package android.hardware.display {
    field public static final int SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS = 2; // 0x2
    field public static final int SWITCHING_TYPE_NONE = 0; // 0x0
    field public static final int SWITCHING_TYPE_WITHIN_GROUPS = 1; // 0x1
    field public static final int VIRTUAL_DISPLAY_FLAG_OWN_FOCUS = 16384; // 0x4000
    field public static final int VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 512; // 0x200
  }

+2 −1
Original line number Diff line number Diff line
@@ -76,7 +76,8 @@ public final class VirtualDeviceManager {
                    | DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY
                    | DisplayManager.VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL
                    | DisplayManager.VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH
                    | DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP;
                    | DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP
                    | DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_FOCUS;

    /**
     * The default device ID, which is the ID of the primary (non-virtual) device.
+18 −1
Original line number Diff line number Diff line
@@ -137,7 +137,8 @@ public final class DisplayManager {
            VIRTUAL_DISPLAY_FLAG_TRUSTED,
            VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP,
            VIRTUAL_DISPLAY_FLAG_ALWAYS_UNLOCKED,
            VIRTUAL_DISPLAY_FLAG_TOUCH_FEEDBACK_DISABLED
            VIRTUAL_DISPLAY_FLAG_TOUCH_FEEDBACK_DISABLED,
            VIRTUAL_DISPLAY_FLAG_OWN_FOCUS,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface VirtualDisplayFlag {}
@@ -403,6 +404,22 @@ public final class DisplayManager {
     */
    public static final int VIRTUAL_DISPLAY_FLAG_TOUCH_FEEDBACK_DISABLED = 1 << 13;

    /**
     * Virtual display flags: Indicates that the display maintains its own focus and touch mode.
     *
     * This flag is similar to {@link com.android.internal.R.bool.config_perDisplayFocusEnabled} in
     * behavior, but only applies to the specific display instead of system-wide to all displays.
     *
     * Note: The display must be trusted in order to have its own focus.
     *
     * @see #createVirtualDisplay
     * @see #VIRTUAL_DISPLAY_FLAG_TRUSTED
     * @hide
     */
    @TestApi
    public static final int VIRTUAL_DISPLAY_FLAG_OWN_FOCUS = 1 << 14;


    /** @hide */
    @IntDef(prefix = {"MATCH_CONTENT_FRAMERATE_"}, value = {
            MATCH_CONTENT_FRAMERATE_UNKNOWN,
+13 −0
Original line number Diff line number Diff line
@@ -318,6 +318,19 @@ public final class Display {
     */
    public static final int FLAG_TOUCH_FEEDBACK_DISABLED = 1 << 10;

    /**
     * Flag: Indicates that the display maintains its own focus and touch mode.
     *
     * This flag is similar to {@link com.android.internal.R.bool.config_perDisplayFocusEnabled} in
     * behavior, but only applies to the specific display instead of system-wide to all displays.
     *
     * Note: The display must be trusted in order to have its own focus.
     *
     * @see #FLAG_TRUSTED
     * @hide
     */
    public static final int FLAG_OWN_FOCUS = 1 << 11;

    /**
     * Display flag: Indicates that the contents of the display should not be scaled
     * to fit the physical screen dimensions.  Used for development only to emulate
+34 −0
Original line number Diff line number Diff line
@@ -157,6 +157,19 @@ final class DisplayDeviceInfo {
     */
    public static final int FLAG_TOUCH_FEEDBACK_DISABLED = 1 << 16;

    /**
     * Flag: Indicates that the display maintains its own focus and touch mode.
     *
     * This flag is similar to {@link com.android.internal.R.bool.config_perDisplayFocusEnabled} in
     * behavior, but only applies to the specific display instead of system-wide to all displays.
     *
     * Note: The display must be trusted in order to have its own focus.
     *
     * @see #FLAG_TRUSTED
     * @hide
     */
    public static final int FLAG_OWN_FOCUS = 1 << 17;

    /**
     * Touch attachment: Display does not receive touch.
     */
@@ -584,9 +597,30 @@ final class DisplayDeviceInfo {
        if ((flags & FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD) != 0) {
            msg.append(", FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD");
        }
        if ((flags & FLAG_DESTROY_CONTENT_ON_REMOVAL) != 0) {
            msg.append(", FLAG_DESTROY_CONTENT_ON_REMOVAL");
        }
        if ((flags & FLAG_MASK_DISPLAY_CUTOUT) != 0) {
            msg.append(", FLAG_MASK_DISPLAY_CUTOUT");
        }
        if ((flags & FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS) != 0) {
            msg.append(", FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS");
        }
        if ((flags & FLAG_TRUSTED) != 0) {
            msg.append(", FLAG_TRUSTED");
        }
        if ((flags & FLAG_OWN_DISPLAY_GROUP) != 0) {
            msg.append(", FLAG_OWN_DISPLAY_GROUP");
        }
        if ((flags & FLAG_ALWAYS_UNLOCKED) != 0) {
            msg.append(", FLAG_ALWAYS_UNLOCKED");
        }
        if ((flags & FLAG_TOUCH_FEEDBACK_DISABLED) != 0) {
            msg.append(", FLAG_TOUCH_FEEDBACK_DISABLED");
        }
        if ((flags & FLAG_OWN_FOCUS) != 0) {
            msg.append(", FLAG_OWN_FOCUS");
        }
        return msg.toString();
    }
}
Loading