summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorEugene Susla <eugenesusla@google.com>2018-02-26 10:41:28 -0800
committerEugene Susla <eugenesusla@google.com>2018-04-03 21:36:01 +0000
commitbd573236f8f419161c56be72876a0546f650f947 (patch)
tree717b85af0f6a28dafe3aaebc520a530ce908d442 /core/java
parent315c230cbb4fccbb13cfb8799247427d4dc08368 (diff)
[DO NOT MERGE] Sort A11yService#getWindows by layer descending
This is what A11yService#getWindows promises in the javadoc. Fixes: 71581072 Test: using testback ensure the order is correct Change-Id: I5038c4de29c60e235b65751f7bd7771ef35eb339 (cherry picked from commit f40da1a884493b6af61e3b978fdf7c7ff059b2dc)
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/accessibilityservice/AccessibilityService.java2
-rw-r--r--core/java/android/app/UiAutomation.java11
2 files changed, 10 insertions, 3 deletions
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java
index 0a4541ba4777..829a94446937 100644
--- a/core/java/android/accessibilityservice/AccessibilityService.java
+++ b/core/java/android/accessibilityservice/AccessibilityService.java
@@ -537,7 +537,7 @@ public abstract class AccessibilityService extends Service {
* anything behind it, then only the modal window will be reported
* (assuming it is the top one). For convenience the returned windows
* are ordered in a descending layer order, which is the windows that
- * are higher in the Z-order are reported first. Since the user can always
+ * are on top are reported first. Since the user can always
* interact with the window that has input focus by typing, the focused
* window is always returned (even if covered by a modal window).
* <p>
diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java
index bd4933a2081c..c03340e84a85 100644
--- a/core/java/android/app/UiAutomation.java
+++ b/core/java/android/app/UiAutomation.java
@@ -580,6 +580,8 @@ public final class UiAutomation {
// Execute the command *without* the lock being held.
command.run();
+ List<AccessibilityEvent> receivedEvents = new ArrayList<>();
+
// Acquire the lock and wait for the event.
try {
// Wait for the event.
@@ -600,14 +602,14 @@ public final class UiAutomation {
if (filter.accept(event)) {
return event;
}
- event.recycle();
+ receivedEvents.add(event);
}
// Check if timed out and if not wait.
final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
final long remainingTimeMillis = timeoutMillis - elapsedTimeMillis;
if (remainingTimeMillis <= 0) {
throw new TimeoutException("Expected event not received within: "
- + timeoutMillis + " ms.");
+ + timeoutMillis + " ms among: " + receivedEvents);
}
synchronized (mLock) {
if (mEventQueue.isEmpty()) {
@@ -620,6 +622,11 @@ public final class UiAutomation {
}
}
} finally {
+ int size = receivedEvents.size();
+ for (int i = 0; i < size; i++) {
+ receivedEvents.get(i).recycle();
+ }
+
synchronized (mLock) {
mWaitingForEventDelivery = false;
mEventQueue.clear();