From a7d7f78c08b4a872fc505e8874bdf137d7843059 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 30 Jun 2021 11:59:08 -0700 Subject: [PATCH 01/11] Defer cleaning up screenshot until after we actually switch to screenshot - In the case where we get a screenshot on cancel, we should wait to finish the recents animation until the view gets a chance to update Bug: 185643608 Test: Swipe up to overview in 2 button, hit home Change-Id: I2ac3567006f6fa7e6f473499f6862e5e408dfc3d --- .../src/com/android/quickstep/AbsSwipeUpHandler.java | 6 +++--- quickstep/src/com/android/quickstep/GestureState.java | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 524cd53839..7727d5752f 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -383,10 +383,10 @@ public abstract class AbsSwipeUpHandler, // Set up a entire animation lifecycle callback to notify the current recents view when // the animation is canceled mGestureState.runOnceAtState(STATE_RECENTS_ANIMATION_CANCELED, () -> { - ThumbnailData snapshot = mGestureState.getRecentsAnimationCanceledSnapshot(); + ThumbnailData snapshot = mGestureState.consumeRecentsAnimationCanceledSnapshot(); if (snapshot != null) { - RecentsModel.INSTANCE.get(mContext).onTaskSnapshotChanged( - mRecentsView.getRunningTaskId(), snapshot); + mRecentsView.switchToScreenshot(snapshot, + () -> mRecentsAnimationController.cleanupScreenshot()); mRecentsView.onRecentsAnimationComplete(); } }); diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index a302a07bca..015002f0e1 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -376,11 +376,14 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL } /** - * Returns the canceled animation thumbnail data. This call only returns a value while - * STATE_RECENTS_ANIMATION_CANCELED state is being set. + * Returns and clears the canceled animation thumbnail data. This call only returns a value + * while STATE_RECENTS_ANIMATION_CANCELED state is being set, and the caller is responsible for + * calling {@link RecentsAnimationController#cleanupScreenshot()}. */ - ThumbnailData getRecentsAnimationCanceledSnapshot() { - return mRecentsAnimationCanceledSnapshot; + ThumbnailData consumeRecentsAnimationCanceledSnapshot() { + ThumbnailData data = mRecentsAnimationCanceledSnapshot; + mRecentsAnimationCanceledSnapshot = null; + return data; } void setSwipeUpStartTimeMs(long uptimeMs) { From 25f386edc82c44714f8fdd5040831e3b6c73eb0b Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 30 Jun 2021 12:19:07 -0700 Subject: [PATCH 02/11] Fixing some dimentions in AllSet activity Bug: 192412172 Test: Manual Change-Id: I599c858fc21d45dd41eaa01ff3d91863d52f6ae8 --- quickstep/res/drawable/ic_all_set.xml | 8 ++++---- quickstep/res/values/dimens.xml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/quickstep/res/drawable/ic_all_set.xml b/quickstep/res/drawable/ic_all_set.xml index 656c59669c..f718b8b64b 100644 --- a/quickstep/res/drawable/ic_all_set.xml +++ b/quickstep/res/drawable/ic_all_set.xml @@ -14,10 +14,10 @@ limitations under the License. --> + android:width="48dp" + android:height="48dp" + android:viewportWidth="24" + android:viewportHeight="24"> diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 28262a8721..1f86d62d31 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -114,8 +114,8 @@ 40dp - 28dp - 80dp + 24dp + 32dp 52dp 24dp From 17cc821c28cfa6b83a779dbcf39511e516bee91f Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 30 Jun 2021 17:09:46 -0700 Subject: [PATCH 03/11] Fix bug where app icon is gone for first frame on cold start. We need the icon to be full alpha during the init pass, then when the actual animation starts, we can swap the icon with the window (splash screen that draws the icon). Bug: 192366079 Test: slow down window animations check no empty frame on cold start app launch check no empty frame on warm start app launch Change-Id: I16a1779e5252d8e88bc3c408e1dc40b264fe4cf4 --- .../src/com/android/launcher3/QuickstepTransitionManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 6163447482..bd7a4780b1 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -725,7 +725,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener floatingIconBounds.bottom += offsetY; if (initOnly) { - floatingView.update(mIconAlpha.value, 255, floatingIconBounds, percent, 0f, + // For the init pass, we want full alpha since the window is not yet ready. + floatingView.update(1f, 255, floatingIconBounds, percent, 0f, mWindowRadius.value * scale, true /* isOpening */); return; } From 2cc33ed29adb97b2660a12b8fa31db3162a6e731 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 30 Jun 2021 17:59:17 -0700 Subject: [PATCH 04/11] Cancel existing preview item animation during non-animated update. Otherwise we end up in a bad folder icon state. Bug: 191227370 Test: Drag icon out of folder bounds, Suddenly drop it so its forced to go back to the folder Close folder before the animation finishes Change-Id: Ib751a8209d66c5e9772731fdc1d7f365ae47531a --- src/com/android/launcher3/folder/PreviewItemManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/android/launcher3/folder/PreviewItemManager.java b/src/com/android/launcher3/folder/PreviewItemManager.java index a6674fcb08..8bef6ad7ff 100644 --- a/src/com/android/launcher3/folder/PreviewItemManager.java +++ b/src/com/android/launcher3/folder/PreviewItemManager.java @@ -269,6 +269,9 @@ public class PreviewItemManager { setDrawable(p, items.get(i)); if (!animate) { + if (p.anim != null) { + p.anim.cancel(); + } computePreviewItemDrawingParams(i, numItemsInFirstPagePreview, p); if (mReferenceDrawable == null) { mReferenceDrawable = p.drawable; From 551b4297ed394afa51a19ff1746ea5c51797d533 Mon Sep 17 00:00:00 2001 From: Cyrus Boadway Date: Thu, 1 Jul 2021 12:10:53 +0000 Subject: [PATCH 05/11] Use nullable field and boolean rather than optional Optional won't hold null parameters, so use a boolean flag and colorschange fields to represent the value and whether changes are present. Bug: 190818220 Test: manual Change-Id: I794507340345864e73f04039f12a035c8053fd96 --- .../widget/LauncherAppWidgetHostView.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java index b554c212ca..63bc416fa4 100644 --- a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java @@ -57,7 +57,6 @@ import com.android.launcher3.views.BaseDragLayer.TouchCompleteListener; import com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener; import java.util.List; -import java.util.Optional; /** * {@inheritDoc} @@ -118,7 +117,8 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView private final ViewGroupFocusHelper mDragLayerRelativeCoordinateHelper; private long mDeferUpdatesUntilMillis = 0; private RemoteViews mDeferredRemoteViews; - private Optional mDeferredColorChange = Optional.empty(); + private boolean mHasDeferredColorChange = false; + private @Nullable SparseIntArray mDeferredColorChange = null; private boolean mEnableColorExtraction = true; public LauncherAppWidgetHostView(Context context) { @@ -244,18 +244,23 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView */ public void endDeferringUpdates() { RemoteViews remoteViews; - Optional deferredColors; + SparseIntArray deferredColors; + boolean hasDeferredColors; synchronized (mUpdateLock) { mDeferUpdatesUntilMillis = 0; remoteViews = mDeferredRemoteViews; mDeferredRemoteViews = null; deferredColors = mDeferredColorChange; - mDeferredColorChange = Optional.empty(); + hasDeferredColors = mHasDeferredColorChange; + mDeferredColorChange = null; + mHasDeferredColorChange = false; } if (remoteViews != null) { updateAppWidget(remoteViews); } - deferredColors.ifPresent(colors -> onColorsChanged(null /* rectF */, colors)); + if (hasDeferredColors) { + onColorsChanged(null /* rectF */, deferredColors); + } } public boolean onInterceptTouchEvent(MotionEvent ev) { @@ -437,10 +442,12 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView public void onColorsChanged(RectF rectF, SparseIntArray colors) { synchronized (mUpdateLock) { if (isDeferringUpdates()) { - mDeferredColorChange = Optional.ofNullable(colors); + mDeferredColorChange = colors; + mHasDeferredColorChange = true; return; } - mDeferredColorChange = Optional.empty(); + mDeferredColorChange = null; + mHasDeferredColorChange = false; } // setColorResources will reapply the view, which must happen in the UI thread. From e0fcee01b3e192a6c28c7f6633590edb3225edee Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 1 Jul 2021 16:34:58 +0100 Subject: [PATCH 06/11] Restore previous currentPage in applyLoadPlan in case task is re-ordered Fix: 186537288 Test: Repeatededly launch task from home and swipe to home, animation is correct Test: Quick switch, launch task then swipe up, there is no jump Change-Id: I9fd7416d9811ce4e54a1c6d20374d89d00417cd5 --- .../src/com/android/quickstep/views/RecentsView.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 710a9ab9fe..65ccb138b4 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1087,6 +1087,12 @@ public abstract class RecentsView 0) { setCurrentPage(indexOfChild(getTaskViewAt(0))); } + } else if (currentTaskId != -1) { + currentTaskView = getTaskView(currentTaskId); + if (currentTaskView != null) { + setCurrentPage(indexOfChild(currentTaskView)); + } } if (mIgnoreResetTaskId != -1 && getTaskView(mIgnoreResetTaskId) != ignoreResetTaskView) { From 99adef95b3e121a9c90f905589fa68d293425fe6 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Thu, 1 Jul 2021 10:30:59 -0700 Subject: [PATCH 07/11] Do not switch to screenshot and finish recents animation for menu options that already do so The issue is that in landscape mode we add overview shortcuts (e.g. screenshot) to the task view menu, where we switch to screenshot and finish recents animation before executing the shortcut action. However for shortcut actions like screenshot, we do the same, resulting in two chained "switch to screenshot and finish". This is a temporary fix for S given it's late in the cycle and we don't want to introduce unwanted regressions. Fixes: 192272546 Test: manual Change-Id: I7ef596e8bce6c15aa4a27163197beac12359b691 --- .../src/com/android/quickstep/TaskOverlayFactory.java | 2 ++ .../src/com/android/quickstep/views/TaskMenuView.java | 2 +- src/com/android/launcher3/popup/SystemShortcut.java | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java index c1c85de413..2bcc229fff 100644 --- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java +++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java @@ -88,6 +88,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { SystemShortcut screenshotShortcut = TaskShortcutFactory.SCREENSHOT .getShortcut(activity, taskView); if (screenshotShortcut != null) { + screenshotShortcut.setHasFinishRecentsInAction(true); shortcuts.add(screenshotShortcut); } @@ -96,6 +97,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { SystemShortcut modalShortcut = TaskShortcutFactory.MODAL .getShortcut(activity, taskView); if (modalShortcut != null) { + modalShortcut.setHasFinishRecentsInAction(true); shortcuts.add(modalShortcut); } } diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java index c97225ec17..f5f25f491d 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java @@ -212,7 +212,7 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange menuOptionView.setEnabled(menuOption.isEnabled()); menuOptionView.setAlpha(menuOption.isEnabled() ? 1 : 0.5f); menuOptionView.setOnClickListener(view -> { - if (LIVE_TILE.get()) { + if (LIVE_TILE.get() && !menuOption.hasFinishRecentsInAction()) { RecentsView recentsView = mTaskView.getRecentsView(); recentsView.switchToScreenshot(null, () -> recentsView.finishRecentsAnimation(true /* toRecents */, diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index e5424cfe0a..d3f4909296 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -50,6 +50,8 @@ public abstract class SystemShortcut extends Ite */ private boolean isEnabled = true; + private boolean mHasFinishRecentsInAction = false; + public SystemShortcut(int iconResId, int labelResId, T target, ItemInfo itemInfo) { mIconResId = iconResId; mLabelResId = labelResId; @@ -100,6 +102,14 @@ public abstract class SystemShortcut extends Ite return mAccessibilityActionId == action; } + public void setHasFinishRecentsInAction(boolean hasFinishRecentsInAction) { + mHasFinishRecentsInAction = hasFinishRecentsInAction; + } + + public boolean hasFinishRecentsInAction() { + return mHasFinishRecentsInAction; + } + public interface Factory { @Nullable SystemShortcut getShortcut(T activity, ItemInfo itemInfo); From d09ebe660f1256a088543d8cddb227d1740d35ec Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Wed, 2 Jun 2021 23:54:44 -0700 Subject: [PATCH 08/11] Enable live tile in 3 button mode - Previously we rely on whether launcher is resumed as a signal to see what "toggle" means. This no longer works since launcher is not resumed in Overview. Instead, we need to check the live tile signals. - Use screenshot doesn't propagate after setting a new current task. So followed the logic around mRunningTaskIconScaledDown to work it out. - Get rid of NavigationModeFeatureFlag, pending on 3rd party launcher change ag/14409355 Fixes: 185934639 Test: (1) Toggle overview from home screen and toggle back to fullscreen. (2) Toggle overview from app and keep toggling. Change-Id: Iffaea18afb2179b5bb7dadda49e56efefa5658bc --- .../launcher3/BaseQuickstepLauncher.java | 6 +- .../NavBarToHomeTouchController.java | 6 +- .../android/quickstep/AbsSwipeUpHandler.java | 16 ++--- .../quickstep/FallbackActivityInterface.java | 9 ++- .../quickstep/LauncherActivityInterface.java | 23 ++++-- .../quickstep/OverviewCommandHelper.java | 1 + .../QuickstepProcessInitializer.java | 4 -- .../android/quickstep/RecentsActivity.java | 4 +- .../quickstep/TaskAnimationManager.java | 6 +- .../android/quickstep/TaskOverlayFactory.java | 4 +- .../com/android/quickstep/TaskViewUtils.java | 8 +-- .../quickstep/TouchInteractionService.java | 8 ++- .../fallback/RecentsTaskController.java | 4 +- .../inputconsumers/OverviewInputConsumer.java | 4 +- .../util/NavigationModeFeatureFlag.java | 58 --------------- .../android/quickstep/views/RecentsView.java | 70 ++++++++++++++----- .../quickstep/views/TaskThumbnailView.java | 4 +- .../com/android/quickstep/views/TaskView.java | 13 +++- .../quickstep/AbstractQuickStepTest.java | 4 +- 19 files changed, 126 insertions(+), 126 deletions(-) delete mode 100644 quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 052e66267e..475f06109e 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -20,11 +20,11 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON; import static com.android.launcher3.LauncherState.FLAG_HIDE_BACK_BUTTON; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.NO_OFFSET; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID; import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY; import android.animation.AnimatorSet; @@ -185,7 +185,7 @@ public abstract class BaseQuickstepLauncher extends Launcher @Override protected void onScreenOff() { super.onScreenOff(); - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { RecentsView recentsView = getOverviewPanel(); recentsView.finishRecentsAnimation(true /* toRecents */, null); } @@ -483,7 +483,7 @@ public abstract class BaseQuickstepLauncher extends Launcher super.onDisplayInfoChanged(context, info, flags); // When changing screens with live tile active, finish the recents animation to close // overview as it should be an interim state - if ((flags & CHANGE_ACTIVE_SCREEN) != 0 && LIVE_TILE.get()) { + if ((flags & CHANGE_ACTIVE_SCREEN) != 0 && ENABLE_QUICKSTEP_LIVE_TILE.get()) { RecentsView recentsView = getOverviewPanel(); recentsView.finishRecentsAnimation(/* toRecents= */ true, null); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java index 521dd233b8..86c42caa7b 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java @@ -25,8 +25,8 @@ import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback; import static com.android.launcher3.anim.Interpolators.DEACCEL_3; import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_EDU; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import android.animation.ValueAnimator; @@ -140,7 +140,7 @@ public class NavBarToHomeTouchController implements TouchController, AnimatorControllerWithResistance.createRecentsResistanceFromOverviewAnim(mLauncher, builder); - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { builder.addOnFrameCallback(recentsView::redrawLiveTile); } @@ -189,7 +189,7 @@ public class NavBarToHomeTouchController implements TouchController, boolean success = interpolatedProgress >= SUCCESS_TRANSITION_PROGRESS || (velocity < 0 && fling); if (success) { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { RecentsView recentsView = mLauncher.getOverviewPanel(); recentsView.switchToScreenshot(null, () -> recentsView.finishRecentsAnimation(true /* toRecents */, null)); diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 6d81bcf31b..6423352376 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -25,6 +25,7 @@ import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAG import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE; @@ -45,7 +46,6 @@ import static com.android.quickstep.GestureState.STATE_END_TARGET_SET; import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_CANCELED; import static com.android.quickstep.GestureState.STATE_RECENTS_SCROLLING_FINISHED; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME; @@ -327,7 +327,7 @@ public abstract class AbsSwipeUpHandler, mStateCallback.runOnceAtState(STATE_HANDLER_INVALIDATED | STATE_FINISH_WITH_NO_END, this::resetStateForAnimationCancel); - if (!LIVE_TILE.get()) { + if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) { mStateCallback.addChangeListener(STATE_APP_CONTROLLER_RECEIVED | STATE_LAUNCHER_PRESENT | STATE_SCREENSHOT_VIEW_SHOWN | STATE_CAPTURE_SCREENSHOT, (b) -> mRecentsView.setRunningTaskHidden(!b)); @@ -490,7 +490,7 @@ public abstract class AbsSwipeUpHandler, } private void onDeferredActivityLaunch() { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { mActivityInterface.switchRunningTaskViewToScreenshot( null, () -> { mTaskAnimationManager.finishRunningRecentsAnimation(true /* toHome */); @@ -1430,7 +1430,7 @@ public abstract class AbsSwipeUpHandler, } private void invalidateHandler() { - if (!LIVE_TILE.get() || !mActivityInterface.isInLiveTileMode() + if (!ENABLE_QUICKSTEP_LIVE_TILE.get() || !mActivityInterface.isInLiveTileMode() || mGestureState.getEndTarget() != RECENTS) { mInputConsumerProxy.destroy(); mTaskAnimationManager.setLiveTileCleanUpHandler(null); @@ -1475,7 +1475,7 @@ public abstract class AbsSwipeUpHandler, */ private void resetLauncherListeners() { // Reset the callback for deferred activity launches - if (!LIVE_TILE.get()) { + if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) { mActivityInterface.setOnDeferredActivityLaunchCallback(null); } mActivity.getRootView().setOnApplyWindowInsetsListener(null); @@ -1499,7 +1499,7 @@ public abstract class AbsSwipeUpHandler, mStateCallback.setStateOnUiThread(STATE_SCREENSHOT_CAPTURED); } else { final int runningTaskId = mGestureState.getRunningTaskId(); - final boolean refreshView = !LIVE_TILE.get() /* refreshView */; + final boolean refreshView = !ENABLE_QUICKSTEP_LIVE_TILE.get() /* refreshView */; boolean finishTransitionPosted = false; if (mRecentsAnimationController != null) { // Update the screenshot of the task @@ -1555,7 +1555,7 @@ public abstract class AbsSwipeUpHandler, } private void finishCurrentTransitionToRecents() { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED); if (mRecentsAnimationController != null) { mRecentsAnimationController.detachNavigationBarFromApp(true); @@ -1609,7 +1609,7 @@ public abstract class AbsSwipeUpHandler, } endLauncherTransitionController(); mRecentsView.onSwipeUpAnimationSuccess(); - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { mTaskAnimationManager.setLiveTileCleanUpHandler(mInputConsumerProxy::destroy); mTaskAnimationManager.enableLiveTileRestartListener(); } diff --git a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java index 906599f560..f29d68a72a 100644 --- a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java +++ b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java @@ -15,6 +15,7 @@ */ package com.android.quickstep; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; import static com.android.quickstep.fallback.RecentsState.BACKGROUND_APP; import static com.android.quickstep.fallback.RecentsState.DEFAULT; @@ -105,8 +106,12 @@ public final class FallbackActivityInterface extends @Override public RecentsView getVisibleRecentsView() { RecentsActivity activity = getCreatedActivity(); - if (activity != null && activity.hasBeenResumed()) { - return activity.getOverviewPanel(); + if (activity != null) { + RecentsView recentsView = activity.getOverviewPanel(); + if (activity.hasBeenResumed() || (ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode() + && recentsView.getRunningTaskId() == -1)) { + return recentsView; + } } return null; } diff --git a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java index 09474a1ac2..94a47e6cd0 100644 --- a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java +++ b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java @@ -21,6 +21,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.LauncherState.QUICK_SWITCH; import static com.android.launcher3.anim.AnimatorListeners.forEndCallback; import static com.android.launcher3.anim.Interpolators.LINEAR; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.animation.Animator; @@ -184,16 +185,24 @@ public final class LauncherActivityInterface extends @Override public RecentsView getVisibleRecentsView() { Launcher launcher = getVisibleLauncher(); - return launcher != null && launcher.getStateManager().getState().overviewUi - ? launcher.getOverviewPanel() : null; + RecentsView recentsView = + launcher != null && launcher.getStateManager().getState().overviewUi + ? launcher.getOverviewPanel() : null; + if (recentsView == null || (!launcher.hasBeenResumed() + && recentsView.getRunningTaskId() == -1)) { + // If live tile has ended, return null. + return null; + } + return recentsView; } @Nullable @UiThread private Launcher getVisibleLauncher() { Launcher launcher = getCreatedActivity(); - return (launcher != null) && launcher.isStarted() && launcher.hasBeenResumed() - ? launcher : null; + return (launcher != null) && launcher.isStarted() + && ((ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode()) + || launcher.hasBeenResumed()) ? launcher : null; } @Override @@ -202,6 +211,12 @@ public final class LauncherActivityInterface extends if (launcher == null) { return false; } + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode()) { + RecentsView recentsView = getVisibleRecentsView(); + if (recentsView == null) { + return false; + } + } closeOverlay(); launcher.getStateManager().goToState(OVERVIEW, diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index 2beef0a7ce..742d02d204 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -15,6 +15,7 @@ */ package com.android.quickstep; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID; diff --git a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java index 192738f76a..65847f11bb 100644 --- a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java +++ b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java @@ -15,8 +15,6 @@ */ package com.android.quickstep; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; - import android.annotation.TargetApi; import android.content.Context; import android.content.pm.PackageManager; @@ -61,8 +59,6 @@ public class QuickstepProcessInitializer extends MainProcessInitializer { super.init(context); - LIVE_TILE.initialize(context); - // Elevate GPU priority for Quickstep and Remote animations. ThreadedRendererCompat.setContextPriority( ThreadedRendererCompat.EGL_CONTEXT_PRIORITY_HIGH_IMG); diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index fa5ab1cb7b..9dfcd12dde 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -23,10 +23,10 @@ import static com.android.launcher3.QuickstepTransitionManager.STATUS_BAR_TRANSI import static com.android.launcher3.QuickstepTransitionManager.STATUS_BAR_TRANSITION_PRE_DELAY; import static com.android.launcher3.Utilities.createHomeIntent; import static com.android.launcher3.graphics.SysUiScrim.SYSUI_PROGRESS; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL; import static com.android.quickstep.TaskUtils.taskIsATargetWithMode; import static com.android.quickstep.TaskViewUtils.createRecentsWindowAnimator; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING; @@ -359,7 +359,7 @@ public final class RecentsActivity extends StatefulActivity { } public void startHome() { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { RecentsView recentsView = getOverviewPanel(); recentsView.switchToScreenshot(() -> recentsView.finishRecentsAnimation(true, this::startHomeInternal)); diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index ae2328e643..33718a3cac 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -15,11 +15,11 @@ */ package com.android.quickstep; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_INITIALIZED; import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_STARTED; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import android.app.ActivityManager; import android.content.Context; @@ -65,7 +65,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn return; } BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface(); - if (LIVE_TILE.get() && activityInterface.isInLiveTileMode() + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode() && activityInterface.getCreatedActivity() != null) { RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel(); if (recentsView != null) { @@ -139,7 +139,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn @Override public void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) { BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface(); - if (LIVE_TILE.get() && activityInterface.isInLiveTileMode() + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode() && activityInterface.getCreatedActivity() != null) { RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel(); diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java index 729710715a..ffa254d14c 100644 --- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java +++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java @@ -18,7 +18,7 @@ package com.android.quickstep; import static android.view.Surface.ROTATION_0; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.quickstep.views.OverviewActionsView.DISABLED_NO_THUMBNAIL; import static com.android.quickstep.views.OverviewActionsView.DISABLED_ROTATED; @@ -188,7 +188,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { * @param callback callback to run, after switching to screenshot */ public void endLiveTileMode(@NonNull Runnable callback) { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { RecentsView recentsView = mThumbnailView.getTaskView().getRecentsView(); recentsView.switchToScreenshot( () -> recentsView.finishRecentsAnimation(true /* toRecents */, diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 3293810582..37fda73d44 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -34,7 +34,6 @@ import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLAT import static com.android.launcher3.anim.Interpolators.clampToProgress; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.statehandlers.DepthController.DEPTH; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING; @@ -155,7 +154,7 @@ public final class TaskViewUtils { boolean isRunningTask = v.isRunningTask(); TransformParams params = null; TaskViewSimulator tsv = null; - if (LIVE_TILE.get() && isRunningTask) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && isRunningTask) { params = v.getRecentsView().getLiveTileParams(); tsv = v.getRecentsView().getLiveTileTaskViewSimulator(); } @@ -176,7 +175,8 @@ public final class TaskViewUtils { boolean isQuickSwitch = v.isEndQuickswitchCuj(); v.setEndQuickswitchCuj(false); - boolean inLiveTileMode = LIVE_TILE.get() && v.getRecentsView().getRunningTaskIndex() != -1; + boolean inLiveTileMode = + ENABLE_QUICKSTEP_LIVE_TILE.get() && v.getRecentsView().getRunningTaskIndex() != -1; final RemoteAnimationTargets targets = new RemoteAnimationTargets(appTargets, wallpaperTargets, nonAppTargets, inLiveTileMode ? MODE_CLOSING : MODE_OPENING); @@ -531,7 +531,7 @@ public final class TaskViewUtils { }; } pa.add(launcherAnim); - if (LIVE_TILE.get() && recentsView.getRunningTaskIndex() != -1) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskIndex() != -1) { pa.addOnFrameCallback(recentsView::redrawLiveTile); } anim.play(pa.buildAnim()); diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index e8324f70e0..af1a01a4ec 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -21,9 +21,9 @@ import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.config.FeatureFlags.ASSISTANT_GIVES_LAUNCHER_FOCUS; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.quickstep.GestureState.DEFAULT_STATE; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SHELL_ONE_HANDED; import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SHELL_PIP; @@ -765,7 +765,8 @@ public class TouchInteractionService extends Service implements PluginListener, T extends StatefulAct @Override public void onKeyEvent(KeyEvent ev) { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { switch (ev.getKeyCode()) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: diff --git a/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java b/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java deleted file mode 100644 index 60c7add38f..0000000000 --- a/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2021 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.quickstep.util; - -import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; - -import android.content.Context; - -import com.android.quickstep.SysUINavigationMode; - -import java.util.function.Predicate; -import java.util.function.Supplier; - -/** A feature flag that listens to navigation mode changes. */ -public class NavigationModeFeatureFlag implements - SysUINavigationMode.NavigationModeChangeListener { - - public static final NavigationModeFeatureFlag LIVE_TILE = new NavigationModeFeatureFlag( - ENABLE_QUICKSTEP_LIVE_TILE::get, mode -> mode.hasGestures); - - private final Supplier mBasePredicate; - private final Predicate mModePredicate; - private boolean mSupported; - - private NavigationModeFeatureFlag(Supplier basePredicate, - Predicate modePredicate) { - mBasePredicate = basePredicate; - mModePredicate = modePredicate; - } - - public boolean get() { - return mBasePredicate.get() && mSupported; - } - - public void initialize(Context context) { - onNavigationModeChanged(SysUINavigationMode.INSTANCE.get(context).getMode()); - SysUINavigationMode.INSTANCE.get(context).addModeChangeListener(this); - } - - @Override - public void onNavigationModeChanged(SysUINavigationMode.Mode newMode) { - mSupported = mModePredicate.test(newMode); - } -} diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index a72a205def..538f626f86 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -37,6 +37,7 @@ import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.clampToProgress; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_CLEAR_ALL; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_DISMISS_SWIPE_UP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_SWIPE_DOWN; @@ -46,7 +47,6 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.SystemUiController.UI_STATE_FULLSCREEN_TASK; import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NON_ZERO_ROTATION; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_RECENTS; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_TASKS; @@ -129,6 +129,7 @@ import com.android.launcher3.util.IntSet; import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.util.ResourceBasedOverride.Overrides; import com.android.launcher3.util.SplitConfigurationOptions; +import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption; import com.android.launcher3.util.Themes; import com.android.launcher3.util.TranslateEdgeEffect; @@ -504,6 +505,7 @@ public abstract class RecentsView 0 ? getTaskViewAt(0).getTaskId() : -1; if (mRecentsAnimationController != null) { - if (LIVE_TILE.get() && mEnableDrawingLiveTile) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mEnableDrawingLiveTile) { // We are still drawing the live tile, finish it now to clean up. finishRecentsAnimation(true /* toRecents */, null); } else { @@ -1757,7 +1783,7 @@ public abstract class RecentsView { mLiveTileTaskViewSimulator.taskSecondaryTranslation.value = mOrientationHandler.getSecondaryValue( @@ -2347,7 +2375,8 @@ public abstract class RecentsView { mLiveTileTaskViewSimulator.taskPrimaryTranslation.value = @@ -2417,8 +2446,8 @@ public abstract class RecentsView() { @Override public void accept(Boolean success) { - if (LIVE_TILE.get() && mEnableDrawingLiveTile && dismissedTaskView.isRunningTask() - && success) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mEnableDrawingLiveTile + && dismissedTaskView.isRunningTask() && success) { finishRecentsAnimation(true /* toRecents */, false /* shouldPip */, () -> onEnd(success)); } else { @@ -2431,7 +2460,8 @@ public abstract class RecentsView removeTaskInternal(dismissedTaskId)); } else { @@ -2876,7 +2906,8 @@ public abstract class RecentsView { if (isSuccess) { - if (LIVE_TILE.get() && tv.isRunningTask()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && tv.isRunningTask()) { finishRecentsAnimation(false /* toRecents */, null); onTaskLaunchAnimationEnd(true /* success */); } else { @@ -3450,7 +3481,7 @@ public abstract class RecentsView { - if (LIVE_TILE.get() && isRunningTask()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && isRunningTask()) { RecentsView recentsView = getRecentsView(); recentsView.switchToScreenshot( () -> recentsView.finishRecentsAnimation(true /* toRecents */, diff --git a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java index 4f27e21ae8..dc73a9a51c 100644 --- a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java +++ b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java @@ -16,7 +16,7 @@ package com.android.quickstep; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static org.junit.Assert.assertTrue; @@ -75,7 +75,7 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest { private boolean isInLiveTileMode(Launcher launcher, LauncherInstrumentation.ContainerType expectedContainerType) { - if (!LIVE_TILE.get() + if (!ENABLE_QUICKSTEP_LIVE_TILE.get() || expectedContainerType != LauncherInstrumentation.ContainerType.OVERVIEW) { return false; } From 1fe5fda3d8a6cbeead21c4c76fb70eb022000231 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Wed, 2 Jun 2021 23:54:44 -0700 Subject: [PATCH 09/11] Enable live tile in 3 button mode - Previously we rely on whether launcher is resumed as a signal to see what "toggle" means. This no longer works since launcher is not resumed in Overview. Instead, we need to check the live tile signals. - Use screenshot doesn't propagate after setting a new current task. So followed the logic around mRunningTaskIconScaledDown to work it out. - Get rid of NavigationModeFeatureFlag, pending on 3rd party launcher change ag/14409355 Fixes: 185934639 Test: (1) Toggle overview from home screen and toggle back to fullscreen. (2) Toggle overview from app and keep toggling. Change-Id: Iffaea18afb2179b5bb7dadda49e56efefa5658bc Merged-In: Iffaea18afb2179b5bb7dadda49e56efefa5658bc --- .../launcher3/BaseQuickstepLauncher.java | 4 +- .../NavBarToHomeTouchController.java | 6 +- .../android/quickstep/AbsSwipeUpHandler.java | 16 ++--- .../quickstep/FallbackActivityInterface.java | 9 ++- .../quickstep/LauncherActivityInterface.java | 23 +++++-- .../quickstep/OverviewCommandHelper.java | 1 + .../QuickstepProcessInitializer.java | 4 -- .../android/quickstep/RecentsActivity.java | 4 +- .../quickstep/TaskAnimationManager.java | 6 +- .../android/quickstep/TaskOverlayFactory.java | 4 +- .../com/android/quickstep/TaskViewUtils.java | 8 +-- .../quickstep/TouchInteractionService.java | 8 ++- .../fallback/RecentsTaskController.java | 4 +- .../inputconsumers/OverviewInputConsumer.java | 4 +- .../util/NavigationModeFeatureFlag.java | 58 ---------------- .../quickstep/util/TaskViewSimulator.java | 4 +- .../android/quickstep/views/RecentsView.java | 67 ++++++++++++++----- .../android/quickstep/views/TaskMenuView.java | 4 +- .../quickstep/views/TaskThumbnailView.java | 4 +- .../com/android/quickstep/views/TaskView.java | 11 ++- .../quickstep/AbstractQuickStepTest.java | 4 +- 21 files changed, 126 insertions(+), 127 deletions(-) delete mode 100644 quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 2498d12931..32e2f1ad10 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -20,10 +20,10 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON; import static com.android.launcher3.LauncherState.FLAG_HIDE_BACK_BUTTON; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.NO_OFFSET; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY; import android.animation.AnimatorSet; @@ -181,7 +181,7 @@ public abstract class BaseQuickstepLauncher extends Launcher @Override protected void onScreenOff() { super.onScreenOff(); - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { RecentsView recentsView = getOverviewPanel(); recentsView.finishRecentsAnimation(true /* toRecents */, null); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java index 521dd233b8..86c42caa7b 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java @@ -25,8 +25,8 @@ import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback; import static com.android.launcher3.anim.Interpolators.DEACCEL_3; import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_EDU; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import android.animation.ValueAnimator; @@ -140,7 +140,7 @@ public class NavBarToHomeTouchController implements TouchController, AnimatorControllerWithResistance.createRecentsResistanceFromOverviewAnim(mLauncher, builder); - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { builder.addOnFrameCallback(recentsView::redrawLiveTile); } @@ -189,7 +189,7 @@ public class NavBarToHomeTouchController implements TouchController, boolean success = interpolatedProgress >= SUCCESS_TRANSITION_PROGRESS || (velocity < 0 && fling); if (success) { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { RecentsView recentsView = mLauncher.getOverviewPanel(); recentsView.switchToScreenshot(null, () -> recentsView.finishRecentsAnimation(true /* toRecents */, null)); diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index ea4b08d3bd..ad7c7106ce 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -25,6 +25,7 @@ import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAG import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE; @@ -45,7 +46,6 @@ import static com.android.quickstep.GestureState.STATE_END_TARGET_SET; import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_CANCELED; import static com.android.quickstep.GestureState.STATE_RECENTS_SCROLLING_FINISHED; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME; @@ -327,7 +327,7 @@ public abstract class AbsSwipeUpHandler, mStateCallback.runOnceAtState(STATE_HANDLER_INVALIDATED | STATE_FINISH_WITH_NO_END, this::resetStateForAnimationCancel); - if (!LIVE_TILE.get()) { + if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) { mStateCallback.addChangeListener(STATE_APP_CONTROLLER_RECEIVED | STATE_LAUNCHER_PRESENT | STATE_SCREENSHOT_VIEW_SHOWN | STATE_CAPTURE_SCREENSHOT, (b) -> mRecentsView.setRunningTaskHidden(!b)); @@ -490,7 +490,7 @@ public abstract class AbsSwipeUpHandler, } private void onDeferredActivityLaunch() { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { mActivityInterface.switchRunningTaskViewToScreenshot( null, () -> { mTaskAnimationManager.finishRunningRecentsAnimation(true /* toHome */); @@ -1429,7 +1429,7 @@ public abstract class AbsSwipeUpHandler, } private void invalidateHandler() { - if (!LIVE_TILE.get() || !mActivityInterface.isInLiveTileMode() + if (!ENABLE_QUICKSTEP_LIVE_TILE.get() || !mActivityInterface.isInLiveTileMode() || mGestureState.getEndTarget() != RECENTS) { mInputConsumerProxy.destroy(); mTaskAnimationManager.setLiveTileCleanUpHandler(null); @@ -1474,7 +1474,7 @@ public abstract class AbsSwipeUpHandler, */ private void resetLauncherListeners() { // Reset the callback for deferred activity launches - if (!LIVE_TILE.get()) { + if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) { mActivityInterface.setOnDeferredActivityLaunchCallback(null); } mActivity.getRootView().setOnApplyWindowInsetsListener(null); @@ -1498,7 +1498,7 @@ public abstract class AbsSwipeUpHandler, mStateCallback.setStateOnUiThread(STATE_SCREENSHOT_CAPTURED); } else { final int runningTaskId = mGestureState.getRunningTaskId(); - final boolean refreshView = !LIVE_TILE.get() /* refreshView */; + final boolean refreshView = !ENABLE_QUICKSTEP_LIVE_TILE.get() /* refreshView */; boolean finishTransitionPosted = false; if (mRecentsAnimationController != null) { // Update the screenshot of the task @@ -1554,7 +1554,7 @@ public abstract class AbsSwipeUpHandler, } private void finishCurrentTransitionToRecents() { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED); if (mRecentsAnimationController != null) { mRecentsAnimationController.detachNavigationBarFromApp(true); @@ -1608,7 +1608,7 @@ public abstract class AbsSwipeUpHandler, } endLauncherTransitionController(); mRecentsView.onSwipeUpAnimationSuccess(); - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { mTaskAnimationManager.setLiveTileCleanUpHandler(mInputConsumerProxy::destroy); mTaskAnimationManager.enableLiveTileRestartListener(); } diff --git a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java index 906599f560..f29d68a72a 100644 --- a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java +++ b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java @@ -15,6 +15,7 @@ */ package com.android.quickstep; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; import static com.android.quickstep.fallback.RecentsState.BACKGROUND_APP; import static com.android.quickstep.fallback.RecentsState.DEFAULT; @@ -105,8 +106,12 @@ public final class FallbackActivityInterface extends @Override public RecentsView getVisibleRecentsView() { RecentsActivity activity = getCreatedActivity(); - if (activity != null && activity.hasBeenResumed()) { - return activity.getOverviewPanel(); + if (activity != null) { + RecentsView recentsView = activity.getOverviewPanel(); + if (activity.hasBeenResumed() || (ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode() + && recentsView.getRunningTaskId() == -1)) { + return recentsView; + } } return null; } diff --git a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java index 30abfbb922..fb1391a309 100644 --- a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java +++ b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java @@ -21,6 +21,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.LauncherState.QUICK_SWITCH; import static com.android.launcher3.anim.AnimatorListeners.forEndCallback; import static com.android.launcher3.anim.Interpolators.LINEAR; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.animation.Animator; @@ -184,16 +185,24 @@ public final class LauncherActivityInterface extends @Override public RecentsView getVisibleRecentsView() { Launcher launcher = getVisibleLauncher(); - return launcher != null && launcher.getStateManager().getState().overviewUi - ? launcher.getOverviewPanel() : null; + RecentsView recentsView = + launcher != null && launcher.getStateManager().getState().overviewUi + ? launcher.getOverviewPanel() : null; + if (recentsView == null || (!launcher.hasBeenResumed() + && recentsView.getRunningTaskId() == -1)) { + // If live tile has ended, return null. + return null; + } + return recentsView; } @Nullable @UiThread private Launcher getVisibleLauncher() { Launcher launcher = getCreatedActivity(); - return (launcher != null) && launcher.isStarted() && launcher.hasBeenResumed() - ? launcher : null; + return (launcher != null) && launcher.isStarted() + && ((ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode()) + || launcher.hasBeenResumed()) ? launcher : null; } @Override @@ -202,6 +211,12 @@ public final class LauncherActivityInterface extends if (launcher == null) { return false; } + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode()) { + RecentsView recentsView = getVisibleRecentsView(); + if (recentsView == null) { + return false; + } + } closeOverlay(); launcher.getStateManager().goToState(OVERVIEW, diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index 2beef0a7ce..742d02d204 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -15,6 +15,7 @@ */ package com.android.quickstep; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID; diff --git a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java index 192738f76a..65847f11bb 100644 --- a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java +++ b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java @@ -15,8 +15,6 @@ */ package com.android.quickstep; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; - import android.annotation.TargetApi; import android.content.Context; import android.content.pm.PackageManager; @@ -61,8 +59,6 @@ public class QuickstepProcessInitializer extends MainProcessInitializer { super.init(context); - LIVE_TILE.initialize(context); - // Elevate GPU priority for Quickstep and Remote animations. ThreadedRendererCompat.setContextPriority( ThreadedRendererCompat.EGL_CONTEXT_PRIORITY_HIGH_IMG); diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index fa5ab1cb7b..9dfcd12dde 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -23,10 +23,10 @@ import static com.android.launcher3.QuickstepTransitionManager.STATUS_BAR_TRANSI import static com.android.launcher3.QuickstepTransitionManager.STATUS_BAR_TRANSITION_PRE_DELAY; import static com.android.launcher3.Utilities.createHomeIntent; import static com.android.launcher3.graphics.SysUiScrim.SYSUI_PROGRESS; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL; import static com.android.quickstep.TaskUtils.taskIsATargetWithMode; import static com.android.quickstep.TaskViewUtils.createRecentsWindowAnimator; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING; @@ -359,7 +359,7 @@ public final class RecentsActivity extends StatefulActivity { } public void startHome() { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { RecentsView recentsView = getOverviewPanel(); recentsView.switchToScreenshot(() -> recentsView.finishRecentsAnimation(true, this::startHomeInternal)); diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index 223c46df26..6c445e1b3e 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -15,11 +15,11 @@ */ package com.android.quickstep; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_INITIALIZED; import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_STARTED; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import android.app.ActivityManager; import android.content.Context; @@ -64,7 +64,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn return; } BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface(); - if (LIVE_TILE.get() && activityInterface.isInLiveTileMode() + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode() && activityInterface.getCreatedActivity() != null) { RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel(); if (recentsView != null) { @@ -139,7 +139,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn @Override public void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) { BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface(); - if (LIVE_TILE.get() && activityInterface.isInLiveTileMode() + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode() && activityInterface.getCreatedActivity() != null) { RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel(); diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java index 2bcc229fff..06a3c7048b 100644 --- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java +++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java @@ -18,7 +18,7 @@ package com.android.quickstep; import static android.view.Surface.ROTATION_0; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.quickstep.views.OverviewActionsView.DISABLED_NO_THUMBNAIL; import static com.android.quickstep.views.OverviewActionsView.DISABLED_ROTATED; @@ -189,7 +189,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { * @param callback callback to run, after switching to screenshot */ public void endLiveTileMode(@NonNull Runnable callback) { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { RecentsView recentsView = mThumbnailView.getTaskView().getRecentsView(); recentsView.switchToScreenshot( () -> recentsView.finishRecentsAnimation(true /* toRecents */, diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 3293810582..37fda73d44 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -34,7 +34,6 @@ import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLAT import static com.android.launcher3.anim.Interpolators.clampToProgress; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.statehandlers.DepthController.DEPTH; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING; @@ -155,7 +154,7 @@ public final class TaskViewUtils { boolean isRunningTask = v.isRunningTask(); TransformParams params = null; TaskViewSimulator tsv = null; - if (LIVE_TILE.get() && isRunningTask) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && isRunningTask) { params = v.getRecentsView().getLiveTileParams(); tsv = v.getRecentsView().getLiveTileTaskViewSimulator(); } @@ -176,7 +175,8 @@ public final class TaskViewUtils { boolean isQuickSwitch = v.isEndQuickswitchCuj(); v.setEndQuickswitchCuj(false); - boolean inLiveTileMode = LIVE_TILE.get() && v.getRecentsView().getRunningTaskIndex() != -1; + boolean inLiveTileMode = + ENABLE_QUICKSTEP_LIVE_TILE.get() && v.getRecentsView().getRunningTaskIndex() != -1; final RemoteAnimationTargets targets = new RemoteAnimationTargets(appTargets, wallpaperTargets, nonAppTargets, inLiveTileMode ? MODE_CLOSING : MODE_OPENING); @@ -531,7 +531,7 @@ public final class TaskViewUtils { }; } pa.add(launcherAnim); - if (LIVE_TILE.get() && recentsView.getRunningTaskIndex() != -1) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskIndex() != -1) { pa.addOnFrameCallback(recentsView::redrawLiveTile); } anim.play(pa.buildAnim()); diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 84f7e83737..069ed11553 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -21,9 +21,9 @@ import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.config.FeatureFlags.ASSISTANT_GIVES_LAUNCHER_FOCUS; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.quickstep.GestureState.DEFAULT_STATE; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SHELL_ONE_HANDED; import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SHELL_PIP; @@ -737,7 +737,8 @@ public class TouchInteractionService extends Service implements PluginListener, T extends StatefulAct @Override public void onKeyEvent(KeyEvent ev) { - if (LIVE_TILE.get()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { switch (ev.getKeyCode()) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: diff --git a/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java b/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java deleted file mode 100644 index 60c7add38f..0000000000 --- a/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2021 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.quickstep.util; - -import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; - -import android.content.Context; - -import com.android.quickstep.SysUINavigationMode; - -import java.util.function.Predicate; -import java.util.function.Supplier; - -/** A feature flag that listens to navigation mode changes. */ -public class NavigationModeFeatureFlag implements - SysUINavigationMode.NavigationModeChangeListener { - - public static final NavigationModeFeatureFlag LIVE_TILE = new NavigationModeFeatureFlag( - ENABLE_QUICKSTEP_LIVE_TILE::get, mode -> mode.hasGestures); - - private final Supplier mBasePredicate; - private final Predicate mModePredicate; - private boolean mSupported; - - private NavigationModeFeatureFlag(Supplier basePredicate, - Predicate modePredicate) { - mBasePredicate = basePredicate; - mModePredicate = modePredicate; - } - - public boolean get() { - return mBasePredicate.get() && mSupported; - } - - public void initialize(Context context) { - onNavigationModeChanged(SysUINavigationMode.INSTANCE.get(context).getMode()); - SysUINavigationMode.INSTANCE.get(context).addModeChangeListener(this); - } - - @Override - public void onNavigationModeChanged(SysUINavigationMode.Mode newMode) { - mSupported = mModePredicate.test(newMode); - } -} diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index b15bbf3ed2..c97ca32aa2 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -15,9 +15,9 @@ */ package com.android.quickstep.util; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.states.RotationHelper.deltaRotation; import static com.android.launcher3.touch.PagedOrientationHandler.MATRIX_POST_TRANSLATE; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.quickstep.util.RecentsOrientedState.postDisplayRotation; import static com.android.quickstep.util.RecentsOrientedState.preDisplayRotation; import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_FULLSCREEN; @@ -302,7 +302,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { .withWindowCrop(mTmpCropRect) .withCornerRadius(getCurrentCornerRadius()); - if (LIVE_TILE.get() && params.getRecentsSurface() != null) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && params.getRecentsSurface() != null) { // When relativeLayer = 0, it reverts the surfaces back to the original order. builder.withRelativeLayerTo(params.getRecentsSurface(), mDrawsBelowRecents ? Integer.MIN_VALUE : 0); diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 6767d32bac..fb5fdac23c 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -38,6 +38,7 @@ import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.clampToProgress; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_CLEAR_ALL; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_DISMISS_SWIPE_UP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_SWIPE_DOWN; @@ -47,7 +48,6 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.SystemUiController.UI_STATE_FULLSCREEN_TASK; import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NON_ZERO_ROTATION; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_RECENTS; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_TASKS; @@ -131,6 +131,7 @@ import com.android.launcher3.util.IntSet; import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.util.ResourceBasedOverride.Overrides; import com.android.launcher3.util.SplitConfigurationOptions; +import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption; import com.android.launcher3.util.Themes; import com.android.launcher3.util.TranslateEdgeEffect; @@ -496,6 +497,7 @@ public abstract class RecentsView { mLiveTileTaskViewSimulator.taskSecondaryTranslation.value = mOrientationHandler.getSecondaryValue( @@ -2321,7 +2349,8 @@ public abstract class RecentsView { mLiveTileTaskViewSimulator.taskPrimaryTranslation.value = @@ -2365,8 +2394,8 @@ public abstract class RecentsView() { @Override public void accept(Boolean success) { - if (LIVE_TILE.get() && mEnableDrawingLiveTile && taskView.isRunningTask() - && success) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mEnableDrawingLiveTile + && taskView.isRunningTask() && success) { finishRecentsAnimation(true /* toRecents */, false /* shouldPip */, () -> onEnd(success)); } else { @@ -2379,7 +2408,7 @@ public abstract class RecentsView removeTaskInternal(taskView)); } else { @@ -2816,7 +2845,8 @@ public abstract class RecentsView { if (isSuccess) { - if (LIVE_TILE.get() && tv.isRunningTask()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && tv.isRunningTask()) { finishRecentsAnimation(false /* toRecents */, null); onTaskLaunchAnimationEnd(true /* success */); } else { @@ -3384,7 +3414,7 @@ public abstract class RecentsView { - if (LIVE_TILE.get() && !menuOption.hasFinishRecentsInAction()) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && !menuOption.hasFinishRecentsInAction()) { RecentsView recentsView = mTaskView.getRecentsView(); recentsView.switchToScreenshot(null, () -> recentsView.finishRecentsAnimation(true /* toRecents */, diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java index f730d2d31e..8d69d88062 100644 --- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java +++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java @@ -19,7 +19,7 @@ package com.android.quickstep.views; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS; -import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_FULLSCREEN; import android.content.Context; @@ -306,7 +306,7 @@ public class TaskThumbnailView extends View implements PluginListener Date: Thu, 1 Jul 2021 14:22:31 +0100 Subject: [PATCH 10/11] Avoid calling AppWidgetHostViedw#updateAppWidgetSize We cannot call it anymore, because the system padding is not always used. Bug: 191612352 Test: Manually, using CtsVerifier and dedicated widgets Change-Id: I06353ba49a8e62127e593cdbcb86fadcf89ecb24 --- .../launcher3/widget/util/WidgetSizes.java | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/com/android/launcher3/widget/util/WidgetSizes.java b/src/com/android/launcher3/widget/util/WidgetSizes.java index 5c8ea7299b..6d053be812 100644 --- a/src/com/android/launcher3/widget/util/WidgetSizes.java +++ b/src/com/android/launcher3/widget/util/WidgetSizes.java @@ -17,9 +17,7 @@ package com.android.launcher3.widget.util; import static android.appwidget.AppWidgetHostView.getDefaultPaddingForWidget; -import static com.android.launcher3.Utilities.ATLEAST_S; -import android.annotation.SuppressLint; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetManager; import android.content.ComponentName; @@ -37,21 +35,30 @@ import com.android.launcher3.LauncherAppState; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** A utility class for widget sizes related calculations. */ public final class WidgetSizes { /** * Returns the list of all possible sizes, in dp, for a widget of given spans on this device. + * + *

The returned sizes already take into account the system padding, and whether it is applied + * or not in that specific configuration. */ - public static ArrayList getWidgetSizes(Context context, int spanX, int spanY) { + public static ArrayList getWidgetPaddedSizes(Context context, ComponentName provider, + int spanX, int spanY) { + Rect padding = getDefaultPaddingForWidget(context, provider, /* padding= */ null); + ArrayList sizes = new ArrayList<>(2); final float density = context.getResources().getDisplayMetrics().density; final Point cellSize = new Point(); for (DeviceProfile profile : LauncherAppState.getIDP(context).supportedProfiles) { Size widgetSizePx = getWidgetSizePx(profile, spanX, spanY, cellSize); + if (!profile.shouldInsetWidgets()) { + widgetSizePx = new Size(widgetSizePx.getWidth() - padding.left - padding.right, + widgetSizePx.getHeight() - padding.top - padding.bottom); + } sizes.add(new SizeF(widgetSizePx.getWidth() / density, widgetSizePx.getHeight() / density)); } @@ -81,17 +88,22 @@ public final class WidgetSizes { *

On Android S+, it also updates the given {@code widgetView} with a list of sizes derived * from {@code spanX}, {@code spanY} in all supported device profiles. */ - @SuppressLint("NewApi") // Already added API check. public static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Context context, int spanX, int spanY) { - List sizes = getWidgetSizes(context, spanX, spanY); - if (ATLEAST_S) { - widgetView.updateAppWidgetSize(new Bundle(), sizes); - } else { - Rect bounds = getMinMaxSizes(sizes); - widgetView.updateAppWidgetSize(new Bundle(), bounds.left, bounds.top, bounds.right, - bounds.bottom); + AppWidgetManager widgetManager = AppWidgetManager.getInstance(context); + int widgetId = widgetView.getAppWidgetId(); + if (widgetId <= 0) { + return; } + Bundle sizeOptions = getWidgetSizeOptions(context, widgetView.getAppWidgetInfo().provider, + spanX, spanY); + if (sizeOptions.getParcelableArrayList( + AppWidgetManager.OPTION_APPWIDGET_SIZES).equals( + widgetManager.getAppWidgetOptions(widgetId).getParcelableArrayList( + AppWidgetManager.OPTION_APPWIDGET_SIZES))) { + return; + } + widgetManager.updateAppWidgetOptions(widgetId, sizeOptions); } /** @@ -99,17 +111,7 @@ public final class WidgetSizes { */ public static Bundle getWidgetSizeOptions(Context context, ComponentName provider, int spanX, int spanY) { - ArrayList sizes = getWidgetSizes(context, spanX, spanY); - Rect padding = getDefaultPaddingForWidget(context, provider, null); - float density = context.getResources().getDisplayMetrics().density; - float xPaddingDips = (padding.left + padding.right) / density; - float yPaddingDips = (padding.top + padding.bottom) / density; - - ArrayList paddedSizes = sizes.stream() - .map(size -> new SizeF( - Math.max(0.f, size.getWidth() - xPaddingDips), - Math.max(0.f, size.getHeight() - yPaddingDips))) - .collect(Collectors.toCollection(ArrayList::new)); + ArrayList paddedSizes = getWidgetPaddedSizes(context, provider, spanX, spanY); Rect rect = getMinMaxSizes(paddedSizes); Bundle options = new Bundle(); From a7b3a14e7550f161e0a0173bce6fd6bfdd2c8c16 Mon Sep 17 00:00:00 2001 From: Pierre Barbier de Reuille Date: Thu, 1 Jul 2021 15:38:15 +0100 Subject: [PATCH 11/11] Use the computation of the widget size including padding. Found all the uses of getWidgetSizePx and replaced them with the computation of padded sizes (checked it all made sense). Test: Try the various widget pickers. Bug: 191612352 Change-Id: Id2a8d12ee7ce6baabef186dbb78d817975ea2212 --- .../widget/DatabaseWidgetPreviewLoader.java | 3 ++- .../android/launcher3/widget/WidgetCell.java | 4 ++- .../widget/picker/WidgetsListAdapter.java | 7 ++--- .../WidgetsRecommendationTableLayout.java | 4 +-- .../launcher3/widget/util/WidgetSizes.java | 27 +++++++++++++++++++ 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java b/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java index 867c770278..4ec7e60c86 100644 --- a/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java +++ b/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java @@ -417,7 +417,8 @@ public class DatabaseWidgetPreviewLoader implements WidgetPreviewLoader { previewHeight = drawable.getIntrinsicHeight(); } else { DeviceProfile dp = launcher.getDeviceProfile(); - Size widgetSize = WidgetSizes.getWidgetSizePx(dp, spanX, spanY); + Size widgetSize = WidgetSizes.getWidgetPaddedSizePx(mContext, info.provider, dp, spanX, + spanY); previewWidth = widgetSize.getWidth(); previewHeight = widgetSize.getHeight(); } diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java index 8798332c85..c3edcce95a 100644 --- a/src/com/android/launcher3/widget/WidgetCell.java +++ b/src/com/android/launcher3/widget/WidgetCell.java @@ -363,7 +363,9 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener { /** Sets the widget preview image size, in number of cells, and preview scale. */ public Size setPreviewSize(int spanX, int spanY, float previewScale) { DeviceProfile deviceProfile = mActivity.getDeviceProfile(); - Size widgetSize = WidgetSizes.getWidgetSizePx(deviceProfile, spanX, spanY); + Size widgetSize = + mItem != null ? WidgetSizes.getWidgetItemSizePx(getContext(), deviceProfile, mItem) + : WidgetSizes.getWidgetSizePx(deviceProfile, spanX, spanY); mPreviewWidth = widgetSize.getWidth(); mPreviewHeight = widgetSize.getHeight(); mPreviewScale = previewScale; diff --git a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java index 08a2263eff..1125b82150 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java +++ b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java @@ -296,11 +296,8 @@ public class WidgetsListAdapter extends Adapter implements OnHeaderC for (int i = 0; i < entry.mWidgets.size(); i++) { WidgetItem widgetItem = entry.mWidgets.get(i); DeviceProfile deviceProfile = activity.getDeviceProfile(); - Size widgetSize = - WidgetSizes.getWidgetSizePx( - deviceProfile, - widgetItem.spanX, - widgetItem.spanY); + Size widgetSize = WidgetSizes.getWidgetItemSizePx(mContext, deviceProfile, + widgetItem); if (widgetItem.isShortcut()) { widgetSize = new Size( diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java b/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java index 6fc684862d..3800ede169 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java +++ b/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java @@ -155,8 +155,8 @@ public final class WidgetsRecommendationTableLayout extends TableLayout { float rowHeight = 0; for (int j = 0; j < widgetItems.size(); j++) { WidgetItem widgetItem = widgetItems.get(j); - Size widgetSize = WidgetSizes.getWidgetSizePx( - deviceProfile, widgetItem.spanX, widgetItem.spanY); + Size widgetSize = WidgetSizes.getWidgetItemSizePx(getContext(), deviceProfile, + widgetItem); float previewHeight = widgetSize.getHeight() * previewScale; rowHeight = Math.max(rowHeight, previewHeight + mWidgetCellTextViewsHeight + mWidgetCellVerticalPadding); diff --git a/src/com/android/launcher3/widget/util/WidgetSizes.java b/src/com/android/launcher3/widget/util/WidgetSizes.java index 6d053be812..e2c84b5770 100644 --- a/src/com/android/launcher3/widget/util/WidgetSizes.java +++ b/src/com/android/launcher3/widget/util/WidgetSizes.java @@ -32,6 +32,7 @@ import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; import com.android.launcher3.LauncherAppState; +import com.android.launcher3.model.WidgetItem; import java.util.ArrayList; import java.util.List; @@ -70,6 +71,32 @@ public final class WidgetSizes { return getWidgetSizePx(profile, spanX, spanY, /* recycledCellSize= */ null); } + /** + * Returns the size, in pixels and removing padding, a widget of given spans & {@code profile}. + */ + public static Size getWidgetPaddedSizePx(Context context, ComponentName component, + DeviceProfile profile, int spanX, int spanY) { + Size size = getWidgetSizePx(profile, spanX, spanY); + if (profile.shouldInsetWidgets()) { + return size; + } + Rect padding = getDefaultPaddingForWidget(context, component, /* padding= */ null); + return new Size(size.getWidth() - padding.left - padding.right, + size.getHeight() - padding.top - padding.bottom); + } + + /** + * Returns the size of a WidgetItem. + */ + public static Size getWidgetItemSizePx(Context context, DeviceProfile profile, + WidgetItem widgetItem) { + if (widgetItem.isShortcut()) { + return getWidgetSizePx(profile, widgetItem.spanX, widgetItem.spanY); + } + return getWidgetPaddedSizePx(context, widgetItem.componentName, profile, widgetItem.spanX, + widgetItem.spanY); + } + private static Size getWidgetSizePx(DeviceProfile profile, int spanX, int spanY, @Nullable Point recycledCellSize) { final int hBorderSpacing = (spanX - 1) * profile.cellLayoutBorderSpacingPx;