From f74f0c27bc25361c96a54d035de10006e2843b44 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 9 Jun 2020 18:07:58 -0700 Subject: [PATCH] Creating correct device profile when appContext and launcher context do not match Bug: 156891776 Change-Id: If2df3a6719de4207fa15d8a416704eb8e7c136b9 --- .../com/android/quickstep/BaseSwipeUpHandler.java | 10 ++++------ .../src/com/android/quickstep/RecentsActivity.java | 3 +-- .../android/quickstep/SwipeUpAnimationLogic.java | 6 +++--- .../quickstep/util/RecentsOrientedState.java | 14 +++++++++++++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java index b5fb31a9de..1b0afaebdf 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java @@ -32,7 +32,6 @@ import androidx.annotation.CallSuper; import androidx.annotation.UiThread; import com.android.launcher3.DeviceProfile; -import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.VibratorWrapper; @@ -96,8 +95,8 @@ public abstract class BaseSwipeUpHandler, Q extend * depend on proper class initialization. */ protected void initAfterSubclassConstructor() { - initTransitionEndpoints(InvariantDeviceProfile.INSTANCE.get(mContext) - .getDeviceProfile(mContext)); + initTransitionEndpoints( + mTaskViewSimulator.getOrientationState().getLauncherDeviceProfile()); } protected void performHapticFeedback() { @@ -205,7 +204,7 @@ public abstract class BaseSwipeUpHandler, Q extend mRecentsAnimationController = recentsAnimationController; mRecentsAnimationTargets = targets; mTransformParams.setTargetSet(mRecentsAnimationTargets); - DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(mContext).getDeviceProfile(mContext); + DeviceProfile dp = mTaskViewSimulator.getOrientationState().getLauncherDeviceProfile(); RemoteAnimationTargetCompat runningTaskTarget = targets.findTask( mGestureState.getRunningTaskId()); @@ -300,8 +299,7 @@ public abstract class BaseSwipeUpHandler, Q extend if (TestProtocol.sDebugTracing) { Log.d(TestProtocol.PAUSE_NOT_DETECTED, "BaseSwipeUpHandler.2"); } - initTransitionEndpoints(InvariantDeviceProfile.INSTANCE.get(mContext) - .getDeviceProfile(mContext)); + initTransitionEndpoints(createdActivity.getDeviceProfile()); } return true; } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsActivity.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsActivity.java index 852a51a9ce..170102047b 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsActivity.java @@ -139,13 +139,12 @@ public final class RecentsActivity extends StatefulActivity { */ protected DeviceProfile createDeviceProfile() { DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(this).getDeviceProfile(this); - DeviceProfile dp1 = InvariantDeviceProfile.INSTANCE.get(this).getDeviceProfile(this); // In case we are reusing IDP, create a copy so that we don't conflict with Launcher // activity. return (mRecentsRootView != null) && isInMultiWindowMode() ? dp.getMultiWindowProfile(this, getMultiWindowDisplaySize()) - : dp1.copy(this); + : dp.copy(this); } @Override diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/SwipeUpAnimationLogic.java index b17730ba6d..dc8f1c54c8 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/SwipeUpAnimationLogic.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/SwipeUpAnimationLogic.java @@ -83,15 +83,15 @@ public abstract class SwipeUpAnimationLogic { mGestureState = gestureState; mTaskViewSimulator = new TaskViewSimulator(context, gestureState.getActivityInterface()); mTransformParams = transformParams; + + mTaskViewSimulator.setLayoutRotation( + mDeviceState.getCurrentActiveRotation(), mDeviceState.getDisplayRotation()); } protected void initTransitionEndpoints(DeviceProfile dp) { mDp = dp; mTaskViewSimulator.setDp(dp); - mTaskViewSimulator.setLayoutRotation( - mDeviceState.getCurrentActiveRotation(), - mDeviceState.getDisplayRotation()); mTransitionDragLength = mGestureState.getActivityInterface().getSwipeUpDestinationAndLength( dp, mContext, TEMP_RECT, mTaskViewSimulator.getOrientationState().getOrientationHandler()); diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java index 7715cca60f..76ca3de5bf 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java @@ -26,8 +26,8 @@ import static android.view.Surface.ROTATION_90; import static com.android.launcher3.logging.LoggerUtils.extractObjectNameAndAddress; import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; - import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS; + import static java.lang.annotation.RetentionPolicy.SOURCE; import android.content.ContentResolver; @@ -49,6 +49,7 @@ import androidx.annotation.IntDef; import androidx.annotation.NonNull; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Utilities; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.touch.PagedOrientationHandler; @@ -524,4 +525,15 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre + " mFlags=" + mFlags + "]"; } + + /** + * Returns the device profile based on expected launcher rotation + */ + public DeviceProfile getLauncherDeviceProfile() { + InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(mContext); + // TODO also check the natural orientation is landscape or portrait + return (mLauncherRotation == ROTATION_90 || mLauncherRotation == ROTATION_270) + ? idp.landscapeProfile + : idp.portraitProfile; + } }