Use normalized CachedDisplayInfo as key

- For system Launcher, migrate to use getPossibleMaximumWindowMetrics instead of getDisplays
- Removed usage of displayId
- In estimateInternalDisplayBounds, use CachedDisplayInfo directly as a key
- When cache retunrs null for the current display (e.g. the 3P launcher case), invalidate the cache and estimate again, and only add to supportedBounds if current display is not found in the new cache

Bug: 227459045
Bug: 198965093
Test: manual
Change-Id: Ibcc05ba483ed31a40d16e3cf49c3f3d43af68cf6
This commit is contained in:
Alex Chau committed 2022-06-09 11:36:47 +01:00
1 parent d3a7d37a57
commit 661f02de18
9 files changed
+159 -177

No files matched your search

@@ -19,7 +19,6 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.Display;
import android.view.WindowInsets;
import com.android.launcher3.deviceemulator.models.DeviceEmulationData;
@@ -32,16 +31,11 @@ public class TestWindowManagerProxy extends WindowManagerProxy {
private final DeviceEmulationData mDevice;
public TestWindowManagerProxy(Context context, DeviceEmulationData device) {
public TestWindowManagerProxy(DeviceEmulationData device) {
super(true);
mDevice = device;
}
@Override
public boolean isInternalDisplay(Display display) {
return display.getDisplayId() == Display.DEFAULT_DISPLAY;
}
@Override
protected int getDimenByName(Resources res, String resName) {
Integer mock = mDevice.resourceOverrides.get(resName);
@@ -54,27 +48,25 @@ public class TestWindowManagerProxy extends WindowManagerProxy {
}
@Override
public CachedDisplayInfo getDisplayInfo(Context context, Display display) {
int rotation = display.getRotation();
public CachedDisplayInfo getDisplayInfo(Context displayInfoContext) {
int rotation = getRotation(displayInfoContext);
Point size = new Point(mDevice.width, mDevice.height);
RotationUtils.rotateSize(size, rotation);
Rect cutout = new Rect(mDevice.cutout);
RotationUtils.rotateRect(cutout, rotation);
return new CachedDisplayInfo(getDisplayId(display), size, rotation, cutout);
return new CachedDisplayInfo(size, rotation, cutout);
}
@Override
public WindowBounds getRealBounds(Context windowContext, Display display,
CachedDisplayInfo info) {
return estimateInternalDisplayBounds(windowContext)
.get(getDisplayId(display)).second[display.getRotation()];
public WindowBounds getRealBounds(Context displayInfoContext, CachedDisplayInfo info) {
return estimateInternalDisplayBounds(displayInfoContext).get(
getDisplayInfo(displayInfoContext))[getDisplay(displayInfoContext).getRotation()];
}
@Override
public WindowInsets normalizeWindowInsets(Context context, WindowInsets oldInsets,
Rect outInsets) {
outInsets.set(getRealBounds(context, context.getDisplay(),
getDisplayInfo(context, context.getDisplay())).insets);
outInsets.set(getRealBounds(context, getDisplayInfo(context)).insets);
return oldInsets;
}
}