OSDN Git Service

Do not restore same autofill id twice
authorPhilip P. Moltmann <moltmann@google.com>
Tue, 20 Jun 2017 00:01:57 +0000 (17:01 -0700)
committerPhilip P. Moltmann <moltmann@google.com>
Tue, 20 Jun 2017 17:08:21 +0000 (10:08 -0700)
View's are restored based on their id. The autofill id is part of the
id's state. Unfortunately the ids of the view are not neccessary
unique. In this case two views would store state of for the same id.
Also two views would be restored frome the same state. This causes
duplicate autofill ids which is not allowed. Hence make sure that for a
single state, the autofill id is only restored once.

Change-Id: I8d950486cb21d9f6afe6d0f5f668799305ae73e7
Fixes: 62658714
Test: cts-tradefed run cts-dev -m CtsAutoFillServiceTestCases

core/java/android/view/View.java

index c329db4..3712776 100644 (file)
@@ -17682,6 +17682,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                 setAutofilled(baseState.mIsAutofilled);
             }
             if ((baseState.mSavedData & BaseSavedState.AUTOFILL_ID) != 0) {
+                // It can happen that views have the same view id and the restoration path will not
+                // be able to distinguish between them. The autofill id needs to be unique though.
+                // Hence prevent the same autofill view id from being restored multiple times.
+                ((BaseSavedState) state).mSavedData &= ~BaseSavedState.AUTOFILL_ID;
+
                 mAutofillViewId = baseState.mAutofillViewId;
             }
         }