Commit Graph

9 Commits

Author SHA1 Message Date
Emmanuel Garcia edee1fea58 Add @Keep annotation (#11893) 2019-09-05 13:23:04 -07:00
Jason Simmons d9bbe37ce3 Remove use of the deprecated AccessibilityNodeInfo boundsInParent API (#10773) 2019-08-08 15:25:56 -07:00
Michael Klimushyn 6d5aaa090a Fix a11y in embedded Android views post O (#9321)
This patch works around Android's limitations on reflection. With it embedded
platform views that use virtual node hierarchy trees should be accessible on all
Android versions to date.

The workarounds in this PR are brittle. Ideally the methods would be made public
in Android instead so we wouldn't need to employ tactics like these to work
around the missing methods.

`AccessibilityNodeInfo#getChildId` is blocked from any type of reflection
access, but the underlying private member that the getter accesses,
`mChildNodeIds`, can still be reflected on. On Android versions where we can't
access the getter, this patch falls back on reflectively accessing the field
instead. Unfortunately this field is a
[`LongArray`](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/util/LongArray.java),
a utility data class private to Android. So in this case we're reflecting to
both access the member and actually read data from it, since we need to use
reflection to call `LongArray.get(index)`.

`AccessibilityNodeInfo#getParent()` doesn't have any lucky available underlying
members. However, `AccessibilityNodeInfo` itself is `Parcelable`, and
`mParentNodeId` is one of the pieces of data that's written to a parcel via
`AccessibilityNodeInfo#writeToParcel`. So the fallback for that is to write the
node to a parcel and then read the parcel for the ID in question. This will
break if the implementation details of `AccessibilityNodeInfo#writeToParcel`
ever change. The details have already changed enough in the past to require two
sets of logic for reading from the parcel.
2019-06-14 11:43:41 -07:00
Chris Bracken 9acdf1837f Make AccessibilityViewEmbedder final (#8429)
Since this class implements equals() and hashCode() it should either be
final or handle subclasses in equals(); given this is unlikely to be
subclassed, making it final is the simpler option.
2019-04-03 15:06:11 -07:00
Chris Bracken 804d54ddff Eliminate unused displayBounds parameter (#8427)
Use of this parameter was eliminated in 37947f9.
2019-04-03 14:28:29 -07:00
Amir Hardon 82071e9161 Don't access a11y APIs with reflection starting Android P. (#8393) 2019-03-31 23:21:51 -07:00
Amir Hardon 37947f961a Allow delegation of a11y events from nodes that were not yet traversed (#8333)
The AccessibilityViewEmbedder was not delegating a11y events coming virtual nodes(of the embedded view) that were not previously traversed by the a11y framework.

It turns out the a11y framework might leave parts of the tree untraversed in some circumstances, changed the behavior to create an originId<-->flutterId mapping on the fly when an event is delegated from a not previously traversed node.

Fixes flutter/flutter#30010.
2019-03-27 15:49:15 -07:00
Amir Hardon 345ae7d373 Delegate a11y events and action to/from embedded Android platform views. (#8250)
Delegate a11y events and action to/from embedded Android platfrom views.

This handles delegation of:
  * AccessibilityNodeProvider#performAction
  * ViewGroup#requestSendAccessibilityEvent
  * View#onHoverEvent

Additionally updates the currently input accessibility focused node state that is
tracked by the a11y bridge when an embedded view's node is focused.
2019-03-25 14:26:49 -07:00
Amir Hardon 06635d38a9 Mirror Android platform views a11y tree in the Flutter a11y tree. (#8237)
This PR mirrors virtual a11y tree of embedded platform views in the Flutter
a11y tree.

Non virtual hierarchies are not currently supported.

Only works on Android versions earlier than Android P as it relies on
reflection access to hidden system APIs which cannot be done starting
Android P.

A11y is not yet working as we also need to delegate a11y events from the
platform view to the FlutterView. This will be done in a following PR to
keep the change size a little saner.
2019-03-21 15:26:44 -07:00