From bd4ab0384061ef64a64a1ed3e2dae8667c7743de Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Mon, 31 Oct 2022 10:56:36 +0800 Subject: [PATCH] Fixes NPE crash when VRI#setView fail before input stage was create. Also catch RuntimeException for addToDisplayAsUser in case the throwing type was not RemoteException. Bug: 253200800 Bug: 263078961 Test: Simulate to throw a runtime exception in WMS#addWindow, and verify VRI#setView should catch that exception, and clear resources without crash. Change-Id: Ia113b836e4a18c656093f9db7f63e9c50c427e6c Merged-In: Ia113b836e4a18c656093f9db7f63e9c50c427e6c (cherry picked from commit f1a574074ac81906be3a2a500aae96f8da330733) --- core/java/android/view/ViewRootImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 6f4a63ca0fd72..8d52d001da2e9 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -1274,7 +1274,7 @@ public final class ViewRootImpl implements ViewParent, mTmpFrames.attachedFrame = attachedFrame; mTmpFrames.compatScale = compatScale[0]; mInvCompatScale = 1f / compatScale[0]; - } catch (RemoteException e) { + } catch (RemoteException | RuntimeException e) { mAdded = false; mView = null; mAttachInfo.mRootView = null;