diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-06-10 12:38:36 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2011-06-10 12:43:00 -0700 |
commit | 8dffad68c7aa7da9a3d73d1ee41f3c4460f733b4 (patch) | |
tree | acd8e9b265e0c9e25387e7752d6e930efb26bda5 /core/java | |
parent | 679dd99cdce72683816e6ac75e4f0e68ca6ad51c (diff) | |
download | frameworks_base-8dffad68c7aa7da9a3d73d1ee41f3c4460f733b4.zip frameworks_base-8dffad68c7aa7da9a3d73d1ee41f3c4460f733b4.tar.gz frameworks_base-8dffad68c7aa7da9a3d73d1ee41f3c4460f733b4.tar.bz2 |
Bug fixes in the accessibility interrogation APIs
1. AccessibilityNodeInfo was not overriding equals.
2. ViewAncestor was not calling the callback for
setting the result of an interrogation request
thus making the system process wait upto the
maximal timeout.
Change-Id: I040a3c12d97f48aee319ba6414879546e71e9b8e
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/view/ViewAncestor.java | 122 | ||||
-rw-r--r-- | core/java/android/view/accessibility/AccessibilityNodeInfo.java | 21 |
2 files changed, 81 insertions, 62 deletions
diff --git a/core/java/android/view/ViewAncestor.java b/core/java/android/view/ViewAncestor.java index d587788..17d7454 100644 --- a/core/java/android/view/ViewAncestor.java +++ b/core/java/android/view/ViewAncestor.java @@ -4364,17 +4364,16 @@ public final class ViewAncestor extends Handler implements ViewParent, final IAccessibilityInteractionConnectionCallback callback = (IAccessibilityInteractionConnectionCallback) message.obj; - View root = ViewAncestor.this.mView; - if (root == null) { - return; - } - - FindByAccessibilitytIdPredicate predicate = mFindByAccessibilityIdPredicate; - predicate.init(accessibilityId); - - View target = root.findViewByPredicate(predicate); - if (target != null) { - AccessibilityNodeInfo info = target.createAccessibilityNodeInfo(); + AccessibilityNodeInfo info = null; + try { + FindByAccessibilitytIdPredicate predicate = mFindByAccessibilityIdPredicate; + predicate.init(accessibilityId); + View root = ViewAncestor.this.mView; + View target = root.findViewByPredicate(predicate); + if (target != null) { + info = target.createAccessibilityNodeInfo(); + } + } finally { try { callback.setFindAccessibilityNodeInfoResult(info, interactionId); } catch (RemoteException re) { @@ -4399,13 +4398,14 @@ public final class ViewAncestor extends Handler implements ViewParent, final IAccessibilityInteractionConnectionCallback callback = (IAccessibilityInteractionConnectionCallback) message.obj; - View root = ViewAncestor.this.mView; - if (root == null) { - return; - } - View target = root.findViewById(viewId); - if (target != null) { - AccessibilityNodeInfo info = target.createAccessibilityNodeInfo(); + AccessibilityNodeInfo info = null; + try { + View root = ViewAncestor.this.mView; + View target = root.findViewById(viewId); + if (target != null) { + info = target.createAccessibilityNodeInfo(); + } + } finally { try { callback.setFindAccessibilityNodeInfoResult(info, interactionId); } catch (RemoteException re) { @@ -4434,32 +4434,32 @@ public final class ViewAncestor extends Handler implements ViewParent, (IAccessibilityInteractionConnectionCallback) args.arg2; mPool.release(args); - View root = ViewAncestor.this.mView; - if (root == null) { - return; - } - - ArrayList<View> foundViews = mAttachInfo.mFocusablesTempList; - foundViews.clear(); + List<AccessibilityNodeInfo> infos = null; + try { + View root = ViewAncestor.this.mView; - root.findViewsWithText(foundViews, text); - if (foundViews.isEmpty()) { - return; - } + ArrayList<View> foundViews = mAttachInfo.mFocusablesTempList; + foundViews.clear(); - List<AccessibilityNodeInfo> infos = mTempAccessibilityNodeInfoList; - infos.clear(); + root.findViewsWithText(foundViews, text); + if (foundViews.isEmpty()) { + return; + } - final int viewCount = foundViews.size(); - for (int i = 0; i < viewCount; i++) { - View foundView = foundViews.get(i); - infos.add(foundView.createAccessibilityNodeInfo()); - } + infos = mTempAccessibilityNodeInfoList; + infos.clear(); - try { - callback.setFindAccessibilityNodeInfosResult(infos, interactionId); - } catch (RemoteException re) { - /* ignore - the other side will time out */ + final int viewCount = foundViews.size(); + for (int i = 0; i < viewCount; i++) { + View foundView = foundViews.get(i); + infos.add(foundView.createAccessibilityNodeInfo()); + } + } finally { + try { + callback.setFindAccessibilityNodeInfosResult(infos, interactionId); + } catch (RemoteException re) { + /* ignore - the other side will time out */ + } } } @@ -4485,30 +4485,28 @@ public final class ViewAncestor extends Handler implements ViewParent, (IAccessibilityInteractionConnectionCallback) args.arg1; mPool.release(args); - if (ViewAncestor.this.mView == null) { - return; - } - boolean succeeded = false; - switch (action) { - case AccessibilityNodeInfo.ACTION_FOCUS: { - succeeded = performActionFocus(accessibilityId); - } break; - case AccessibilityNodeInfo.ACTION_CLEAR_FOCUS: { - succeeded = performActionClearFocus(accessibilityId); - } break; - case AccessibilityNodeInfo.ACTION_SELECT: { - succeeded = performActionSelect(accessibilityId); - } break; - case AccessibilityNodeInfo.ACTION_CLEAR_SELECTION: { - succeeded = performActionClearSelection(accessibilityId); - } break; - } - try { - callback.setPerformAccessibilityActionResult(succeeded, interactionId); - } catch (RemoteException re) { - /* ignore - the other side will time out */ + switch (action) { + case AccessibilityNodeInfo.ACTION_FOCUS: { + succeeded = performActionFocus(accessibilityId); + } break; + case AccessibilityNodeInfo.ACTION_CLEAR_FOCUS: { + succeeded = performActionClearFocus(accessibilityId); + } break; + case AccessibilityNodeInfo.ACTION_SELECT: { + succeeded = performActionSelect(accessibilityId); + } break; + case AccessibilityNodeInfo.ACTION_CLEAR_SELECTION: { + succeeded = performActionClearSelection(accessibilityId); + } break; + } + } finally { + try { + callback.setPerformAccessibilityActionResult(succeeded, interactionId); + } catch (RemoteException re) { + /* ignore - the other side will time out */ + } } } diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index a4801fd..5fa65b4 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -870,6 +870,27 @@ public class AccessibilityNodeInfo implements Parcelable { } @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (object == null) { + return false; + } + if (getClass() != object.getClass()) { + return false; + } + AccessibilityNodeInfo other = (AccessibilityNodeInfo) object; + if (mAccessibilityViewId != other.mAccessibilityViewId) { + return false; + } + if (mAccessibilityWindowId != other.mAccessibilityWindowId) { + return false; + } + return true; + } + + @Override public int hashCode() { final int prime = 31; int result = 1; |