diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index ebc5cde391670c..1e0519aa8ce446 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -854,20 +854,6 @@ public void onGlobalLayout() { checkForDeviceDimensionsChanges(); } - private @Nullable WindowManager.LayoutParams getWindowLayoutParams() { - View view = ReactRootView.this; - if (view.getLayoutParams() instanceof WindowManager.LayoutParams) { - return (WindowManager.LayoutParams) view.getLayoutParams(); - } - while (view.getParent() instanceof View) { - view = (View) view.getParent(); - if (view.getLayoutParams() instanceof WindowManager.LayoutParams) { - return (WindowManager.LayoutParams) view.getLayoutParams(); - } - } - return null; - } - @RequiresApi(api = Build.VERSION_CODES.R) private void checkForKeyboardEvents() { getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea); @@ -885,13 +871,10 @@ private void checkForKeyboardEvents() { Insets barInsets = rootInsets.getInsets(WindowInsets.Type.systemBars()); int height = imeInsets.bottom - barInsets.bottom; - int softInputMode; - WindowManager.LayoutParams windowLayoutParams = getWindowLayoutParams(); - if (windowLayoutParams != null) { - softInputMode = windowLayoutParams.softInputMode; - } else { - return; - } + ViewGroup.LayoutParams rootLayoutParams = getRootView().getLayoutParams(); + Assertions.assertCondition(rootLayoutParams instanceof WindowManager.LayoutParams); + + int softInputMode = ((WindowManager.LayoutParams) rootLayoutParams).softInputMode; int screenY = softInputMode == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING ? mVisibleViewArea.bottom - height