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

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

Merge "InputSettings: add setting to disable touchpads" into main

parents 22bbc09d 97cef717
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static com.android.hardware.input.Flags.mouseScrollingAcceleration;
import static com.android.hardware.input.Flags.mouseReverseVerticalScrolling;
import static com.android.hardware.input.Flags.mouseSwapPrimaryButton;
import static com.android.hardware.input.Flags.pointerAcceleration;
import static com.android.hardware.input.Flags.touchpadDisable;
import static com.android.hardware.input.Flags.touchpadSystemGestureDisable;
import static com.android.hardware.input.Flags.touchpadThreeFingerTapShortcut;
import static com.android.hardware.input.Flags.touchpadVisualizer;
@@ -434,6 +435,15 @@ public class InputSettings {
        return touchpadSystemGestureDisable();
    }

    /**
     * Returns true if the feature flag for disabling touchpads is enabled.
     *
     * @hide
     */
    public static boolean isTouchpadDisableFeatureFlagEnabled() {
        return touchpadDisable();
    }

    /**
     * Returns true if the feature flag for touchpad visualizer is enabled.
     *
@@ -636,6 +646,39 @@ public class InputSettings {
                Settings.System.TOUCHPAD_SYSTEM_GESTURES, enabled ? 1 : 0, UserHandle.USER_CURRENT);
    }

    /**
     * Returns true if touchpads should be enabled.
     *
     * @param context The application context.
     * @return Whether touchpads are enabled
     *
     * @hide
     */
    public static boolean useTouchpads(@NonNull Context context) {
        if (!isTouchpadDisableFeatureFlagEnabled()) {
            return true;
        }
        return Settings.System.getIntForUser(context.getContentResolver(),
                Settings.System.TOUCHPAD_ENABLED, 1, UserHandle.USER_CURRENT) == 1;
    }

    /**
     * Sets whether touchpads are enabled.
     *
     * @param context The application context.
     * @param enabled True to enable touchpads.
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.WRITE_SETTINGS)
    public static void setTouchpadsEnabled(@NonNull Context context, boolean enabled) {
        if (!isTouchpadDisableFeatureFlagEnabled()) {
            return;
        }
        Settings.System.putIntForUser(context.getContentResolver(),
                Settings.System.TOUCHPAD_ENABLED, 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
@@ -229,3 +229,10 @@ flag {
    description: "Enables shortcut for quick settings panel"
    bug: "423899230"
}

flag {
    name: "touchpad_disable"
    namespace: "input"
    description: "Adds an accessibility setting to disable touchpads"
    bug: "372857036"
}
+8 −0
Original line number Diff line number Diff line
@@ -6452,6 +6452,13 @@ public final class Settings {
        public static final String TOUCHPAD_ACCELERATION_ENABLED =
                "touchpad_acceleration_enabled";
        /**
         * Whether to enable touchpads.
         *
         * @hide
         */
        public static final String TOUCHPAD_ENABLED = "touchpad_enabled";
        /**
         * Whether to enable reversed vertical scrolling for connected mice.
         *
@@ -6773,6 +6780,7 @@ public final class Settings {
            PRIVATE_SETTINGS.add(TOUCHPAD_RIGHT_CLICK_ZONE);
            PRIVATE_SETTINGS.add(TOUCHPAD_SYSTEM_GESTURES);
            PRIVATE_SETTINGS.add(TOUCHPAD_ACCELERATION_ENABLED);
            PRIVATE_SETTINGS.add(TOUCHPAD_ENABLED);
            PRIVATE_SETTINGS.add(CAMERA_FLASH_NOTIFICATION);
            PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION);
            PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION_COLOR);
+3 −1
Original line number Diff line number Diff line
@@ -958,7 +958,9 @@ public class SettingsBackupTest {
                        Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ,
                        Settings.System.MULTI_AUDIO_FOCUS_ENABLED, // form-factor/OEM specific
                        // Potentially disruptive to on-boarding flow on new devices
                        Settings.System.TOUCHPAD_SYSTEM_GESTURES
                        Settings.System.TOUCHPAD_SYSTEM_GESTURES,
                        // Potentially disruptive to on-boarding flow on new devices
                        Settings.System.TOUCHPAD_ENABLED
                );
        if (!Flags.backUpSmoothDisplayAndForcePeakRefreshRate()) {
            settings.add(Settings.System.MIN_REFRESH_RATE);
+6 −0
Original line number Diff line number Diff line
@@ -92,6 +92,8 @@ class InputSettingsObserver extends ContentObserver {
                        (reason) -> updateTouchpadSystemGesturesEnabled()),
                Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_ACCELERATION_ENABLED),
                        (reason) -> updateTouchpadAccelerationEnabled()),
                Map.entry(Settings.System.getUriFor(Settings.System.TOUCHPAD_ENABLED),
                        (reason) -> updateTouchpadsEnabled()),
                Map.entry(Settings.System.getUriFor(Settings.System.SHOW_TOUCHES),
                        (reason) -> updateShowTouches()),
                Map.entry(Settings.System.getUriFor(Settings.System.POINTER_LOCATION),
@@ -248,6 +250,10 @@ class InputSettingsObserver extends ContentObserver {
                InputSettings.isTouchpadAccelerationEnabled(mContext));
    }

    private void updateTouchpadsEnabled() {
        mNative.setTouchpadsEnabled(InputSettings.useTouchpads(mContext));
    }

    private void updateShowTouches() {
        mNative.setShowTouches(getBoolean(Settings.System.SHOW_TOUCHES, false));
    }
Loading