Set autofill id on virtual structures.

ViewStructure.newChild(virtualId) uses the AutoFillId of the parent,
which was not set anymore due do a previous refactoring, and was
causing this method to crash a custom view when
onProvideAutoFillVirtualStructure() was called on it.

Test: manual verification
Bug: 31001899

Change-Id: I602b421b0ec3a926ffdd52253d5b2498c4217d02
This commit is contained in:
Felipe Leme
2017-02-07 13:40:55 -08:00
parent fb0f360222
commit 1bdf3f070b

View File

@@ -7171,6 +7171,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
boolean blocked = forAutoFill ? isAutoFillBlocked() : isAssistBlocked();
if (!blocked) {
if (forAutoFill) {
// The auto-fill id needs to be unique, but its value doesn't matter,
// so it's better to reuse the accessibility id to save space.
structure.setAutoFillId(getAccessibilityViewId());
// NOTE: flags are not currently supported, hence 0
onProvideAutoFillStructure(structure, 0);
onProvideAutoFillVirtualStructure(structure, 0);