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

Commit 474b4bfc authored by Asmita Poddar's avatar Asmita Poddar
Browse files

Add numpad support for mouse keys

Add support for mouse keys when used with keyboards with a numpad.
The default key bindings for mouse keys is still the primary keys
(since not all keyboards come with numpads).
If a user chooses to use numpads for mouse keys, we check if all the
numpad key bindings exist on the keyboard, If they exist, the user can
use mouse keys with the numpad, if not, it defaults back to the
primary keys.
If the user has multiple keyboards connected, and has selected to use
numpad for mouse keys, they will only be able to use the numpad for the
keyboards which support numpad, and primary keys with the keyboards that
don't.
Also update access to the mouse keys enums in a more efficient way.

Bug: 369779909
Test: atest FrameworksServicesTests:MouseKeysInterceptorTest
Flag: com.android.server.accessibility.enable_mouse_key_enhancement
Change-Id: Ia6d68730ead63a49ab7d5deb32f6b34e799af2c6
parent 328835e7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1271,6 +1271,7 @@ public class InputSettings {
     * @hide
     */
    @FlaggedApi(FLAG_KEYBOARD_A11Y_MOUSE_KEYS)
    @RequiresPermission(Manifest.permission.WRITE_SETTINGS)
    public static void setPrimaryKeysForMouseKeysEnabled(
            @NonNull Context context, boolean enabled) {
        if (!isAccessibilityMouseKeysFeatureFlagEnabled()) {
+16 −14
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.graphics.Region;
import android.hardware.input.InputManager;
import android.os.Build;
import android.os.Looper;
import android.os.PowerManager;
@@ -66,7 +65,6 @@ import com.android.server.policy.WindowManagerPolicy;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Objects;
import java.util.StringJoiner;

/**
@@ -805,6 +803,7 @@ public class AccessibilityInputFilter extends InputFilter implements EventStream
        }

        if ((mEnabledFeatures & FLAG_FEATURE_MOUSE_KEYS) != 0) {
            if (mMouseKeysInterceptor == null) {
                TimeSource systemClockTimeSource = new TimeSource() {
                    @Override
                    public long uptimeMillis() {
@@ -812,12 +811,14 @@ public class AccessibilityInputFilter extends InputFilter implements EventStream
                    }
                };
                mMouseKeysInterceptor = new MouseKeysInterceptor(mAms,
                    Objects.requireNonNull(mContext.getSystemService(InputManager.class)),
                        mContext,
                        Looper.myLooper(),
                        Display.DEFAULT_DISPLAY,
                    systemClockTimeSource);
                        systemClockTimeSource,
                        mUserId);
                addFirstEventHandler(Display.DEFAULT_DISPLAY, mMouseKeysInterceptor);
            }
        }

        if (Flags.enableMagnificationKeyboardControl()
                && isAnyMagnificationEnabled(mEnabledFeatures)) {
@@ -1498,3 +1499,4 @@ public class AccessibilityInputFilter extends InputFilter implements EventStream
        }
    }
}
+284 −48

File changed.

Preview size limit exceeded, changes collapsed.

+158 −24

File changed.

Preview size limit exceeded, changes collapsed.