Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb9c96ae authored by Feng Cao's avatar Feng Cao
Browse files

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

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

Change-Id: I87d0436e0aa2088a3272eadb26e7d69777612320
parent 05ad6df9
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ public final class FillWindow implements AutoCloseable {
    @GuardedBy("mLock")
    private Rect mBounds;

    @GuardedBy("mLock")
    private boolean mUpdateCalled;
    @GuardedBy("mLock")
    private boolean mDestroyed;

@@ -103,6 +105,7 @@ public final class FillWindow implements AutoCloseable {
        }
        // 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 @@ public final class FillWindow implements AutoCloseable {
            if (DEBUG) {
                Log.d(TAG, "Created FillWindow: params= " + smartSuggestion + " view=" + rootView);
            }
            mUpdateCalled = true;
            mDestroyed = false;
            mProxy.setFillWindow(this);
            return true;
@@ -237,8 +241,10 @@ public final class FillWindow implements AutoCloseable {
        }
        synchronized (mLock) {
            if (mDestroyed) return;
            if (mUpdateCalled) {
                hide();
                mProxy.report(AutofillProxy.REPORT_EVENT_UI_DESTROYED);
            }
            mDestroyed = true;
            mCloseGuard.close();
        }
@@ -266,6 +272,7 @@ public final class FillWindow implements AutoCloseable {
    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");