Fix the UDFPS overlay being offset by the status bar

"lp.setFitInsetsTypes(0)" alone is not enough to get rid of the status
bar offset/inset. After numerous experiments and digging through
com.android.server.wm.DisplayPolicy#getLayoutHint I found out that this
(now deprecated) flag solves the issue:

WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR

Setting this flag forces "getLayoutHint" to fill "outDisplayCutout"
with the right "safeInsets" and "boundTop". Any other flag either
results in zero-filled "outDisplayCutout" or causes WindowManager to
crash.

FYI, here are some other things that I tried that didn't work:
mView.setFitsSystemWindows(false)
mView.makeFrameworkOptionalFitsSystemWindows()
mView.makeOptionalFitsSystemWindows()
mView.setSystemUiVisibility(View.SYSTEM_UI_LAYOUT_FLAGS)
lp.flags |= WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
lp.privateFlags += WindowManager.LayoutParams.PRIVATE_FLAG_APPEARANCE_CONTROLLED;
lp.privateFlags += WindowManager.LayoutParams.PRIVATE_FLAG_BEHAVIOR_CONTROLLED;
lp.privateFlags += WindowManager.LayoutParams.PRIVATE_FLAG_FIT_INSETS_CONTROLLED;

This CL also removes the LinearLayout root view, but it's simply a clean
up and is unrelated to the status bar offset issue. The layout was only
used to provide WindowManager.LayoutParams to UdfpsView, but it wasn't
necessary because the parameters are also provided in the "addView" call
to WindowManager.

Bug: 162909513
Test: manual on device
Change-Id: I58ea27b54e720de4d8051623e0cd56b6f7d9e196
1 file changed