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

Commit 684722c3 authored by Peter_Liang's avatar Peter_Liang
Browse files

Fix that holding volume buttons to activate Extra dim feature doesn't do anything.

Root cause:
Original framework design which has 3 seconds restriction to prevent users from easily triggering the accessibility volume shortcut when first time using it.

Solution:
The system would bypass the 3 seconds restriction if users manually set any feature as the volume key shortcut.

Bug: 202602908
Test: manual test
Change-Id: Iace0804fc36809f7cf39d19850c1bbd8ba9fca02
parent 77946e2a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ import android.util.Log;
import android.util.MemoryIntArray;
import android.view.Display;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.widget.Editor;
@@ -7474,6 +7475,16 @@ public final class Settings {
        public static final String ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN =
                "accessibility_shortcut_dialog_shown";
        /**
         * Setting specifying if the timeout restriction
         * {@link ViewConfiguration#getAccessibilityShortcutKeyTimeout()}
         * of the accessibility shortcut dialog is skipped.
         *
         * @hide
         */
        public static final String SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION =
                "skip_accessibility_shortcut_dialog_timeout_restriction";
        /**
         * Setting specifying the accessibility services, accessibility shortcut targets,
         * or features to be toggled via the accessibility shortcut.
+13 −5
Original line number Diff line number Diff line
@@ -1490,11 +1490,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    private long getAccessibilityShortcutTimeout() {
        ViewConfiguration config = ViewConfiguration.get(mContext);
        return Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, 0, mCurrentUserId) == 0
                ? config.getAccessibilityShortcutKeyTimeout()
                : config.getAccessibilityShortcutKeyTimeoutAfterConfirmation();
        final ViewConfiguration config = ViewConfiguration.get(mContext);
        final boolean hasDialogShown = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, 0, mCurrentUserId) != 0;
        final boolean skipTimeoutRestriction =
                Settings.Secure.getIntForUser(mContext.getContentResolver(),
                        Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, 0,
                        mCurrentUserId) != 0;

        // If users manually set the volume key shortcut for any accessibility service, the
        // system would bypass the timeout restriction of the shortcut dialog.
        return hasDialogShown || skipTimeoutRestriction
                ? config.getAccessibilityShortcutKeyTimeoutAfterConfirmation()
                : config.getAccessibilityShortcutKeyTimeout();
    }

    private long getScreenshotChordLongPressDelay() {