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

Commit f499fe5c authored by Harry Cutts's avatar Harry Cutts Committed by Android (Google) Code Review
Browse files

Merge "InputSettings: add touchpad system gesture setting" into main

parents 5d21251f b8e7a1ae
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static com.android.hardware.input.Flags.keyboardA11ySlowKeysFlag;
import static com.android.hardware.input.Flags.keyboardA11yStickyKeysFlag;
import static com.android.hardware.input.Flags.mouseReverseVerticalScrolling;
import static com.android.hardware.input.Flags.mouseSwapPrimaryButton;
import static com.android.hardware.input.Flags.touchpadSystemGestureDisable;
import static com.android.hardware.input.Flags.touchpadTapDragging;
import static com.android.hardware.input.Flags.touchpadThreeFingerTapShortcut;
import static com.android.hardware.input.Flags.touchpadVisualizer;
@@ -373,6 +374,15 @@ public class InputSettings {
        return touchpadTapDragging();
    }

    /**
     * Returns true if the feature flag for disabling system gestures on touchpads is enabled.
     *
     * @hide
     */
    public static boolean isTouchpadSystemGestureDisableFeatureFlagEnabled() {
        return touchpadSystemGestureDisable();
    }

    /**
     * Returns true if the feature flag for touchpad visualizer is enabled.
     *
@@ -529,6 +539,40 @@ public class InputSettings {
                && isTouchpadThreeFingerTapShortcutFeatureFlagEnabled();
    }

    /**
     * Returns true if system gestures (three- and four-finger swipes) should be enabled for
     * touchpads.
     *
     * @param context The application context.
     * @return Whether system gestures on touchpads are enabled
     *
     * @hide
     */
    public static boolean useTouchpadSystemGestures(@NonNull Context context) {
        if (!isTouchpadSystemGestureDisableFeatureFlagEnabled()) {
            return true;
        }
        return Settings.System.getIntForUser(context.getContentResolver(),
                Settings.System.TOUCHPAD_SYSTEM_GESTURES, 1, UserHandle.USER_CURRENT) == 1;
    }

    /**
     * Sets whether system gestures are enabled for touchpads.
     *
     * @param context The application context.
     * @param enabled True to enable system gestures.
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.WRITE_SETTINGS)
    public static void setTouchpadSystemGesturesEnabled(@NonNull Context context, boolean enabled) {
        if (!isTouchpadSystemGestureDisableFeatureFlagEnabled()) {
            return;
        }
        Settings.System.putIntForUser(context.getContentResolver(),
                Settings.System.TOUCHPAD_SYSTEM_GESTURES, enabled ? 1 : 0, UserHandle.USER_CURRENT);
    }

    /**
     * Whether a pointer icon will be shown over the location of a stylus pointer.
     *
+7 −0
Original line number Diff line number Diff line
@@ -148,6 +148,13 @@ flag {
  bug: "373458181"
}

flag {
    name: "touchpad_system_gesture_disable"
    namespace: "input"
    description: "Adds an accessibility setting to disable system navigation gestures (3- and 4-finger swipes) on touchpads"
    bug: "353947750"
}

flag {
    name: "enable_customizable_input_gestures"
    namespace: "input"
+9 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.service.voice.VisualQueryDetectedResult;
import android.speech.tts.TextToSpeech;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -6288,6 +6289,13 @@ public final class Settings {
         */
        public static final String TOUCHPAD_RIGHT_CLICK_ZONE = "touchpad_right_click_zone";
        /**
         * Whether to enable system gestures (three- and four-finger swipes) on touchpads.
         *
         * @hide
         */
        public static final String TOUCHPAD_SYSTEM_GESTURES = "touchpad_system_gestures";
        /**
         * Whether to enable reversed vertical scrolling for connected mice.
         *
@@ -6549,6 +6557,7 @@ public final class Settings {
            PRIVATE_SETTINGS.add(TOUCHPAD_TAP_TO_CLICK);
            PRIVATE_SETTINGS.add(TOUCHPAD_TAP_DRAGGING);
            PRIVATE_SETTINGS.add(TOUCHPAD_RIGHT_CLICK_ZONE);
            PRIVATE_SETTINGS.add(TOUCHPAD_SYSTEM_GESTURES);
            PRIVATE_SETTINGS.add(CAMERA_FLASH_NOTIFICATION);
            PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION);
            PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION_COLOR);
+1 −0
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ message SystemSettingsProto {
        optional SettingProto tap_to_click = 4 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto tap_dragging = 5 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto three_finger_tap_customization = 6 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto system_gestures = 7 [ (android.privacy).dest = DEST_AUTOMATIC ];;
    }
    optional Touchpad touchpad = 36;

+1 −0
Original line number Diff line number Diff line
@@ -230,6 +230,7 @@ public class SystemSettingsValidators {
        VALIDATORS.put(System.TOUCHPAD_TAP_TO_CLICK, BOOLEAN_VALIDATOR);
        VALIDATORS.put(System.TOUCHPAD_TAP_DRAGGING, BOOLEAN_VALIDATOR);
        VALIDATORS.put(System.TOUCHPAD_RIGHT_CLICK_ZONE, BOOLEAN_VALIDATOR);
        VALIDATORS.put(System.TOUCHPAD_SYSTEM_GESTURES, BOOLEAN_VALIDATOR);
        VALIDATORS.put(System.LOCK_TO_APP_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(
                System.EGG_MODE,
Loading