Fix fillwindow destory() throwing IllegalStateException if update is never called.

Fixes: 126118917
Test: atest android.autofillservice.cts.augmented.AugmentedLoginActivityTest

Change-Id: I87d0436e0aa2088a3272eadb26e7d69777612320
diff --git a/core/java/android/service/autofill/augmented/FillWindow.java b/core/java/android/service/autofill/augmented/FillWindow.java
index 6e06754..bd532a3 100644
--- a/core/java/android/service/autofill/augmented/FillWindow.java
+++ b/core/java/android/service/autofill/augmented/FillWindow.java
@@ -82,6 +82,8 @@
     private Rect mBounds;
 
     @GuardedBy("mLock")
+    private boolean mUpdateCalled;
+    @GuardedBy("mLock")
     private boolean mDestroyed;
 
     private AutofillProxy mProxy;
@@ -103,6 +105,7 @@
         }
         // TODO(b/123100712): add test case for null
         Preconditions.checkNotNull(area);
+        Preconditions.checkNotNull(area.proxy);
         Preconditions.checkNotNull(rootView);
         // TODO(b/123100712): must check the area is a valid object returned by
         // SmartSuggestionParams, throw IAE if not
@@ -149,6 +152,7 @@
             if (DEBUG) {
                 Log.d(TAG, "Created FillWindow: params= " + smartSuggestion + " view=" + rootView);
             }
+            mUpdateCalled = true;
             mDestroyed = false;
             mProxy.setFillWindow(this);
             return true;
@@ -237,8 +241,10 @@
         }
         synchronized (mLock) {
             if (mDestroyed) return;
-            hide();
-            mProxy.report(AutofillProxy.REPORT_EVENT_UI_DESTROYED);
+            if (mUpdateCalled) {
+                hide();
+                mProxy.report(AutofillProxy.REPORT_EVENT_UI_DESTROYED);
+            }
             mDestroyed = true;
             mCloseGuard.close();
         }
@@ -266,6 +272,7 @@
     public void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
         synchronized (this) {
             pw.print(prefix); pw.print("destroyed: "); pw.println(mDestroyed);
+            pw.print(prefix); pw.print("updateCalled: "); pw.println(mUpdateCalled);
             if (mFillView != null) {
                 pw.print(prefix); pw.print("fill window: ");
                 pw.println(mShowing ? "shown" : "hidden");