Prevent autofilling directly after autofilling.

Clear the WebTextView's data adapter after autofill fills
out the form. This ensures that the dropdown disappears.

Change-Id: I2fd1e8b5d249f6ff3943d0a0b5d2f2b55beac70a
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 39aebd0..063623b6 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -648,6 +648,7 @@
     static final int SAVE_WEBARCHIVE_FINISHED           = 132;
 
     static final int SET_AUTOFILLABLE                   = 133;
+    static final int AUTOFILL_COMPLETE                  = 134;
 
     private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID;
     private static final int LAST_PACKAGE_MSG_ID = SET_TOUCH_HIGHLIGHT_RECTS;
@@ -699,7 +700,8 @@
         "SELECTION_STRING_CHANGED", //       = 130;
         "SET_TOUCH_HIGHLIGHT_RECTS", //      = 131;
         "SAVE_WEBARCHIVE_FINISHED", //       = 132;
-        "SET_AUTOFILLABLE" //                = 133;
+        "SET_AUTOFILLABLE", //               = 133;
+        "AUTOFILL_COMPLETE" //               = 134;
     };
 
     // If the site doesn't use the viewport meta tag to specify the viewport,
@@ -7147,6 +7149,14 @@
                     }
                     break;
 
+                case AUTOFILL_COMPLETE:
+                    if (mWebTextView != null) {
+                        // Clear the WebTextView adapter when AutoFill finishes
+                        // so that the drop down gets cleared.
+                        mWebTextView.setAdapterCustom(null);
+                    }
+                    break;
+
                 default:
                     super.handleMessage(msg);
                     break;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index a7a839d..cc94fd0 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -1512,6 +1512,8 @@
 
                         case AUTOFILL_FORM:
                             nativeAutoFillForm(msg.arg1);
+                            mWebView.mPrivateHandler.obtainMessage(WebView.AUTOFILL_COMPLETE, null)
+                                    .sendToTarget();
                             break;
                     }
                 }