From 787dcec13513001a3eecd2bf7d746af2cf2ae525 Mon Sep 17 00:00:00 2001 From: Will Osborn Date: Fri, 21 Feb 2025 17:01:26 +0000 Subject: [PATCH] DeviceProfile refactoring for connected displays Test: locally tested on Tangor Flag: com.android.launcher3.enable_overview_on_connected_displays Bug: 392858637 Change-Id: I0f45710eb60c7ea3359153c7961461532fec8e97 --- .../android/quickstep/AbsSwipeUpHandler.java | 5 ++-- .../fallback/window/RecentsWindowContext.kt | 4 +-- .../quickstep/util/RecentsOrientedState.java | 30 ++++++++++++------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 0566f09104..7574c7f51d 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -413,7 +413,7 @@ public abstract class AbsSwipeUpHandler< mMSDLPlayerWrapper = msdlPlayerWrapper; initTransitionEndpoints(mRemoteTargetHandles[0].getTaskViewSimulator() - .getOrientationState().getLauncherDeviceProfile()); + .getOrientationState().getLauncherDeviceProfile(gestureState.getDisplayId())); initStateCallbacks(); mIsTransientTaskbar = mDp.isTaskbarPresent @@ -991,7 +991,8 @@ public abstract class AbsSwipeUpHandler< // both split and non-split RecentsOrientedState orientationState = mRemoteTargetHandles[0].getTaskViewSimulator() .getOrientationState(); - DeviceProfile dp = orientationState.getLauncherDeviceProfile(); + DeviceProfile dp = orientationState.getLauncherDeviceProfile( + mGestureState.getDisplayId()); if (targets.minimizedHomeBounds != null && primaryTaskTarget != null) { Rect overviewStackBounds = mContainerInterface .getOverviewWindowBounds(targets.minimizedHomeBounds, primaryTaskTarget); diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowContext.kt b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowContext.kt index d70d7eb094..333571c234 100644 --- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowContext.kt +++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowContext.kt @@ -18,7 +18,7 @@ package com.android.quickstep.fallback.window import android.content.Context import android.graphics.PixelFormat -import android.view.Display +import android.view.Display.DEFAULT_DISPLAY import android.view.ViewGroup import android.view.WindowManager import android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS @@ -53,7 +53,7 @@ abstract class RecentsWindowContext(windowContext: Context, wallpaperColorHints: fun initDeviceProfile() { deviceProfile = - if (displayId == Display.DEFAULT_DISPLAY) + if (displayId == DEFAULT_DISPLAY) InvariantDeviceProfile.INSTANCE[this].getDeviceProfile(this) else InvariantDeviceProfile.INSTANCE[this].createDeviceProfileForSecondaryDisplay(this) } diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java index a5be89af19..8954d80822 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java @@ -22,6 +22,7 @@ import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; +import static com.android.launcher3.Flags.enableOverviewOnConnectedDisplays; import static com.android.launcher3.LauncherPrefs.ALLOW_ROTATION; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.SettingsCache.ROTATION_SETTING_URI; @@ -53,6 +54,7 @@ import com.android.launcher3.util.SettingsCache; import com.android.quickstep.BaseContainerInterface; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TaskAnimationManager; +import com.android.quickstep.fallback.window.RecentsDisplayModel; import com.android.quickstep.orientation.RecentsPagedOrientationHandler; import java.lang.annotation.Retention; @@ -571,19 +573,25 @@ public class RecentsOrientedState implements LauncherPrefChangeListener { /** * Returns the device profile based on expected launcher rotation */ - public DeviceProfile getLauncherDeviceProfile() { - InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(mContext); - Point currentSize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize; - - int width, height; - if ((mRecentsActivityRotation == ROTATION_90 || mRecentsActivityRotation == ROTATION_270)) { - width = Math.max(currentSize.x, currentSize.y); - height = Math.min(currentSize.x, currentSize.y); + public DeviceProfile getLauncherDeviceProfile(int displayId) { + if (enableOverviewOnConnectedDisplays()) { + return RecentsDisplayModel.getINSTANCE().get(mContext).getRecentsWindowManager( + displayId).getDeviceProfile(); } else { - width = Math.min(currentSize.x, currentSize.y); - height = Math.max(currentSize.x, currentSize.y); + InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(mContext); + Point currentSize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize; + + int width, height; + if ((mRecentsActivityRotation == ROTATION_90 + || mRecentsActivityRotation == ROTATION_270)) { + width = Math.max(currentSize.x, currentSize.y); + height = Math.min(currentSize.x, currentSize.y); + } else { + width = Math.min(currentSize.x, currentSize.y); + height = Math.max(currentSize.x, currentSize.y); + } + return idp.getBestMatch(width, height, mRecentsActivityRotation); } - return idp.getBestMatch(width, height, mRecentsActivityRotation); } private static String nameAndAddress(Object obj) {