From 6efff5eeacaf366c852a235e21ff42f9607fb6e0 Mon Sep 17 00:00:00 2001 From: Daniel Akinola Date: Tue, 13 May 2025 13:26:41 -0700 Subject: [PATCH] Update StatusBarTouchController to work on external display Dragging on launcher background on external display didn't do anything because there was no StatusBarTouchController. Now by adding it to SecondaryDragLayer, we can open the shade on external display via launcher drag Bug: 362719719 Bug: 416511740 Test: manual testing Flag: EXEMPT refactor only Change-Id: I1a587fe85bf2e7c6f212b3358646d5d282019eef --- .../uioverrides/QuickstepLauncher.java | 3 ++- .../launcher3/uioverrides/SystemApiWrapper.kt | 10 ++++++++++ .../StatusBarTouchController.java | 13 ++++++++----- .../secondarydisplay/SecondaryDragLayer.java | 19 +++++++++++++++++-- .../android/launcher3/util/ApiWrapper.java | 11 +++++++++++ 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 1a5649935f..3097804ffb 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -706,7 +706,8 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, } if (!getDeviceProfile().isMultiWindowMode) { - list.add(new StatusBarTouchController(this)); + list.add(new StatusBarTouchController( + this, () -> this.isInState(LauncherState.NORMAL))); } if (enableExpressiveDismissTaskMotion()) { diff --git a/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt b/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt index 8ca603b11a..abad4078ff 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt +++ b/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt @@ -38,6 +38,7 @@ import android.view.SurfaceControlViewHost import android.widget.Toast import android.window.RemoteTransition import android.window.ScreenCapture +import com.android.launcher3.BaseActivity import com.android.launcher3.Flags.enablePrivateSpace import com.android.launcher3.Flags.privateSpaceSysAppsSeparation import com.android.launcher3.R @@ -45,11 +46,13 @@ import com.android.launcher3.Utilities import com.android.launcher3.dagger.ApplicationContext import com.android.launcher3.dagger.LauncherAppSingleton import com.android.launcher3.proxy.ProxyActivityStarter +import com.android.launcher3.uioverrides.touchcontrollers.StatusBarTouchController import com.android.launcher3.util.ApiWrapper import com.android.launcher3.util.Executors import com.android.launcher3.util.StartActivityParams import com.android.launcher3.util.UserIconInfo import com.android.quickstep.util.FadeOutRemoteTransition +import java.util.function.Supplier import javax.inject.Inject /** A wrapper for the hidden API calls */ @@ -195,6 +198,13 @@ open class SystemApiWrapper @Inject constructor(@ApplicationContext context: Con } } + override fun createStatusBarTouchController( + launcher: BaseActivity, + isEnabledCheck: Supplier, + ): StatusBarTouchController? { + return StatusBarTouchController(launcher, isEnabledCheck) + } + override fun isFileDrawable(shortcutInfo: ShortcutInfo) = shortcutInfo.hasIconFile() || shortcutInfo.hasIconUri() diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java index 959c334e53..6b82741c77 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java @@ -32,12 +32,13 @@ import android.view.Window; import android.view.WindowManager; import com.android.launcher3.AbstractFloatingView; +import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; -import com.android.launcher3.Launcher; -import com.android.launcher3.LauncherState; import com.android.launcher3.util.TouchController; import com.android.quickstep.SystemUiProxy; +import java.util.function.Supplier; + /** * TouchController for handling touch events that get sent to the StatusBar. Once the * Once the event delta mDownY passes the touch slop, the events start getting forwarded. @@ -47,21 +48,23 @@ public class StatusBarTouchController implements TouchController { private static final String TAG = "StatusBarController"; - private final Launcher mLauncher; + private final BaseActivity mLauncher; private final SystemUiProxy mSystemUiProxy; private final float mTouchSlop; private int mLastAction; private final SparseArray mDownEvents; + private final Supplier mIsEnabledCheck; /* If {@code false}, this controller should not handle the input {@link MotionEvent}.*/ private boolean mCanIntercept; - public StatusBarTouchController(Launcher l) { + public StatusBarTouchController(BaseActivity l, Supplier isEnabledCheck) { mLauncher = l; mSystemUiProxy = SystemUiProxy.INSTANCE.get(mLauncher); // Guard against TAPs by increasing the touch slop. mTouchSlop = 2 * ViewConfiguration.get(l).getScaledTouchSlop(); mDownEvents = new SparseArray<>(); + mIsEnabledCheck = isEnabledCheck; } @Override @@ -150,7 +153,7 @@ public class StatusBarTouchController implements TouchController { } private boolean canInterceptTouch(MotionEvent ev) { - if (isTrackpadScroll(ev) || !mLauncher.isInState(LauncherState.NORMAL) + if (isTrackpadScroll(ev) || !mIsEnabledCheck.get() || AbstractFloatingView.getTopOpenViewWithType(mLauncher, AbstractFloatingView.TYPE_STATUS_BAR_SWIPE_DOWN_DISALLOW) != null) { return false; diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java b/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java index 7c1bffbc69..4d69482cc9 100644 --- a/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java +++ b/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java @@ -39,6 +39,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.popup.PopupDataProvider; import com.android.launcher3.popup.SystemShortcut; +import com.android.launcher3.util.ApiWrapper; import com.android.launcher3.util.ShortcutUtil; import com.android.launcher3.util.TouchController; import com.android.launcher3.views.BaseDragLayer; @@ -65,8 +66,22 @@ public class SecondaryDragLayer extends BaseDragLayer @Override public void recreateControllers() { super.recreateControllers(); - mControllers = new TouchController[]{new CloseAllAppsTouchController(), - mContainer.getDragController()}; + TouchController statusBarController = + ApiWrapper.INSTANCE.get(getContext()) + .createStatusBarTouchController(mContainer, () -> true); + + if (statusBarController != null) { + mControllers = new TouchController[]{ + new CloseAllAppsTouchController(), + mContainer.getDragController(), + statusBarController + }; + } else { + mControllers = new TouchController[]{ + new CloseAllAppsTouchController(), + mContainer.getDragController() + }; + } } /** diff --git a/src/com/android/launcher3/util/ApiWrapper.java b/src/com/android/launcher3/util/ApiWrapper.java index 53cae67a29..ba86b85980 100644 --- a/src/com/android/launcher3/util/ApiWrapper.java +++ b/src/com/android/launcher3/util/ApiWrapper.java @@ -37,6 +37,7 @@ import android.view.SurfaceControlViewHost; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.android.launcher3.BaseActivity; import com.android.launcher3.BuildConfig; import com.android.launcher3.Launcher; import com.android.launcher3.Utilities; @@ -44,10 +45,12 @@ import com.android.launcher3.dagger.ApplicationContext; import com.android.launcher3.dagger.LauncherAppComponent; import com.android.launcher3.dagger.LauncherAppSingleton; import com.android.launcher3.icons.BitmapRenderer; +import com.android.launcher3.util.TouchController; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.function.Supplier; import javax.inject.Inject; @@ -203,6 +206,14 @@ public class ApiWrapper { } } + @Nullable + public TouchController createStatusBarTouchController( + BaseActivity launcher, + Supplier isEnabledCheck + ) { + return null; + } + /** * Checks if the shortcut is using an icon with file or URI source */