Merge "Adding public event callback instead of the internal one to UiAutomation."
This commit is contained in:
@@ -4153,7 +4153,7 @@ package android.app {
|
||||
}
|
||||
|
||||
public final class UiAutomation {
|
||||
method public android.view.accessibility.AccessibilityEvent executeAndWaitForEvent(java.lang.Runnable, com.android.internal.util.Predicate<android.view.accessibility.AccessibilityEvent>, long) throws java.util.concurrent.TimeoutException;
|
||||
method public android.view.accessibility.AccessibilityEvent executeAndWaitForEvent(java.lang.Runnable, android.app.UiAutomation.AccessibilityEventFilter, long) throws java.util.concurrent.TimeoutException;
|
||||
method public android.view.accessibility.AccessibilityNodeInfo getRootInActiveWindow();
|
||||
method public final android.accessibilityservice.AccessibilityServiceInfo getServiceInfo();
|
||||
method public boolean injectInputEvent(android.view.InputEvent, boolean);
|
||||
@@ -4171,6 +4171,10 @@ package android.app {
|
||||
field public static final int ROTATION_UNFREEZE = -2; // 0xfffffffe
|
||||
}
|
||||
|
||||
public static abstract interface UiAutomation.AccessibilityEventFilter {
|
||||
method public abstract boolean accept(android.view.accessibility.AccessibilityEvent);
|
||||
}
|
||||
|
||||
public static abstract interface UiAutomation.OnAccessibilityEventListener {
|
||||
method public abstract void onAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ import android.view.accessibility.AccessibilityInteractionClient;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.accessibility.IAccessibilityInteractionConnection;
|
||||
|
||||
import com.android.internal.util.Predicate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@@ -134,6 +132,21 @@ public final class UiAutomation {
|
||||
public void onAccessibilityEvent(AccessibilityEvent event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for filtering accessibility events.
|
||||
*/
|
||||
public static interface AccessibilityEventFilter {
|
||||
|
||||
/**
|
||||
* Callback for determining whether an event is accepted or
|
||||
* it is filtered out.
|
||||
*
|
||||
* @param event The event to process.
|
||||
* @return True if the event is accepted, false to filter it out.
|
||||
*/
|
||||
public boolean accept(AccessibilityEvent event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance that will handle callbacks from the accessibility
|
||||
* layer on the thread of the provided looper and perform requests for privileged
|
||||
@@ -428,7 +441,7 @@ public final class UiAutomation {
|
||||
* @throws TimeoutException If the expected event is not received within the timeout.
|
||||
*/
|
||||
public AccessibilityEvent executeAndWaitForEvent(Runnable command,
|
||||
Predicate<AccessibilityEvent> filter, long timeoutMillis) throws TimeoutException {
|
||||
AccessibilityEventFilter filter, long timeoutMillis) throws TimeoutException {
|
||||
synchronized (mLock) {
|
||||
throwIfNotConnectedLocked();
|
||||
|
||||
@@ -452,7 +465,7 @@ public final class UiAutomation {
|
||||
if (event.getEventTime() <= executionStartTimeMillis) {
|
||||
continue;
|
||||
}
|
||||
if (filter.apply(event)) {
|
||||
if (filter.accept(event)) {
|
||||
return event;
|
||||
}
|
||||
event.recycle();
|
||||
|
||||
Reference in New Issue
Block a user