As it turned out, my application just needed 2 additional lines:
EdgeToEdge.enable(this); in onCreate
and <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item> in the application theme.
With these lines the cutout calculation works correctly.