summaryrefslogtreecommitdiff
path: root/services/accessibility
diff options
context:
space:
mode:
author Yuhan Yang <yyhyyh@google.com> 2025-03-11 17:57:41 +0000
committer Yuhan Yang <yyhyyh@google.com> 2025-03-11 13:18:04 -0700
commit241cd23d457a4fb8ff35c224d715b567177fffca (patch)
treebe50dccf3de7c23732d976af994f1d66c9fd8f67 /services/accessibility
parent45a14a7df87d62ebbffe5054830e3a0191bac953 (diff)
Implement double click as autoclick type
screencast: go/screencast-ndc1njczodi1mdexmzaynhw2mti1mmm1mi01yg Bug: 388844955 Test: atest AutoclickControllerTest Flag: com.android.server.accessibility.enable_autoclick_indicator Change-Id: Ic0db436e65ab9de4758f6d3ac9d6e2559ec63bc7
Diffstat (limited to 'services/accessibility')
-rw-r--r--services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java31
1 files changed, 25 insertions, 6 deletions
diff --git a/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java b/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java
index 23166a800245..84158cf911ad 100644
--- a/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java
+++ b/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java
@@ -24,6 +24,7 @@ import static android.view.accessibility.AccessibilityManager.AUTOCLICK_IGNORE_M
import static android.view.accessibility.AccessibilityManager.AUTOCLICK_REVERT_TO_LEFT_CLICK_DEFAULT;
import static com.android.server.accessibility.autoclick.AutoclickIndicatorView.SHOW_INDICATOR_DELAY_TIME;
+import static com.android.server.accessibility.autoclick.AutoclickTypePanel.AUTOCLICK_TYPE_DOUBLE_CLICK;
import static com.android.server.accessibility.autoclick.AutoclickTypePanel.AUTOCLICK_TYPE_LEFT_CLICK;
import static com.android.server.accessibility.autoclick.AutoclickTypePanel.AUTOCLICK_TYPE_RIGHT_CLICK;
import static com.android.server.accessibility.autoclick.AutoclickTypePanel.AUTOCLICK_TYPE_SCROLL;
@@ -45,6 +46,7 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.MotionEvent.PointerCoords;
import android.view.MotionEvent.PointerProperties;
+import android.view.ViewConfiguration;
import android.view.WindowManager;
import androidx.annotation.VisibleForTesting;
@@ -799,7 +801,7 @@ public class AutoclickController extends BaseEventStreamTransformation {
final long now = SystemClock.uptimeMillis();
- int actionButton;
+ int actionButton = BUTTON_PRIMARY;
if (mHoveredState) {
// Always triggers left-click when the cursor hovers over the autoclick type
// panel, to always allow users to change a different click type. Otherwise, if
@@ -807,15 +809,32 @@ public class AutoclickController extends BaseEventStreamTransformation {
// select other click types.
actionButton = BUTTON_PRIMARY;
} else {
- actionButton = mActiveClickType == AUTOCLICK_TYPE_RIGHT_CLICK
- ? BUTTON_SECONDARY
- : BUTTON_PRIMARY;
+ switch (mActiveClickType) {
+ case AUTOCLICK_TYPE_LEFT_CLICK:
+ actionButton = BUTTON_PRIMARY;
+ break;
+ case AUTOCLICK_TYPE_RIGHT_CLICK:
+ actionButton = BUTTON_SECONDARY;
+ break;
+ case AUTOCLICK_TYPE_DOUBLE_CLICK:
+ actionButton = BUTTON_PRIMARY;
+ long doubleTapMinimumTimeout = ViewConfiguration.getDoubleTapMinTime();
+ sendMotionEvent(actionButton, now);
+ sendMotionEvent(actionButton, now + doubleTapMinimumTimeout);
+ return;
+ default:
+ break;
+ }
}
+ sendMotionEvent(actionButton, now);
+ }
+
+ private void sendMotionEvent(int actionButton, long eventTime) {
MotionEvent downEvent =
MotionEvent.obtain(
- /* downTime= */ now,
- /* eventTime= */ now,
+ /* downTime= */ eventTime,
+ /* eventTime= */ eventTime,
MotionEvent.ACTION_DOWN,
/* pointerCount= */ 1,
mTempPointerProperties,