Merge "Catch WindowManager exceptions so they don't crash the system." into oc-dev

am: 301fc823f3

Change-Id: Ib28ae2a7b3614fa73fa4e1b08e5607f7d6011891
This commit is contained in:
Felipe Leme
2017-06-06 23:44:42 +00:00
committed by android-build-merger

View File

@@ -398,6 +398,12 @@ final class FillUi {
} catch (WindowManager.BadTokenException e) { } catch (WindowManager.BadTokenException e) {
if (sDebug) Slog.d(TAG, "Filed with with token " + params.token + " gone."); if (sDebug) Slog.d(TAG, "Filed with with token " + params.token + " gone.");
mCallback.onDestroy(); mCallback.onDestroy();
} catch (IllegalStateException e) {
// WM throws an ISE if mContentView was added twice; this should never happen -
// since show() and hide() are always called in the UIThread - but when it does,
// it should not crash the system.
Slog.e(TAG, "Exception showing window " + params, e);
mCallback.onDestroy();
} }
} }
@@ -405,10 +411,18 @@ final class FillUi {
* Hides the window. * Hides the window.
*/ */
void hide() { void hide() {
if (mShowing) { try {
mContentView.setOnTouchListener(null); if (mShowing) {
mWm.removeView(mContentView); mContentView.setOnTouchListener(null);
mShowing = false; mWm.removeView(mContentView);
mShowing = false;
}
} catch (IllegalStateException e) {
// WM might thrown an ISE when removing the mContentView; this should never
// happen - since show() and hide() are always called in the UIThread - but if it
// does, it should not crash the system.
Slog.e(TAG, "Exception hiding window ", e);
mCallback.onDestroy();
} }
} }