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

Commit dafe2480 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit Committed by Android (Google) Code Review
Browse files

Merge "Enable Dynamic Button Behaviors for Power/Stem Keys"

parents e8128c17 7302e547
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
@@ -16743,6 +16743,30 @@ public final class Settings {
        @Readable
        public static final String AWARE_ALLOWED = "aware_allowed";
        /**
         * Overrides internal R.integer.config_shortPressOnPowerBehavior.
         * Allowable values detailed in frameworks/base/core/res/res/values/config.xml.
         * Used by PhoneWindowManager.
         * @hide
         */
        public static final String POWER_BUTTON_SHORT_PRESS = "power_button_short_press";
        /**
         * Overrides internal R.integer.config_doublePressOnPowerBehavior.
         * Allowable values detailed in frameworks/base/core/res/res/values/config.xml.
         * Used by PhoneWindowManager.
         * @hide
         */
        public static final String POWER_BUTTON_DOUBLE_PRESS = "power_button_double_press";
        /**
         * Overrides internal R.integer.config_triplePressOnPowerBehavior.
         * Allowable values detailed in frameworks/base/core/res/res/values/config.xml.
         * Used by PhoneWindowManager.
         * @hide
         */
        public static final String POWER_BUTTON_TRIPLE_PRESS = "power_button_triple_press";
        /**
         * Overrides internal R.integer.config_longPressOnPowerBehavior.
         * Allowable values detailed in frameworks/base/core/res/res/values/config.xml.
@@ -16773,6 +16797,42 @@ public final class Settings {
        public static final String POWER_BUTTON_VERY_LONG_PRESS =
                "power_button_very_long_press";
        /**
         * Overrides internal R.integer.config_shortPressOnStemPrimaryBehavior.
         * Allowable values detailed in frameworks/base/core/res/res/values/config.xml.
         * Used by PhoneWindowManager.
         * @hide
         */
        public static final String STEM_PRIMARY_BUTTON_SHORT_PRESS =
                "stem_primary_button_short_press";
        /**
         * Overrides internal R.integer.config_doublePressOnStemPrimaryBehavior.
         * Allowable values detailed in frameworks/base/core/res/res/values/config.xml.
         * Used by PhoneWindowManager.
         * @hide
         */
        public static final String STEM_PRIMARY_BUTTON_DOUBLE_PRESS =
                "stem_primary_button_double_press";
        /**
         * Overrides internal R.integer.config_triplePressOnStemPrimaryBehavior.
         * Allowable values detailed in frameworks/base/core/res/res/values/config.xml.
         * Used by PhoneWindowManager.
         * @hide
         */
        public static final String STEM_PRIMARY_BUTTON_TRIPLE_PRESS =
                "stem_primary_button_triple_press";
        /**
         * Overrides internal R.integer.config_longPressOnStemPrimaryBehavior.
         * Allowable values detailed in frameworks/base/core/res/res/values/config.xml.
         * Used by PhoneWindowManager.
         * @hide
         */
        public static final String STEM_PRIMARY_BUTTON_LONG_PRESS =
                "stem_primary_button_long_press";
        /**
         * Overrides internal R.integer.config_keyChordPowerVolumeUp.
         * Allowable values detailed in frameworks/base/core/res/res/values/config.xml.
+11 −0
Original line number Diff line number Diff line
@@ -176,10 +176,21 @@ public class GlobalSettingsValidators {
        VALIDATORS.put(Global.REQUIRE_PASSWORD_TO_DECRYPT, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Global.DEVICE_DEMO_MODE, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Global.AWARE_ALLOWED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Global.POWER_BUTTON_SHORT_PRESS, new InclusiveIntegerRangeValidator(0, 7));
        VALIDATORS.put(Global.POWER_BUTTON_DOUBLE_PRESS, new InclusiveIntegerRangeValidator(0, 3));
        VALIDATORS.put(Global.POWER_BUTTON_TRIPLE_PRESS, new InclusiveIntegerRangeValidator(0, 3));
        VALIDATORS.put(Global.POWER_BUTTON_LONG_PRESS, new InclusiveIntegerRangeValidator(0, 5));
        VALIDATORS.put(
                Global.POWER_BUTTON_VERY_LONG_PRESS, new InclusiveIntegerRangeValidator(0, 1));
        VALIDATORS.put(Global.KEY_CHORD_POWER_VOLUME_UP, new InclusiveIntegerRangeValidator(0, 2));
        VALIDATORS.put(
                Global.STEM_PRIMARY_BUTTON_SHORT_PRESS, new InclusiveIntegerRangeValidator(0, 1));
        VALIDATORS.put(
                Global.STEM_PRIMARY_BUTTON_DOUBLE_PRESS, new InclusiveIntegerRangeValidator(0, 1));
        VALIDATORS.put(
                Global.STEM_PRIMARY_BUTTON_TRIPLE_PRESS, new InclusiveIntegerRangeValidator(0, 1));
        VALIDATORS.put(
                Global.STEM_PRIMARY_BUTTON_LONG_PRESS, new InclusiveIntegerRangeValidator(0, 1));
        VALIDATORS.put(Global.CUSTOM_BUGREPORT_HANDLER_APP, ANY_STRING_VALIDATOR);
        VALIDATORS.put(Global.CUSTOM_BUGREPORT_HANDLER_USER, ANY_INTEGER_VALIDATOR);
        VALIDATORS.put(Global.DEVELOPMENT_SETTINGS_ENABLED, BOOLEAN_VALIDATOR);
+7 −0
Original line number Diff line number Diff line
@@ -596,7 +596,14 @@ public class SettingsBackupTest {
                    Settings.Global.RADIO_BUG_SYSTEM_ERROR_COUNT_THRESHOLD,
                    Settings.Global.ENABLED_SUBSCRIPTION_FOR_SLOT,
                    Settings.Global.MODEM_STACK_ENABLED_FOR_SLOT,
                    Settings.Global.POWER_BUTTON_SHORT_PRESS,
                    Settings.Global.POWER_BUTTON_DOUBLE_PRESS,
                    Settings.Global.POWER_BUTTON_TRIPLE_PRESS,
                    Settings.Global.POWER_BUTTON_VERY_LONG_PRESS,
                    Settings.Global.STEM_PRIMARY_BUTTON_SHORT_PRESS,
                    Settings.Global.STEM_PRIMARY_BUTTON_DOUBLE_PRESS,
                    Settings.Global.STEM_PRIMARY_BUTTON_TRIPLE_PRESS,
                    Settings.Global.STEM_PRIMARY_BUTTON_LONG_PRESS,
                    Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, // Temporary for R beta
                    Settings.Global.INTEGRITY_CHECK_INCLUDES_RULE_PROVIDER,
                    Settings.Global.CACHED_APPS_FREEZER_ENABLED,
+67 −14
Original line number Diff line number Diff line
@@ -266,7 +266,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    // Whether to allow devices placed in vr headset viewers to have an alternative Home intent.
    static final boolean ENABLE_VR_HEADSET_HOME_CAPTURE = true;

    // --------- Key behavior definitions below. ---------
    // NOTE: When updating the valid range of any of these behaviors, and if that behavior has a
    // Settings key associated to it for dynamic update, update its valid Settings value range in
    // android.provider.settings.validators.GlobalSettingsValidators.

    // must match: config_shortPressOnPowerBehavior in config.xml
    // The config value can be overridden using Settings.Global.POWER_BUTTON_SHORT_PRESS
    static final int SHORT_PRESS_POWER_NOTHING = 0;
    static final int SHORT_PRESS_POWER_GO_TO_SLEEP = 1;
    static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP = 2;
@@ -277,6 +283,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    static final int SHORT_PRESS_POWER_DREAM_OR_SLEEP = 7;

    // must match: config_LongPressOnPowerBehavior in config.xml
    // The config value can be overridden using Settings.Global.POWER_BUTTON_LONG_PRESS
    static final int LONG_PRESS_POWER_NOTHING = 0;
    static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
    static final int LONG_PRESS_POWER_SHUT_OFF = 2;
@@ -285,6 +292,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    static final int LONG_PRESS_POWER_ASSISTANT = 5; // Settings.Secure.ASSISTANT

    // must match: config_veryLongPresOnPowerBehavior in config.xml
    // The config value can be overridden using Settings.Global.POWER_BUTTON_VERY_LONG_PRESS
    static final int VERY_LONG_PRESS_POWER_NOTHING = 0;
    static final int VERY_LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;

@@ -294,6 +302,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    static final int POWER_VOLUME_UP_BEHAVIOR_GLOBAL_ACTIONS = 2;

    // must match: config_doublePressOnPowerBehavior in config.xml
    // The config value can be overridden using Settings.Global.POWER_BUTTON_DOUBLE_PRESS and/or
    // Settings.Global.POWER_BUTTON_TRIPLE_PRESS
    static final int MULTI_PRESS_POWER_NOTHING = 0;
    static final int MULTI_PRESS_POWER_THEATER_MODE = 1;
    static final int MULTI_PRESS_POWER_BRIGHTNESS_BOOST = 2;
@@ -324,18 +334,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    static final int PENDING_KEY_NULL = -1;

    // Must match: config_shortPressOnStemPrimaryBehavior in config.xml
    // The config value can be overridden using Settings.Global.STEM_PRIMARY_BUTTON_SHORT_PRESS
    static final int SHORT_PRESS_PRIMARY_NOTHING = 0;
    static final int SHORT_PRESS_PRIMARY_LAUNCH_ALL_APPS = 1;

    // Must match: config_longPressOnStemPrimaryBehavior in config.xml
    // The config value can be overridden using Settings.Global.STEM_PRIMARY_BUTTON_LONG_PRESS
    static final int LONG_PRESS_PRIMARY_NOTHING = 0;
    static final int LONG_PRESS_PRIMARY_LAUNCH_VOICE_ASSISTANT = 1;

    // Must match: config_doublePressOnStemPrimaryBehavior in config.xml
    //The config value can be overridden using Settings.Global.STEM_PRIMARY_BUTTON_DOUBLE_PRESS
    static final int DOUBLE_PRESS_PRIMARY_NOTHING = 0;
    static final int DOUBLE_PRESS_PRIMARY_SWITCH_RECENT_APP = 1;

    // Must match: config_triplePressOnStemPrimaryBehavior in config.xml
    // The config value can be overridden using Settings.Global.STEM_PRIMARY_BUTTON_TRIPLE_PRESS
    static final int TRIPLE_PRESS_PRIMARY_NOTHING = 0;
    static final int TRIPLE_PRESS_PRIMARY_TOGGLE_ACCESSIBILITY = 1;

@@ -803,6 +817,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.Secure.getUriFor(
                    Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.POWER_BUTTON_SHORT_PRESS), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.POWER_BUTTON_DOUBLE_PRESS), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.POWER_BUTTON_TRIPLE_PRESS), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.POWER_BUTTON_LONG_PRESS), false, this,
                    UserHandle.USER_ALL);
@@ -812,6 +835,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.POWER_BUTTON_VERY_LONG_PRESS), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.STEM_PRIMARY_BUTTON_SHORT_PRESS), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.STEM_PRIMARY_BUTTON_DOUBLE_PRESS), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.STEM_PRIMARY_BUTTON_TRIPLE_PRESS), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.STEM_PRIMARY_BUTTON_LONG_PRESS), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.KEY_CHORD_POWER_VOLUME_UP), false, this,
                    UserHandle.USER_ALL);
@@ -2193,33 +2228,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mLongPressOnBackBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_longPressOnBackBehavior);

        mShortPressOnPowerBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_shortPressOnPowerBehavior);
        mLongPressOnPowerBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_longPressOnPowerBehavior);
        mLongPressOnPowerAssistantTimeoutMs = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_longPressOnPowerDurationMs);
        mVeryLongPressOnPowerBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_veryLongPressOnPowerBehavior);
        mDoublePressOnPowerBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_doublePressOnPowerBehavior);
        mPowerDoublePressTargetActivity = ComponentName.unflattenFromString(
            mContext.getResources().getString(
                com.android.internal.R.string.config_doublePressOnPowerTargetActivity));
        mTriplePressOnPowerBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_triplePressOnPowerBehavior);
        mShortPressOnSleepBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_shortPressOnSleepBehavior);
        mAllowStartActivityForLongPressOnPowerDuringSetup = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_allowStartActivityForLongPressOnPowerInSetup);
        mShortPressOnStemPrimaryBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_shortPressOnStemPrimaryBehavior);
        mLongPressOnStemPrimaryBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_longPressOnStemPrimaryBehavior);
        mDoublePressOnStemPrimaryBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_doublePressOnStemPrimaryBehavior);
        mTriplePressOnStemPrimaryBehavior = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_triplePressOnStemPrimaryBehavior);

        mHapticTextHandleEnabled = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_enableHapticTextHandle);
@@ -2681,6 +2702,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                updateRotation = true;
            }

            mShortPressOnPowerBehavior = Settings.Global.getInt(resolver,
                    Settings.Global.POWER_BUTTON_SHORT_PRESS,
                    mContext.getResources().getInteger(
                            com.android.internal.R.integer.config_shortPressOnPowerBehavior));
            mDoublePressOnPowerBehavior = Settings.Global.getInt(resolver,
                    Settings.Global.POWER_BUTTON_DOUBLE_PRESS,
                    mContext.getResources().getInteger(
                            com.android.internal.R.integer.config_doublePressOnPowerBehavior));
            mTriplePressOnPowerBehavior = Settings.Global.getInt(resolver,
                    Settings.Global.POWER_BUTTON_TRIPLE_PRESS,
                    mContext.getResources().getInteger(
                            com.android.internal.R.integer.config_triplePressOnPowerBehavior));

            final int longPressOnPowerBehavior = Settings.Global.getInt(resolver,
                    Settings.Global.POWER_BUTTON_LONG_PRESS,
                    mContext.getResources().getInteger(
@@ -2706,6 +2740,25 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mContext.getResources().getInteger(
                            com.android.internal.R.integer.config_keyChordPowerVolumeUp));

            mShortPressOnStemPrimaryBehavior = Settings.Global.getInt(resolver,
                    Settings.Global.STEM_PRIMARY_BUTTON_SHORT_PRESS,
                    mContext.getResources().getInteger(
                            com.android.internal.R.integer.config_shortPressOnStemPrimaryBehavior));
            mDoublePressOnStemPrimaryBehavior = Settings.Global.getInt(resolver,
                    Settings.Global.STEM_PRIMARY_BUTTON_DOUBLE_PRESS,
                    mContext.getResources().getInteger(
                            com.android.internal.R.integer
                                    .config_doublePressOnStemPrimaryBehavior));
            mTriplePressOnStemPrimaryBehavior = Settings.Global.getInt(resolver,
                    Settings.Global.STEM_PRIMARY_BUTTON_TRIPLE_PRESS,
                    mContext.getResources().getInteger(
                            com.android.internal.R.integer
                                    .config_triplePressOnStemPrimaryBehavior));
            mLongPressOnStemPrimaryBehavior = Settings.Global.getInt(resolver,
                    Settings.Global.STEM_PRIMARY_BUTTON_LONG_PRESS,
                    mContext.getResources().getInteger(
                            com.android.internal.R.integer.config_longPressOnStemPrimaryBehavior));

            mStylusButtonsEnabled = Settings.Secure.getIntForUser(resolver,
                    Secure.STYLUS_BUTTONS_ENABLED, 1, UserHandle.USER_CURRENT) == 1;
            mInputManagerInternal.setStylusButtonMotionEventsEnabled(mStylusButtonsEnabled);