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
This commit is contained in:
Peter_Liang
2022-03-09 10:56:10 +08:00
parent 77946e2ae8
commit 684722c399
2 changed files with 24 additions and 5 deletions

View File

@@ -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.

View File

@@ -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() {