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

Commit a132f03d authored by Vania Januar's avatar Vania Januar
Browse files

Toggle for disabling stylus buttons.

This change enables users to disable stylus button
pressed from the Stylus Connected Device details Settings page.

Bug: b/251199452
Test: StylusDevicesControllerTest
Change-Id: Iab293cb91dec294026f3c8a96201a3d8e883b6bb
parent 61ccc384
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -7205,6 +7205,15 @@ public final class Settings {
        @SuppressLint("NoSettingsProvider")
        @SuppressLint("NoSettingsProvider")
        public static final String SHOW_IME_WITH_HARD_KEYBOARD = "show_ime_with_hard_keyboard";
        public static final String SHOW_IME_WITH_HARD_KEYBOARD = "show_ime_with_hard_keyboard";
        /**
         * Whether stylus button presses are disabled. This is a boolean that
         * determines if stylus buttons are ignored.
         *
         * @hide
         */
        @SuppressLint("NoSettingsProvider")
        public static final String STYLUS_BUTTONS_DISABLED = "stylus_buttons_disabled";
        /**
        /**
         * Host name and port for global http proxy. Uses ':' seperator for
         * Host name and port for global http proxy. Uses ':' seperator for
         * between host and port.
         * between host and port.
+1 −0
Original line number Original line Diff line number Diff line
@@ -770,6 +770,7 @@ public class SettingsBackupTest {
                 Settings.Secure.SLEEP_TIMEOUT,
                 Settings.Secure.SLEEP_TIMEOUT,
                 Settings.Secure.SMS_DEFAULT_APPLICATION,
                 Settings.Secure.SMS_DEFAULT_APPLICATION,
                 Settings.Secure.SPELL_CHECKER_ENABLED,  // Intentionally removed in Q
                 Settings.Secure.SPELL_CHECKER_ENABLED,  // Intentionally removed in Q
                 Settings.Secure.STYLUS_BUTTONS_DISABLED,
                 Settings.Secure.TRUST_AGENTS_INITIALIZED,
                 Settings.Secure.TRUST_AGENTS_INITIALIZED,
                 Settings.Secure.KNOWN_TRUST_AGENTS_INITIALIZED,
                 Settings.Secure.KNOWN_TRUST_AGENTS_INITIALIZED,
                 Settings.Secure.TV_APP_USES_NON_SYSTEM_INPUTS,
                 Settings.Secure.TV_APP_USES_NON_SYSTEM_INPUTS,
+11 −1
Original line number Original line Diff line number Diff line
@@ -151,6 +151,7 @@ import android.os.Vibrator;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig;
import android.provider.MediaStore;
import android.provider.MediaStore;
import android.provider.Settings;
import android.provider.Settings;
import android.provider.Settings.Secure;
import android.service.dreams.DreamManagerInternal;
import android.service.dreams.DreamManagerInternal;
import android.service.dreams.DreamService;
import android.service.dreams.DreamService;
import android.service.dreams.IDreamManager;
import android.service.dreams.IDreamManager;
@@ -516,6 +517,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    int mDoublePressOnStemPrimaryBehavior;
    int mDoublePressOnStemPrimaryBehavior;
    int mTriplePressOnStemPrimaryBehavior;
    int mTriplePressOnStemPrimaryBehavior;
    int mLongPressOnStemPrimaryBehavior;
    int mLongPressOnStemPrimaryBehavior;
    boolean mStylusButtonsDisabled = false;
    boolean mHasSoftInput = false;
    boolean mHasSoftInput = false;
    boolean mHapticTextHandleEnabled;
    boolean mHapticTextHandleEnabled;
    boolean mUseTvRouting;
    boolean mUseTvRouting;
@@ -771,6 +773,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.Global.getUriFor(
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.POWER_BUTTON_SUPPRESSION_DELAY_AFTER_GESTURE_WAKE), false, this,
                    Settings.Global.POWER_BUTTON_SUPPRESSION_DELAY_AFTER_GESTURE_WAKE), false, this,
                    UserHandle.USER_ALL);
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Secure.getUriFor(
                    Settings.Secure.STYLUS_BUTTONS_DISABLED), false, this,
                    UserHandle.USER_ALL);
            updateSettings();
            updateSettings();
        }
        }


@@ -2560,6 +2565,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    Settings.Global.KEY_CHORD_POWER_VOLUME_UP,
                    Settings.Global.KEY_CHORD_POWER_VOLUME_UP,
                    mContext.getResources().getInteger(
                    mContext.getResources().getInteger(
                            com.android.internal.R.integer.config_keyChordPowerVolumeUp));
                            com.android.internal.R.integer.config_keyChordPowerVolumeUp));

            mStylusButtonsDisabled = Settings.Secure.getIntForUser(resolver,
                    Secure.STYLUS_BUTTONS_DISABLED, 0, UserHandle.USER_CURRENT) == 1;
        }
        }
        if (updateRotation) {
        if (updateRotation) {
            updateRotation(true);
            updateRotation(true);
@@ -4183,7 +4191,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_DEMO_APP_3:
            case KeyEvent.KEYCODE_DEMO_APP_3:
            case KeyEvent.KEYCODE_DEMO_APP_4: {
            case KeyEvent.KEYCODE_DEMO_APP_4: {
                // TODO(b/254604589): Dispatch KeyEvent to System UI.
                // TODO(b/254604589): Dispatch KeyEvent to System UI.
                if (!mStylusButtonsDisabled) {
                    sendSystemKeyToStatusBarAsync(keyCode);
                    sendSystemKeyToStatusBarAsync(keyCode);
                }


                // Just drop if keys are not intercepted for direct key.
                // Just drop if keys are not intercepted for direct key.
                result &= ~ACTION_PASS_TO_USER;
                result &= ~ACTION_PASS_TO_USER;