diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index 54de1bb3739d7..943572f56a1b6 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -39,7 +39,6 @@ import android.util.Log; import android.util.Pair; import android.util.Property; import android.util.SparseArray; -import android.view.InputDevice.MotionRange; import android.view.InsetsSourceConsumer.ShowResult; import android.view.InsetsState.InternalInsetsType; import android.view.SurfaceControl.Transaction; @@ -855,6 +854,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } else { hideDirectly(types); } + if (mViewRoot.mView == null) { + return; + } mViewRoot.mView.dispatchWindowInsetsAnimationPrepare(animation); mViewRoot.mView.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() { @Override