Merge "[DO NOT MERGE] Sort A11yService#getWindows by layer descending" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-04-03 23:17:26 +00:00
committed by Android (Google) Code Review
4 changed files with 16 additions and 6 deletions

View File

@@ -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>

View File

@@ -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();

View File

@@ -53,7 +53,6 @@ import android.view.accessibility.AccessibilityWindowInfo;
import android.view.accessibility.IAccessibilityInteractionConnection;
import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.DumpUtils;
import com.android.server.accessibility.AccessibilityManagerService.RemoteAccessibilityConnection;
@@ -76,7 +75,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
implements ServiceConnection, IBinder.DeathRecipient, KeyEventDispatcher.KeyEventFilter,
FingerprintGestureDispatcher.FingerprintGestureClient {
private static final boolean DEBUG = false;
private static final String LOG_TAG = "AccessibilityClientConnection";
private static final String LOG_TAG = "AbstractAccessibilityServiceConnection";
protected final Context mContext;
protected final SystemSupport mSystemSupport;

View File

@@ -2949,7 +2949,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
| AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED
| AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY;
// In Z order
// In Z order top to bottom
public List<AccessibilityWindowInfo> mWindows;
public SparseArray<AccessibilityWindowInfo> mA11yWindowInfoById = new SparseArray<>();
public SparseArray<WindowInfo> mWindowInfoById = new SparseArray<>();
@@ -3145,6 +3145,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
? mWindowsForAccessibilityCallback.populateReportedWindow(windowInfo)
: null;
if (window != null) {
// Flip layers in list to be consistent with AccessibilityService#getWindows
window.setLayer(windowCount - 1 - window.getLayer());
final int windowId = window.getId();
if (window.isFocused()) {
mFocusedWindowId = windowId;