diff options
| author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-02-07 12:07:23 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-07 12:07:23 -0800 |
| commit | d36ad9b1ff99675dd0eca6a3fda1f52353f451a4 (patch) | |
| tree | d68f9eabc083d382fbda52fa9c1c0bca890c46c4 /core/java | |
| parent | e7171effdf9ef0700782520187c0a292b0a74759 (diff) | |
| parent | b765db590ff824fb5827fb773b14ac4286ae2774 (diff) | |
Merge "Adding a method for retching the root node in UiTestAutomationBridge"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/accessibilityservice/UiTestAutomationBridge.java | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/core/java/android/accessibilityservice/UiTestAutomationBridge.java b/core/java/android/accessibilityservice/UiTestAutomationBridge.java index 9d48efc66dc3..616b7966eab6 100644 --- a/core/java/android/accessibilityservice/UiTestAutomationBridge.java +++ b/core/java/android/accessibilityservice/UiTestAutomationBridge.java @@ -63,6 +63,8 @@ public class UiTestAutomationBridge { private AccessibilityEvent mLastEvent; + private AccessibilityEvent mLastWindowStateChangeEvent; + private volatile boolean mWaitingForEventDelivery; private volatile boolean mUnprocessedEventAvailable; @@ -138,12 +140,22 @@ public class UiTestAutomationBridge { public void onAccessibilityEvent(AccessibilityEvent event) { synchronized (mLock) { while (true) { + mLastEvent = AccessibilityEvent.obtain(event); + + final int eventType = event.getEventType(); + if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED + || eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) { + if (mLastWindowStateChangeEvent != null) { + mLastWindowStateChangeEvent.recycle(); + } + mLastWindowStateChangeEvent = mLastEvent; + } + if (!mWaitingForEventDelivery) { break; } if (!mUnprocessedEventAvailable) { mUnprocessedEventAvailable = true; - mLastEvent = AccessibilityEvent.obtain(event); mLock.notifyAll(); break; } @@ -409,6 +421,20 @@ public class UiTestAutomationBridge { accessibilityWindowId, accessibilityNodeId, action); } + /** + * Gets the root {@link AccessibilityNodeInfo} in the active window. + * + * @return The root info. + */ + public AccessibilityNodeInfo getRootAccessibilityNodeInfoInActiveWindow() { + synchronized (mLock) { + if (mLastWindowStateChangeEvent != null) { + return mLastWindowStateChangeEvent.getSource(); + } + } + return null; + } + private void ensureValidConnection(int connectionId) { if (connectionId == AccessibilityInteractionClient.NO_ID) { throw new IllegalStateException("UiAutomationService not connected." |
