public class MotionEventInjector extends Object
AccessibilityService
s to touch the screen on behalf of
users.
All methods except injectEvents
must be called only from the main thread.Constructor and Description |
---|
MotionEventInjector(Looper looper) |
Modifier and Type | Method and Description |
---|---|
void |
clearEvents(int inputSource)
Clears internal state associated with events from specific input source.
|
void |
injectEvents(List<MotionEvent> events,
IAccessibilityServiceClient serviceInterface,
int sequence)
Schedule a series of events for injection.
|
void |
onAccessibilityEvent(AccessibilityEvent event)
Receives an accessibility event.
|
void |
onDestroy()
Destroys this transformation.
|
void |
onKeyEvent(KeyEvent event,
int policyFlags)
Receives a key event.
|
void |
onMotionEvent(MotionEvent event,
MotionEvent rawEvent,
int policyFlags)
Receives a motion event.
|
void |
setNext(com.android.server.accessibility.EventStreamTransformation next)
Sets the next transformation.
|
public MotionEventInjector(Looper looper)
looper
- A looper on the main thread to use for dispatching new eventspublic void injectEvents(List<MotionEvent> events, IAccessibilityServiceClient serviceInterface, int sequence)
downTime
and eventTime
fields will be offset by the current time.events
- The events to inject. Must all be from the same source.serviceInterface
- The interface to call back with a result when the gesture is
either complete or cancelled.public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags)
event
- The transformed motion event.rawEvent
- The raw motion event.policyFlags
- Policy flags for the event.public void onKeyEvent(KeyEvent event, int policyFlags)
event
- The key event.policyFlags
- Policy flags for the event.public void onAccessibilityEvent(AccessibilityEvent event)
event
- The accessibility event.public void setNext(com.android.server.accessibility.EventStreamTransformation next)
next
- The next transformation.public void clearEvents(int inputSource)
inputSource
- The input source class for which transformation state should be cleared.public void onDestroy()