Merge "Skip TaskView settledProgress and fullscreenProgress updates for same progress value" into main
diff --git a/aconfig/launcher.aconfig b/aconfig/launcher.aconfig
index cc746eb..ca6e24c 100644
--- a/aconfig/launcher.aconfig
+++ b/aconfig/launcher.aconfig
@@ -636,3 +636,13 @@
description: "Enables gesture navigation handling on connected displays"
bug: "382130680"
}
+
+flag {
+ name: "enable_taskbar_behind_shade"
+ namespace: "lse_desktop_experience"
+ description: "Keeps taskbar behind notification shade when its pulled down"
+ bug: "343194358"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
diff --git a/aconfig/launcher_growth.aconfig b/aconfig/launcher_growth.aconfig
index 35a91d7..a880538 100644
--- a/aconfig/launcher_growth.aconfig
+++ b/aconfig/launcher_growth.aconfig
@@ -1,5 +1,5 @@
package: "com.android.launcher3"
-container: "system"
+container: "system_ext"
flag {
name: "enable_growth_nudge"
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index 3f3700b..2272d11 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -467,10 +467,15 @@
}
@Override
- protected boolean canToggleHomeAllApps() {
- return mLauncher.isResumed()
+ protected void toggleAllApps(boolean focusSearch) {
+ boolean canToggleHomeAllApps = mLauncher.isResumed()
&& !mTaskbarLauncherStateController.isInOverviewUi()
&& !mLauncher.areDesktopTasksVisible();
+ if (canToggleHomeAllApps) {
+ mLauncher.toggleAllApps(focusSearch);
+ return;
+ }
+ super.toggleAllApps(focusSearch);
}
@Override
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index ade75eb..a1620a1 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -608,16 +608,6 @@
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(false);
}
- /** Toggles Taskbar All Apps overlay. */
- public void toggleAllApps() {
- mControllers.taskbarAllAppsController.toggle();
- }
-
- /** Toggles Taskbar All Apps overlay with keyboard ready for search. */
- public void toggleAllAppsSearch() {
- mControllers.taskbarAllAppsController.toggleSearch();
- }
-
@Override
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;
@@ -2070,10 +2060,6 @@
mControllers.keyboardQuickSwitchController.closeQuickSwitchView(false);
}
- boolean canToggleHomeAllApps() {
- return mControllers.uiController.canToggleHomeAllApps();
- }
-
boolean isIconAlignedWithHotseat() {
return mControllers.uiController.isIconAlignedWithHotseat();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
index d531e2c..1b516be 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
@@ -68,6 +68,7 @@
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.dragndrop.DraggableView;
+import com.android.launcher3.folder.Folder;
import com.android.launcher3.graphics.DragPreviewProvider;
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
import com.android.launcher3.logging.StatsLogManager;
@@ -116,6 +117,7 @@
private int mRegistrationY;
private boolean mIsSystemDragInProgress;
+ private boolean mIsDropHandledByDropTarget;
// Animation for the drag shadow back into position after an unsuccessful drag
private ValueAnimator mReturnAnimator;
@@ -252,7 +254,8 @@
/* originalView = */ btv,
dragLayerX + dragOffset.x,
dragLayerY + dragOffset.y,
- (View target, DropTarget.DragObject d, boolean success) -> {} /* DragSource */,
+ (View target, DropTarget.DragObject d, boolean success) ->
+ mIsDropHandledByDropTarget = success /* DragSource */,
btv.getTag() instanceof ItemInfo itemInfo ? itemInfo : null,
dragRect,
scale * iconScale,
@@ -561,7 +564,7 @@
@Override
protected void endDrag() {
- if (mDisallowGlobalDrag) {
+ if (mDisallowGlobalDrag && !mIsDropHandledByDropTarget) {
// We need to explicitly set deferDragViewCleanupPostAnimation to true here so the
// super call doesn't remove it from the drag layer before the animation completes.
// This variable gets set in to false in super.dispatchDropComplete() because it
@@ -765,8 +768,11 @@
@Override
public void addDropTarget(DropTarget target) {
- // No-op as Taskbar currently doesn't support any drop targets internally.
- // Note: if we do add internal DropTargets, we'll still need to ignore Folder.
+ if (target instanceof Folder) {
+ // we need to ignore Folder.
+ return;
+ }
+ super.addDropTarget(target);
}
@Override
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index 943c44e..19e528a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -511,14 +511,14 @@
/**
* Toggles All Apps for Taskbar or Launcher depending on the current state.
*/
- public void toggleAllApps() {
+ public void toggleAllAppsSearch() {
TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
- if (taskbar == null || taskbar.canToggleHomeAllApps()) {
+ if (taskbar == null) {
// Home All Apps should be toggled from this class, because the controllers are not
// initialized when Taskbar is disabled (i.e. TaskbarActivityContext is null).
- if (mActivity instanceof Launcher l) l.toggleAllAppsSearch();
+ if (mActivity instanceof Launcher l) l.toggleAllApps(true);
} else {
- taskbar.toggleAllAppsSearch();
+ taskbar.getControllers().uiController.toggleAllApps(true);
}
}
@@ -756,13 +756,14 @@
}
}
- public void onSystemUiFlagsChanged(@SystemUiStateFlags long systemUiStateFlags) {
+ /** Called when the SysUI flags for a given display change. */
+ public void onSystemUiFlagsChanged(@SystemUiStateFlags long systemUiStateFlags, int displayId) {
if (DEBUG) {
Log.d(TAG, "SysUI flags changed: " + formatFlagChange(systemUiStateFlags,
mSharedState.sysuiStateFlags, QuickStepContract::getSystemUiStateString));
}
mSharedState.sysuiStateFlags = systemUiStateFlags;
- TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
+ TaskbarActivityContext taskbar = getTaskbarForDisplay(displayId);
if (taskbar != null) {
taskbar.updateSysuiStateFlags(systemUiStateFlags, false /* fromInit */);
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index 89bcb41..ea0b81e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -207,9 +207,18 @@
return false;
}
- /** Returns {@code true} if Home All Apps available instead of Taskbar All Apps. */
- protected boolean canToggleHomeAllApps() {
- return false;
+
+ /**
+ * Toggles all apps UI. Default implementation opens Taskbar All Apps, but may be overridden to
+ * open different Alls Apps variant depending on the context.
+ * @param focusSearch indicates whether All Apps should be opened with search input focused.
+ */
+ protected void toggleAllApps(boolean focusSearch) {
+ if (focusSearch) {
+ mControllers.taskbarAllAppsController.toggleSearch();
+ } else {
+ mControllers.taskbarAllAppsController.toggle();
+ }
}
@CallSuper
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java
index c7ef960..066d4df 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java
@@ -66,7 +66,16 @@
InteractionJankMonitorWrapper.begin(v, Cuj.CUJ_LAUNCHER_OPEN_ALL_APPS,
/* tag= */ "TASKBAR_BUTTON");
mActivity.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP);
- mControllers.taskbarAllAppsController.toggle();
+ if (DisplayController.showLockedTaskbarOnHome(mActivity)
+ || DisplayController.showDesktopTaskbarForFreeformDisplay(mActivity)) {
+ // If the taskbar can be shown on the home screen, use mAllAppsToggler to toggle all
+ // apps, which will toggle the launcher activity all apps when on home screen.
+ // TODO(b/395913143): Reconsider this if a gap in taskbar all apps functionality that
+ // prevents users to drag items to workspace is addressed.
+ mControllers.uiController.toggleAllApps(false);
+ } else {
+ mControllers.taskbarAllAppsController.toggle();
+ }
}
/** Trigger All Apps button long click action. */
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarLocationDropTarget.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarLocationDropTarget.kt
new file mode 100644
index 0000000..383f4d2
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarLocationDropTarget.kt
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2025 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.taskbar.bubbles
+
+import android.graphics.Rect
+import android.view.View
+import com.android.launcher3.DropTarget
+import com.android.launcher3.dragndrop.DragOptions
+import com.android.launcher3.model.data.ItemInfo
+import com.android.wm.shell.shared.bubbles.BubbleBarLocation
+
+/**
+ * Implementation of the {@link DropTarget} that handles drag and drop events over the bubble bar
+ * locations.
+ */
+class BubbleBarLocationDropTarget(
+ private val bubbleBarLocation: BubbleBarLocation,
+ private val bubbleBarDragListener: BubbleBarDragListener,
+) : DropTarget {
+
+ /** Controller that takes care of the bubble bar drag events inside launcher process. */
+ interface BubbleBarDragListener {
+
+ /** Called when the drag event is over the bubble bar drop zone. */
+ fun onLauncherItemDraggedOverBubbleBarDragZone(location: BubbleBarLocation)
+
+ /** Called when the drag event leaves the bubble bar drop zone. */
+ fun onLauncherItemDraggedOutsideBubbleBarDropZone()
+
+ /** Called when the drop event happens over the bubble bar drop zone. */
+ fun onLauncherItemDroppedOverBubbleBarDragZone(
+ location: BubbleBarLocation,
+ itemInfo: ItemInfo,
+ )
+
+ /** Gets the hit [rect][android.graphics.Rect] of the bubble bar location. */
+ fun getBubbleBarLocationHitRect(bubbleBarLocation: BubbleBarLocation, outRect: Rect)
+
+ /** Provides the view that will accept the drop. */
+ fun getDropView(): View
+ }
+
+ private var isShowingDropTarget = false
+
+ override fun isDropEnabled(): Boolean = true
+
+ override fun onDrop(dragObject: DropTarget.DragObject, options: DragOptions) {
+ val itemInfo = dragObject.dragInfo ?: return
+ // TODO(b/397459664) : fix task bar icon animation after drop
+ // TODO(b/397459664) : update bubble bar location
+ bubbleBarDragListener.onLauncherItemDroppedOverBubbleBarDragZone(
+ bubbleBarLocation,
+ itemInfo,
+ )
+ }
+
+ override fun onDragEnter(dragObject: DropTarget.DragObject) {}
+
+ override fun onDragOver(dragObject: DropTarget.DragObject) {
+ if (isShowingDropTarget) return
+ isShowingDropTarget = true
+ bubbleBarDragListener.onLauncherItemDraggedOverBubbleBarDragZone(bubbleBarLocation)
+ }
+
+ override fun onDragExit(dragObject: DropTarget.DragObject) {
+ // TODO(b/397459664) : fix the issue for no bubbles, when moving task bar icon out of
+ // the bubble bar drag zone drag ends and swipes gesture swipes the overview
+ if (!isShowingDropTarget) return
+ isShowingDropTarget = false
+ bubbleBarDragListener.onLauncherItemDraggedOutsideBubbleBarDropZone()
+ }
+
+ override fun acceptDrop(dragObject: DropTarget.DragObject): Boolean = true
+
+ override fun prepareAccessibilityDrop() {}
+
+ override fun getHitRectRelativeToDragLayer(outRect: Rect) {
+ bubbleBarDragListener.getBubbleBarLocationHitRect(bubbleBarLocation, outRect)
+ }
+
+ override fun getDropView(): View = bubbleBarDragListener.getDropView()
+}
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
index b90a5b0..1f5c541 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
@@ -24,6 +24,8 @@
import android.animation.Animator;
import android.animation.AnimatorSet;
+import android.content.Intent;
+import android.content.pm.ShortcutInfo;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.PointF;
@@ -43,11 +45,15 @@
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
+import com.android.launcher3.model.data.ItemInfo;
+import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.taskbar.TaskbarActivityContext;
import com.android.launcher3.taskbar.TaskbarControllers;
+import com.android.launcher3.taskbar.TaskbarDragController;
import com.android.launcher3.taskbar.TaskbarInsetsController;
import com.android.launcher3.taskbar.TaskbarSharedState;
import com.android.launcher3.taskbar.TaskbarStashController;
+import com.android.launcher3.taskbar.bubbles.BubbleBarLocationDropTarget.BubbleBarDragListener;
import com.android.launcher3.taskbar.bubbles.animation.BubbleBarViewAnimator;
import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutController;
import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutPositioner;
@@ -59,6 +65,7 @@
import com.android.quickstep.SystemUiProxy;
import com.android.wm.shell.Flags;
import com.android.wm.shell.shared.bubbles.BubbleBarLocation;
+import com.android.wm.shell.shared.bubbles.DeviceConfig;
import java.io.PrintWriter;
import java.util.List;
@@ -117,6 +124,61 @@
updateTranslationY();
setBubbleBarScaleAndPadding(pinningProgress);
});
+ private final BubbleBarDragListener mDragListener = new BubbleBarDragListener() {
+
+ @NonNull
+ @Override
+ public void getBubbleBarLocationHitRect(@NonNull BubbleBarLocation bubbleBarLocation,
+ Rect outRect) {
+ Point screenSize = DisplayController.INSTANCE.get(mActivity).getInfo().currentSize;
+ outRect.top = screenSize.y - mBubbleBarDropTargetSize;
+ outRect.bottom = screenSize.y;
+ if (bubbleBarLocation.isOnLeft(mBarView.isLayoutRtl())) {
+ outRect.left = 0;
+ outRect.right = mBubbleBarDropTargetSize;
+ } else {
+ outRect.left = screenSize.x - mBubbleBarDropTargetSize;
+ outRect.right = screenSize.x;
+ }
+ }
+
+ @Override
+ public void onLauncherItemDroppedOverBubbleBarDragZone(@NonNull BubbleBarLocation location,
+ @NonNull ItemInfo itemInfo) {
+ //TODO(b/397459664) : fix drag interruption when there are no bubbles
+ //TODO(b/397459664) : update bubble bar location
+ ShortcutInfo shortcutInfo = null;
+ if (itemInfo instanceof WorkspaceItemInfo) {
+ shortcutInfo = ((WorkspaceItemInfo) itemInfo).getDeepShortcutInfo();
+ }
+ Intent itemIntent = itemInfo.getIntent();
+ SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.get(mActivity);
+ if (shortcutInfo != null) {
+ systemUiProxy.showShortcutBubble(shortcutInfo);
+ } else if (itemIntent != null && itemIntent.getComponent() != null) {
+ systemUiProxy.showAppBubble(itemIntent, itemInfo.user);
+ }
+ }
+
+ @Override
+ public void onLauncherItemDraggedOutsideBubbleBarDropZone() {
+ //TODO(b/397459664) : hide expanded view drop target
+ onItemDraggedOutsideBubbleBarDropZone();
+ }
+
+ @Override
+ public void onLauncherItemDraggedOverBubbleBarDragZone(
+ @NonNull BubbleBarLocation location) {
+ //TODO(b/397459664) : show expanded view drop target
+ onDragItemOverBubbleBarDragZone(location);
+ }
+
+ @NonNull
+ @Override
+ public View getDropView() {
+ return mBarView;
+ }
+ };
// Modified when swipe up is happening on the bubble bar or task bar.
private float mBubbleBarSwipeUpTranslationY;
@@ -139,8 +201,12 @@
private BubbleBarFlyoutController mBubbleBarFlyoutController;
private BubbleBarPinController mBubbleBarPinController;
private TaskbarSharedState mTaskbarSharedState;
+ private TaskbarDragController mTaskbarDragController;
+ private final BubbleBarLocationDropTarget mBubbleBarLeftDropTarget;
+ private final BubbleBarLocationDropTarget mBubbleBarRightDropTarget;
private final TimeSource mTimeSource = System::currentTimeMillis;
private final int mTaskbarTranslationDelta;
+ private final int mBubbleBarDropTargetSize;
@Nullable
private BubbleBarBoundsChangeListener mBoundsChangeListener;
@@ -158,11 +224,21 @@
R.dimen.bubblebar_transient_taskbar_min_distance);
mDragElevation = res.getDimensionPixelSize(R.dimen.bubblebar_drag_elevation);
mTaskbarTranslationDelta = getBubbleBarTranslationDeltaForTaskbar(activity);
+ if (DeviceConfig.isSmallTablet(mActivity)) {
+ mBubbleBarDropTargetSize = res.getDimensionPixelSize(R.dimen.drag_zone_bubble_fold);
+ } else {
+ mBubbleBarDropTargetSize = res.getDimensionPixelSize(R.dimen.drag_zone_bubble_tablet);
+ }
+ mBubbleBarLeftDropTarget = new BubbleBarLocationDropTarget(BubbleBarLocation.LEFT,
+ mDragListener);
+ mBubbleBarRightDropTarget = new BubbleBarLocationDropTarget(BubbleBarLocation.RIGHT,
+ mDragListener);
}
/** Initializes controller. */
public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers,
TaskbarViewPropertiesProvider taskbarViewPropertiesProvider) {
+ mTaskbarDragController = controllers.taskbarDragController;
mTaskbarSharedState = controllers.getSharedState();
mBubbleStashController = bubbleControllers.bubbleStashController;
mBubbleBarController = bubbleControllers.bubbleBarController;
@@ -264,6 +340,8 @@
mBubbleBarController.updateBubbleBarLocation(location, source);
}
};
+ mTaskbarDragController.addDropTarget(mBubbleBarLeftDropTarget);
+ mTaskbarDragController.addDropTarget(mBubbleBarRightDropTarget);
}
/** Returns animated float property responsible for pinning transition animation. */
@@ -542,7 +620,9 @@
*/
public void onDragItemOverBubbleBarDragZone(@NonNull BubbleBarLocation bubbleBarLocation) {
mBarView.showDropTarget(/* isDropTarget = */ true);
- mIsLocationUpdatedForDropTarget = getBubbleBarLocation() != bubbleBarLocation;
+ boolean isRtl = mBarView.isLayoutRtl();
+ mIsLocationUpdatedForDropTarget = getBubbleBarLocation().isOnLeft(isRtl)
+ != bubbleBarLocation.isOnLeft(isRtl);
if (mIsLocationUpdatedForDropTarget) {
animateBubbleBarLocation(bubbleBarLocation);
}
@@ -1278,6 +1358,8 @@
/** Called when the controller is destroyed. */
public void onDestroy() {
adjustTaskbarAndHotseatToBubbleBarState(/*isBubbleBarExpanded = */false);
+ mTaskbarDragController.removeDropTarget(mBubbleBarLeftDropTarget);
+ mTaskbarDragController.removeDropTarget(mBubbleBarRightDropTarget);
}
/**
diff --git a/quickstep/src/com/android/quickstep/DisplayModel.kt b/quickstep/src/com/android/quickstep/DisplayModel.kt
index cbc2f7d..27a3379 100644
--- a/quickstep/src/com/android/quickstep/DisplayModel.kt
+++ b/quickstep/src/com/android/quickstep/DisplayModel.kt
@@ -20,28 +20,28 @@
import android.hardware.display.DisplayManager
import android.util.Log
import android.util.SparseArray
+import android.view.Display
import androidx.core.util.valueIterator
+import com.android.launcher3.util.Executors
import com.android.quickstep.DisplayModel.DisplayResource
+import java.io.PrintWriter
/** data model for managing resources with lifecycles that match that of the connected display */
abstract class DisplayModel<RESOURCE_TYPE : DisplayResource>(val context: Context) {
companion object {
- private const val TAG = "DisplayViewModel"
+ private const val TAG = "DisplayModel"
private const val DEBUG = false
}
- protected val displayManager =
- context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
- protected val displayResourceArray = SparseArray<RESOURCE_TYPE>()
+ private val displayManager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
+ private val displayResourceArray = SparseArray<RESOURCE_TYPE>()
- abstract fun createDisplayResource(displayId: Int)
-
- protected val displayListener: DisplayManager.DisplayListener =
+ private val displayListener: DisplayManager.DisplayListener =
(object : DisplayManager.DisplayListener {
override fun onDisplayAdded(displayId: Int) {
if (DEBUG) Log.d(TAG, "onDisplayAdded: displayId=$displayId")
- createDisplayResource(displayId)
+ storeDisplayResource(displayId)
}
override fun onDisplayRemoved(displayId: Int) {
@@ -54,6 +54,17 @@
}
})
+ protected abstract fun createDisplayResource(display: Display): RESOURCE_TYPE
+
+ protected fun registerDisplayListener() {
+ displayManager.registerDisplayListener(displayListener, Executors.MAIN_EXECUTOR.handler)
+ // In the scenario where displays were added before this display listener was
+ // registered, we should store the DisplayResources for those displays directly.
+ displayManager.displays
+ .filter { getDisplayResource(it.displayId) == null }
+ .forEach { storeDisplayResource(it.displayId) }
+ }
+
fun destroy() {
displayResourceArray.valueIterator().forEach { displayResource ->
displayResource.cleanup()
@@ -73,7 +84,36 @@
displayResourceArray.remove(displayId)
}
- abstract class DisplayResource() {
+ fun storeDisplayResource(displayId: Int) {
+ if (DEBUG) Log.d(TAG, "store: displayId=$displayId")
+ getDisplayResource(displayId)?.let {
+ return
+ }
+ val display = displayManager.getDisplay(displayId)
+ if (display == null) {
+ if (DEBUG)
+ Log.w(
+ TAG,
+ "storeDisplayResource: could not create display for displayId=$displayId",
+ Exception(),
+ )
+ return
+ }
+ displayResourceArray[displayId] = createDisplayResource(display)
+ }
+
+ fun dump(prefix: String, writer: PrintWriter) {
+ writer.println("${prefix}${this::class.simpleName}: display resources=[")
+
+ displayResourceArray.valueIterator().forEach { displayResource ->
+ displayResource.dump("${prefix}\t", writer)
+ }
+ writer.println("${prefix}]")
+ }
+
+ abstract class DisplayResource {
abstract fun cleanup()
+
+ abstract fun dump(prefix: String, writer: PrintWriter)
}
}
diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java
index e1d4536..699c5df 100644
--- a/quickstep/src/com/android/quickstep/GestureState.java
+++ b/quickstep/src/com/android/quickstep/GestureState.java
@@ -30,6 +30,7 @@
import android.content.Intent;
import android.os.SystemClock;
+import android.view.Display;
import android.view.MotionEvent;
import android.view.RemoteAnimationTarget;
import android.window.TransitionInfo;
@@ -158,6 +159,7 @@
private final BaseContainerInterface mContainerInterface;
private final MultiStateCallback mStateCallback;
private final int mGestureId;
+ private final int mDisplayId;
public enum TrackpadGestureType {
NONE,
@@ -190,7 +192,8 @@
private boolean mHandlingAtomicEvent;
private boolean mIsInExtendedSlopRegion;
- public GestureState(OverviewComponentObserver componentObserver, int gestureId) {
+ public GestureState(OverviewComponentObserver componentObserver, int displayId, int gestureId) {
+ mDisplayId = displayId;
mHomeIntent = componentObserver.getHomeIntent();
mOverviewIntent = componentObserver.getOverviewIntent();
mContainerInterface = componentObserver.getContainerInterface();
@@ -200,6 +203,7 @@
}
public GestureState(GestureState other) {
+ mDisplayId = other.mDisplayId;
mHomeIntent = other.mHomeIntent;
mOverviewIntent = other.mOverviewIntent;
mContainerInterface = other.mContainerInterface;
@@ -214,6 +218,7 @@
public GestureState() {
// Do nothing, only used for initializing the gesture state prior to user unlock
+ mDisplayId = Display.DEFAULT_DISPLAY;
mHomeIntent = new Intent();
mOverviewIntent = new Intent();
mContainerInterface = null;
@@ -285,6 +290,13 @@
}
/**
+ * @return the id for the display this particular gesture was performed on.
+ */
+ public int getDisplayId() {
+ return mDisplayId;
+ }
+
+ /**
* Sets if the gesture is is from the trackpad, if so, whether 3-finger, or 4-finger
*/
public void setTrackpadGestureType(TrackpadGestureType trackpadGestureType) {
@@ -545,6 +557,7 @@
public void dump(String prefix, PrintWriter pw) {
pw.println(prefix + "GestureState:");
+ pw.println(prefix + "\tdisplayID=" + mDisplayId);
pw.println(prefix + "\tgestureID=" + mGestureId);
pw.println(prefix + "\trunningTask=" + mRunningTask);
pw.println(prefix + "\tendTarget=" + mEndTarget);
diff --git a/quickstep/src/com/android/quickstep/InputConsumer.java b/quickstep/src/com/android/quickstep/InputConsumer.java
index 0185737..081ed9d 100644
--- a/quickstep/src/com/android/quickstep/InputConsumer.java
+++ b/quickstep/src/com/android/quickstep/InputConsumer.java
@@ -17,6 +17,7 @@
import android.annotation.TargetApi;
import android.os.Build;
+import android.view.Display;
import android.view.InputEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -66,6 +67,10 @@
int getType();
+ default int getDisplayId() {
+ return Display.DEFAULT_DISPLAY;
+ }
+
/**
* Returns true if the user has crossed the threshold for it to be an explicit action.
*/
diff --git a/quickstep/src/com/android/quickstep/InputConsumerUtils.kt b/quickstep/src/com/android/quickstep/InputConsumerUtils.kt
index c340c92..cd3ac12 100644
--- a/quickstep/src/com/android/quickstep/InputConsumerUtils.kt
+++ b/quickstep/src/com/android/quickstep/InputConsumerUtils.kt
@@ -76,7 +76,12 @@
val bubbleControllers = tac?.bubbleControllers
if (bubbleControllers != null && BubbleBarInputConsumer.isEventOnBubbles(tac, event)) {
val consumer: InputConsumer =
- BubbleBarInputConsumer(context, bubbleControllers, inputMonitorCompat)
+ BubbleBarInputConsumer(
+ context,
+ gestureState.displayId,
+ bubbleControllers,
+ inputMonitorCompat,
+ )
logInputConsumerSelectionReason(
consumer,
newCompoundString("event is on bubbles, creating new input consumer"),
@@ -285,7 +290,13 @@
"%ssystem dialog is showing, using SysUiOverlayInputConsumer",
SUBSTRING_PREFIX,
)
- base = SysUiOverlayInputConsumer(context, deviceState, inputMonitorCompat)
+ base =
+ SysUiOverlayInputConsumer(
+ context,
+ gestureState.displayId,
+ deviceState,
+ inputMonitorCompat,
+ )
}
if (
@@ -299,7 +310,13 @@
"%sTrackpad 3-finger gesture, using TrackpadStatusBarInputConsumer",
SUBSTRING_PREFIX,
)
- base = TrackpadStatusBarInputConsumer(context, base, inputMonitorCompat)
+ base =
+ TrackpadStatusBarInputConsumer(
+ context,
+ gestureState.displayId,
+ base,
+ inputMonitorCompat,
+ )
}
if (deviceState.isScreenPinningActive) {
@@ -322,7 +339,14 @@
reasonPrefix,
SUBSTRING_PREFIX,
)
- base = OneHandedModeInputConsumer(context, deviceState, base, inputMonitorCompat)
+ base =
+ OneHandedModeInputConsumer(
+ context,
+ gestureState.displayId,
+ deviceState,
+ base,
+ inputMonitorCompat,
+ )
}
if (deviceState.isAccessibilityMenuAvailable) {
@@ -332,7 +356,14 @@
reasonPrefix,
SUBSTRING_PREFIX,
)
- base = AccessibilityInputConsumer(context, deviceState, base, inputMonitorCompat)
+ base =
+ AccessibilityInputConsumer(
+ context,
+ gestureState.displayId,
+ deviceState,
+ base,
+ inputMonitorCompat,
+ )
}
} else {
val reasonPrefix = "device is not in gesture navigation mode"
@@ -354,7 +385,14 @@
reasonPrefix,
SUBSTRING_PREFIX,
)
- base = OneHandedModeInputConsumer(context, deviceState, base, inputMonitorCompat)
+ base =
+ OneHandedModeInputConsumer(
+ context,
+ gestureState.displayId,
+ deviceState,
+ base,
+ inputMonitorCompat,
+ )
}
}
logInputConsumerSelectionReason(base, reasonString)
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt b/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
index afdb403..fff85f6 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
@@ -399,6 +399,7 @@
val gestureState =
touchInteractionService.createGestureState(
+ focusedDisplayId,
GestureState.DEFAULT_STATE,
GestureState.TrackpadGestureType.NONE,
)
diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java
index a178c3c..f506039 100644
--- a/quickstep/src/com/android/quickstep/RecentTasksList.java
+++ b/quickstep/src/com/android/quickstep/RecentTasksList.java
@@ -410,7 +410,7 @@
tmpLockedUsers.get(task2Key.userId) /* isLocked */);
} else {
// Is fullscreen task
- if (!isFirstVisibleTaskFound) {
+ if (isFirstVisibleTaskFound) {
boolean isExcluded = (taskInfo1.baseIntent.getFlags()
& FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
if (taskInfo1.isTopActivityTransparent && isExcluded) {
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index 090ccdc..6710096 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -88,6 +88,9 @@
import com.android.systemui.shared.system.TaskStackChangeListeners;
import java.io.PrintWriter;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
@@ -119,6 +122,7 @@
InputMethodService.canImeRenderGesturalNavButtons();
private @SystemUiStateFlags long mSystemUiStateFlags = QuickStepContract.SYSUI_STATE_AWAKE;
+ private final Map<Integer, Long> mSysUIStateFlagsPerDisplay = new ConcurrentHashMap<>();
private NavigationMode mMode = THREE_BUTTONS;
private NavBarPosition mNavBarPosition;
@@ -321,13 +325,6 @@
}
/**
- * @return the display id for the display that Launcher is running on.
- */
- public int getDisplayId() {
- return DEFAULT_DISPLAY;
- }
-
- /**
* @return whether the user has completed setup wizard
*/
public boolean isUserSetupComplete() {
@@ -353,22 +350,51 @@
}
/**
- * Updates the system ui state flags from SystemUI.
+ * Updates the system ui state flags from SystemUI for a specific display.
+ *
+ * @param stateFlags the current {@link SystemUiStateFlags} for the display.
+ * @param displayId the display's ID.
*/
- public void setSystemUiFlags(@SystemUiStateFlags long stateFlags) {
- mSystemUiStateFlags = stateFlags;
+ public void setSysUIStateFlagsForDisplay(@SystemUiStateFlags long stateFlags,
+ int displayId) {
+ mSysUIStateFlagsPerDisplay.put(displayId, stateFlags);
}
/**
- * @return the system ui state flags.
+ * Clears the system ui state flags for a specific display. This is called when the display is
+ * destroyed.
+ *
+ * @param displayId the display's ID.
+ */
+ public void clearSysUIStateFlagsForDisplay(int displayId) {
+ mSysUIStateFlagsPerDisplay.remove(displayId);
+ }
+
+ /**
+ * @return the system ui state flags for the default display.
*/
// TODO(141886704): See if we can remove this
@SystemUiStateFlags
- public long getSystemUiStateFlags() {
- return mSystemUiStateFlags;
+ public long getSysuiStateFlag() {
+ return getSystemUiStateFlags(DEFAULT_DISPLAY);
}
/**
+ * @return the system ui state flags for a given display ID.
+ */
+ @SystemUiStateFlags
+ public long getSystemUiStateFlags(int displayId) {
+ return mSysUIStateFlagsPerDisplay.getOrDefault(displayId,
+ QuickStepContract.SYSUI_STATE_AWAKE);
+ }
+
+ /**
+ * @return the display ids that have sysui state.
+ */
+ public Set<Integer> getDisplaysWithSysUIState() {
+ return mSysUIStateFlagsPerDisplay.keySet();
+ }
+ /**
* Sets the flag that indicates whether a predictive back-to-home animation is in progress
*/
public void setPredictiveBackToHomeInProgress(boolean isInProgress) {
@@ -386,8 +412,8 @@
* @return whether SystemUI is in a state where we can start a system gesture.
*/
public boolean canStartSystemGesture() {
- boolean canStartWithNavHidden = (mSystemUiStateFlags & SYSUI_STATE_NAV_BAR_HIDDEN) == 0
- || (mSystemUiStateFlags & SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY) != 0
+ boolean canStartWithNavHidden = (getSysuiStateFlag() & SYSUI_STATE_NAV_BAR_HIDDEN) == 0
+ || (getSysuiStateFlag() & SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY) != 0
|| mRotationTouchHelper.isTaskListFrozen();
return canStartWithNavHidden && canStartAnyGesture();
}
@@ -399,7 +425,7 @@
*/
public boolean canStartTrackpadGesture() {
boolean trackpadGesturesEnabled =
- (mSystemUiStateFlags & SYSUI_STATE_TOUCHPAD_GESTURES_DISABLED) == 0;
+ (getSysuiStateFlag() & SYSUI_STATE_TOUCHPAD_GESTURES_DISABLED) == 0;
return trackpadGesturesEnabled && canStartAnyGesture();
}
@@ -407,8 +433,8 @@
* Common logic to determine if either trackpad or finger gesture can be started
*/
private boolean canStartAnyGesture() {
- boolean homeOrOverviewEnabled = (mSystemUiStateFlags & SYSUI_STATE_HOME_DISABLED) == 0
- || (mSystemUiStateFlags & SYSUI_STATE_OVERVIEW_DISABLED) == 0;
+ boolean homeOrOverviewEnabled = (getSysuiStateFlag() & SYSUI_STATE_HOME_DISABLED) == 0
+ || (getSysuiStateFlag() & SYSUI_STATE_OVERVIEW_DISABLED) == 0;
long gestureDisablingStates = SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED
| SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING
| SYSUI_STATE_QUICK_SETTINGS_EXPANDED
@@ -416,7 +442,7 @@
| SYSUI_STATE_DEVICE_DREAMING
| SYSUI_STATE_DISABLE_GESTURE_SPLIT_INVOCATION
| SYSUI_STATE_DISABLE_GESTURE_PIP_ANIMATING;
- return (gestureDisablingStates & mSystemUiStateFlags) == 0 && homeOrOverviewEnabled;
+ return (gestureDisablingStates & getSysuiStateFlag()) == 0 && homeOrOverviewEnabled;
}
/**
@@ -424,35 +450,35 @@
* (like camera or maps)
*/
public boolean isKeyguardShowingOccluded() {
- return (mSystemUiStateFlags & SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED) != 0;
+ return (getSysuiStateFlag() & SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED) != 0;
}
/**
* @return whether screen pinning is enabled and active
*/
public boolean isScreenPinningActive() {
- return (mSystemUiStateFlags & SYSUI_STATE_SCREEN_PINNING) != 0;
+ return (getSysuiStateFlag() & SYSUI_STATE_SCREEN_PINNING) != 0;
}
/**
* @return whether assistant gesture is constraint
*/
public boolean isAssistantGestureIsConstrained() {
- return (mSystemUiStateFlags & SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED) != 0;
+ return (getSysuiStateFlag() & SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED) != 0;
}
/**
* @return whether the bubble stack is expanded
*/
public boolean isBubblesExpanded() {
- return (mSystemUiStateFlags & SYSUI_STATE_BUBBLES_EXPANDED) != 0;
+ return (getSysuiStateFlag() & SYSUI_STATE_BUBBLES_EXPANDED) != 0;
}
/**
* @return whether the global actions dialog is showing
*/
public boolean isSystemUiDialogShowing() {
- return (mSystemUiStateFlags & SYSUI_STATE_DIALOG_SHOWING) != 0;
+ return (getSysuiStateFlag() & SYSUI_STATE_DIALOG_SHOWING) != 0;
}
/**
@@ -466,35 +492,35 @@
* @return whether the accessibility menu is available.
*/
public boolean isAccessibilityMenuAvailable() {
- return (mSystemUiStateFlags & SYSUI_STATE_A11Y_BUTTON_CLICKABLE) != 0;
+ return (getSysuiStateFlag() & SYSUI_STATE_A11Y_BUTTON_CLICKABLE) != 0;
}
/**
* @return whether the accessibility menu shortcut is available.
*/
public boolean isAccessibilityMenuShortcutAvailable() {
- return (mSystemUiStateFlags & SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) != 0;
+ return (getSysuiStateFlag() & SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) != 0;
}
/**
* @return whether home is disabled (either by SUW/SysUI/device policy)
*/
public boolean isHomeDisabled() {
- return (mSystemUiStateFlags & SYSUI_STATE_HOME_DISABLED) != 0;
+ return (getSysuiStateFlag() & SYSUI_STATE_HOME_DISABLED) != 0;
}
/**
* @return whether overview is disabled (either by SUW/SysUI/device policy)
*/
public boolean isOverviewDisabled() {
- return (mSystemUiStateFlags & SYSUI_STATE_OVERVIEW_DISABLED) != 0;
+ return (getSysuiStateFlag() & SYSUI_STATE_OVERVIEW_DISABLED) != 0;
}
/**
* @return whether one-handed mode is enabled and active
*/
public boolean isOneHandedModeActive() {
- return (mSystemUiStateFlags & SYSUI_STATE_ONE_HANDED_ACTIVE) != 0;
+ return (getSysuiStateFlag() & SYSUI_STATE_ONE_HANDED_ACTIVE) != 0;
}
/**
@@ -557,7 +583,7 @@
*/
public boolean canTriggerAssistantAction(MotionEvent ev) {
return mAssistantAvailable
- && !QuickStepContract.isAssistantGestureDisabled(mSystemUiStateFlags)
+ && !QuickStepContract.isAssistantGestureDisabled(getSysuiStateFlag())
&& mRotationTouchHelper.touchInAssistantRegion(ev)
&& !isTrackpadScroll(ev)
&& !isLockToAppActive();
@@ -597,7 +623,7 @@
/** Returns whether IME is rendering nav buttons, and IME is currently showing. */
public boolean isImeRenderingNavButtons() {
return mCanImeRenderGesturalNavButtons && mMode == NO_BUTTON
- && ((mSystemUiStateFlags & SYSUI_STATE_IME_VISIBLE) != 0);
+ && ((getSysuiStateFlag() & SYSUI_STATE_IME_VISIBLE) != 0);
}
/**
@@ -629,24 +655,37 @@
return touchSlop * touchSlop;
}
+ /** Returns a string representation of the system ui state flags for the default display. */
public String getSystemUiStateString() {
- return QuickStepContract.getSystemUiStateString(mSystemUiStateFlags);
+ return getSystemUiStateString(getSysuiStateFlag());
+ }
+
+ /** Returns a string representation of the system ui state flags. */
+ public String getSystemUiStateString(long flags) {
+ return QuickStepContract.getSystemUiStateString(flags);
}
public void dump(PrintWriter pw) {
pw.println("DeviceState:");
pw.println(" canStartSystemGesture=" + canStartSystemGesture());
- pw.println(" systemUiFlags=" + mSystemUiStateFlags);
+ pw.println(" systemUiFlagsForDefaultDisplay=" + getSysuiStateFlag());
pw.println(" systemUiFlagsDesc=" + getSystemUiStateString());
pw.println(" assistantAvailable=" + mAssistantAvailable);
pw.println(" assistantDisabled="
- + QuickStepContract.isAssistantGestureDisabled(mSystemUiStateFlags));
+ + QuickStepContract.isAssistantGestureDisabled(getSysuiStateFlag()));
pw.println(" isOneHandedModeEnabled=" + mIsOneHandedModeEnabled);
pw.println(" isSwipeToNotificationEnabled=" + mIsSwipeToNotificationEnabled);
pw.println(" deferredGestureRegion=" + mDeferredGestureRegion.getBounds());
pw.println(" exclusionRegion=" + mExclusionRegion.getBounds());
pw.println(" pipIsActive=" + mPipIsActive);
pw.println(" predictiveBackToHomeInProgress=" + mIsPredictiveBackToHomeInProgress);
+ for (int displayId : mSysUIStateFlagsPerDisplay.keySet()) {
+ pw.println(" systemUiFlagsForDisplay" + displayId + "=" + getSystemUiStateFlags(
+ displayId));
+ pw.println(" systemUiFlagsForDisplay" + displayId + "Desc=" + getSystemUiStateString(
+ getSystemUiStateFlags(displayId)));
+ }
+ pw.println(" RotationTouchHelper:");
mRotationTouchHelper.dump(pw);
}
}
diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
index cb11afa..64a8c25 100644
--- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java
+++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
@@ -318,7 +318,7 @@
mRecentsAnimationStartPending = getSystemUiProxy().startRecentsActivity(intent, options,
mCallbacks, gestureState.useSyntheticRecentsTransition());
RecentsDisplayModel.getINSTANCE().get(mCtx)
- .getRecentsWindowManager(mDeviceState.getDisplayId())
+ .getRecentsWindowManager(gestureState.getDisplayId())
.startRecentsWindow(mCallbacks);
} else {
mRecentsAnimationStartPending = getSystemUiProxy().startRecentsActivity(intent,
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index ba4c65a..8bc8549 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -40,6 +40,7 @@
import android.app.PendingIntent;
import android.app.Service;
+import android.content.Context;
import android.content.IIntentReceiver;
import android.content.IIntentSender;
import android.content.Intent;
@@ -53,9 +54,11 @@
import android.os.SystemClock;
import android.util.Log;
import android.view.Choreographer;
+import android.view.Display;
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.MotionEvent;
+import android.window.DesktopModeFlags;
import androidx.annotation.BinderThread;
import androidx.annotation.NonNull;
@@ -139,6 +142,9 @@
private static final ConstantItem<Boolean> HAS_ENABLED_QUICKSTEP_ONCE = backedUpItem(
"launcher.has_enabled_quickstep_once", false, EncryptionType.ENCRYPTED);
+ private static final DesktopModeFlags.DesktopModeFlag ENABLE_GESTURE_NAV_ON_CONNECTED_DISPLAYS =
+ new DesktopModeFlags.DesktopModeFlag(Flags::enableGestureNavOnConnectedDisplays, false);
+
private final TISBinder mTISBinder = new TISBinder(this);
/**
@@ -274,11 +280,12 @@
}
@BinderThread
- public void onSystemUiStateChanged(@SystemUiStateFlags long stateFlags) {
+ public void onSystemUiStateChanged(@SystemUiStateFlags long stateFlags, int displayId) {
MAIN_EXECUTOR.execute(() -> executeForTouchInteractionService(tis -> {
- long lastFlags = tis.mDeviceState.getSystemUiStateFlags();
- tis.mDeviceState.setSystemUiFlags(stateFlags);
- tis.onSystemUiFlagsChanged(lastFlags);
+ // Last flags is only used for the default display case.
+ long lastFlags = tis.mDeviceState.getSysuiStateFlag();
+ tis.mDeviceState.setSysUIStateFlagsForDisplay(stateFlags, displayId);
+ tis.onSystemUiFlagsChanged(lastFlags, displayId);
}));
}
@@ -312,6 +319,9 @@
public void onDisplayRemoved(int displayId) {
executeForTaskbarManager(taskbarManager ->
taskbarManager.onDisplayRemoved(displayId));
+ executeForTouchInteractionService(tis -> {
+ tis.mDeviceState.clearSysUIStateFlagsForDisplay(displayId);
+ });
}
@BinderThread
@@ -550,6 +560,7 @@
private @Nullable ResetGestureInputConsumer mResetGestureInputConsumer;
private GestureState mGestureState = DEFAULT_STATE;
+ private InputMonitorDisplayModel mInputMonitorDisplayModel;
private InputMonitorCompat mInputMonitorCompat;
private InputEventReceiver mInputEventReceiver;
@@ -599,9 +610,34 @@
ScreenOnTracker.INSTANCE.get(this).addListener(mScreenOnListener);
}
+ @Nullable
+ private InputEventReceiver getInputEventReceiver(int displayId) {
+ if (ENABLE_GESTURE_NAV_ON_CONNECTED_DISPLAYS.isTrue()) {
+ InputMonitorResource inputMonitorResource = mInputMonitorDisplayModel == null
+ ? null : mInputMonitorDisplayModel.getDisplayResource(displayId);
+ return inputMonitorResource == null ? null : inputMonitorResource.inputEventReceiver;
+ }
+ return mInputEventReceiver;
+ }
+
+ @Nullable
+ private InputMonitorCompat getInputMonitorCompat(int displayId) {
+ if (ENABLE_GESTURE_NAV_ON_CONNECTED_DISPLAYS.isTrue()) {
+ InputMonitorResource inputMonitorResource = mInputMonitorDisplayModel == null
+ ? null : mInputMonitorDisplayModel.getDisplayResource(displayId);
+ return inputMonitorResource == null ? null : inputMonitorResource.inputMonitorCompat;
+ }
+ return mInputMonitorCompat;
+ }
+
private void disposeEventHandlers(String reason) {
Log.d(TAG, "disposeEventHandlers: Reason: " + reason
+ " instance=" + System.identityHashCode(this));
+ if (ENABLE_GESTURE_NAV_ON_CONNECTED_DISPLAYS.isTrue()) {
+ if (mInputMonitorDisplayModel == null) return;
+ mInputMonitorDisplayModel.destroy();
+ return;
+ }
if (mInputEventReceiver != null) {
mInputEventReceiver.dispose();
mInputEventReceiver = null;
@@ -620,10 +656,13 @@
&& (mTrackpadsConnected.isEmpty())) {
return;
}
-
- mInputMonitorCompat = new InputMonitorCompat("swipe-up", mDeviceState.getDisplayId());
- mInputEventReceiver = mInputMonitorCompat.getInputReceiver(Looper.getMainLooper(),
- mMainChoreographer, this::onInputEvent);
+ if (ENABLE_GESTURE_NAV_ON_CONNECTED_DISPLAYS.isTrue()) {
+ mInputMonitorDisplayModel = new InputMonitorDisplayModel(this);
+ } else {
+ mInputMonitorCompat = new InputMonitorCompat("swipe-up", Display.DEFAULT_DISPLAY);
+ mInputEventReceiver = mInputMonitorCompat.getInputReceiver(Looper.getMainLooper(),
+ mMainChoreographer, this::onInputEvent);
+ }
mRotationTouchHelper.updateGestureTouchRegions();
}
@@ -649,7 +688,9 @@
mResetGestureInputConsumer = new ResetGestureInputConsumer(
mTaskAnimationManager, mTaskbarManager::getCurrentActivityContext);
mInputConsumer.registerInputConsumer();
- onSystemUiFlagsChanged(mDeviceState.getSystemUiStateFlags());
+ for (int displayId : mDeviceState.getDisplaysWithSysUIState()) {
+ onSystemUiFlagsChanged(mDeviceState.getSystemUiStateFlags(displayId), displayId);
+ }
onAssistantVisibilityChanged();
// Initialize the task tracker
@@ -705,19 +746,25 @@
public void send(int code, Intent intent, String resolvedType,
IBinder allowlistToken, IIntentReceiver finishedReceiver,
String requiredPermission, Bundle options) {
- MAIN_EXECUTOR.execute(() -> mTaskbarManager.toggleAllApps());
+ MAIN_EXECUTOR.execute(() -> mTaskbarManager.toggleAllAppsSearch());
}
});
}
@UiThread
- private void onSystemUiFlagsChanged(@SystemUiStateFlags long lastSysUIFlags) {
+ private void onSystemUiFlagsChanged(@SystemUiStateFlags long lastSysUIFlags, int displayId) {
if (LockedUserState.get(this).isUserUnlocked()) {
- long systemUiStateFlags = mDeviceState.getSystemUiStateFlags();
- SystemUiProxy.INSTANCE.get(this).setLastSystemUiStateFlags(systemUiStateFlags);
- mOverviewComponentObserver.setHomeDisabled(mDeviceState.isHomeDisabled());
- mTaskbarManager.onSystemUiFlagsChanged(systemUiStateFlags);
- mTaskAnimationManager.onSystemUiFlagsChanged(lastSysUIFlags, systemUiStateFlags);
+ long systemUiStateFlags = mDeviceState.getSystemUiStateFlags(displayId);
+ mTaskbarManager.onSystemUiFlagsChanged(systemUiStateFlags, displayId);
+ if (displayId == Display.DEFAULT_DISPLAY) {
+ // The following don't care about non-default displays, at least for now. If they
+ // ever will, they should be taken care of.
+ SystemUiProxy.INSTANCE.get(this).setLastSystemUiStateFlags(systemUiStateFlags);
+ mOverviewComponentObserver.setHomeDisabled(mDeviceState.isHomeDisabled());
+ // TODO b/399371607 - Propagate to taskAnimationManager once overview is multi
+ // display.
+ mTaskAnimationManager.onSystemUiFlagsChanged(lastSysUIFlags, systemUiStateFlags);
+ }
}
}
@@ -774,8 +821,9 @@
}
private void onInputEvent(InputEvent ev) {
+ int displayId = ev.getDisplayId();
if (!(ev instanceof MotionEvent)) {
- ActiveGestureProtoLogProxy.logUnknownInputEvent(ev.toString());
+ ActiveGestureProtoLogProxy.logUnknownInputEvent(displayId, ev.toString());
return;
}
MotionEvent event = (MotionEvent) ev;
@@ -784,19 +832,19 @@
TestProtocol.SEQUENCE_TIS, "TouchInteractionService.onInputEvent", event);
if (!LockedUserState.get(this).isUserUnlocked()) {
- ActiveGestureProtoLogProxy.logOnInputEventUserLocked();
+ ActiveGestureProtoLogProxy.logOnInputEventUserLocked(displayId);
return;
}
NavigationMode currentNavMode = mDeviceState.getMode();
if (mGestureStartNavMode != null && mGestureStartNavMode != currentNavMode) {
ActiveGestureProtoLogProxy.logOnInputEventNavModeSwitched(
- mGestureStartNavMode.name(), currentNavMode.name());
+ displayId, mGestureStartNavMode.name(), currentNavMode.name());
event.setAction(ACTION_CANCEL);
} else if (mDeviceState.isButtonNavMode()
&& !mDeviceState.supportsAssistantGestureInButtonNav()
&& !isTrackpadMotionEvent(event)) {
- ActiveGestureProtoLogProxy.logOnInputEventThreeButtonNav();
+ ActiveGestureProtoLogProxy.logOnInputEventThreeButtonNav(displayId);
return;
}
@@ -812,12 +860,15 @@
}
if (mTaskAnimationManager.shouldIgnoreMotionEvents()) {
if (action == ACTION_DOWN || isHoverActionWithoutConsumer) {
- ActiveGestureProtoLogProxy.logOnInputIgnoringFollowingEvents();
+ ActiveGestureProtoLogProxy.logOnInputIgnoringFollowingEvents(displayId);
}
return;
}
}
+ InputMonitorCompat inputMonitorCompat = getInputMonitorCompat(displayId);
+ InputEventReceiver inputEventReceiver = getInputEventReceiver(displayId);
+
if (action == ACTION_DOWN || isHoverActionWithoutConsumer) {
mGestureStartNavMode = currentNavMode;
} else if (action == ACTION_UP || action == ACTION_CANCEL) {
@@ -844,10 +895,14 @@
if (mDeviceState.canTriggerAssistantAction(event)) {
reasonString.append(" and event can trigger assistant action, "
+ "consuming gesture for assistant action");
- mGestureState =
- createGestureState(mGestureState, getTrackpadGestureType(event));
+ mGestureState = createGestureState(
+ displayId, mGestureState, getTrackpadGestureType(event));
mUncheckedConsumer = tryCreateAssistantInputConsumer(
- this, mDeviceState, mInputMonitorCompat, mGestureState, event);
+ this,
+ mDeviceState,
+ inputMonitorCompat,
+ mGestureState,
+ event);
} else {
reasonString.append(" but event cannot trigger Assistant, "
+ "consuming gesture as no-op");
@@ -862,8 +917,8 @@
// Clone the previous gesture state since onConsumerAboutToBeSwitched might trigger
// onConsumerInactive and wipe the previous gesture state
GestureState prevGestureState = new GestureState(mGestureState);
- GestureState newGestureState = createGestureState(mGestureState,
- getTrackpadGestureType(event));
+ GestureState newGestureState = createGestureState(
+ displayId, mGestureState, getTrackpadGestureType(event));
mConsumer.onConsumerAboutToBeSwitched();
mGestureState = newGestureState;
mConsumer = newConsumer(
@@ -874,10 +929,10 @@
prevGestureState,
mGestureState,
mTaskAnimationManager,
- mInputMonitorCompat,
+ inputMonitorCompat,
getSwipeUpHandlerFactory(),
this::onConsumerInactive,
- mInputEventReceiver,
+ inputEventReceiver,
mTaskbarManager,
mSwipeUpProxyProvider,
mOverviewCommandHelper,
@@ -890,18 +945,19 @@
+ "consuming gesture for assistant action"
: "event is a trackpad multi-finger swipe and event can trigger assistant "
+ "action, consuming gesture for assistant action");
- mGestureState = createGestureState(mGestureState, getTrackpadGestureType(event));
+ mGestureState = createGestureState(
+ displayId, mGestureState, getTrackpadGestureType(event));
// Do not change mConsumer as if there is an ongoing QuickSwitch gesture, we
// should not interrupt it. QuickSwitch assumes that interruption can only
// happen if the next gesture is also quick switch.
mUncheckedConsumer = tryCreateAssistantInputConsumer(
- this, mDeviceState, mInputMonitorCompat, mGestureState, event);
+ this, mDeviceState, inputMonitorCompat, mGestureState, event);
} else if (mDeviceState.canTriggerOneHandedAction(event)) {
reasonString.append("event can trigger one-handed action, "
+ "consuming gesture for one-handed action");
// Consume gesture event for triggering one handed feature.
- mUncheckedConsumer = new OneHandedModeInputConsumer(this, mDeviceState,
- InputConsumer.NO_OP, mInputMonitorCompat);
+ mUncheckedConsumer = new OneHandedModeInputConsumer(
+ this, displayId, mDeviceState, InputConsumer.NO_OP, inputMonitorCompat);
} else {
mUncheckedConsumer = InputConsumer.NO_OP;
}
@@ -916,25 +972,28 @@
if (mUncheckedConsumer != InputConsumer.NO_OP) {
switch (action) {
case ACTION_DOWN:
- ActiveGestureProtoLogProxy.logOnInputEventActionDown(reasonString);
+ ActiveGestureProtoLogProxy.logOnInputEventActionDown(displayId, reasonString);
// fall through
case ACTION_UP:
ActiveGestureProtoLogProxy.logOnInputEventActionUp(
(int) event.getRawX(),
(int) event.getRawY(),
action,
- MotionEvent.classificationToString(event.getClassification()));
+ MotionEvent.classificationToString(event.getClassification()),
+ displayId);
break;
case ACTION_MOVE:
ActiveGestureProtoLogProxy.logOnInputEventActionMove(
MotionEvent.actionToString(action),
MotionEvent.classificationToString(event.getClassification()),
- event.getPointerCount());
+ event.getPointerCount(),
+ displayId);
break;
default: {
ActiveGestureProtoLogProxy.logOnInputEventGenericAction(
MotionEvent.actionToString(action),
- MotionEvent.classificationToString(event.getClassification()));
+ MotionEvent.classificationToString(event.getClassification()),
+ displayId);
}
}
}
@@ -958,7 +1017,7 @@
}
if (cleanUpConsumer) {
- reset();
+ reset(displayId);
}
traceToken.close();
}
@@ -977,13 +1036,15 @@
return event.isHoverEvent() && event.getSource() == InputDevice.SOURCE_MOUSE;
}
- public GestureState createGestureState(GestureState previousGestureState,
+ public GestureState createGestureState(
+ int displayId,
+ GestureState previousGestureState,
GestureState.TrackpadGestureType trackpadGestureType) {
final GestureState gestureState;
TopTaskTracker.CachedTaskInfo taskInfo;
if (mTaskAnimationManager.isRecentsAnimationRunning()) {
- gestureState = new GestureState(mOverviewComponentObserver,
- ActiveGestureLog.INSTANCE.getLogId());
+ gestureState = new GestureState(
+ mOverviewComponentObserver, displayId, ActiveGestureLog.INSTANCE.getLogId());
TopTaskTracker.CachedTaskInfo previousTaskInfo = previousGestureState.getRunningTask();
// previousTaskInfo can be null iff previousGestureState == GestureState.DEFAULT_STATE
taskInfo = previousTaskInfo != null
@@ -994,7 +1055,9 @@
gestureState.updatePreviouslyAppearedTaskIds(
previousGestureState.getPreviouslyAppearedTaskIds());
} else {
- gestureState = new GestureState(mOverviewComponentObserver,
+ gestureState = new GestureState(
+ mOverviewComponentObserver,
+ displayId,
ActiveGestureLog.INSTANCE.incrementLogId());
taskInfo = TopTaskTracker.INSTANCE.get(this).getCachedTopTask(false);
gestureState.updateRunningTask(taskInfo);
@@ -1022,17 +1085,18 @@
*/
private void onConsumerInactive(InputConsumer caller) {
if (mConsumer != null && mConsumer.getActiveConsumerInHierarchy() == caller) {
- reset();
+ reset(caller.getDisplayId());
}
}
- private void reset() {
+ private void reset(int displayId) {
mConsumer = mUncheckedConsumer = getDefaultInputConsumer();
mGestureState = DEFAULT_STATE;
// By default, use batching of the input events, but check receiver before using in the rare
// case that the monitor was disposed before the swipe settled
- if (mInputEventReceiver != null) {
- mInputEventReceiver.setBatchingEnabled(true);
+ InputEventReceiver inputEventReceiver = getInputEventReceiver(displayId);
+ if (inputEventReceiver != null) {
+ inputEventReceiver.setBatchingEnabled(true);
}
}
@@ -1112,6 +1176,11 @@
pw.println("Input state:");
pw.println("\tmInputMonitorCompat=" + mInputMonitorCompat);
pw.println("\tmInputEventReceiver=" + mInputEventReceiver);
+ if (mInputMonitorDisplayModel == null) {
+ pw.println("\tmInputMonitorDisplayModel=null");
+ } else {
+ mInputMonitorDisplayModel.dump("\t", pw);
+ }
DisplayController.INSTANCE.get(this).dump(pw);
pw.println("TouchState:");
RecentsViewContainer createdOverviewContainer = mOverviewComponentObserver == null ? null
@@ -1158,4 +1227,53 @@
gestureState, touchTimeMs, mTaskAnimationManager.isRecentsAnimationRunning(),
mInputConsumer, MSDLPlayerWrapper.INSTANCE.get(this));
}
+
+ /**
+ * Helper class that keeps track of external displays and prepares input monitors for each.
+ */
+ private class InputMonitorDisplayModel extends DisplayModel<InputMonitorResource> {
+
+ private InputMonitorDisplayModel(Context context) {
+ super(context);
+ registerDisplayListener();
+ }
+
+ @NonNull
+ @Override
+ public InputMonitorResource createDisplayResource(@NonNull Display display) {
+ return new InputMonitorResource(display.getDisplayId());
+ }
+ }
+
+ private class InputMonitorResource extends DisplayModel.DisplayResource {
+
+ private final int displayId;
+
+ private final InputMonitorCompat inputMonitorCompat;
+ private final InputEventReceiver inputEventReceiver;
+
+ private InputMonitorResource(int displayId) {
+ this.displayId = displayId;
+ inputMonitorCompat = new InputMonitorCompat("swipe-up", displayId);
+ inputEventReceiver = inputMonitorCompat.getInputReceiver(
+ Looper.getMainLooper(),
+ TouchInteractionService.this.mMainChoreographer,
+ TouchInteractionService.this::onInputEvent);
+ }
+
+ @Override
+ public void cleanup() {
+ inputEventReceiver.dispose();
+ inputMonitorCompat.dispose();
+ }
+
+ @Override
+ public void dump(String prefix , PrintWriter writer) {
+ writer.println(prefix + "InputMonitorResource:");
+
+ writer.println(prefix + "\tdisplayId=" + displayId);
+ writer.println(prefix + "\tinputMonitorCompat=" + inputMonitorCompat);
+ writer.println(prefix + "\tinputEventReceiver=" + inputEventReceiver);
+ }
+ }
}
diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsDisplayModel.kt b/quickstep/src/com/android/quickstep/fallback/window/RecentsDisplayModel.kt
index 95a3ec2..116b8f2 100644
--- a/quickstep/src/com/android/quickstep/fallback/window/RecentsDisplayModel.kt
+++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsDisplayModel.kt
@@ -17,19 +17,18 @@
package com.android.quickstep.fallback.window
import android.content.Context
-import android.util.Log
import android.view.Display
import com.android.launcher3.Flags
import com.android.launcher3.dagger.ApplicationContext
import com.android.launcher3.dagger.LauncherAppSingleton
import com.android.launcher3.util.DaggerSingletonObject
import com.android.launcher3.util.DaggerSingletonTracker
-import com.android.launcher3.util.Executors
import com.android.launcher3.util.WallpaperColorHints
import com.android.quickstep.DisplayModel
import com.android.quickstep.FallbackWindowInterface
import com.android.quickstep.dagger.QuickstepBaseAppComponent
import com.android.quickstep.fallback.window.RecentsDisplayModel.RecentsDisplayResource
+import java.io.PrintWriter
import javax.inject.Inject
@LauncherAppSingleton
@@ -58,42 +57,17 @@
init {
if (enableOverviewInWindow()) {
- displayManager.registerDisplayListener(displayListener, Executors.MAIN_EXECUTOR.handler)
- // In the scenario where displays were added before this display listener was
- // registered, we should store the RecentsDisplayResources for those displays
- // directly.
- displayManager.displays
- .filter { getDisplayResource(it.displayId) == null }
- .forEach { storeRecentsDisplayResource(it.displayId, it) }
+ registerDisplayListener()
tracker.addCloseable { destroy() }
}
}
- override fun createDisplayResource(displayId: Int) {
- if (DEBUG) Log.d(TAG, "createDisplayResource: displayId=$displayId")
- getDisplayResource(displayId)?.let {
- return
- }
- val display = displayManager.getDisplay(displayId)
- if (display == null) {
- if (DEBUG)
- Log.w(
- TAG,
- "createDisplayResource: could not create display for displayId=$displayId",
- Exception(),
- )
- return
- }
- storeRecentsDisplayResource(displayId, display)
- }
-
- private fun storeRecentsDisplayResource(displayId: Int, display: Display) {
- displayResourceArray[displayId] =
- RecentsDisplayResource(
- displayId,
- context.createDisplayContext(display),
- wallpaperColorHints.hints,
- )
+ override fun createDisplayResource(display: Display): RecentsDisplayResource {
+ return RecentsDisplayResource(
+ display.displayId,
+ context.createDisplayContext(display),
+ wallpaperColorHints.hints,
+ )
}
fun getRecentsWindowManager(displayId: Int): RecentsWindowManager? {
@@ -105,8 +79,8 @@
}
data class RecentsDisplayResource(
- var displayId: Int,
- var displayContext: Context,
+ val displayId: Int,
+ val displayContext: Context,
val wallpaperColorHints: Int,
) : DisplayResource() {
val recentsWindowManager = RecentsWindowManager(displayContext, wallpaperColorHints)
@@ -116,5 +90,15 @@
override fun cleanup() {
recentsWindowManager.destroy()
}
+
+ override fun dump(prefix: String, writer: PrintWriter) {
+ writer.println("${prefix}RecentsDisplayResource:")
+
+ writer.println("${prefix}\tdisplayId=${displayId}")
+ writer.println("${prefix}\tdisplayContext=${displayContext}")
+ writer.println("${prefix}\twallpaperColorHints=${wallpaperColorHints}")
+ writer.println("${prefix}\trecentsWindowManager=${recentsWindowManager}")
+ writer.println("${prefix}\tfallbackWindowInterface=${fallbackWindowInterface}")
+ }
}
}
diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java
index 5adc960..1d85feb 100644
--- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java
@@ -163,7 +163,7 @@
&& endTarget == GestureState.GestureEndTarget.HOME;
if (fromHomeToHome) {
RecentsWindowManager manager =
- mRecentsDisplayModel.getRecentsWindowManager(mDeviceState.getDisplayId());
+ mRecentsDisplayModel.getRecentsWindowManager(mGestureState.getDisplayId());
if (manager != null) {
manager.startHome(/* finishRecentsAnimation= */ false);
}
@@ -228,7 +228,7 @@
recentsCallback = () -> {
callback.run();
RecentsWindowManager manager =
- mRecentsDisplayModel.getRecentsWindowManager(mDeviceState.getDisplayId());
+ mRecentsDisplayModel.getRecentsWindowManager(mGestureState.getDisplayId());
if (manager != null) {
manager.startHome();
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java
index 4e5d037..365c80c 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java
@@ -56,9 +56,13 @@
private float mDownY;
private float mTotalY;
- public AccessibilityInputConsumer(Context context, RecentsAnimationDeviceState deviceState,
- InputConsumer delegate, InputMonitorCompat inputMonitor) {
- super(delegate, inputMonitor);
+ public AccessibilityInputConsumer(
+ Context context,
+ int displayId,
+ RecentsAnimationDeviceState deviceState,
+ InputConsumer delegate,
+ InputMonitorCompat inputMonitor) {
+ super(displayId, delegate, inputMonitor);
mContext = context;
mVelocityTracker = VelocityTracker.obtain();
mMinGestureDistance = context.getResources()
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java
index 222ccd3..365014d 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java
@@ -95,7 +95,7 @@
InputMonitorCompat inputMonitor,
RecentsAnimationDeviceState deviceState,
MotionEvent startEvent) {
- super(delegate, inputMonitor);
+ super(gestureState.getDisplayId(), delegate, inputMonitor);
final Resources res = context.getResources();
mContext = context;
mDragDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold);
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java
index b2e7015..86d7190 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java
@@ -57,12 +57,19 @@
private final int mTouchSlop;
private final PointF mDownPos = new PointF();
private final PointF mLastPos = new PointF();
+
+ private final int mDisplayId;
+
private long mDownTime;
private final long mTimeForLongPress;
private int mActivePointerId = INVALID_POINTER_ID;
- public BubbleBarInputConsumer(Context context, BubbleControllers bubbleControllers,
+ public BubbleBarInputConsumer(
+ Context context,
+ int displayId,
+ BubbleControllers bubbleControllers,
InputMonitorCompat inputMonitorCompat) {
+ mDisplayId = displayId;
mBubbleStashController = bubbleControllers.bubbleStashController;
mBubbleBarViewController = bubbleControllers.bubbleBarViewController;
mBubbleBarSwipeController = bubbleControllers.bubbleBarSwipeController.orElse(null);
@@ -78,6 +85,11 @@
}
@Override
+ public int getDisplayId() {
+ return mDisplayId;
+ }
+
+ @Override
public void onMotionEvent(MotionEvent ev) {
final int action = ev.getAction();
switch (action) {
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
index 4afd92a..0b1a6c4 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
@@ -17,15 +17,24 @@
protected final InputConsumer mDelegate;
protected final InputMonitorCompat mInputMonitor;
+ private final int mDisplayId;
+
protected int mState;
- public DelegateInputConsumer(InputConsumer delegate, InputMonitorCompat inputMonitor) {
+ public DelegateInputConsumer(
+ int displayId, InputConsumer delegate, InputMonitorCompat inputMonitor) {
+ mDisplayId = displayId;
mDelegate = delegate;
mInputMonitor = inputMonitor;
mState = STATE_INACTIVE;
}
@Override
+ public int getDisplayId() {
+ return mDisplayId;
+ }
+
+ @Override
public InputConsumer getActiveConsumerInHierarchy() {
if (mState == STATE_ACTIVE) {
return this;
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
index 503b900..e192702 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
@@ -108,8 +108,11 @@
private RecentsAnimationController mRecentsAnimationController;
- public DeviceLockedInputConsumer(Context context, RecentsAnimationDeviceState deviceState,
- TaskAnimationManager taskAnimationManager, GestureState gestureState,
+ public DeviceLockedInputConsumer(
+ Context context,
+ RecentsAnimationDeviceState deviceState,
+ TaskAnimationManager taskAnimationManager,
+ GestureState gestureState,
InputMonitorCompat inputMonitorCompat) {
mContext = context;
mTaskAnimationManager = taskAnimationManager;
@@ -138,6 +141,11 @@
}
@Override
+ public int getDisplayId() {
+ return mGestureState.getDisplayId();
+ }
+
+ @Override
public void onMotionEvent(MotionEvent ev) {
if (mVelocityTracker == null) {
return;
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
index a703c23..e7e2074 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
@@ -74,10 +74,14 @@
private MotionEvent mCurrentMotionEvent; // Most recent motion event.
private boolean mDeepPressLogged; // Whether deep press has been logged for the current touch.
- public NavHandleLongPressInputConsumer(Context context, InputConsumer delegate,
- InputMonitorCompat inputMonitor, RecentsAnimationDeviceState deviceState,
- NavHandle navHandle, GestureState gestureState) {
- super(delegate, inputMonitor);
+ public NavHandleLongPressInputConsumer(
+ Context context,
+ InputConsumer delegate,
+ InputMonitorCompat inputMonitor,
+ RecentsAnimationDeviceState deviceState,
+ NavHandle navHandle,
+ GestureState gestureState) {
+ super(gestureState.getDisplayId(), delegate, inputMonitor);
mScreenWidth = DisplayController.INSTANCE.get(context).getInfo().currentSize.x;
mDeepPressEnabled = DeviceConfigWrapper.get().getEnableLpnhDeepPress();
ContextualSearchStateManager contextualSearchStateManager =
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
index 83b556d..67cb992 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
@@ -61,9 +61,13 @@
private boolean mPassedSlop;
private boolean mIsStopGesture;
- public OneHandedModeInputConsumer(Context context, RecentsAnimationDeviceState deviceState,
- InputConsumer delegate, InputMonitorCompat inputMonitor) {
- super(delegate, inputMonitor);
+ public OneHandedModeInputConsumer(
+ Context context,
+ int displayId,
+ RecentsAnimationDeviceState deviceState,
+ InputConsumer delegate,
+ InputMonitorCompat inputMonitor) {
+ super(displayId, delegate, inputMonitor);
mContext = context;
mDeviceState = deviceState;
mDragDistThreshold = context.getResources().getDimensionPixelSize(
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
index dd2b2be..5963a7c 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
@@ -126,11 +126,17 @@
// The callback called upon finishing the recents transition if it was force-canceled
private Runnable mForceFinishRecentsTransitionCallback;
- public OtherActivityInputConsumer(Context base, RecentsAnimationDeviceState deviceState,
- TaskAnimationManager taskAnimationManager, GestureState gestureState,
- boolean isDeferredDownTarget, Consumer<OtherActivityInputConsumer> onCompleteCallback,
- InputMonitorCompat inputMonitorCompat, InputEventReceiver inputEventReceiver,
- boolean disableHorizontalSwipe, Factory handlerFactory) {
+ public OtherActivityInputConsumer(
+ Context base,
+ RecentsAnimationDeviceState deviceState,
+ TaskAnimationManager taskAnimationManager,
+ GestureState gestureState,
+ boolean isDeferredDownTarget,
+ Consumer<OtherActivityInputConsumer> onCompleteCallback,
+ InputMonitorCompat inputMonitorCompat,
+ InputEventReceiver inputEventReceiver,
+ boolean disableHorizontalSwipe,
+ Factory handlerFactory) {
super(base);
mDeviceState = deviceState;
mNavBarPosition = mDeviceState.getNavBarPosition();
@@ -166,6 +172,11 @@
}
@Override
+ public int getDisplayId() {
+ return mGestureState.getDisplayId();
+ }
+
+ @Override
public boolean isConsumerDetachedFromGesture() {
return true;
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
index a236eca..4658cb0 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
@@ -55,12 +55,16 @@
private final int[] mLocationOnScreen = new int[2];
private final boolean mStartingInActivityBounds;
+
private boolean mTargetHandledTouch;
private boolean mHasSetTouchModeForFirstDPadEvent;
private boolean mIsWaitingForAttachToWindow;
- public OverviewInputConsumer(GestureState gestureState, T container,
- @Nullable InputMonitorCompat inputMonitor, boolean startingInActivityBounds) {
+ public OverviewInputConsumer(
+ GestureState gestureState,
+ T container,
+ @Nullable InputMonitorCompat inputMonitor,
+ boolean startingInActivityBounds) {
mContainer = container;
mInputMonitor = inputMonitor;
mStartingInActivityBounds = startingInActivityBounds;
@@ -77,6 +81,11 @@
}
@Override
+ public int getDisplayId() {
+ return mGestureState.getDisplayId();
+ }
+
+ @Override
public boolean allowInterceptByParent() {
return !mTargetHandledTouch;
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java
index be47df9..7838e86 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java
@@ -43,9 +43,12 @@
private final TriggerSwipeUpTouchTracker mTriggerSwipeUpTracker;
private final GestureState mGestureState;
- public OverviewWithoutFocusInputConsumer(Context context,
- RecentsAnimationDeviceState deviceState, GestureState gestureState,
- InputMonitorCompat inputMonitor, boolean disableHorizontalSwipe) {
+ public OverviewWithoutFocusInputConsumer(
+ Context context,
+ RecentsAnimationDeviceState deviceState,
+ GestureState gestureState,
+ InputMonitorCompat inputMonitor,
+ boolean disableHorizontalSwipe) {
mContext = context;
mGestureState = gestureState;
mInputMonitor = inputMonitor;
@@ -59,6 +62,11 @@
}
@Override
+ public int getDisplayId() {
+ return mGestureState.getDisplayId();
+ }
+
+ @Override
public boolean allowInterceptByParent() {
return !mTriggerSwipeUpTracker.interceptedTouch();
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java
index c91bebe..52aaa03 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java
@@ -89,9 +89,12 @@
private RecentsAnimationController mRecentsAnimationController;
private Boolean mFlingEndsOnHome;
- public ProgressDelegateInputConsumer(Context context,
- TaskAnimationManager taskAnimationManager, GestureState gestureState,
- InputMonitorCompat inputMonitorCompat, AnimatedFloat progress) {
+ public ProgressDelegateInputConsumer(
+ Context context,
+ TaskAnimationManager taskAnimationManager,
+ GestureState gestureState,
+ InputMonitorCompat inputMonitorCompat,
+ AnimatedFloat progress) {
mContext = context;
mTaskAnimationManager = taskAnimationManager;
mGestureState = gestureState;
@@ -118,6 +121,11 @@
}
@Override
+ public int getDisplayId() {
+ return mGestureState.getDisplayId();
+ }
+
+ @Override
public void onMotionEvent(MotionEvent ev) {
if (mFlingEndsOnHome == null) {
mSwipeDetector.onTouchEvent(ev);
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java
index d73c23f..9dc27de 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java
@@ -36,9 +36,12 @@
private final float mMotionPauseMinDisplacement;
private final MotionPauseDetector mMotionPauseDetector;
+ private final int mDisplayId;
+
private float mTouchDownY;
public ScreenPinnedInputConsumer(Context context, GestureState gestureState) {
+ mDisplayId = gestureState.getDisplayId();
mMotionPauseMinDisplacement = context.getResources().getDimension(
R.dimen.motion_pause_detector_min_displacement_from_app);
mMotionPauseDetector = new MotionPauseDetector(context, true /* makePauseHarderToTrigger*/);
@@ -61,6 +64,11 @@
}
@Override
+ public int getDisplayId() {
+ return mDisplayId;
+ }
+
+ @Override
public void onMotionEvent(MotionEvent ev) {
float y = ev.getY();
switch (ev.getAction()) {
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/SysUiOverlayInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/SysUiOverlayInputConsumer.java
index 871d075..ad1a01b 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/SysUiOverlayInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/SysUiOverlayInputConsumer.java
@@ -47,11 +47,15 @@
private final InputMonitorCompat mInputMonitor;
private final TriggerSwipeUpTouchTracker mTriggerSwipeUpTracker;
+ private final int mDisplayId;
+
public SysUiOverlayInputConsumer(
Context context,
+ int displayId,
RecentsAnimationDeviceState deviceState,
InputMonitorCompat inputMonitor) {
mContext = context;
+ mDisplayId = displayId;
mInputMonitor = inputMonitor;
mTriggerSwipeUpTracker = new TriggerSwipeUpTouchTracker(context, true,
deviceState.getNavBarPosition(), this);
@@ -63,6 +67,11 @@
}
@Override
+ public int getDisplayId() {
+ return mDisplayId;
+ }
+
+ @Override
public boolean allowInterceptByParent() {
return !mTriggerSwipeUpTracker.interceptedTouch();
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java
index 49bff8d..dbe6e14 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java
@@ -89,10 +89,14 @@
// Velocity defined as dp per s
private float mTaskbarSlowVelocityYThreshold;
- public TaskbarUnstashInputConsumer(Context context, InputConsumer delegate,
- InputMonitorCompat inputMonitor, TaskbarActivityContext taskbarActivityContext,
- OverviewCommandHelper overviewCommandHelper, GestureState gestureState) {
- super(delegate, inputMonitor);
+ public TaskbarUnstashInputConsumer(
+ Context context,
+ InputConsumer delegate,
+ InputMonitorCompat inputMonitor,
+ TaskbarActivityContext taskbarActivityContext,
+ OverviewCommandHelper overviewCommandHelper,
+ GestureState gestureState) {
+ super(gestureState.getDisplayId(), delegate, inputMonitor);
mTaskbarActivityContext = taskbarActivityContext;
mOverviewCommandHelper = overviewCommandHelper;
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/TrackpadStatusBarInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/TrackpadStatusBarInputConsumer.java
index f3e21e1..a53a395 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/TrackpadStatusBarInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/TrackpadStatusBarInputConsumer.java
@@ -35,9 +35,12 @@
private final PointF mDown = new PointF();
private boolean mHasPassedTouchSlop;
- public TrackpadStatusBarInputConsumer(Context context, InputConsumer delegate,
+ public TrackpadStatusBarInputConsumer(
+ Context context,
+ int displayId,
+ InputConsumer delegate,
InputMonitorCompat inputMonitor) {
- super(delegate, inputMonitor);
+ super(displayId, delegate, inputMonitor);
mSystemUiProxy = SystemUiProxy.INSTANCE.get(context);
mTouchSlop = 2 * ViewConfiguration.get(context).getScaledTouchSlop();
diff --git a/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java
index e265e61..c63cddf 100644
--- a/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java
@@ -34,6 +34,7 @@
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.view.Display;
import android.view.View;
import android.view.ViewOutlineProvider;
@@ -84,8 +85,8 @@
SwipeUpGestureTutorialController(TutorialFragment tutorialFragment, TutorialType tutorialType) {
super(tutorialFragment, tutorialType);
- mTaskViewSwipeUpAnimation = new ViewSwipeUpAnimation(mContext,
- new GestureState(OverviewComponentObserver.INSTANCE.get(mContext), -1));
+ mTaskViewSwipeUpAnimation = new ViewSwipeUpAnimation(mContext, new GestureState(
+ OverviewComponentObserver.INSTANCE.get(mContext), Display.DEFAULT_DISPLAY, -1));
DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(mContext)
.getDeviceProfile(mContext)
diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
index b844079..661fe89 100644
--- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
+++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
@@ -378,6 +378,29 @@
}
/**
+ * Calculates the crop rect for desktop tasks given the current matrix.
+ */
+ private void calculateDesktopTaskCropRect() {
+ // The approach here is to map a rect that represents the untransformed thumbnail position
+ // using the current matrix. This will give us a rect that can be intersected with
+ // [mFullTaskSize]. Using the intersection, we then compute how much of the task window that
+ // needs to be cropped (which will be nothing if the window is entirely within the desktop).
+ mTempRectF.set(0, 0, mThumbnailPosition.width(), mThumbnailPosition.height());
+ mMatrix.mapRect(mTempRectF);
+
+ float offsetX = mTempRectF.left;
+ float offsetY = mTempRectF.top;
+ float scale = mThumbnailPosition.width() / mTempRectF.width();
+
+ if (mTempRectF.intersect(mFullTaskSize.left, mFullTaskSize.top, mFullTaskSize.right,
+ mFullTaskSize.bottom)) {
+ mTempRectF.offset(-offsetX, -offsetY);
+ mTempRectF.scale(scale);
+ mTempRectF.round(mTmpCropRect);
+ }
+ }
+
+ /**
* Applies the rotation on the matrix to so that it maps from launcher coordinate space to
* window coordinate space.
*/
@@ -442,7 +465,16 @@
mMatrix.postTranslate(mTaskRect.left, mTaskRect.top);
if (mTaskRectTransform != null) {
mMatrix.postConcat(mTaskRectTransform);
+
+ // Calculate cropping for desktop tasks. The order is important since it uses the
+ // current matrix. Therefore we calculate it here, after applying the task rect
+ // transform, but before applying scaling/translation that affects the whole
+ // recentsview.
+ if (mIsDesktopTask) {
+ calculateDesktopTaskCropRect();
+ }
}
+
mOrientationState.getOrientationHandler().setPrimary(mMatrix, MATRIX_POST_TRANSLATE,
taskPrimaryTranslation.value);
mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE,
diff --git a/quickstep/src_protolog/com/android/quickstep/util/ActiveGestureProtoLogProxy.java b/quickstep/src_protolog/com/android/quickstep/util/ActiveGestureProtoLogProxy.java
index 37c64cf..18a5338 100644
--- a/quickstep/src_protolog/com/android/quickstep/util/ActiveGestureProtoLogProxy.java
+++ b/quickstep/src_protolog/com/android/quickstep/util/ActiveGestureProtoLogProxy.java
@@ -159,31 +159,37 @@
ProtoLog.d(ACTIVE_GESTURE_LOG, "cleanUpRecentsAnimation");
}
- public static void logOnInputEventUserLocked() {
- ActiveGestureLog.INSTANCE.addLog(
- "TIS.onInputEvent: Cannot process input event: user is locked");
+ public static void logOnInputEventUserLocked(int displayId) {
+ ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
+ "TIS.onInputEvent(displayId=%d): Cannot process input event: user is locked",
+ displayId));
if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
- "TIS.onInputEvent: Cannot process input event: user is locked");
+ "TIS.onInputEvent(displayId=%d): Cannot process input event: user is locked",
+ displayId);
}
- public static void logOnInputIgnoringFollowingEvents() {
- ActiveGestureLog.INSTANCE.addLog("TIS.onMotionEvent: A new gesture has been started, "
+ public static void logOnInputIgnoringFollowingEvents(int displayId) {
+ ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
+ "TIS.onMotionEvent(displayId=%d): A new gesture has been started, "
+ "but a previously-requested recents animation hasn't started. "
- + "Ignoring all following motion events.",
+ + "Ignoring all following motion events.", displayId),
RECENTS_ANIMATION_START_PENDING);
if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return;
- ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onMotionEvent: A new gesture has been started, "
- + "but a previously-requested recents animation hasn't started. "
- + "Ignoring all following motion events.");
+ ProtoLog.d(ACTIVE_GESTURE_LOG,
+ "TIS.onMotionEvent(displayId=%d): A new gesture has been started, "
+ + "but a previously-requested recents animation hasn't started. "
+ + "Ignoring all following motion events.", displayId);
}
- public static void logOnInputEventThreeButtonNav() {
- ActiveGestureLog.INSTANCE.addLog("TIS.onInputEvent: Cannot process input event: "
- + "using 3-button nav and event is not a trackpad event");
+ public static void logOnInputEventThreeButtonNav(int displayId) {
+ ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
+ "TIS.onInputEvent(displayId=%d): Cannot process input event: "
+ + "using 3-button nav and event is not a trackpad event", displayId));
if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return;
- ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onInputEvent: Cannot process input event: "
- + "using 3-button nav and event is not a trackpad event");
+ ProtoLog.d(ACTIVE_GESTURE_LOG,
+ "TIS.onInputEvent(displayId=%d): Cannot process input event: "
+ + "using 3-button nav and event is not a trackpad event", displayId);
}
public static void logPreloadRecentsAnimation() {
@@ -322,61 +328,84 @@
}
public static void logOnInputEventActionUp(
- int x, int y, int action, @NonNull String classification) {
+ int x, int y, int action, @NonNull String classification, int displayId) {
String actionString = MotionEvent.actionToString(action);
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
- "onMotionEvent(%d, %d): %s, %s", x, y, actionString, classification),
+ "onMotionEvent(%d, %d): %s, %s, displayId=%d",
+ x,
+ y,
+ actionString,
+ classification,
+ displayId),
/* gestureEvent= */ action == ACTION_DOWN
? MOTION_DOWN
: MOTION_UP);
if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
- "onMotionEvent(%d, %d): %s, %s", x, y, actionString, classification);
+ "onMotionEvent(%d, %d): %s, %s, displayId=%d",
+ x,
+ y,
+ actionString,
+ classification,
+ displayId);
}
public static void logOnInputEventActionMove(
- @NonNull String action, @NonNull String classification, int pointerCount) {
+ @NonNull String action,
+ @NonNull String classification,
+ int pointerCount,
+ int displayId) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
- "onMotionEvent: %s, %s, pointerCount: %d",
+ "onMotionEvent: %s, %s, pointerCount: %d, displayId=%d",
action,
classification,
- pointerCount),
+ pointerCount,
+ displayId),
MOTION_MOVE);
if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
- "onMotionEvent: %s, %s, pointerCount: %d", action, classification, pointerCount);
+ "onMotionEvent: %s, %s, pointerCount: %d, displayId=%d",
+ action,
+ classification,
+ pointerCount,
+ displayId);
}
public static void logOnInputEventGenericAction(
- @NonNull String action, @NonNull String classification) {
+ @NonNull String action, @NonNull String classification, int displayId) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
- "onMotionEvent: %s, %s", action, classification));
+ "onMotionEvent: %s, %s, displayId=%d", action, classification, displayId));
if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return;
- ProtoLog.d(ACTIVE_GESTURE_LOG, "onMotionEvent: %s, %s", action, classification);
+ ProtoLog.d(ACTIVE_GESTURE_LOG,
+ "onMotionEvent: %s, %s, displayId=%d", action, classification, displayId);
}
public static void logOnInputEventNavModeSwitched(
- @NonNull String startNavMode, @NonNull String currentNavMode) {
+ int displayId, @NonNull String startNavMode, @NonNull String currentNavMode) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
- "TIS.onInputEvent: Navigation mode switched mid-gesture (%s -> %s); "
+ "TIS.onInputEvent(displayId=%d): Navigation mode switched mid-gesture (%s -> %s); "
+ "cancelling gesture.",
+ displayId,
startNavMode,
currentNavMode),
NAVIGATION_MODE_SWITCHED);
if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
- "TIS.onInputEvent: Navigation mode switched mid-gesture (%s -> %s); "
+ "TIS.onInputEvent(displayId=%d): Navigation mode switched mid-gesture (%s -> %s); "
+ "cancelling gesture.",
+ displayId,
startNavMode,
currentNavMode);
}
- public static void logUnknownInputEvent(@NonNull String event) {
+ public static void logUnknownInputEvent(int displayId, @NonNull String event) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
- "TIS.onInputEvent: Cannot process input event: received unknown event %s", event));
+ "TIS.onInputEvent(displayId=%d): Cannot process input event: "
+ + "received unknown event %s", displayId, event));
if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
- "TIS.onInputEvent: Cannot process input event: received unknown event %s", event);
+ "TIS.onInputEvent(displayId=%d): Cannot process input event: "
+ + "received unknown event %s", displayId, event);
}
public static void logFinishRunningRecentsAnimation(boolean toHome) {
@@ -433,11 +462,13 @@
ProtoLog.d(ACTIVE_GESTURE_LOG, "Launching side task id=%d", taskId);
}
- public static void logOnInputEventActionDown(@NonNull ActiveGestureLog.CompoundString reason) {
+ public static void logOnInputEventActionDown(
+ int displayId, @NonNull ActiveGestureLog.CompoundString reason) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
- "TIS.onMotionEvent: ").append(reason));
+ "TIS.onMotionEvent(displayId=%d): ", displayId).append(reason));
if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return;
- ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onMotionEvent: %s", reason.toString());
+ ProtoLog.d(ACTIVE_GESTURE_LOG,
+ "TIS.onMotionEvent(displayId=%d): %s", displayId, reason.toString());
}
public static void logStartNewTask(@NonNull ActiveGestureLog.CompoundString tasks) {
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/DisplayModelTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/DisplayModelTest.kt
index a939e84..fa7907f 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/DisplayModelTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/DisplayModelTest.kt
@@ -21,6 +21,7 @@
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
+import java.io.PrintWriter
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Test
@@ -37,25 +38,29 @@
override fun cleanup() {
isCleanupCalled = true
}
+
+ override fun dump(prefix: String, writer: PrintWriter) {
+ // No-Op
+ }
}
private val testableDisplayModel =
object : DisplayModel<TestableResource>(context) {
- override fun createDisplayResource(displayId: Int) {
- displayResourceArray.put(displayId, TestableResource())
+ override fun createDisplayResource(display: Display): TestableResource {
+ return TestableResource()
}
}
@Test
fun testCreate() {
- testableDisplayModel.createDisplayResource(Display.DEFAULT_DISPLAY)
+ testableDisplayModel.storeDisplayResource(Display.DEFAULT_DISPLAY)
val resource = testableDisplayModel.getDisplayResource(Display.DEFAULT_DISPLAY)
assertNotNull(resource)
}
@Test
fun testCleanAndDelete() {
- testableDisplayModel.createDisplayResource(Display.DEFAULT_DISPLAY)
+ testableDisplayModel.storeDisplayResource(Display.DEFAULT_DISPLAY)
val resource = testableDisplayModel.getDisplayResource(Display.DEFAULT_DISPLAY)!!
assertNotNull(resource)
testableDisplayModel.deleteDisplayResource(Display.DEFAULT_DISPLAY)
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/LauncherSwipeHandlerV2Test.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/LauncherSwipeHandlerV2Test.kt
index af741f6..35f1218 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/LauncherSwipeHandlerV2Test.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/LauncherSwipeHandlerV2Test.kt
@@ -91,7 +91,14 @@
.bindRotationHelper(mock(RotationTouchHelper::class.java))
.bindRecentsState(mock(RecentsAnimationDeviceState::class.java))
)
- gestureState = spy(GestureState(OverviewComponentObserver.INSTANCE.get(sandboxContext), 0))
+ gestureState =
+ spy(
+ GestureState(
+ OverviewComponentObserver.INSTANCE.get(sandboxContext),
+ DEFAULT_DISPLAY,
+ 0,
+ )
+ )
underTest =
LauncherSwipeHandlerV2(
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsAnimationDeviceStateTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsAnimationDeviceStateTest.kt
index b652ee8..a7370b0 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsAnimationDeviceStateTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsAnimationDeviceStateTest.kt
@@ -1,5 +1,6 @@
package com.android.quickstep
+import android.view.Display
import androidx.test.annotation.UiThreadTest
import androidx.test.filters.SmallTest
import com.android.launcher3.dagger.LauncherComponentProvider
@@ -13,6 +14,7 @@
import com.android.launcher3.util.NavigationMode
import com.android.launcher3.util.SandboxApplication
import com.android.quickstep.util.GestureExclusionManager
+import com.android.systemui.shared.system.QuickStepContract
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DEVICE_DREAMING
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DISABLE_GESTURE_SPLIT_INVOCATION
@@ -150,7 +152,7 @@
allSysUiStates().forEach { state ->
val canStartGesture = !disablingStates.contains(state)
- underTest.setSystemUiFlags(state)
+ underTest.setSysUIStateFlagsForDisplay(state, Display.DEFAULT_DISPLAY)
assertThat(underTest.canStartTrackpadGesture()).isEqualTo(canStartGesture)
}
}
@@ -166,7 +168,7 @@
)
stateToExpectedResult.forEach { (state, allowed) ->
- underTest.setSystemUiFlags(state)
+ underTest.setSysUIStateFlagsForDisplay(state, Display.DEFAULT_DISPLAY)
assertThat(underTest.canStartTrackpadGesture()).isEqualTo(allowed)
}
}
@@ -177,7 +179,7 @@
allSysUiStates().forEach { state ->
val canStartGesture = !disablingStates.contains(state)
- underTest.setSystemUiFlags(state)
+ underTest.setSysUIStateFlagsForDisplay(state, Display.DEFAULT_DISPLAY)
assertThat(underTest.canStartSystemGesture()).isEqualTo(canStartGesture)
}
}
@@ -197,11 +199,42 @@
)
stateToExpectedResult.forEach { (state, gestureAllowed) ->
- underTest.setSystemUiFlags(state)
+ underTest.setSysUIStateFlagsForDisplay(state, Display.DEFAULT_DISPLAY)
assertThat(underTest.canStartSystemGesture()).isEqualTo(gestureAllowed)
}
}
+ @Test
+ fun getSystemUiStateFlags_defaultAwake() {
+ val NOT_EXISTENT_DISPLAY = 2
+ assertThat(underTest.getSystemUiStateFlags(NOT_EXISTENT_DISPLAY))
+ .isEqualTo(QuickStepContract.SYSUI_STATE_AWAKE)
+ }
+
+ @Test
+ fun clearSysUIStateFlagsForDisplay_displayNotReturnedAnymore() {
+ underTest.setSysUIStateFlagsForDisplay(1, /* displayId= */ 1)
+
+ assertThat(underTest.displaysWithSysUIState).contains(1)
+ assertThat(underTest.getSystemUiStateFlags(1)).isEqualTo(1)
+
+ underTest.clearSysUIStateFlagsForDisplay(1)
+
+ assertThat(underTest.displaysWithSysUIState).doesNotContain(1)
+ assertThat(underTest.getSystemUiStateFlags(1))
+ .isEqualTo(QuickStepContract.SYSUI_STATE_AWAKE)
+ }
+
+ @Test
+ fun setSysUIStateFlagsForDisplay_setsCorrectly() {
+ underTest.setSysUIStateFlagsForDisplay(1, /* displayId= */ 1)
+ underTest.setSysUIStateFlagsForDisplay(2, /* displayId= */ 2)
+
+ assertThat(underTest.getSystemUiStateFlags(1)).isEqualTo(1)
+ assertThat(underTest.getSystemUiStateFlags(2)).isEqualTo(2)
+ assertThat(underTest.displaysWithSysUIState).containsAtLeast(1, 2)
+ }
+
private fun allSysUiStates(): List<Long> {
// SYSUI_STATES_* are binary flags
return (0..SYSUI_STATES_COUNT).map { 1L shl it }
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/window/RecentsDisplayModelTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/window/RecentsDisplayModelTest.kt
index 44ea73e..0119679 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/window/RecentsDisplayModelTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/window/RecentsDisplayModelTest.kt
@@ -88,16 +88,16 @@
@Test
fun testCreateSeparateInstances() {
- val display = Display.DEFAULT_DISPLAY + 1
- runOnMainSync { recentsDisplayModel.createDisplayResource(display) }
+ val displayId = Display.DEFAULT_DISPLAY + 1
+ runOnMainSync { recentsDisplayModel.storeDisplayResource(displayId) }
val defaultManager = recentsDisplayModel.getRecentsWindowManager(Display.DEFAULT_DISPLAY)
- val secondaryManager = recentsDisplayModel.getRecentsWindowManager(display)
+ val secondaryManager = recentsDisplayModel.getRecentsWindowManager(displayId)
Assert.assertNotSame(defaultManager, secondaryManager)
val defaultInterface =
recentsDisplayModel.getFallbackWindowInterface(Display.DEFAULT_DISPLAY)
- val secondInterface = recentsDisplayModel.getFallbackWindowInterface(display)
+ val secondInterface = recentsDisplayModel.getFallbackWindowInterface(displayId)
Assert.assertNotSame(defaultInterface, secondInterface)
}
diff --git a/quickstep/tests/src/com/android/quickstep/InputConsumerUtilsTest.java b/quickstep/tests/src/com/android/quickstep/InputConsumerUtilsTest.java
index e2ca91a..ef6f55e 100644
--- a/quickstep/tests/src/com/android/quickstep/InputConsumerUtilsTest.java
+++ b/quickstep/tests/src/com/android/quickstep/InputConsumerUtilsTest.java
@@ -30,6 +30,7 @@
import android.annotation.Nullable;
import android.os.Looper;
import android.view.Choreographer;
+import android.view.Display;
import android.view.MotionEvent;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -99,7 +100,8 @@
@Rule public final SandboxApplication mContext = new SandboxApplication();
- @NonNull private final InputMonitorCompat mInputMonitorCompat = new InputMonitorCompat("", 0);
+ @NonNull private final InputMonitorCompat mInputMonitorCompat =
+ new InputMonitorCompat("", Display.DEFAULT_DISPLAY);
private TaskAnimationManager mTaskAnimationManager;
private InputChannelCompat.InputEventReceiver mInputEventReceiver;
@@ -196,7 +198,6 @@
@Before
public void setupDeviceState() {
- when(mDeviceState.getDisplayId()).thenReturn(0);
when(mDeviceState.canStartTrackpadGesture()).thenReturn(true);
when(mDeviceState.canStartSystemGesture()).thenReturn(true);
when(mDeviceState.isFullyGesturalNavMode()).thenReturn(true);
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index 1c87bce..1af48a9 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -433,18 +433,17 @@
(Math.abs(recentsView.getTopRowTaskCountForTablet()
- recentsView.getBottomRowTaskCountForTablet()) <= 1)));
- // TODO(b/308841019): Re-enable after fixing Overview jank when dismiss
-// // Test dismissing more tasks.
-// assertIsInState(
-// "Launcher internal state didn't remain in Overview", ExpectedState.OVERVIEW);
-// overview.getCurrentTask().dismiss();
-// assertIsInState(
-// "Launcher internal state didn't remain in Overview", ExpectedState.OVERVIEW);
-// overview.getCurrentTask().dismiss();
-// runOnRecentsView(recentsView -> assertTrue(
-// "Grid did not rebalance after multiple dismissals",
-// (Math.abs(recentsView.getTopRowTaskCountForTablet()
-// - recentsView.getBottomRowTaskCountForTablet()) <= 1)));
+ // Test dismissing more tasks.
+ assertIsInState(
+ "Launcher internal state didn't remain in Overview", ExpectedState.OVERVIEW);
+ overview.getCurrentTask().dismiss();
+ assertIsInState(
+ "Launcher internal state didn't remain in Overview", ExpectedState.OVERVIEW);
+ overview.getCurrentTask().dismiss();
+ runOnRecentsView(recentsView -> assertTrue(
+ "Grid did not rebalance after multiple dismissals",
+ (Math.abs(recentsView.getTopRowTaskCountForTablet()
+ - recentsView.getBottomRowTaskCountForTablet()) <= 1)));
// Test dismissing all tasks.
mLauncher.goHome().switchToOverview().dismissAllTasks();
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index 753b2e2..b90200b 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -126,7 +126,8 @@
/** Type of popups that should get exclusive accessibility focus. */
public static final int TYPE_ACCESSIBLE = TYPE_ALL & ~TYPE_DISCOVERY_BOUNCE & ~TYPE_LISTENER
& ~TYPE_ALL_APPS_EDU & ~TYPE_TASKBAR_ALL_APPS & ~TYPE_PIN_IME_POPUP
- & ~TYPE_WIDGET_RESIZE_FRAME & ~TYPE_ONE_GRID_MIGRATION_EDU & ~TYPE_ON_BOARD_POPUP;
+ & ~TYPE_WIDGET_RESIZE_FRAME & ~TYPE_ONE_GRID_MIGRATION_EDU & ~TYPE_ON_BOARD_POPUP
+ & ~TYPE_TASKBAR_OVERLAY_PROXY;
// These view all have particular operation associated with swipe down interaction.
public static final int TYPE_STATUS_BAR_SWIPE_DOWN_DISALLOW = TYPE_WIDGETS_BOTTOM_SHEET |
diff --git a/src/com/android/launcher3/DropTarget.java b/src/com/android/launcher3/DropTarget.java
index 2d99510..7f0c7b5 100644
--- a/src/com/android/launcher3/DropTarget.java
+++ b/src/com/android/launcher3/DropTarget.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.graphics.Rect;
+import android.view.View;
import com.android.launcher3.accessibility.DragViewStateAnnouncer;
import com.android.launcher3.dragndrop.DragOptions;
@@ -145,4 +146,9 @@
// These methods are implemented in Views
void getHitRectRelativeToDragLayer(Rect outRect);
+
+ /** Returns the drop target view. By default, the implementor class is cast to the view. */
+ default View getDropView() {
+ return (View) this;
+ }
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 728bc34..7b41586 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1669,7 +1669,7 @@
} else if (Intent.ACTION_ALL_APPS.equals(intent.getAction())) {
showAllAppsFromIntent(alreadyOnHome);
} else if (INTENT_ACTION_ALL_APPS_TOGGLE.equals(intent.getAction())) {
- toggleAllAppsSearch(alreadyOnHome);
+ toggleAllApps(alreadyOnHome, true);
} else if (Intent.ACTION_SHOW_WORK_APPS.equals(intent.getAction())) {
showAllAppsWithSelectedTabFromIntent(alreadyOnHome,
ActivityAllAppsContainerView.AdapterHolder.WORK);
@@ -1683,12 +1683,15 @@
// Overridden
}
- /** Toggles Launcher All Apps with keyboard ready for search. */
- public void toggleAllAppsSearch() {
- toggleAllAppsSearch(/* alreadyOnHome= */ true);
+ /**
+ * Toggles Launcher All Apps.
+ * @param focusSearch Indicates whether to make All Apps keyboard ready for search.
+ */
+ public void toggleAllApps(boolean focusSearch) {
+ toggleAllApps(/* alreadyOnHome= */ true, focusSearch);
}
- protected void toggleAllAppsSearch(boolean alreadyOnHome) {
+ private void toggleAllApps(boolean alreadyOnHome, boolean focusSearch) {
if (getStateManager().isInStableState(ALL_APPS)) {
getStateManager().goToState(NORMAL, alreadyOnHome);
} else {
@@ -1700,7 +1703,8 @@
new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
- if (mAppsView.getSearchUiManager().getEditText() != null) {
+ if (focusSearch
+ && mAppsView.getSearchUiManager().getEditText() != null) {
mAppsView.getSearchUiManager().getEditText().requestFocus();
}
}
diff --git a/src/com/android/launcher3/LauncherPrefs.kt b/src/com/android/launcher3/LauncherPrefs.kt
index 2a5cd63..7a04b0f 100644
--- a/src/com/android/launcher3/LauncherPrefs.kt
+++ b/src/com/android/launcher3/LauncherPrefs.kt
@@ -75,18 +75,18 @@
@Suppress("IMPLICIT_CAST_TO_ANY", "UNCHECKED_CAST")
private fun <T> getInner(item: Item, default: T): T {
val sp = getSharedPrefs(item)
-
- return when (item.type) {
- String::class.java -> sp.getString(item.sharedPrefKey, default as? String)
- Boolean::class.java,
- java.lang.Boolean::class.java -> sp.getBoolean(item.sharedPrefKey, default as Boolean)
- Int::class.java,
- java.lang.Integer::class.java -> sp.getInt(item.sharedPrefKey, default as Int)
- Float::class.java,
- java.lang.Float::class.java -> sp.getFloat(item.sharedPrefKey, default as Float)
- Long::class.java,
- java.lang.Long::class.java -> sp.getLong(item.sharedPrefKey, default as Long)
- Set::class.java -> sp.getStringSet(item.sharedPrefKey, default as? Set<String>)
+ return when {
+ item.type == String::class.java -> sp.getString(item.sharedPrefKey, default as? String)
+ item.type == Boolean::class.java || item.type == java.lang.Boolean::class.java ->
+ sp.getBoolean(item.sharedPrefKey, default as Boolean)
+ item.type == Int::class.java || item.type == java.lang.Integer::class.java ->
+ sp.getInt(item.sharedPrefKey, default as Int)
+ item.type == Float::class.java || item.type == java.lang.Float::class.java ->
+ sp.getFloat(item.sharedPrefKey, default as Float)
+ item.type == Long::class.java || item.type == java.lang.Long::class.java ->
+ sp.getLong(item.sharedPrefKey, default as Long)
+ Set::class.java.isAssignableFrom(item.type) ->
+ sp.getStringSet(item.sharedPrefKey, default as? Set<String>)
else ->
throw IllegalArgumentException(
"item type: ${item.type}" + " is not compatible with sharedPref methods"
@@ -147,17 +147,18 @@
item: Item,
value: Any?,
): SharedPreferences.Editor =
- when (item.type) {
- String::class.java -> putString(item.sharedPrefKey, value as? String)
- Boolean::class.java,
- java.lang.Boolean::class.java -> putBoolean(item.sharedPrefKey, value as Boolean)
- Int::class.java,
- java.lang.Integer::class.java -> putInt(item.sharedPrefKey, value as Int)
- Float::class.java,
- java.lang.Float::class.java -> putFloat(item.sharedPrefKey, value as Float)
- Long::class.java,
- java.lang.Long::class.java -> putLong(item.sharedPrefKey, value as Long)
- Set::class.java -> putStringSet(item.sharedPrefKey, value as? Set<String>)
+ when {
+ item.type == String::class.java -> putString(item.sharedPrefKey, value as? String)
+ item.type == Boolean::class.java || item.type == java.lang.Boolean::class.java ->
+ putBoolean(item.sharedPrefKey, value as Boolean)
+ item.type == Int::class.java || item.type == java.lang.Integer::class.java ->
+ putInt(item.sharedPrefKey, value as Int)
+ item.type == Float::class.java || item.type == java.lang.Float::class.java ->
+ putFloat(item.sharedPrefKey, value as Float)
+ item.type == Long::class.java || item.type == java.lang.Long::class.java ->
+ putLong(item.sharedPrefKey, value as Long)
+ Set::class.java.isAssignableFrom(item.type) ->
+ putStringSet(item.sharedPrefKey, value as? Set<String>)
else ->
throw IllegalArgumentException(
"item type: ${item.type} is not compatible with sharedPref methods"
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 5595828..1b5e2e6 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -891,6 +891,9 @@
mScreenOrder.removeValue(extraEmptyPageId);
});
+ // Since we removed some screens, before moving to next page, update the state
+ // description with correct page numbers.
+ updateAccessibilityViewPageDescription();
setCurrentPage(getNextPage());
// Update the page indicator to reflect the removed page.
@@ -1116,6 +1119,9 @@
if (pageShift >= 0) {
setCurrentPage(currentPage - pageShift);
}
+
+ // Now that we have removed some pages, ensure state description is up to date.
+ updateAccessibilityViewPageDescription();
}
/**
@@ -3479,6 +3485,18 @@
protected void announcePageForAccessibility() {
// Talkback focuses on AccessibilityActionView by default, so we need to modify the state
// description there in order for the change in page scroll to be announced.
+ updateAccessibilityViewPageDescription();
+ }
+
+ /**
+ * Updates the state description that is set on the accessibility actions view for the
+ * workspace.
+ * <p>The updated value is called out when talkback focuses on the view and is not disruptive.
+ * </p>
+ */
+ protected void updateAccessibilityViewPageDescription() {
+ // Set the state description on accessibility action view so that when it is focused,
+ // talkback describes the correct state of home screen pages.
ViewCompat.setStateDescription(mLauncher.getAccessibilityActionView(),
getCurrentPageDescription());
}
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index c50c008..c4086b2 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -521,17 +521,13 @@
mDragObject.dragComplete = true;
if (mIsInPreDrag) {
- if (dropTarget != null) {
- dropTarget.onDragExit(mDragObject);
- }
- return;
+ mDragObject.cancelled = true;
}
-
// Drop onto the target.
boolean accepted = false;
if (dropTarget != null) {
dropTarget.onDragExit(mDragObject);
- if (dropTarget.acceptDrop(mDragObject)) {
+ if (!mIsInPreDrag && dropTarget.acceptDrop(mDragObject)) {
if (flingAnimation != null) {
flingAnimation.run();
} else {
@@ -558,7 +554,7 @@
target.getHitRectRelativeToDragLayer(r);
if (r.contains(x, y)) {
- mActivity.getDragLayer().mapCoordInSelfToDescendant((View) target,
+ mActivity.getDragLayer().mapCoordInSelfToDescendant(target.getDropView(),
mCoordinatesTemp);
mDragObject.x = mCoordinatesTemp[0];
mDragObject.y = mCoordinatesTemp[1];
diff --git a/src/com/android/launcher3/dragndrop/LauncherDragController.java b/src/com/android/launcher3/dragndrop/LauncherDragController.java
index 4aa3673..e3b8965 100644
--- a/src/com/android/launcher3/dragndrop/LauncherDragController.java
+++ b/src/com/android/launcher3/dragndrop/LauncherDragController.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.dragndrop;
+import static android.view.View.VISIBLE;
+
import static com.android.launcher3.AbstractFloatingView.TYPE_DISCOVERY_BOUNCE;
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
import static com.android.launcher3.LauncherState.EDIT_MODE;
@@ -25,6 +27,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.HapticFeedbackConstants;
+import android.view.MotionEvent;
import android.view.View;
import androidx.annotation.Nullable;
@@ -33,10 +36,13 @@
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
+import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.accessibility.DragViewStateAnnouncer;
+import com.android.launcher3.dragndrop.DragOptions.PreDragCondition;
import com.android.launcher3.model.data.ItemInfo;
+import com.android.launcher3.util.TouchUtil;
import com.android.launcher3.widget.util.WidgetDragScaleUtils;
/**
@@ -47,6 +53,9 @@
private static final boolean PROFILE_DRAWING_DURING_DRAG = false;
private final FlingToDeleteHelper mFlingToDeleteHelper;
+ /** Whether or not the drag operation is triggered by mouse right click. */
+ private boolean mIsInMouseRightClick = false;
+
public LauncherDragController(Launcher launcher) {
super(launcher);
mFlingToDeleteHelper = new FlingToDeleteHelper(launcher);
@@ -69,6 +78,27 @@
android.os.Debug.startMethodTracing("Launcher");
}
+ if (mIsInMouseRightClick && options.preDragCondition == null
+ && originalView instanceof View v) {
+ options.preDragCondition = new PreDragCondition() {
+
+ @Override
+ public boolean shouldStartDrag(double distanceDragged) {
+ return false;
+ }
+
+ @Override
+ public void onPreDragStart(DragObject dragObject) {
+ // Set it to visible so the text of FolderIcon would not flash (avoid it from
+ // being invisible and then visible)
+ v.setVisibility(VISIBLE);
+ }
+
+ @Override
+ public void onPreDragEnd(DragObject dragObject, boolean dragStarted) { }
+ };
+ }
+
mActivity.hideKeyboard();
AbstractFloatingView.closeOpenViews(mActivity, false, TYPE_DISCOVERY_BOUNCE);
@@ -191,7 +221,7 @@
@Override
protected void exitDrag() {
- if (!mActivity.isInState(EDIT_MODE)) {
+ if (!mIsInPreDrag && !mActivity.isInState(EDIT_MODE)) {
mActivity.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
}
}
@@ -218,4 +248,13 @@
dropCoordinates);
return mActivity.getWorkspace();
}
+
+ /**
+ * Intercepts touch events from a drag source view.
+ */
+ @Override
+ public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
+ mIsInMouseRightClick = TouchUtil.isMouseRightClickDownOrMove(ev);
+ return super.onControllerInterceptTouchEvent(ev);
+ }
}
diff --git a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java
index 8af18f5..3641896 100644
--- a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java
+++ b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java
@@ -88,8 +88,9 @@
private static final String KEY_COLOR_RESOURCE_IDS = "color_resource_ids";
private static final String KEY_COLOR_VALUES = "color_values";
private static final String KEY_DARK_MODE = "use_dark_mode";
+ public static final String KEY_SKIP_ANIMATIONS = "skip_animations";
- private Context mContext;
+ private final Context mContext;
private SparseIntArray mPreviewColorOverride;
private String mGridName;
private String mShapeKey;
@@ -102,6 +103,7 @@
private final IBinder mHostToken;
private final int mWidth;
private final int mHeight;
+ private final boolean mSkipAnimations;
private final int mDisplayId;
private final Display mDisplay;
private final WallpaperColors mWallpaperColors;
@@ -128,6 +130,7 @@
mHostToken = bundle.getBinder(KEY_HOST_TOKEN);
mWidth = bundle.getInt(KEY_VIEW_WIDTH);
mHeight = bundle.getInt(KEY_VIEW_HEIGHT);
+ mSkipAnimations = bundle.getBoolean(KEY_SKIP_ANIMATIONS, false);
mDisplayId = bundle.getInt(KEY_DISPLAY_ID);
mDisplay = context.getSystemService(DisplayManager.class)
.getDisplay(mDisplayId);
@@ -421,7 +424,7 @@
if (!Flags.newCustomizationPickerUi()) {
- view.setAlpha(0);
+ view.setAlpha(mSkipAnimations ? 1 : 0);
view.animate().alpha(1)
.setInterpolator(new AccelerateDecelerateInterpolator())
.setDuration(FADE_IN_ANIMATION_DURATION)
@@ -442,7 +445,7 @@
);
mViewRoot.setLayoutParams(layoutParams);
mViewRoot.addView(view);
- mViewRoot.setAlpha(0);
+ mViewRoot.setAlpha(mSkipAnimations ? 1 : 0);
mViewRoot.animate().alpha(1)
.setInterpolator(new AccelerateDecelerateInterpolator())
.setDuration(FADE_IN_ANIMATION_DURATION)
diff --git a/tests/multivalentTests/src/com/android/launcher3/LauncherPrefsTest.kt b/tests/multivalentTests/src/com/android/launcher3/LauncherPrefsTest.kt
index 4aeef2e..da9cc86 100644
--- a/tests/multivalentTests/src/com/android/launcher3/LauncherPrefsTest.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/LauncherPrefsTest.kt
@@ -24,12 +24,18 @@
import com.google.common.truth.Truth.assertThat
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
+import org.junit.Assert.assertThrows
import org.junit.Test
import org.junit.runner.RunWith
private val TEST_BOOLEAN_ITEM = LauncherPrefs.nonRestorableItem("1", false)
private val TEST_STRING_ITEM = LauncherPrefs.nonRestorableItem("2", "( ͡❛ ͜ʖ ͡❛)")
private val TEST_INT_ITEM = LauncherPrefs.nonRestorableItem("3", -1)
+private val TEST_FLOAT_ITEM = LauncherPrefs.nonRestorableItem("4", -1f)
+private val TEST_LONG_ITEM = LauncherPrefs.nonRestorableItem("5", -1L)
+private val TEST_SET_ITEM = LauncherPrefs.nonRestorableItem("6", setOf<String>())
+private val TEST_HASHSET_ITEM = LauncherPrefs.nonRestorableItem("7", hashSetOf<String>())
+
private val TEST_CONTEXTUAL_ITEM =
ContextualItem("4", true, { true }, EncryptionType.ENCRYPTED, Boolean::class.java)
@@ -144,15 +150,49 @@
}
@Test
+ fun whenItemType_isInvalid_thenThrowException() {
+ val badItem = LauncherPrefs.nonRestorableItem("8", mapOf<String, String>())
+ with(launcherPrefs) {
+ assertThrows(IllegalArgumentException::class.java) {
+ putSync(badItem.to(badItem.defaultValue))
+ }
+ assertThrows(IllegalArgumentException::class.java) { get(badItem) }
+ }
+ }
+
+ @Test
fun put_storesListOfItemsInLauncherPrefs_successfully() {
with(launcherPrefs) {
putSync(
TEST_STRING_ITEM.to(TEST_STRING_ITEM.defaultValue),
TEST_INT_ITEM.to(TEST_INT_ITEM.defaultValue),
TEST_BOOLEAN_ITEM.to(TEST_BOOLEAN_ITEM.defaultValue),
+ TEST_FLOAT_ITEM.to(TEST_FLOAT_ITEM.defaultValue),
+ TEST_LONG_ITEM.to(TEST_LONG_ITEM.defaultValue),
+ TEST_SET_ITEM.to(TEST_SET_ITEM.defaultValue),
+ TEST_HASHSET_ITEM.to(TEST_HASHSET_ITEM.defaultValue),
)
- assertThat(has(TEST_BOOLEAN_ITEM, TEST_INT_ITEM, TEST_STRING_ITEM)).isTrue()
- remove(TEST_STRING_ITEM, TEST_INT_ITEM, TEST_BOOLEAN_ITEM)
+ assertThat(
+ has(
+ TEST_STRING_ITEM,
+ TEST_INT_ITEM,
+ TEST_BOOLEAN_ITEM,
+ TEST_FLOAT_ITEM,
+ TEST_LONG_ITEM,
+ TEST_SET_ITEM,
+ TEST_HASHSET_ITEM,
+ )
+ )
+ .isTrue()
+ remove(
+ TEST_STRING_ITEM,
+ TEST_INT_ITEM,
+ TEST_BOOLEAN_ITEM,
+ TEST_FLOAT_ITEM,
+ TEST_LONG_ITEM,
+ TEST_SET_ITEM,
+ TEST_HASHSET_ITEM,
+ )
}
}
diff --git a/tests/multivalentTests/src/com/android/launcher3/icons/mono/MonoIconThemeControllerTest.kt b/tests/multivalentTests/src/com/android/launcher3/icons/mono/MonoIconThemeControllerTest.kt
index 12c14fb..2c9cb2f 100644
--- a/tests/multivalentTests/src/com/android/launcher3/icons/mono/MonoIconThemeControllerTest.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/icons/mono/MonoIconThemeControllerTest.kt
@@ -38,6 +38,7 @@
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assume.assumeFalse
+import org.junit.Assume.assumeTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -77,6 +78,8 @@
@EnableFlags(Flags.FLAG_FORCE_MONOCHROME_APP_ICONS)
fun `createThemedBitmap when mono generation is enabled`() {
ensureBitmapSerializationSupported()
+ // Make sure forced theme icon is enabled in BaseIconFactory
+ assumeTrue(iconFactory.shouldForceThemeIcon())
val icon = AdaptiveIconDrawable(ColorDrawable(Color.BLACK), null, null)
assertNotNull(
MonoIconThemeController().createThemedBitmap(icon, BitmapInfo.LOW_RES_INFO, iconFactory)
diff --git a/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java b/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java
index f490bd6..95d5076 100644
--- a/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java
+++ b/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java
@@ -36,6 +36,7 @@
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.Wait;
+import com.android.launcher3.util.rule.ScreenRecordRule;
import org.junit.Test;
@@ -126,6 +127,7 @@
* Adds three icons to the workspace and removes one of them by dragging to uninstall.
*/
@Test
+ @ScreenRecordRule.ScreenRecord // b/399756302
@PlatinumTest(focusArea = "launcher")
public void uninstallWorkspaceIcon() throws IOException {
Point[] gridPositions = TestUtil.getCornersAndCenterPositions(mLauncher);
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 16faf14..de31c4d 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -947,7 +947,9 @@
waitUntilLauncherObjectGone(WORKSPACE_RES_ID);
waitUntilLauncherObjectGone(WIDGETS_RES_ID);
waitUntilSystemLauncherObjectGone(OVERVIEW_RES_ID);
- waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
+ if (isTransientTaskbar()) {
+ waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
+ }
waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID);
waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID);