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

Commit a0d2cc09 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "InputSettings: add touchpad tap dragging setting" into main

parents 97e8a47e 33ee6e96
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.hardware.input;
import static com.android.hardware.input.Flags.keyboardA11yBounceKeysFlag;
import static com.android.hardware.input.Flags.keyboardA11ySlowKeysFlag;
import static com.android.hardware.input.Flags.keyboardA11yStickyKeysFlag;
import static com.android.hardware.input.Flags.touchpadTapDragging;
import static com.android.input.flags.Flags.enableInputFilterRustImpl;

import android.Manifest;
@@ -302,6 +303,53 @@ public class InputSettings {
                UserHandle.USER_CURRENT);
    }

    /**
     * Returns true if the feature flag for touchpad tap dragging is enabled.
     *
     * @hide
     */
    public static boolean isTouchpadTapDraggingFeatureFlagEnabled() {
        return touchpadTapDragging();
    }

    /**
     * Returns true if the touchpad should allow tap dragging.
     *
     * The returned value only applies to gesture-compatible touchpads.
     *
     * @param context The application context.
     * @return Whether the touchpad should allow tap dragging.
     *
     * @hide
     */
    public static boolean useTouchpadTapDragging(@NonNull Context context) {
        if (!isTouchpadTapDraggingFeatureFlagEnabled()) {
            return false;
        }
        return Settings.System.getIntForUser(context.getContentResolver(),
                Settings.System.TOUCHPAD_TAP_DRAGGING, 0, UserHandle.USER_CURRENT) == 1;
    }

    /**
     * Sets the tap dragging behavior for the touchpad.
     *
     * The new behavior is only applied to gesture-compatible touchpads.
     *
     * @param context The application context.
     * @param enabled Will enable tap dragging if true, disable it if false
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.WRITE_SETTINGS)
    public static void setTouchpadTapDragging(@NonNull Context context, boolean enabled) {
        if (!isTouchpadTapDraggingFeatureFlagEnabled()) {
            return;
        }
        Settings.System.putIntForUser(context.getContentResolver(),
                Settings.System.TOUCHPAD_TAP_DRAGGING, enabled ? 1 : 0,
                UserHandle.USER_CURRENT);
    }

    /**
     * Returns true if the touchpad should use the right click zone.
     *
+7 −0
Original line number Diff line number Diff line
@@ -37,3 +37,10 @@ flag {
    description: "Controls if the slow keys accessibility feature for physical keyboard is available to the user"
    bug: "294546335"
}

flag {
    namespace: "input_native"
    name: "touchpad_tap_dragging"
    description: "Offers a setting to enable touchpad tap dragging"
    bug: "321978150"
}
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
@@ -6048,6 +6048,13 @@ public final class Settings {
         */
        public static final String TOUCHPAD_TAP_TO_CLICK = "touchpad_tap_to_click";
        /**
         * Whether to enable tap dragging on touchpads.
         *
         * @hide
         */
        public static final String TOUCHPAD_TAP_DRAGGING = "touchpad_tap_dragging";
        /**
         * Whether to enable a right-click zone on touchpads.
         *
@@ -6270,6 +6277,7 @@ public final class Settings {
            PRIVATE_SETTINGS.add(TOUCHPAD_POINTER_SPEED);
            PRIVATE_SETTINGS.add(TOUCHPAD_NATURAL_SCROLLING);
            PRIVATE_SETTINGS.add(TOUCHPAD_TAP_TO_CLICK);
            PRIVATE_SETTINGS.add(TOUCHPAD_TAP_DRAGGING);
            PRIVATE_SETTINGS.add(TOUCHPAD_RIGHT_CLICK_ZONE);
            PRIVATE_SETTINGS.add(CAMERA_FLASH_NOTIFICATION);
            PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION);
+1 −0
Original line number Diff line number Diff line
@@ -207,6 +207,7 @@ message SystemSettingsProto {
        optional SettingProto pointer_speed = 2 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto right_click_zone = 3 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto tap_to_click = 4 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto tap_dragging = 5 [ (android.privacy).dest = DEST_AUTOMATIC ];
    }
    optional Touchpad touchpad = 36;

+1 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ public class SystemSettings {
                Settings.System.TOUCHPAD_POINTER_SPEED,
                Settings.System.TOUCHPAD_NATURAL_SCROLLING,
                Settings.System.TOUCHPAD_TAP_TO_CLICK,
                Settings.System.TOUCHPAD_TAP_DRAGGING,
                Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE,
                Settings.System.CAMERA_FLASH_NOTIFICATION,
                Settings.System.SCREEN_FLASH_NOTIFICATION,
Loading