OSDN Git Service

Ignore dispatchProvideStructureForAutofill() when layout is being updated.
authorFelipe Leme <felipeal@google.com>
Fri, 9 Jun 2017 01:12:32 +0000 (18:12 -0700)
committerFelipe Leme <felipeal@google.com>
Fri, 9 Jun 2017 01:45:11 +0000 (18:45 -0700)
View already checks if its layout is being updated when calling
notifyEnterOrExitForAutoFillIfNeeded(), but that doesn't prevent apps crashing
when the autofill process was triggered by another view.

Test: existing CtsAutoFillServiceTestCases pass
Fixes: 38198484

change-Id: I8e9435ddc4cf21fb648d39aace93f3af0e1fdf4f

core/java/android/view/View.java

index a9c85f0..5c926f6 100644 (file)
@@ -8065,6 +8065,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
             boolean forAutofill, @AutofillFlags int flags) {
         if (forAutofill) {
             structure.setAutofillId(getAutofillId());
+            if (!isLaidOut()) {
+                Log.w(VIEW_LOG_TAG, "dispatchProvideAutofillStructure(): not laid out, ignoring");
+                return;
+            }
             onProvideAutofillStructure(structure, flags);
             onProvideAutofillVirtualStructure(structure, flags);
         } else if (!isAssistBlocked()) {