Use WindowBounds#insets instead of WindowInsets in DeviceProfile
This reports more consistently and is cheaper.
Test: Log windowBounds.insets.bottom vs windowInsets.getSystemWindowInsetBottom() and note that the former is correct after fold/unfold even though the latter starts reporting 0
Bug: 196874770
Change-Id: I41eb0ab51d3761a988e680cd6d61e40bcacf567f
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index eb058e8..9fb8167 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -17,7 +17,6 @@
package com.android.launcher3;
import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE;
-import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static com.android.launcher3.ResourceUtils.pxFromDp;
import static com.android.launcher3.Utilities.dpiFromPx;
@@ -33,11 +32,8 @@
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
-import android.hardware.display.DisplayManager;
import android.util.DisplayMetrics;
import android.view.Surface;
-import android.view.WindowInsets;
-import android.view.WindowManager;
import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.DevicePaddings.DevicePadding;
@@ -267,13 +263,7 @@
// Taskbar will be added later, but provides bottom insets that we should subtract
// from availableHeightPx.
taskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_size);
- WindowInsets windowInsets =
- context.createWindowContext(
- context.getSystemService(DisplayManager.class).getDisplay(mInfo.id),
- TYPE_APPLICATION, null)
- .getSystemService(WindowManager.class)
- .getCurrentWindowMetrics().getWindowInsets();
- nonOverlappingTaskbarInset = taskbarSize - windowInsets.getSystemWindowInsetBottom();
+ nonOverlappingTaskbarInset = taskbarSize - windowBounds.insets.bottom;
if (nonOverlappingTaskbarInset > 0) {
nonFinalAvailableHeightPx -= nonOverlappingTaskbarInset;
}