From f5ce2f624db11b7d2153301ff387732ff43e95f4 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Mon, 16 Aug 2021 15:21:11 -0700 Subject: [PATCH] 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 --- src/com/android/launcher3/DeviceProfile.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index eb058e8df4..9fb8167e3d 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.Path; 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 @@ public class DeviceProfile { // 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; }