Merge tag 'android-14.0.0_r31' into leaf-3.2
Android 14.0.0 Release 31 (AP1A.240405.002.A1)
* tag 'android-14.0.0_r31':
Allow stashed taskbar to be long pressed.
Change-Id: I9d0222b06624346431a3a92f32817151ede820fd
diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
index 7c30111..6b5b9f1 100644
--- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
@@ -20,6 +20,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
+import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Outline;
@@ -37,6 +38,7 @@
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiValueAlpha;
+import com.android.quickstep.NavHandle;
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
import java.io.PrintWriter;
@@ -44,7 +46,8 @@
/**
* Handles properties/data collection, then passes the results to our stashed handle View to render.
*/
-public class StashedHandleViewController implements TaskbarControllers.LoggableTaskbarController {
+public class StashedHandleViewController implements TaskbarControllers.LoggableTaskbarController,
+ NavHandle {
public static final int ALPHA_INDEX_STASHED = 0;
public static final int ALPHA_INDEX_HOME_DISABLED = 1;
@@ -302,4 +305,24 @@
pw.println(prefix + "\tmStashedHandleHeight=" + mStashedHandleHeight);
mRegionSamplingHelper.dump(prefix, pw);
}
+
+ @Override
+ public void animateNavBarLongPress(boolean isTouchDown, boolean shrink, long durationMs) {
+ // TODO(b/308693847): Animate similarly to NavigationHandle.java (SysUI).
+ }
+
+ @Override
+ public boolean isNavHandleStashedTaskbar() {
+ return true;
+ }
+
+ @Override
+ public boolean canNavHandleBeLongPressed() {
+ return isStashedHandleVisible();
+ }
+
+ @Override
+ public int getNavHandleWidth(Context context) {
+ return mStashedHandleWidth;
+ }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 4290948..f9d92a6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -120,6 +120,7 @@
import com.android.launcher3.util.VibratorWrapper;
import com.android.launcher3.util.ViewCache;
import com.android.launcher3.views.ActivityContext;
+import com.android.quickstep.NavHandle;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
@@ -580,6 +581,11 @@
return mControllers.bubbleControllers.orElse(null);
}
+ @NonNull
+ public NavHandle getNavHandle() {
+ return mControllers.stashedHandleViewController;
+ }
+
@Override
public ViewCache getViewCache() {
return mViewCache;
diff --git a/quickstep/src/com/android/quickstep/NavHandle.java b/quickstep/src/com/android/quickstep/NavHandle.java
new file mode 100644
index 0000000..da3311f
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/NavHandle.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.quickstep;
+
+import android.content.Context;
+
+import com.android.launcher3.R;
+
+/**
+ * Control and get information about the gesture nav bar at the bottom of the screen, which has
+ * historically been drawn by SysUI, but is also emulated by the stashed Taskbar on large screens.
+ */
+public interface NavHandle {
+
+ /**
+ * Animate the nav bar being long-pressed.
+ *
+ * @param isTouchDown {@code true} if the button is starting to be pressed ({@code false} if
+ * released or canceled)
+ * @param shrink {@code true} if the handle should shrink, {@code false} if it should grow
+ * @param durationMs how long the animation should take (for the {@code isTouchDown} case, this
+ * should be the same as the amount of time to trigger a long-press)
+ */
+ void animateNavBarLongPress(boolean isTouchDown, boolean shrink, long durationMs);
+
+ /** @return {@code true} if this nav handle is actually the stashed taskbar */
+ default boolean isNavHandleStashedTaskbar() {
+ return false;
+ }
+
+ /** @return {@code true} if this nav handle can currently accept long presses */
+ default boolean canNavHandleBeLongPressed() {
+ return true;
+ }
+
+ /** @return the width of this nav handle, in pixels */
+ default int getNavHandleWidth(Context context) {
+ return context.getResources().getDimensionPixelSize(R.dimen.navigation_home_handle_width);
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index 0cb04bf..613da96 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -106,7 +106,7 @@
/**
* Holds the reference to SystemUI.
*/
-public class SystemUiProxy implements ISystemUiProxy {
+public class SystemUiProxy implements ISystemUiProxy, NavHandle {
private static final String TAG = SystemUiProxy.class.getSimpleName();
public static final MainThreadInitializedObject<SystemUiProxy> INSTANCE =
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index bd4625b..aa55e67 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -986,14 +986,22 @@
base = new TaskbarUnstashInputConsumer(this, base, mInputMonitorCompat, tac,
mOverviewCommandHelper);
}
- } else if (canStartSystemGesture && !previousGestureState.isRecentsAnimationRunning()) {
+ }
+
+ NavHandle navHandle = tac != null ? tac.getNavHandle()
+ : SystemUiProxy.INSTANCE.get(this);
+ if (canStartSystemGesture && !previousGestureState.isRecentsAnimationRunning()
+ && navHandle.canNavHandleBeLongPressed()) {
reasonString.append(NEWLINE_PREFIX)
.append(reasonPrefix)
.append(SUBSTRING_PREFIX)
- .append("Not running recents animation, ")
- .append("using NavHandleLongPressInputConsumer");
+ .append("Not running recents animation, ");
+ if (tac != null && tac.getNavHandle().canNavHandleBeLongPressed()) {
+ reasonString.append("stashed handle is long-pressable, ");
+ }
+ reasonString.append("using NavHandleLongPressInputConsumer");
base = new NavHandleLongPressInputConsumer(this, base, mInputMonitorCompat,
- mDeviceState);
+ mDeviceState, navHandle);
}
if (mDeviceState.isBubblesExpanded()) {
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressHandler.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressHandler.java
index 4d47f07..1d00e53 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressHandler.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressHandler.java
@@ -22,6 +22,7 @@
import com.android.launcher3.R;
import com.android.launcher3.util.ResourceBasedOverride;
+import com.android.quickstep.NavHandle;
/**
* Class for extending nav handle long press behavior
@@ -42,19 +43,26 @@
* A Runnable is returned here to ensure the InputConsumer can call
* {@link android.view.InputMonitor#pilferPointers()} before invoking the long press behavior
* since pilfering can break the long press behavior.
+ *
+ * @param navHandle to handle this long press
*/
- public @Nullable Runnable getLongPressRunnable() {
+ public @Nullable Runnable getLongPressRunnable(NavHandle navHandle) {
return null;
}
/**
* Called when nav handle gesture starts.
+ *
+ * @param navHandle to handle the animation for this touch
*/
- public void onTouchStarted() {}
+ public void onTouchStarted(NavHandle navHandle) {}
/**
* Called when nav handle gesture is finished by the user lifting their finger or the system
* cancelling the touch for some other reason.
+ *
+ * @param navHandle to handle the animation for this touch
+ * @param reason why the touch ended
*/
- public void onTouchFinished(String reason) {}
+ public void onTouchFinished(NavHandle navHandle, String reason) {}
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
index 0a558e2..4c0b550 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
@@ -17,7 +17,9 @@
import static com.android.launcher3.LauncherPrefs.LONG_PRESS_NAV_HANDLE_TIMEOUT_MS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DEEP_PRESS_NAVBAR;
+import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DEEP_PRESS_STASHED_TASKBAR;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_LONG_PRESS_NAVBAR;
+import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_LONG_PRESS_STASHED_TASKBAR;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import android.content.Context;
@@ -25,11 +27,11 @@
import android.view.ViewConfiguration;
import com.android.launcher3.LauncherPrefs;
-import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.util.DisplayController;
import com.android.quickstep.InputConsumer;
+import com.android.quickstep.NavHandle;
import com.android.quickstep.RecentsAnimationDeviceState;
import com.android.quickstep.TopTaskTracker;
import com.android.systemui.shared.system.InputMonitorCompat;
@@ -47,6 +49,7 @@
private final float mTouchSlopSquared;
private final int mLongPressTimeout;
private final boolean mDeepPressEnabled;
+ private final NavHandle mNavHandle;
private final StatsLogManager mStatsLogManager;
private final TopTaskTracker mTopTaskTracker;
@@ -54,10 +57,9 @@
private boolean mDeepPressLogged; // Whether deep press has been logged for the current touch.
public NavHandleLongPressInputConsumer(Context context, InputConsumer delegate,
- InputMonitorCompat inputMonitor, RecentsAnimationDeviceState deviceState) {
+ InputMonitorCompat inputMonitor, RecentsAnimationDeviceState deviceState,
+ NavHandle navHandle) {
super(delegate, inputMonitor);
- mNavHandleWidth = context.getResources().getDimensionPixelSize(
- R.dimen.navigation_home_handle_width);
mScreenWidth = DisplayController.INSTANCE.get(context).getInfo().currentSize.x;
mDeepPressEnabled = FeatureFlags.ENABLE_LPNH_DEEP_PRESS.get();
if (FeatureFlags.CUSTOM_LPNH_THRESHOLDS.get()) {
@@ -66,6 +68,8 @@
mLongPressTimeout = ViewConfiguration.getLongPressTimeout();
}
mTouchSlopSquared = deviceState.getSquaredTouchSlop();
+ mNavHandle = navHandle;
+ mNavHandleWidth = navHandle.getNavHandleWidth(context);
mNavHandleLongPressHandler = NavHandleLongPressHandler.newInstance(context);
mStatsLogManager = StatsLogManager.newInstance(context);
mTopTaskTracker = TopTaskTracker.INSTANCE.get(context);
@@ -89,6 +93,11 @@
}
}
+ @Override
+ public void onHoverEvent(MotionEvent ev) {
+ mDelegate.onHoverEvent(ev);
+ }
+
private void handleMotionEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN -> {
@@ -98,9 +107,8 @@
mCurrentDownEvent = MotionEvent.obtain(ev);
mDeepPressLogged = false;
if (isInNavBarHorizontalArea(ev.getRawX())) {
- mNavHandleLongPressHandler.onTouchStarted();
- MAIN_EXECUTOR.getHandler().postDelayed(mTriggerLongPress,
- mLongPressTimeout);
+ mNavHandleLongPressHandler.onTouchStarted(mNavHandle);
+ MAIN_EXECUTOR.getHandler().postDelayed(mTriggerLongPress, mLongPressTimeout);
}
}
case MotionEvent.ACTION_MOVE -> {
@@ -127,8 +135,9 @@
// Log deep press even if feature is disabled.
String runningPackage = mTopTaskTracker.getCachedTopTask(
/* filterOnlyVisibleRecents */ true).getPackageName();
- mStatsLogManager.logger().withPackageName(runningPackage)
- .log(LAUNCHER_DEEP_PRESS_NAVBAR);
+ mStatsLogManager.logger().withPackageName(runningPackage).log(
+ mNavHandle.isNavHandleStashedTaskbar() ? LAUNCHER_DEEP_PRESS_STASHED_TASKBAR
+ : LAUNCHER_DEEP_PRESS_NAVBAR);
mDeepPressLogged = true;
// But only trigger if the feature is enabled.
@@ -142,9 +151,11 @@
private void triggerLongPress() {
String runningPackage = mTopTaskTracker.getCachedTopTask(
/* filterOnlyVisibleRecents */ true).getPackageName();
- mStatsLogManager.logger().withPackageName(runningPackage).log(LAUNCHER_LONG_PRESS_NAVBAR);
+ mStatsLogManager.logger().withPackageName(runningPackage).log(
+ mNavHandle.isNavHandleStashedTaskbar() ? LAUNCHER_LONG_PRESS_STASHED_TASKBAR
+ : LAUNCHER_LONG_PRESS_NAVBAR);
- Runnable longPressRunnable = mNavHandleLongPressHandler.getLongPressRunnable();
+ Runnable longPressRunnable = mNavHandleLongPressHandler.getLongPressRunnable(mNavHandle);
if (longPressRunnable == null) {
return;
}
@@ -161,7 +172,7 @@
private void cancelLongPress(String reason) {
MAIN_EXECUTOR.getHandler().removeCallbacks(mTriggerLongPress);
- mNavHandleLongPressHandler.onTouchFinished(reason);
+ mNavHandleLongPressHandler.onTouchFinished(mNavHandle, reason);
}
private boolean isInNavBarHorizontalArea(float x) {
diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java
index d8388c2..5fa2d57 100644
--- a/src/com/android/launcher3/logging/StatsLogManager.java
+++ b/src/com/android/launcher3/logging/StatsLogManager.java
@@ -281,6 +281,12 @@
@UiEvent(doc = "User long presses on the bottom bezel area.")
LAUNCHER_LONG_PRESS_NAVBAR(1544),
+ @UiEvent(doc = "User deep presses on the stashed taskbar")
+ LAUNCHER_DEEP_PRESS_STASHED_TASKBAR(1602),
+
+ @UiEvent(doc = "User long presses on the stashed taskbar")
+ LAUNCHER_LONG_PRESS_STASHED_TASKBAR(1592),
+
@UiEvent(doc = "User swipes or fling in UP direction from bottom bazel area.")
LAUNCHER_HOME_GESTURE(574),