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

Commit caa162f1 authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Add new keycodes for Emoji and Screenshot

Bug: 315307777
Test: manual
Change-Id: I02bf14feb97b4a88d1e809371925f703d274cebb
parent 3d66fa7d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -50640,6 +50640,7 @@ package android.view {
    field public static final int KEYCODE_DVR = 173; // 0xad
    field public static final int KEYCODE_E = 33; // 0x21
    field public static final int KEYCODE_EISU = 212; // 0xd4
    field @FlaggedApi("com.android.hardware.input.emoji_and_screenshot_keycodes_available") public static final int KEYCODE_EMOJI_PICKER = 317; // 0x13d
    field public static final int KEYCODE_ENDCALL = 6; // 0x6
    field public static final int KEYCODE_ENTER = 66; // 0x42
    field public static final int KEYCODE_ENVELOPE = 65; // 0x41
@@ -50772,6 +50773,7 @@ package android.view {
    field public static final int KEYCODE_RIGHT_BRACKET = 72; // 0x48
    field public static final int KEYCODE_RO = 217; // 0xd9
    field public static final int KEYCODE_S = 47; // 0x2f
    field @FlaggedApi("com.android.hardware.input.emoji_and_screenshot_keycodes_available") public static final int KEYCODE_SCREENSHOT = 318; // 0x13e
    field public static final int KEYCODE_SCROLL_LOCK = 116; // 0x74
    field public static final int KEYCODE_SEARCH = 84; // 0x54
    field public static final int KEYCODE_SEMICOLON = 74; // 0x4a
+1 −1
Original line number Diff line number Diff line
@@ -3606,7 +3606,7 @@ package android.view {
    method public final int getDisplayId();
    method public final void setDisplayId(int);
    field public static final int FLAG_IS_ACCESSIBILITY_EVENT = 2048; // 0x800
    field public static final int LAST_KEYCODE = 316; // 0x13c
    field public static final int LAST_KEYCODE = 318; // 0x13e
  }

  public final class KeyboardShortcutGroup implements android.os.Parcelable {
+7 −0
Original line number Diff line number Diff line
@@ -31,6 +31,13 @@ flag {
    bug: "298197511"
}

flag {
    namespace: "input_native"
    name: "emoji_and_screenshot_keycodes_available"
    description: "Add new KeyEvent keycodes for opening Emoji Picker and Taking Screenshots"
    bug: "315307777"
}

flag {
    namespace: "input_native"
    name: "keyboard_a11y_slow_keys_flag"
+23 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view;
import static android.os.IInputConstants.INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT;
import static android.view.Display.INVALID_DISPLAY;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
@@ -31,6 +32,8 @@ import android.util.Log;
import android.util.SparseIntArray;
import android.view.KeyCharacterMap.KeyData;

import com.android.hardware.input.Flags;

import java.util.concurrent.TimeUnit;

/**
@@ -384,7 +387,13 @@ public class KeyEvent extends InputEvent implements Parcelable {
    public static final int KEYCODE_META_RIGHT      = 118;
    /** Key code constant: Function modifier key. */
    public static final int KEYCODE_FUNCTION        = 119;
    /** Key code constant: System Request / Print Screen key. */
    /**
     * Key code constant: System Request / Print Screen key.
     *
     * This key is sent to the app first and only if the app doesn't handle it, the framework
     * handles it (to take a screenshot), unlike {@code KEYCODE_TAKE_SCREENSHOT} which is
     * fully handled by the framework.
     */
    public static final int KEYCODE_SYSRQ           = 120;
    /** Key code constant: Break / Pause key. */
    public static final int KEYCODE_BREAK           = 121;
@@ -921,14 +930,25 @@ public class KeyEvent extends InputEvent implements Parcelable {
     * User customizable key #4.
     */
    public static final int KEYCODE_MACRO_4 = 316;

    /** Key code constant: To open emoji picker */
    @FlaggedApi(Flags.FLAG_EMOJI_AND_SCREENSHOT_KEYCODES_AVAILABLE)
    public static final int KEYCODE_EMOJI_PICKER = 317;
    /**
     * Key code constant: To take a screenshot
     *
     * This key is fully handled by the framework and will not be sent to the foreground app,
     * unlike {@code KEYCODE_SYSRQ} which is sent to the app first and only if the app
     * doesn't handle it, the framework handles it (to take a screenshot).
     */
    @FlaggedApi(Flags.FLAG_EMOJI_AND_SCREENSHOT_KEYCODES_AVAILABLE)
    public static final int KEYCODE_SCREENSHOT = 318;

   /**
     * Integer value of the last KEYCODE. Increases as new keycodes are added to KeyEvent.
     * @hide
     */
    @TestApi
    public static final int LAST_KEYCODE = KEYCODE_MACRO_4;
    public static final int LAST_KEYCODE = KEYCODE_SCREENSHOT;

    // NOTE: If you add a new keycode here you must also add it to:
    //  isSystem()
+12 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ import static android.view.WindowManagerGlobal.ADD_OKAY;
import static android.view.WindowManagerGlobal.ADD_PERMISSION_DENIED;
import static android.view.contentprotection.flags.Flags.createAccessibilityOverlayAppOpEnabled;

import static com.android.hardware.input.Flags.emojiAndScreenshotKeycodesAvailable;
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.SCREENSHOT_KEYCHORD_DELAY;
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVERED;
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVER_ABSENT;
@@ -3779,6 +3780,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    sendSystemKeyToStatusBarAsync(event);
                    return true;
                }
            case KeyEvent.KEYCODE_SCREENSHOT:
                if (emojiAndScreenshotKeycodesAvailable() && down && repeatCount == 0) {
                    interceptScreenshotChord(SCREENSHOT_KEY_OTHER, 0 /*pressDelay*/);
                }
                return true;
        }
        if (isValidGlobalKey(keyCode)
                && mGlobalKeyManager.handleGlobalKey(mContext, keyCode, event)) {
@@ -5022,6 +5028,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_MACRO_4:
                result &= ~ACTION_PASS_TO_USER;
                break;
            case KeyEvent.KEYCODE_EMOJI_PICKER:
                if (!emojiAndScreenshotKeycodesAvailable()) {
                    // Don't allow EMOJI_PICKER key to be dispatched until flag is released.
                    result &= ~ACTION_PASS_TO_USER;
                }
                break;
        }

        if (useHapticFeedback) {
Loading