Skip to content

Commit 3efa8ba

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Adding accessibility events for touch and gesture detection states." into jb-mr1-dev
2 parents b4ad71a + 77276b6 commit 3efa8ba

File tree

4 files changed

+199
-74
lines changed

4 files changed

+199
-74
lines changed

api/current.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26054,9 +26054,13 @@ package android.view.accessibility {
2605426054
field public static final deprecated int MAX_TEXT_LENGTH = 500; // 0x1f4
2605526055
field public static final int TYPES_ALL_MASK = -1; // 0xffffffff
2605626056
field public static final int TYPE_ANNOUNCEMENT = 16384; // 0x4000
26057+
field public static final int TYPE_GESTURE_DETECTION_END = 524288; // 0x80000
26058+
field public static final int TYPE_GESTURE_DETECTION_START = 262144; // 0x40000
2605726059
field public static final int TYPE_NOTIFICATION_STATE_CHANGED = 64; // 0x40
2605826060
field public static final int TYPE_TOUCH_EXPLORATION_GESTURE_END = 1024; // 0x400
2605926061
field public static final int TYPE_TOUCH_EXPLORATION_GESTURE_START = 512; // 0x200
26062+
field public static final int TYPE_TOUCH_INTERACTION_END = 2097152; // 0x200000
26063+
field public static final int TYPE_TOUCH_INTERACTION_START = 1048576; // 0x100000
2606026064
field public static final int TYPE_VIEW_ACCESSIBILITY_FOCUSED = 32768; // 0x8000
2606126065
field public static final int TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED = 65536; // 0x10000
2606226066
field public static final int TYPE_VIEW_CLICKED = 1; // 0x1

core/java/android/view/accessibility/AccessibilityEvent.java

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -424,22 +424,37 @@
424424
* </ul>
425425
* </p>
426426
* <p>
427+
* <b>Touch interaction start</b> - represents the event of starting a touch
428+
* interaction, which is the user starts touching the screen.</br>
429+
* <em>Type:</em> {@link #TYPE_TOUCH_INTERACTION_START}</br>
430+
* <em>Properties:</em></br>
431+
* <ul>
432+
* <li>{@link #getEventType()} - The type of the event.</li>
433+
* </ul>
434+
* <em>Note:</em> This event is fired only by the system and is not passed to the
435+
* view tree to be populated.</br>
436+
* </p>
437+
* <p>
438+
* <b>Touch interaction end</b> - represents the event of ending a touch
439+
* interaction, which is the user stops touching the screen.</br>
440+
* <em>Type:</em> {@link #TYPE_TOUCH_INTERACTION_END}</br>
441+
* <em>Properties:</em></br>
442+
* <ul>
443+
* <li>{@link #getEventType()} - The type of the event.</li>
444+
* </ul>
445+
* <em>Note:</em> This event is fired only by the system and is not passed to the
446+
* view tree to be populated.</br>
447+
* </p>
448+
* <p>
427449
* <b>Touch exploration gesture start</b> - represents the event of starting a touch
428450
* exploring gesture.</br>
429451
* <em>Type:</em> {@link #TYPE_TOUCH_EXPLORATION_GESTURE_START}</br>
430452
* <em>Properties:</em></br>
431453
* <ul>
432454
* <li>{@link #getEventType()} - The type of the event.</li>
433455
* </ul>
434-
* <em>Note:</em> This event type is not dispatched to descendants though
435-
* {@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
436-
* View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)}, hence the event
437-
* source {@link android.view.View} and the sub-tree rooted at it will not receive
438-
* calls to {@link android.view.View#onPopulateAccessibilityEvent(AccessibilityEvent)
439-
* View.onPopulateAccessibilityEvent(AccessibilityEvent)}. The preferred way to add
440-
* text content to such events is by setting the
441-
* {@link android.R.styleable#View_contentDescription contentDescription} of the source
442-
* view.</br>
456+
* <em>Note:</em> This event is fired only by the system and is not passed to the
457+
* view tree to be populated.</br>
443458
* </p>
444459
* <p>
445460
* <b>Touch exploration gesture end</b> - represents the event of ending a touch
@@ -449,15 +464,30 @@
449464
* <ul>
450465
* <li>{@link #getEventType()} - The type of the event.</li>
451466
* </ul>
452-
* <em>Note:</em> This event type is not dispatched to descendants though
453-
* {@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
454-
* View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)}, hence the event
455-
* source {@link android.view.View} and the sub-tree rooted at it will not receive
456-
* calls to {@link android.view.View#onPopulateAccessibilityEvent(AccessibilityEvent)
457-
* View.onPopulateAccessibilityEvent(AccessibilityEvent)}. The preferred way to add
458-
* text content to such events is by setting the
459-
* {@link android.R.styleable#View_contentDescription contentDescription} of the source
460-
* view.</br>
467+
* <em>Note:</em> This event is fired only by the system and is not passed to the
468+
* view tree to be populated.</br>
469+
* </p>
470+
* <p>
471+
* <b>Touch gesture detection start</b> - represents the event of starting a user
472+
* gesture detection.</br>
473+
* <em>Type:</em> {@link #TYPE_GESTURE_DETECTION_START}</br>
474+
* <em>Properties:</em></br>
475+
* <ul>
476+
* <li>{@link #getEventType()} - The type of the event.</li>
477+
* </ul>
478+
* <em>Note:</em> This event is fired only by the system and is not passed to the
479+
* view tree to be populated.</br>
480+
* </p>
481+
* <p>
482+
* <b>Touch gesture detection end</b> - represents the event of ending a user
483+
* gesture detection.</br>
484+
* <em>Type:</em> {@link #TYPE_GESTURE_DETECTION_END}</br>
485+
* <em>Properties:</em></br>
486+
* <ul>
487+
* <li>{@link #getEventType()} - The type of the event.</li>
488+
* </ul>
489+
* <em>Note:</em> This event is fired only by the system and is not passed to the
490+
* view tree to be populated.</br>
461491
* </p>
462492
* <p>
463493
* <b>MISCELLANEOUS TYPES</b></br>
@@ -609,6 +639,26 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
609639
*/
610640
public static final int TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY = 0x00020000;
611641

642+
/**
643+
* Represents the event of beginning gesture detection.
644+
*/
645+
public static final int TYPE_GESTURE_DETECTION_START = 0x00040000;
646+
647+
/**
648+
* Represents the event of ending gesture detection.
649+
*/
650+
public static final int TYPE_GESTURE_DETECTION_END = 0x00080000;
651+
652+
/**
653+
* Represents the event of the user starting to touch the screen.
654+
*/
655+
public static final int TYPE_TOUCH_INTERACTION_START = 0x00100000;
656+
657+
/**
658+
* Represents the event of the user ending to touch the screen.
659+
*/
660+
public static final int TYPE_TOUCH_INTERACTION_END = 0x00200000;
661+
612662
/**
613663
* Mask for {@link AccessibilityEvent} all types.
614664
*
@@ -628,6 +678,10 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
628678
* @see #TYPE_VIEW_TEXT_SELECTION_CHANGED
629679
* @see #TYPE_ANNOUNCEMENT
630680
* @see #TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY
681+
* @see #TYPE_GESTURE_DETECTION_START
682+
* @see #TYPE_GESTURE_DETECTION_END
683+
* @see #TYPE_TOUCH_INTERACTION_START
684+
* @see #TYPE_TOUCH_INTERACTION_END
631685
*/
632686
public static final int TYPES_ALL_MASK = 0xFFFFFFFF;
633687

@@ -1120,6 +1174,14 @@ public static String eventTypeToString(int eventType) {
11201174
return "TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED";
11211175
case TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY:
11221176
return "TYPE_CURRENT_AT_GRANULARITY_MOVEMENT_CHANGED";
1177+
case TYPE_GESTURE_DETECTION_START:
1178+
return "TYPE_GESTURE_DETECTION_START";
1179+
case TYPE_GESTURE_DETECTION_END:
1180+
return "TYPE_GESTURE_DETECTION_END";
1181+
case TYPE_TOUCH_INTERACTION_START:
1182+
return "TYPE_TOUCH_INTERACTION_START";
1183+
case TYPE_TOUCH_INTERACTION_END:
1184+
return "TYPE_TOUCH_INTERACTION_END";
11231185
default:
11241186
return null;
11251187
}

services/java/com/android/server/accessibility/AccessibilityManagerService.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
173173

174174
private Service mQueryBridge;
175175

176-
private boolean mTouchExplorationGestureEnded;
177-
178-
private boolean mTouchExplorationGestureStarted;
179-
180176
private AlertDialog mEnableTouchExplorationDialog;
181177

182178
/**
@@ -400,18 +396,6 @@ public void binderDied() {
400396
}
401397

402398
public boolean sendAccessibilityEvent(AccessibilityEvent event) {
403-
final int eventType = event.getEventType();
404-
405-
// The event for gesture start should be strictly before the
406-
// first hover enter event for the gesture.
407-
if (eventType == AccessibilityEvent.TYPE_VIEW_HOVER_ENTER
408-
&& mTouchExplorationGestureStarted) {
409-
mTouchExplorationGestureStarted = false;
410-
AccessibilityEvent gestureStartEvent = AccessibilityEvent.obtain(
411-
AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START);
412-
sendAccessibilityEvent(gestureStartEvent);
413-
}
414-
415399
synchronized (mLock) {
416400
if (mSecurityPolicy.canDispatchAccessibilityEvent(event)) {
417401
mSecurityPolicy.updateActiveWindowAndEventSourceLocked(event);
@@ -421,22 +405,10 @@ public boolean sendAccessibilityEvent(AccessibilityEvent event) {
421405
if (mHasInputFilter && mInputFilter != null) {
422406
mMainHandler.obtainMessage(MSG_SEND_ACCESSIBILITY_EVENT_TO_INPUT_FILTER,
423407
AccessibilityEvent.obtain(event)).sendToTarget();
424-
425408
}
426409
event.recycle();
427410
mHandledFeedbackTypes = 0;
428411
}
429-
430-
// The event for gesture end should be strictly after the
431-
// last hover exit event for the gesture.
432-
if (eventType == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT
433-
&& mTouchExplorationGestureEnded) {
434-
mTouchExplorationGestureEnded = false;
435-
AccessibilityEvent gestureEndEvent = AccessibilityEvent.obtain(
436-
AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END);
437-
sendAccessibilityEvent(gestureEndEvent);
438-
}
439-
440412
return (OWN_PROCESS_ID != Binder.getCallingPid());
441413
}
442414

@@ -628,14 +600,6 @@ private Service getQueryBridge() {
628600
return mQueryBridge;
629601
}
630602

631-
public void touchExplorationGestureEnded() {
632-
mTouchExplorationGestureEnded = true;
633-
}
634-
635-
public void touchExplorationGestureStarted() {
636-
mTouchExplorationGestureStarted = true;
637-
}
638-
639603
private boolean notifyGestureLocked(int gestureId, boolean isDefault) {
640604
// TODO: Now we are giving the gestures to the last enabled
641605
// service that can handle them which is the last one

0 commit comments

Comments
 (0)