From bc9b08fdd10af050e204988ab2b4b4426ca7d530 Mon Sep 17 00:00:00 2001 From: Shikha Malhotra Date: Fri, 29 Apr 2022 16:54:54 +0000 Subject: [PATCH 1/4] [Cherry pick merge conflict] Updating visibility of some members for easier extensibility This change is causing a merge conflict with ag/19441591. Hopefully only a cherrypick is needed. Bug: b/218186980 Test: Manual Testing that Launcher3 compiles and works Change-Id: Id85486ef763ce9a04b83fef44542b2eb3e0e599d (cherry picked from commit c487e1b4c549eac179f3dd0956a58beb4b1de5c4) --- src/com/android/launcher3/Workspace.java | 69 +++++++++++++----------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index ffb72b3732..e025790ca2 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -169,7 +169,7 @@ public class Workspace extends PagedView /** * CellInfo for the cell that is currently being dragged */ - private CellLayout.CellInfo mDragInfo; + protected CellLayout.CellInfo mDragInfo; /** * Target drop area calculated during last acceptDrop call. @@ -214,7 +214,7 @@ public class Workspace extends PagedView private boolean mUnlockWallpaperFromDefaultPageOnLayout; public static final int REORDER_TIMEOUT = 650; - private final Alarm mReorderAlarm = new Alarm(); + protected final Alarm mReorderAlarm = new Alarm(); private PreviewBackground mFolderCreateBg; private FolderIcon mDragOverFolderIcon = null; private boolean mCreateUserFolderOnDrop = false; @@ -242,7 +242,7 @@ public class Workspace extends PagedView private static final int DRAG_MODE_CREATE_FOLDER = 1; private static final int DRAG_MODE_ADD_TO_FOLDER = 2; private static final int DRAG_MODE_REORDER = 3; - private int mDragMode = DRAG_MODE_NONE; + protected int mDragMode = DRAG_MODE_NONE; @Thunk int mLastReorderX = -1; @Thunk int mLastReorderY = -1; @@ -1980,10 +1980,10 @@ public class Workspace extends PagedView // If the item being dropped is a shortcut and the nearest drop // cell also contains a shortcut, then create a folder with the two shortcuts. - if (createUserFolderIfNecessary(cell, container, - dropTargetLayout, mTargetCell, distance, false, d) + if (createUserFolderIfNecessary(cell, container, dropTargetLayout, mTargetCell, + distance, false, d) || addToExistingFolderIfNecessary(cell, dropTargetLayout, mTargetCell, - distance, d, false)) { + distance, d, false)) { mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY); return; } @@ -2012,8 +2012,8 @@ public class Workspace extends PagedView mTargetCell[0] = mTargetCell[1] = -1; } else { mTargetCell = dropTargetLayout.performReorder((int) mDragViewVisualCenter[0], - (int) mDragViewVisualCenter[1], minSpanX, minSpanY, spanX, spanY, cell, - mTargetCell, resultSpan, CellLayout.MODE_ON_DROP); + (int) mDragViewVisualCenter[1], minSpanX, minSpanY, spanX, spanY, + cell, mTargetCell, resultSpan, CellLayout.MODE_ON_DROP); } boolean foundCell = mTargetCell[0] >= 0 && mTargetCell[1] >= 0; @@ -2297,7 +2297,7 @@ public class Workspace extends PagedView } } - private void cleanupFolderCreation() { + protected void cleanupFolderCreation() { if (mFolderCreateBg != null) { mFolderCreateBg.animateToRest(); } @@ -2310,7 +2310,7 @@ public class Workspace extends PagedView } } - private void cleanupReorder(boolean cancelAlarm) { + protected void cleanupReorder(boolean cancelAlarm) { // Any pending reorders are canceled if (cancelAlarm) { mReorderAlarm.cancelAlarm(); @@ -2402,26 +2402,7 @@ public class Workspace extends PagedView mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], item.spanX, item.spanY, child, mTargetCell); - if (!nearestDropOccupied) { - mDragTargetLayout.visualizeDropLocation(mTargetCell[0], mTargetCell[1], - item.spanX, item.spanY, d); - } else if ((mDragMode == DRAG_MODE_NONE || mDragMode == DRAG_MODE_REORDER) - && !mReorderAlarm.alarmPending() - && (mLastReorderX != reorderX || mLastReorderY != reorderY) - && targetCellDistance < mDragTargetLayout.getReorderRadius(mTargetCell)) { - - int[] resultSpan = new int[2]; - mDragTargetLayout.performReorder((int) mDragViewVisualCenter[0], - (int) mDragViewVisualCenter[1], minSpanX, minSpanY, item.spanX, item.spanY, - child, mTargetCell, resultSpan, CellLayout.MODE_SHOW_REORDER_HINT); - - // Otherwise, if we aren't adding to or creating a folder and there's no pending - // reorder, then we schedule a reorder - ReorderAlarmListener listener = new ReorderAlarmListener(mDragViewVisualCenter, - minSpanX, minSpanY, item.spanX, item.spanY, d, child); - mReorderAlarm.setOnAlarmListener(listener); - mReorderAlarm.setAlarm(REORDER_TIMEOUT); - } + manageReorderOnDragOver(d, targetCellDistance, nearestDropOccupied, minSpanX, minSpanY); if (mDragMode == DRAG_MODE_CREATE_FOLDER || mDragMode == DRAG_MODE_ADD_TO_FOLDER || !nearestDropOccupied) { @@ -2432,6 +2413,34 @@ public class Workspace extends PagedView } } + protected void manageReorderOnDragOver(DragObject d, float targetCellDistance, + boolean nearestDropOccupied, int minSpanX, int minSpanY) { + + ItemInfo item = d.dragInfo; + final View child = (mDragInfo == null) ? null : mDragInfo.cell; + int reorderX = mTargetCell[0]; + int reorderY = mTargetCell[1]; + if (!nearestDropOccupied) { + mDragTargetLayout.visualizeDropLocation(mTargetCell[0], mTargetCell[1], + item.spanX, item.spanY, d); + } else if ((mDragMode == DRAG_MODE_NONE || mDragMode == DRAG_MODE_REORDER) + && !mReorderAlarm.alarmPending() + && (mLastReorderX != reorderX || mLastReorderY != reorderY) + && targetCellDistance < mDragTargetLayout.getReorderRadius(mTargetCell)) { + + int[] resultSpan = new int[2]; + mDragTargetLayout.performReorder((int) mDragViewVisualCenter[0], + (int) mDragViewVisualCenter[1], minSpanX, minSpanY, item.spanX, item.spanY, + child, mTargetCell, resultSpan, CellLayout.MODE_SHOW_REORDER_HINT); + + // Otherwise, if we aren't adding to or creating a folder and there's no pending + // reorder, then we schedule a reorder + ReorderAlarmListener listener = new ReorderAlarmListener(mDragViewVisualCenter, + minSpanX, minSpanY, item.spanX, item.spanY, d, child); + mReorderAlarm.setOnAlarmListener(listener); + mReorderAlarm.setAlarm(REORDER_TIMEOUT); + } + } /** * Updates {@link #mDragTargetLayout} and {@link #mDragOverlappingLayout} * based on the DragObject's position. From 282cf0867f1728d305ece77ec74b83a33d6884a9 Mon Sep 17 00:00:00 2001 From: Iris Yang Date: Wed, 15 Jun 2022 21:19:51 +0800 Subject: [PATCH 2/4] Keep the default display's top running task in the top of running list While we move a task to virtual display, we will receive onTaskMovedToFront() callback to add the task(on virtual display) into the running list. It cause the first item of Recents is virtual display's task but the thumbnail view is showing default display's task snapshot. This change is to keep default display's top task in the first while adding a virtual display's task into the running task list. Fix: 235797788 Test: 1.Launch app1 on default display, launch app2 on virtual display, enter Recents, observed the recent animation and overview is showing app1. 2.Launch app1 on default display, swipe app1 to home, launch app2 on virtual display, enter Recents, observed the overview is showing app2. https://drive.google.com/file/d/1XkGNupJknmFKqjE3c97s6ieCKN5v-n_z/view?resourcekey=0-NLDIaK2EV2tG2ItccUdxDw Change-Id: Ibb740986782eadf02672081cbd716fed04be6468 --- .../com/android/quickstep/TopTaskTracker.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/TopTaskTracker.java b/quickstep/src/com/android/quickstep/TopTaskTracker.java index 42fa86d970..cfcba4c30e 100644 --- a/quickstep/src/com/android/quickstep/TopTaskTracker.java +++ b/quickstep/src/com/android/quickstep/TopTaskTracker.java @@ -20,6 +20,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.content.Intent.ACTION_CHOOSER; import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; +import static android.view.Display.DEFAULT_DISPLAY; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT; @@ -31,9 +32,9 @@ import androidx.annotation.UiThread; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.SplitConfigurationOptions; +import com.android.launcher3.util.SplitConfigurationOptions.SplitStageInfo; import com.android.launcher3.util.SplitConfigurationOptions.StagePosition; import com.android.launcher3.util.SplitConfigurationOptions.StageType; -import com.android.launcher3.util.SplitConfigurationOptions.SplitStageInfo; import com.android.launcher3.util.TraceHelper; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.Task.TaskKey; @@ -85,6 +86,19 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta public void onTaskMovedToFront(RunningTaskInfo taskInfo) { mOrderedTaskList.removeIf(rto -> rto.taskId == taskInfo.taskId); mOrderedTaskList.addFirst(taskInfo); + + // Keep the home display's top running task in the first while adding a non-home + // display's task to the list, to avoid showing non-home display's task upon going to + // Recents animation. + if (taskInfo.displayId != DEFAULT_DISPLAY) { + final RunningTaskInfo topTaskOnHomeDisplay = mOrderedTaskList.stream() + .filter(rto -> rto.displayId == DEFAULT_DISPLAY).findFirst().orElse(null); + if (topTaskOnHomeDisplay != null) { + mOrderedTaskList.removeIf(rto -> rto.taskId == topTaskOnHomeDisplay.taskId); + mOrderedTaskList.addFirst(topTaskOnHomeDisplay); + } + } + if (mOrderedTaskList.size() >= HISTORY_SIZE) { // If we grow in size, remove the last taskInfo which is not part of the split task. Iterator itr = mOrderedTaskList.descendingIterator(); From 24df4bffd814500e4855266f1f80f156aebaf826 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 29 Jul 2022 00:01:17 +0000 Subject: [PATCH 3/4] Revert "Add testSplitFromOverview test (for phones)" This reverts commit 1780cee0fe8d3133b9a4c217b46bf238452178a0. Reason for revert: b/240517487 Change-Id: Id0b690ebba880dd9c978ed42c0f965beb2678b8c --- .../android/quickstep/TaplTestsQuickstep.java | 15 ------ .../android/launcher3/tapl/BaseOverview.java | 6 +-- .../tapl/LauncherInstrumentation.java | 17 +----- .../android/launcher3/tapl/OverviewTask.java | 17 ------ .../launcher3/tapl/OverviewTaskMenu.java | 52 ------------------- .../launcher3/tapl/SplitScreenSelect.java | 6 --- 6 files changed, 2 insertions(+), 111 deletions(-) delete mode 100644 tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index b52ab9b341..81df3c0f1a 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -179,21 +179,6 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { actionsView.clickAndDismissScreenshot(); } - @Test - @PortraitLandscape - public void testSplitFromOverview() { - assumeTrue(!mLauncher.isTablet()); - - startTestActivity(2); - startTestActivity(3); - - mLauncher.goHome().switchToOverview().getCurrentTask() - .tapMenu() - .tapSplitMenuItem() - .getTestActivityTask(2) - .open(); - } - @Test @PortraitLandscape public void testSplitFromOverviewForTablet() { diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java index 3321c63502..6a11336bb9 100644 --- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java +++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java @@ -247,12 +247,8 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { return mLauncher.hasLauncherObject(mLauncher.getOverviewObjectSelector("clear_all")); } - protected boolean isActionsViewVisible() { - return true; - } - private void verifyActionsViewVisibility() { - if (!hasTasks() || !isActionsViewVisible()) { + if (!hasTasks()) { return; } try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 3de49e65a5..5f920972ca 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -169,7 +169,6 @@ public final class LauncherInstrumentation { private static final String WIDGETS_RES_ID = "primary_widgets_list_view"; private static final String CONTEXT_MENU_RES_ID = "popup_container"; private static final String TASKBAR_RES_ID = "taskbar_view"; - private static final String SPLIT_PLACEHOLDER_RES_ID = "split_placeholder"; public static final int WAIT_TIME_MS = 30000; private static final String SYSTEMUI_PACKAGE = "com.android.systemui"; private static final String ANDROID_PACKAGE = "android"; @@ -725,7 +724,6 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); return waitForLauncherObject(WORKSPACE_RES_ID); } @@ -734,7 +732,6 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(APPS_RES_ID); waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); return waitForLauncherObject(WIDGETS_RES_ID); } @@ -744,26 +741,16 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); return waitForLauncherObject(APPS_RES_ID); } - case OVERVIEW: { - waitUntilLauncherObjectGone(APPS_RES_ID); - waitUntilLauncherObjectGone(WORKSPACE_RES_ID); - waitUntilLauncherObjectGone(WIDGETS_RES_ID); - waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); - - return waitForLauncherObject(OVERVIEW_RES_ID); - } + case OVERVIEW: case SPLIT_SCREEN_SELECT: { waitUntilLauncherObjectGone(APPS_RES_ID); waitUntilLauncherObjectGone(WORKSPACE_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitForLauncherObject(SPLIT_PLACEHOLDER_RES_ID); return waitForLauncherObject(OVERVIEW_RES_ID); } case FALLBACK_OVERVIEW: { @@ -771,7 +758,6 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(WORKSPACE_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); return waitForFallbackLauncherObject(OVERVIEW_RES_ID); } @@ -780,7 +766,6 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(APPS_RES_ID); waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); if (isTablet() && !isFallbackOverview()) { waitForLauncherObject(TASKBAR_RES_ID); diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java index a90d4ea3c0..ac7424ef26 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java @@ -20,7 +20,6 @@ import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CH import android.graphics.Rect; -import androidx.annotation.NonNull; import androidx.test.uiautomator.By; import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.UiObject2; @@ -160,20 +159,4 @@ public final class OverviewTask { } } } - - /** Taps the task menu. */ - @NonNull - public OverviewTaskMenu tapMenu() { - try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); - LauncherInstrumentation.Closable c = mLauncher.addContextLayer( - "want to tap the task menu")) { - mLauncher.clickLauncherObject( - mLauncher.waitForObjectInContainer(mTask.getParent(), "icon")); - - try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( - "tapped the task menu")) { - return new OverviewTaskMenu(mLauncher); - } - } - } } diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java b/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java deleted file mode 100644 index 8cdc8a036e..0000000000 --- a/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.launcher3.tapl; - -import androidx.annotation.NonNull; -import androidx.test.uiautomator.By; -import androidx.test.uiautomator.UiObject2; - -/** Represents the menu of an overview task. */ -public class OverviewTaskMenu { - - private final LauncherInstrumentation mLauncher; - private final UiObject2 mMenu; - - OverviewTaskMenu(LauncherInstrumentation launcher) { - mLauncher = launcher; - - mMenu = mLauncher.waitForLauncherObject("menu_option_layout"); - mLauncher.assertTrue("The overview task menus is not visible", - !mMenu.getVisibleBounds().isEmpty()); - } - - /** Taps the split menu item from the overview task menu. */ - @NonNull - public SplitScreenSelect tapSplitMenuItem() { - try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); - LauncherInstrumentation.Closable c = mLauncher.addContextLayer( - "tap split menu item")) { - mLauncher.clickLauncherObject( - mLauncher.findObjectInContainer(mMenu, By.textStartsWith("Split"))); - - try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( - "tapped split menu item")) { - return new SplitScreenSelect(mLauncher); - } - } - } -} diff --git a/tests/tapl/com/android/launcher3/tapl/SplitScreenSelect.java b/tests/tapl/com/android/launcher3/tapl/SplitScreenSelect.java index 9fa74e48c2..3cf3ed662f 100644 --- a/tests/tapl/com/android/launcher3/tapl/SplitScreenSelect.java +++ b/tests/tapl/com/android/launcher3/tapl/SplitScreenSelect.java @@ -32,10 +32,4 @@ public class SplitScreenSelect extends Overview { protected ContainerType getContainerType() { return ContainerType.SPLIT_SCREEN_SELECT; } - - @Override - protected boolean isActionsViewVisible() { - // We don't show overview actions in split select state. - return false; - } } From 6209af67d372f84b158afd4c87eef8a1195b3893 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Wed, 27 Jul 2022 14:08:23 +0100 Subject: [PATCH 4/4] Listen to DisplayController for ignoreAutoRotateSettings - Also skip most of initDeviceProfile/onIdpChanged if DeviceProfile didn't actually change to effectively skip the 2nd unexpected onConfigurationChangeded caused by setRequestedOrientation (b/211763738) Test: Change display size while in app or at home screen Fix: 240019605 Change-Id: If307742639bd269622140a7da0dc900887c67937 --- src/com/android/launcher3/Launcher.java | 18 +++++++++++++++--- .../launcher3/states/RotationHelper.java | 16 ++++++++++------ .../launcher3/util/DisplayController.java | 6 +++--- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 9c622512a4..d2fe8bd7ea 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -636,7 +636,10 @@ public class Launcher extends StatefulActivity @Override public void onIdpChanged(boolean modelPropertiesChanged) { - initDeviceProfile(mDeviceProfile.inv); + if (!initDeviceProfile(mDeviceProfile.inv)) { + return; + } + dispatchDeviceProfileChanged(); reapplyUi(); mDragLayer.recreateControllers(); @@ -659,9 +662,17 @@ public class Launcher extends StatefulActivity mDragLayer.onOneHandedModeStateChanged(activated); } - protected void initDeviceProfile(InvariantDeviceProfile idp) { + /** + * Returns {@code true} if a new DeviceProfile is initialized, and {@code false} otherwise. + */ + protected boolean initDeviceProfile(InvariantDeviceProfile idp) { // Load configuration-specific DeviceProfile - mDeviceProfile = idp.getDeviceProfile(this); + DeviceProfile deviceProfile = idp.getDeviceProfile(this); + if (mDeviceProfile == deviceProfile) { + return false; + } + + mDeviceProfile = deviceProfile; if (isInMultiWindowMode()) { mDeviceProfile = mDeviceProfile.getMultiWindowProfile( this, getMultiWindowDisplaySize()); @@ -669,6 +680,7 @@ public class Launcher extends StatefulActivity onDeviceProfileInitiated(); mModelWriter = mModel.getWriter(getDeviceProfile().isVerticalBarLayout(), true, this); + return true; } public RotationHelper getRotationHelper() { diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java index 38b62d466e..fd8b2e5744 100644 --- a/src/com/android/launcher3/states/RotationHelper.java +++ b/src/com/android/launcher3/states/RotationHelper.java @@ -23,19 +23,21 @@ import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE; import static com.android.launcher3.Utilities.dpiFromPx; import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH; +import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; +import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.UiThreadHelper; /** * Utility class to manage launcher rotation */ public class RotationHelper implements OnSharedPreferenceChangeListener, - DeviceProfile.OnDeviceProfileChangeListener { + DisplayController.DisplayInfoChangeListener { private static final String TAG = "RotationHelper"; @@ -119,8 +121,8 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, } @Override - public void onDeviceProfileChanged(DeviceProfile dp) { - boolean ignoreAutoRotateSettings = dp.isTablet; + public void onDisplayInfoChanged(Context context, DisplayController.Info info, int flags) { + boolean ignoreAutoRotateSettings = info.isTablet(info.realBounds); if (mIgnoreAutoRotateSettings != ignoreAutoRotateSettings) { setIgnoreAutoRotateSettings(ignoreAutoRotateSettings); notifyChange(); @@ -157,8 +159,10 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, public void initialize() { if (!mInitialized) { mInitialized = true; - setIgnoreAutoRotateSettings(mActivity.getDeviceProfile().isTablet); - mActivity.addOnDeviceProfileChangeListener(this); + DisplayController displayController = DisplayController.INSTANCE.get(mActivity); + DisplayController.Info info = displayController.getInfo(); + setIgnoreAutoRotateSettings(info.isTablet(info.realBounds)); + displayController.addChangeListener(this); notifyChange(); } } @@ -166,7 +170,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, public void destroy() { if (!mDestroyed) { mDestroyed = true; - mActivity.removeOnDeviceProfileChangeListener(this); + DisplayController.INSTANCE.get(mActivity).removeChangeListener(this); mActivity = null; if (mSharedPrefs != null) { mSharedPrefs.unregisterOnSharedPreferenceChangeListener(this); diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java index 15fe1d9205..fbc4cb669d 100644 --- a/src/com/android/launcher3/util/DisplayController.java +++ b/src/com/android/launcher3/util/DisplayController.java @@ -278,11 +278,11 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { public final float fontScale; private final int densityDpi; public final NavigationMode navigationMode; - private final PortraitSize mScreenSizeDp; + // WindowBounds + public final WindowBounds realBounds; public final Set supportedBounds = new ArraySet<>(); - private final ArrayMap mPerDisplayBounds = new ArrayMap<>(); @@ -310,7 +310,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { mPerDisplayBounds.putAll(perDisplayBoundsCache); WindowBounds[] cachedValue = mPerDisplayBounds.get(normalizedDisplayInfo); - WindowBounds realBounds = wmProxy.getRealBounds(displayInfoContext, displayInfo); + realBounds = wmProxy.getRealBounds(displayInfoContext, displayInfo); if (cachedValue == null) { // Unexpected normalizedDisplayInfo is found, recreate the cache Log.e(TAG, "Unexpected normalizedDisplayInfo found, invalidating cache");