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

This commit is contained in:
TreeHugger Robot
2019-02-25 23:16:16 +00:00
committed by Android (Google) Code Review

View File

@@ -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;
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 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");