Merge "Add try-catch for the augmented autofill UI to avoid crashing" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-06-18 16:36:10 +00:00
committed by Android (Google) Code Review

View File

@@ -208,12 +208,18 @@ public final class FillWindow implements AutoCloseable {
if (sDebug) Log.d(TAG, "handleShow()"); if (sDebug) Log.d(TAG, "handleShow()");
synchronized (mLock) { synchronized (mLock) {
if (mWm != null && mFillView != null) { if (mWm != null && mFillView != null) {
p.flags |= WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; try {
if (!mShowing) { p.flags |= WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
mWm.addView(mFillView, p); if (!mShowing) {
mShowing = true; mWm.addView(mFillView, p);
} else { mShowing = true;
mWm.updateViewLayout(mFillView, p); } else {
mWm.updateViewLayout(mFillView, p);
}
} catch (WindowManager.BadTokenException e) {
if (sDebug) Log.d(TAG, "Filed with token " + p.token + " gone.");
} catch (IllegalStateException e) {
if (sDebug) Log.d(TAG, "Exception showing window.");
} }
} }
} }
@@ -223,8 +229,12 @@ public final class FillWindow implements AutoCloseable {
if (sDebug) Log.d(TAG, "handleHide()"); if (sDebug) Log.d(TAG, "handleHide()");
synchronized (mLock) { synchronized (mLock) {
if (mWm != null && mFillView != null && mShowing) { if (mWm != null && mFillView != null && mShowing) {
mWm.removeView(mFillView); try {
mShowing = false; mWm.removeView(mFillView);
mShowing = false;
} catch (IllegalStateException e) {
if (sDebug) Log.d(TAG, "Exception hiding window.");
}
} }
} }
} }