From 8aa4b05d2244ddc57ecd7cdc986f4cddad37f093 Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Fri, 18 Feb 2022 11:11:25 -0800 Subject: [PATCH 1/9] Remove popup container drag listener on close complete. Bug: 217162588 Test: Verified removal once drag is finished. Verified working on secondary display launcher. Change-Id: I16515518c6d488b74450456306abbfff646ac11b Merged-In: I16515518c6d488b74450456306abbfff646ac11b --- src/com/android/launcher3/popup/PopupContainerWithArrow.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index b2619701b8..6d2b12f451 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -486,6 +486,9 @@ public class PopupContainerWithArrow @Override protected void closeComplete() { super.closeComplete(); + if (mActivityContext.getDragController() != null) { + mActivityContext.getDragController().removeDragListener(this); + } PopupContainerWithArrow openPopup = getOpen(mActivityContext); if (openPopup == null || openPopup.mOriginalIcon != mOriginalIcon) { mOriginalIcon.setTextVisibility(mOriginalIcon.shouldTextBeVisible()); From a8fe8b448e79677c10e5784b66168ba08b3a9fd2 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Thu, 10 Feb 2022 18:00:06 +0800 Subject: [PATCH 2/9] Cancel recents animation when touch home key(2/2) There should send an opening task transition to remote transition handler to finish the recents animation. For now there is no opening transition send to Shell because the exist home activity won't be collected while start home activity. To collect the home activity, do not set transient launch when start recents animation if the top activity is home, so the home activity would be paused. Then when user touch home key to cancel recents, the home activity will be resumed so it can be collect to the transition. When receive opening home activity while recents is running, enter home and dismiss recents. Bug: 207297486 Test: 1. Enable shell transition. 2. Setup 3rd-party launcher as default home. 3. Entering Recents from home. 4. "adb shell input keyevent KEYCODE_HOME", verify recents animation will be dismissed. Test: atest NexusLauncherTests:com.android.quickstep.FallbackRecentsTest Change-Id: I689032d1fa18aa9a923aaf89077dbd73c09721b7 --- .../quickstep/TaskAnimationManager.java | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index 5e298f4b8d..783c868a19 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -44,7 +44,7 @@ import com.android.systemui.shared.system.RemoteTransitionCompat; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; -import java.util.Arrays; +import java.util.ArrayList; import java.util.HashMap; public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAnimationListener { @@ -156,12 +156,26 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn RemoteAnimationTargetCompat appearedTaskTarget = appearedTaskTargets[0]; BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface(); // Convert appTargets to type RemoteAnimationTarget for all apps except Home app - RemoteAnimationTarget[] nonHomeApps = Arrays.stream(appearedTaskTargets) - .filter(remoteAnimationTarget -> - remoteAnimationTarget.activityType != ACTIVITY_TYPE_HOME) + final ArrayList tmpNonHomeApps = new ArrayList<>(); + final ArrayList tmpHomeApps = new ArrayList<>(); + for (RemoteAnimationTargetCompat compat : appearedTaskTargets) { + if (compat.activityType != ACTIVITY_TYPE_HOME) { + tmpNonHomeApps.add(compat); + } else { + tmpHomeApps.add(compat); + } + } + RemoteAnimationTarget[] nonHomeApps = tmpNonHomeApps.stream() .map(RemoteAnimationTargetCompat::unwrap) .toArray(RemoteAnimationTarget[]::new); - + RemoteAnimationTarget[] homeApps = tmpHomeApps.stream() + .map(RemoteAnimationTargetCompat::unwrap) + .toArray(RemoteAnimationTarget[]::new); + if (homeApps.length > 0 + && activityInterface.getCreatedActivity() instanceof RecentsActivity) { + ((RecentsActivity) activityInterface.getCreatedActivity()).startHome(); + return; + } RemoteAnimationTarget[] nonAppTargets = SystemUiProxy.INSTANCE.getNoCreate() .onGoingToRecentsLegacy(false, nonHomeApps); @@ -198,8 +212,16 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn RemoteTransitionCompat transition = new RemoteTransitionCompat(mCallbacks, mController != null ? mController.getController() : null, mCtx.getIApplicationThread()); - final ActivityOptions options = ActivityOptionsCompat.makeRemoteTransition(transition) - .setTransientLaunch(); + final ActivityOptions options = ActivityOptionsCompat.makeRemoteTransition(transition); + // Allowing to pause Home if Home is top activity and Recents is not Home. So when user + // start home when recents animation is playing, the home activity can be resumed again + // to let the transition controller collect Home activity. + ActivityManager.RunningTaskInfo rti = gestureState.getRunningTask(); + boolean homeIsOnTop = rti != null && rti.topActivity != null + && rti.topActivity.equals(gestureState.getHomeIntent().getComponent()); + if (!homeIsOnTop) { + options.setTransientLaunch(); + } options.setSourceInfo(ActivityOptions.SourceInfo.TYPE_RECENTS_ANIMATION, eventTime); UI_HELPER_EXECUTOR.execute(() -> mCtx.startActivity(intent, options.toBundle())); } else { From 6bc4257d86812f369ad06de4f88fd399e42d4dba Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 28 Feb 2022 17:12:27 -0800 Subject: [PATCH 3/9] Separating refresh rate tracking to a separate class Bug: 221961069 Test: Presubmit Change-Id: I04091ebc9f3d88d2dbbde1bf0d5390c815e026d1 --- .../launcher3/LauncherAnimationRunner.java | 2 +- .../launcher3/QuickstepTransitionManager.java | 2 +- .../NoButtonQuickSwitchTouchController.java | 2 +- .../android/quickstep/AbsSwipeUpHandler.java | 2 +- .../SwipeUpGestureTutorialController.java | 2 +- .../launcher3/FirstFrameAnimatorHelper.java | 2 +- .../anim/AnimatorPlaybackController.java | 2 +- .../anim/SpringAnimationBuilder.java | 4 +- src/com/android/launcher3/folder/Folder.java | 2 +- .../AbstractStateChangeTouchController.java | 2 +- .../launcher3/util/DisplayController.java | 43 +--------- .../util/window/RefreshRateTracker.java | 83 +++++++++++++++++++ .../launcher3/views/BaseDragLayer.java | 2 +- .../launcher3/views/FloatingSurfaceView.java | 4 +- 14 files changed, 98 insertions(+), 56 deletions(-) create mode 100644 src/com/android/launcher3/util/window/RefreshRateTracker.java diff --git a/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java b/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java index 661053af18..62603e9d54 100644 --- a/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java +++ b/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java @@ -16,9 +16,9 @@ package com.android.launcher3; import static com.android.launcher3.Utilities.postAsyncCallback; -import static com.android.launcher3.util.DisplayController.getSingleFrameMs; 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.window.RefreshRateTracker.getSingleFrameMs; import static com.android.systemui.shared.recents.utilities.Utilities.postAtFrontOfQueueAsynchronously; import android.animation.Animator; diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 3eb1935ee8..c4a3fb5572 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -44,7 +44,7 @@ import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVIT import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS; import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID; import static com.android.launcher3.statehandlers.DepthController.DEPTH; -import static com.android.launcher3.util.DisplayController.getSingleFrameMs; +import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION; import static com.android.launcher3.views.FloatingIconView.getFloatingIconView; import static com.android.quickstep.TaskViewUtils.findTaskViewToLaunch; diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index f6148a7c8f..d8f694ec76 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -40,7 +40,7 @@ import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW; import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM; import static com.android.launcher3.touch.BothAxesSwipeDetector.DIRECTION_RIGHT; import static com.android.launcher3.touch.BothAxesSwipeDetector.DIRECTION_UP; -import static com.android.launcher3.util.DisplayController.getSingleFrameMs; +import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import static com.android.quickstep.util.VibratorWrapper.OVERVIEW_HAPTIC; import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_OFFSET; import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA; diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 2cb7100378..b7d3aa03f7 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -32,10 +32,10 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_OVERVIEW_GESTURE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_LEFT; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_RIGHT; -import static com.android.launcher3.util.DisplayController.getSingleFrameMs; 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.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import static com.android.quickstep.GestureState.GestureEndTarget.HOME; import static com.android.quickstep.GestureState.GestureEndTarget.LAST_TASK; import static com.android.quickstep.GestureState.GestureEndTarget.NEW_TASK; diff --git a/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java index 672687da29..9a101b9651 100644 --- a/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java +++ b/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java @@ -16,7 +16,7 @@ package com.android.quickstep.interaction; import static com.android.launcher3.anim.Interpolators.ACCEL; -import static com.android.launcher3.util.DisplayController.getSingleFrameMs; +import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION; import static com.android.quickstep.AbsSwipeUpHandler.MAX_SWIPE_DURATION; import static com.android.quickstep.interaction.TutorialController.TutorialType.HOME_NAVIGATION_COMPLETE; diff --git a/src/com/android/launcher3/FirstFrameAnimatorHelper.java b/src/com/android/launcher3/FirstFrameAnimatorHelper.java index a199a5779a..fdf0101e66 100644 --- a/src/com/android/launcher3/FirstFrameAnimatorHelper.java +++ b/src/com/android/launcher3/FirstFrameAnimatorHelper.java @@ -15,7 +15,7 @@ */ package com.android.launcher3; -import static com.android.launcher3.util.DisplayController.getSingleFrameMs; +import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; diff --git a/src/com/android/launcher3/anim/AnimatorPlaybackController.java b/src/com/android/launcher3/anim/AnimatorPlaybackController.java index 85ca280ba2..1cc0c21745 100644 --- a/src/com/android/launcher3/anim/AnimatorPlaybackController.java +++ b/src/com/android/launcher3/anim/AnimatorPlaybackController.java @@ -19,7 +19,7 @@ import static com.android.launcher3.Utilities.boundToRange; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.clampToProgress; import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity; -import static com.android.launcher3.util.DisplayController.getSingleFrameMs; +import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import android.animation.Animator; import android.animation.Animator.AnimatorListener; diff --git a/src/com/android/launcher3/anim/SpringAnimationBuilder.java b/src/com/android/launcher3/anim/SpringAnimationBuilder.java index bd52158f0a..40fa0cfd02 100644 --- a/src/com/android/launcher3/anim/SpringAnimationBuilder.java +++ b/src/com/android/launcher3/anim/SpringAnimationBuilder.java @@ -25,7 +25,7 @@ import android.util.FloatProperty; import androidx.annotation.FloatRange; import androidx.dynamicanimation.animation.SpringForce; -import com.android.launcher3.util.DisplayController; +import com.android.launcher3.util.window.RefreshRateTracker; /** * Utility class to build an object animator which follows the same path as a spring animation for @@ -134,7 +134,7 @@ public class SpringAnimationBuilder { } public SpringAnimationBuilder computeParams() { - int singleFrameMs = DisplayController.getSingleFrameMs(mContext); + int singleFrameMs = RefreshRateTracker.getSingleFrameMs(mContext); double naturalFreq = Math.sqrt(mStiffness); double dampedFreq = naturalFreq * Math.sqrt(1 - mDampingRatio * mDampingRatio); diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 1e6342cc8b..891651996b 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -24,7 +24,7 @@ import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustom import static com.android.launcher3.config.FeatureFlags.ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_LABEL_UPDATED; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED; -import static com.android.launcher3.util.DisplayController.getSingleFrameMs; +import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index 61d488c91b..c00e174920 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -26,7 +26,7 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_UNKNOWN_SWIPEDOWN; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_UNKNOWN_SWIPEUP; -import static com.android.launcher3.util.DisplayController.getSingleFrameMs; +import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import android.animation.Animator.AnimatorListener; import android.animation.ValueAnimator; diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java index ba925f5256..79634019a6 100644 --- a/src/com/android/launcher3/util/DisplayController.java +++ b/src/com/android/launcher3/util/DisplayController.java @@ -20,7 +20,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static com.android.launcher3.Utilities.dpiFromPx; 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.WindowManagerCompat.MIN_TABLET_WIDTH; import static java.util.Collections.emptyMap; @@ -34,7 +33,6 @@ import android.content.IntentFilter; import android.content.res.Configuration; import android.graphics.Point; import android.hardware.display.DisplayManager; -import android.hardware.display.DisplayManager.DisplayListener; import android.os.Build; import android.text.TextUtils; import android.util.ArrayMap; @@ -44,7 +42,6 @@ import android.view.Display; import androidx.annotation.AnyThread; import androidx.annotation.UiThread; -import androidx.annotation.WorkerThread; import com.android.launcher3.Utilities; import com.android.launcher3.uioverrides.ApiWrapper; @@ -58,7 +55,7 @@ import java.util.Set; * Utility class to cache properties of default display to avoid a system RPC on every call. */ @SuppressLint("NewApi") -public class DisplayController implements DisplayListener, ComponentCallbacks, SafeCloseable { +public class DisplayController implements ComponentCallbacks, SafeCloseable { private static final String TAG = "DisplayController"; @@ -102,7 +99,6 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S } mInfo = new Info(getDisplayInfoContext(display), display, getInternalDisplays(mDM), emptyMap()); - mDM.registerDisplayListener(this, UI_HELPER_EXECUTOR.getHandler()); } private static ArrayMap getInternalDisplays( @@ -128,35 +124,6 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S } else { // TODO: unregister broadcast receiver } - mDM.unregisterDisplayListener(this); - } - - @Override - public final void onDisplayAdded(int displayId) { } - - @Override - public final void onDisplayRemoved(int displayId) { } - - @WorkerThread - @Override - public final void onDisplayChanged(int displayId) { - if (displayId != DEFAULT_DISPLAY) { - return; - } - Display display = mDM.getDisplay(DEFAULT_DISPLAY); - if (display == null) { - return; - } - if (Utilities.ATLEAST_S) { - // Only update refresh rate. Everything else comes from component callbacks - mInfo.mSingleFrameMs = getSingleFrameMs(display); - return; - } - handleInfoChange(display); - } - - public static int getSingleFrameMs(Context context) { - return INSTANCE.get(context).getInfo().mSingleFrameMs; } /** @@ -287,8 +254,6 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S public static class Info { - private int mSingleFrameMs; - // Configuration properties public final int rotation; public final float fontScale; @@ -318,7 +283,6 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S densityDpi = config.densityDpi; mScreenSizeDp = new PortraitSize(config.screenHeightDp, config.screenWidthDp); - mSingleFrameMs = getSingleFrameMs(display); currentSize = new Point(); display.getRealSize(currentSize); @@ -400,9 +364,4 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S return Objects.hash(width, height); } } - - private static int getSingleFrameMs(Display display) { - float refreshRate = display.getRefreshRate(); - return refreshRate > 0 ? (int) (1000 / refreshRate) : 16; - } } diff --git a/src/com/android/launcher3/util/window/RefreshRateTracker.java b/src/com/android/launcher3/util/window/RefreshRateTracker.java new file mode 100644 index 0000000000..7814617b9e --- /dev/null +++ b/src/com/android/launcher3/util/window/RefreshRateTracker.java @@ -0,0 +1,83 @@ +/* + * 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.util.window; + +import static android.view.Display.DEFAULT_DISPLAY; + +import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; + +import android.content.Context; +import android.hardware.display.DisplayManager; +import android.hardware.display.DisplayManager.DisplayListener; +import android.view.Display; + +import androidx.annotation.WorkerThread; + +import com.android.launcher3.util.MainThreadInitializedObject; +import com.android.launcher3.util.SafeCloseable; + +/** + * Utility class to track refresh rate of the current device + */ +public class RefreshRateTracker implements DisplayListener, SafeCloseable { + + private static final MainThreadInitializedObject INSTANCE = + new MainThreadInitializedObject<>(RefreshRateTracker::new); + + private int mSingleFrameMs = 1; + + private final DisplayManager mDM; + + private RefreshRateTracker(Context context) { + mDM = context.getSystemService(DisplayManager.class); + updateSingleFrameMs(); + mDM.registerDisplayListener(this, UI_HELPER_EXECUTOR.getHandler()); + } + + /** + * Returns the single frame time in ms + */ + public static int getSingleFrameMs(Context context) { + return INSTANCE.get(context).mSingleFrameMs; + } + + @Override + public final void onDisplayAdded(int displayId) { } + + @Override + public final void onDisplayRemoved(int displayId) { } + + @WorkerThread + @Override + public final void onDisplayChanged(int displayId) { + if (displayId == DEFAULT_DISPLAY) { + updateSingleFrameMs(); + } + } + + private void updateSingleFrameMs() { + Display display = mDM.getDisplay(DEFAULT_DISPLAY); + if (display != null) { + float refreshRate = display.getRefreshRate(); + mSingleFrameMs = refreshRate > 0 ? (int) (1000 / refreshRate) : 16; + } + } + + @Override + public void close() { + mDM.unregisterDisplayListener(this); + } +} diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index 76dfb3ce2a..f71aa13fdd 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -20,7 +20,7 @@ import static android.view.MotionEvent.ACTION_CANCEL; import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_UP; -import static com.android.launcher3.util.DisplayController.getSingleFrameMs; +import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import android.annotation.TargetApi; import android.app.WallpaperManager; diff --git a/src/com/android/launcher3/views/FloatingSurfaceView.java b/src/com/android/launcher3/views/FloatingSurfaceView.java index e7cb3b3d13..7f54d6dce5 100644 --- a/src/com/android/launcher3/views/FloatingSurfaceView.java +++ b/src/com/android/launcher3/views/FloatingSurfaceView.java @@ -40,8 +40,8 @@ import com.android.launcher3.GestureNavContract; import com.android.launcher3.Insettable; import com.android.launcher3.Launcher; import com.android.launcher3.R; -import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.Executors; +import com.android.launcher3.util.window.RefreshRateTracker; /** * Similar to {@link FloatingIconView} but displays a surface with the targetIcon. It then passes @@ -97,7 +97,7 @@ public class FloatingSurfaceView extends AbstractFloatingView implements // Remove after some time, to avoid flickering Executors.MAIN_EXECUTOR.getHandler().postDelayed(mRemoveViewRunnable, - DisplayController.getSingleFrameMs(mLauncher)); + RefreshRateTracker.getSingleFrameMs(mLauncher)); } private void removeViewFromParent() { From 5a915fb8834fc9b12aa4a2e72f1eb3fcf7852199 Mon Sep 17 00:00:00 2001 From: Iris Yang Date: Thu, 17 Feb 2022 03:20:37 +0000 Subject: [PATCH 4/9] Get display id from display instead of the display of root view Since `getRootView()` will increase the execution time, use `getDisplay()` instead. Bug: 202825727 Test: manually Change-Id: I22ef58cb39716433cd8e91200837ab49229ae3e1 (cherry picked from commit 6a06d8615f24769381e340a544c71d56a79ff25c) --- quickstep/src/com/android/quickstep/views/TaskView.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 984b0efb55..1d621dc740 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -725,7 +725,8 @@ public class TaskView extends FrameLayout implements Reusable { TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "startActivityFromRecentsAsync", mTask); ActivityOptionsWrapper opts = mActivity.getActivityLaunchOptions(this, null); - opts.options.setLaunchDisplayId(getRootViewDisplayId()); + opts.options.setLaunchDisplayId( + getDisplay() == null ? DEFAULT_DISPLAY : getDisplay().getDisplayId()); if (ActivityManagerWrapper.getInstance() .startActivityFromRecents(mTask.key, opts.options)) { RecentsView recentsView = getRecentsView(); @@ -766,7 +767,8 @@ public class TaskView extends FrameLayout implements Reusable { // Indicate success once the system has indicated that the transition has started ActivityOptions opts = ActivityOptionsCompat.makeCustomAnimation( getContext(), 0, 0, () -> callback.accept(true), MAIN_EXECUTOR.getHandler()); - opts.setLaunchDisplayId(getRootViewDisplayId()); + opts.setLaunchDisplayId( + getDisplay() == null ? DEFAULT_DISPLAY : getDisplay().getDisplayId()); if (freezeTaskList) { ActivityOptionsCompat.setFreezeRecentTasksList(opts); } From ede8ad8ec9102c3a3dae63dc88c13ba814b73831 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 3 Mar 2022 18:23:03 +0000 Subject: [PATCH 5/9] Use shared insets resize animation duration for taskbar stashing This is a no-op since they are the same value (by design), but using the constant directly will prevent potential divergences in the future. Test: none Bug: 191269755 Change-Id: I81b98045466398b7a49de872694004e526adf048 --- .../com/android/launcher3/taskbar/TaskbarStashController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 1d5fa4d47b..a4f5a25fd6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -33,6 +33,7 @@ import com.android.launcher3.Utilities; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.quickstep.AnimatedFloat; import com.android.quickstep.SystemUiProxy; +import com.android.systemui.shared.system.WindowManagerWrapper; import java.io.PrintWriter; import java.util.StringJoiner; @@ -68,7 +69,8 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba /** * How long to stash/unstash when manually invoked via long press. */ - public static final long TASKBAR_STASH_DURATION = 300; + public static final long TASKBAR_STASH_DURATION = + WindowManagerWrapper.ANIMATION_DURATION_RESIZE; /** * How long to stash/unstash when keyboard is appearing/disappearing. From 1d7848aedb4f809e5415b5e517b2ad73de72cea2 Mon Sep 17 00:00:00 2001 From: Thiru Ramasamy Date: Mon, 28 Feb 2022 20:03:21 -0800 Subject: [PATCH 6/9] Add OneSearch SuggestionType enums to launcher atom. Bug: 222001231 Test: wwdebug && wwlogcat - http://gpaste/6024652376768512 Change-Id: I6062a5fc6c4046521923f564b99a8150c561c0a2 --- protos/launcher_atom.proto | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/protos/launcher_atom.proto b/protos/launcher_atom.proto index c5599887dd..84892f190a 100644 --- a/protos/launcher_atom.proto +++ b/protos/launcher_atom.proto @@ -156,6 +156,12 @@ enum Attribute { ALL_APPS_SEARCH_RESULT_LEGACY_SHORTCUT = 30; ALL_APPS_SEARCH_RESULT_ASSISTANT_MEMORY = 31; + // Suggestion Type provided by AGA + ONE_SEARCH_WEB_QUERY = 32; + ONE_SEARCH_WEB_TRENDING = 33; + ONE_SEARCH_WEB_ENTITY = 34; + ONE_SEARCH_WEB_ANSWER = 35; + WIDGETS_BOTTOM_TRAY = 28; WIDGETS_TRAY_PREDICTION = 29; } From 27d33e299469fbc627be8c346555e91630502721 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 3 Mar 2022 06:35:03 +0000 Subject: [PATCH 7/9] Address some insets issues in Taskbar All Apps - Don't report insets change to underlying app when stashing taskbar during all apps transition - Internally override all apps insets to take stashing into account - Don't offset all apps window by display cutouts, as we handle them internally via padding internally - Also Fix bug where "stashing" taskbar in 3 button mode (which just fades out taskbar icons but keeps nav buttons) was reporting smaller insets to apps Test: 1) open all apps in Calculator, ensure Calculator doesn't adjust insets and all apps has bottom content padding but no nav scrim 2) in 3 button mode, scroll to bottom of all apps and can read last row icon labels 3) enable display cutout in developer options, ensure no change to tests 1 and 2, and all apps scrim fills the screen (including behind cutout) Fixes: 219980805 Change-Id: Ic3c6a744bc675e4ea277d22c4c0b3b353eddd905 --- .../taskbar/TaskbarStashController.java | 10 ++--- .../allapps/TaskbarAllAppsContext.java | 41 +++++++++++++++++++ .../allapps/TaskbarAllAppsController.java | 2 + 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 1d5fa4d47b..d083602a78 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -60,10 +60,10 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba // If any of these flags are enabled, inset apps by our stashed height instead of our unstashed // height. This way the reported insets are consistent even during transitions out of the app. - // Currently any flag that causes us to stash in an app is included, except for IME since that - // covers the underlying app anyway and thus the app shouldn't change insets. + // Currently any flag that causes us to stash in an app is included, except for IME or All Apps + // since those cover the underlying app anyway and thus the app shouldn't change insets. private static final int FLAGS_REPORT_STASHED_INSETS_TO_APP = FLAGS_STASHED_IN_APP - & ~FLAG_STASHED_IN_APP_IME; + & ~FLAG_STASHED_IN_APP_IME & ~FLAG_STASHED_IN_APP_ALL_APPS; /** * How long to stash/unstash when manually invoked via long press. @@ -187,7 +187,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * Returns whether the taskbar can visually stash into a handle based on the current device * state. */ - private boolean supportsVisualStashing() { + public boolean supportsVisualStashing() { return !mActivity.isThreeButtonNav(); } @@ -254,7 +254,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * Returns the height that taskbar will inset when inside apps. */ public int getContentHeightToReportToApps() { - if (hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) { + if (supportsVisualStashing() && hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) { boolean isAnimating = mAnimator != null && mAnimator.isStarted(); return mControllers.stashedHandleViewController.isStashedHandleVisible() || isAnimating ? mStashedHeight : 0; diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java index 7f3add3761..a67ca7089b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java @@ -22,8 +22,10 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION; import android.content.Context; +import android.graphics.Insets; import android.view.KeyEvent; import android.view.View; +import android.view.WindowInsets; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.DeviceProfile; @@ -59,6 +61,10 @@ class TaskbarAllAppsContext extends BaseTaskbarContext { private final TaskbarAllAppsDragLayer mDragLayer; private final TaskbarAllAppsContainerView mAppsView; + // We automatically stash taskbar when all apps is opened in gesture navigation mode. + private final boolean mWillTaskbarBeVisuallyStashed; + private final int mStashedTaskbarHeight; + TaskbarAllAppsContext( TaskbarActivityContext taskbarContext, TaskbarAllAppsController windowController, @@ -79,6 +85,9 @@ class TaskbarAllAppsContext extends BaseTaskbarContext { windowController, taskbarStashController); mAppsView = slideInView.getAppsView(); + + mWillTaskbarBeVisuallyStashed = taskbarStashController.supportsVisualStashing(); + mStashedTaskbarHeight = taskbarStashController.getStashedHeight(); } TaskbarAllAppsViewController getAllAppsViewController() { @@ -189,5 +198,37 @@ class TaskbarAllAppsContext extends BaseTaskbarContext { inoutInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION); } } + + @Override + public WindowInsets onApplyWindowInsets(WindowInsets insets) { + return updateInsetsDueToStashing(insets); + } + + /** + * Taskbar automatically stashes when opening all apps, but we don't report the insets as + * changing to avoid moving the underlying app. But internally, the apps view should still + * layout according to the stashed insets rather than the unstashed insets. So this method + * does two things: + * 1) Sets navigationBars bottom inset to stashedHeight. + * 2) Sets tappableInsets bottom inset to 0. + */ + private WindowInsets updateInsetsDueToStashing(WindowInsets oldInsets) { + if (!mActivity.mWillTaskbarBeVisuallyStashed) { + return oldInsets; + } + WindowInsets.Builder updatedInsetsBuilder = new WindowInsets.Builder(oldInsets); + + Insets oldNavInsets = oldInsets.getInsets(WindowInsets.Type.navigationBars()); + Insets newNavInsets = Insets.of(oldNavInsets.left, oldNavInsets.top, oldNavInsets.right, + mActivity.mStashedTaskbarHeight); + updatedInsetsBuilder.setInsets(WindowInsets.Type.navigationBars(), newNavInsets); + + Insets oldTappableInsets = oldInsets.getInsets(WindowInsets.Type.tappableElement()); + Insets newTappableInsets = Insets.of(oldTappableInsets.left, oldTappableInsets.top, + oldTappableInsets.right, 0); + updatedInsetsBuilder.setInsets(WindowInsets.Type.tappableElement(), newTappableInsets); + + return updatedInsetsBuilder.build(); + } } } diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java index 87133fcb5a..321ff79308 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.taskbar.allapps; +import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static com.android.launcher3.AbstractFloatingView.TYPE_ALL; @@ -158,6 +159,7 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList layoutParams.gravity = Gravity.BOTTOM; layoutParams.packageName = mTaskbarContext.getPackageName(); layoutParams.setFitInsetsTypes(0); // Handled by container view. + layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; layoutParams.setSystemApplicationOverlay(true); return layoutParams; } From 854f34dcc3cfa3d4645d435364f7d8fed9d11d35 Mon Sep 17 00:00:00 2001 From: thiruram Date: Wed, 2 Mar 2022 10:42:44 -0800 Subject: [PATCH 8/9] Add empty implementation for item_attributes field on Launcher. Test: make -j64 NexusLauncher Change-Id: Ie2781017018b9c0397f2322399cbd0267c988296 (cherry picked from commit e294eadc7425a9066c67fd11ab3f59bbd04920cc) --- .../quickstep/logging/StatsLogCompatManager.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java index 12a638a804..04fc3ba181 100644 --- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java +++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java @@ -141,7 +141,9 @@ public class StatsLogCompatManager extends StatsLogManager { getCardinality(info) /* cardinality */, info.getWidget().getSpanX(), info.getWidget().getSpanY(), - getFeatures(info)); + getFeatures(info), + null /* attributes */ + ); } /** @@ -170,7 +172,8 @@ public class StatsLogCompatManager extends StatsLogManager { info.getAttribute().getNumber(), // attribute_id = 15; getCardinality(info), // cardinality = 16; info.getWidget().getSpanX(), // span_x = 17 [default = 1]; - info.getWidget().getSpanY() // span_y = 18 [default = 1]; + info.getWidget().getSpanY(), // span_y = 18 [default = 1]; + null /* attributes */ ); } @@ -413,7 +416,8 @@ public class StatsLogCompatManager extends StatsLogManager { atomInfo.getFolderIcon().getLabelInfo() /* edittext */, getCardinality(atomInfo) /* cardinality */, getFeatures(atomInfo) /* features */, - getSearchAttributes(atomInfo) /* searchAttributes */ + getSearchAttributes(atomInfo) /* searchAttributes */, + null /* attributes */ ); } } From ac736e7dac6355aead42e6b0315904182935db04 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 3 Mar 2022 20:00:42 +0000 Subject: [PATCH 9/9] Provide content insets while in SUW in portrait mode - We keep the app setup flag set, but adjust the insets to inset SUW itself in portrait Bug: 219879035 Test: With both 3button and gesture nav, verify that portrait mode SUW is always inset Change-Id: Iad0b6c41feaa3fb169af75c071b7f9544b42bab7 --- .../android/launcher3/taskbar/TaskbarStashController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index d083602a78..08e3416a4f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -29,6 +29,7 @@ import android.annotation.Nullable; import android.content.SharedPreferences; import android.view.ViewConfiguration; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.quickstep.AnimatedFloat; @@ -255,6 +256,13 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba */ public int getContentHeightToReportToApps() { if (supportsVisualStashing() && hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) { + DeviceProfile dp = mActivity.getDeviceProfile(); + if (hasAnyFlag(FLAG_STASHED_IN_APP_SETUP) && dp.isTaskbarPresent && !dp.isLandscape) { + // We always show the back button in SUW but in portrait the SUW layout may not + // be wide enough to support overlapping the nav bar with its content. For now, + // just inset by the bar height. + return mUnstashedHeight; + } boolean isAnimating = mAnimator != null && mAnimator.isStarted(); return mControllers.stashedHandleViewController.isStashedHandleVisible() || isAnimating ? mStashedHeight : 0;