From 09b40241fc01df7c132405b42d7b787ca73f5a00 Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Fri, 27 Aug 2021 13:29:01 +0800 Subject: [PATCH 1/7] Always refresh device profile when multi window mode changed Launcher monitors multi-window mode changed and updates device profile through configuration chagned callback. It's possible that a new configuration contains multi-window mode changed but without screen size size change that across screen layout qualifier. Client apps might not even receive onConfingurationChagned. Updates Launcher to monitor multi-window mode changed through onMultiWindowModeChanged to make sure it always refreshes device profile that matches with the latest mulati-window mode. Fix: 197835119 Test: manual check the repo steps. Change-Id: Ie99045a1fc8493ff37645b95e7ccd9d15478d862 --- src/com/android/launcher3/Launcher.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 6ea7b17871..a02f8eedfd 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -554,6 +554,14 @@ public class Launcher extends StatefulActivity implements Launche AbstractFloatingView.closeOpenViews(this, false, TYPE_ICON_SURFACE); } + @Override + public void onMultiWindowModeChanged(boolean isInMultiWindowMode, Configuration newConfig) { + super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig); + // Always update device profile when multi window mode changed. + initDeviceProfile(mDeviceProfile.inv); + dispatchDeviceProfileChanged(); + } + @Override public void onConfigurationChanged(Configuration newConfig) { int diff = newConfig.diff(mOldConfig); @@ -592,11 +600,9 @@ public class Launcher extends StatefulActivity implements Launche private void initDeviceProfile(InvariantDeviceProfile idp) { // Load configuration-specific DeviceProfile - mDeviceProfile = idp.getDeviceProfile(this); - if (isInMultiWindowMode()) { - mDeviceProfile = mDeviceProfile.getMultiWindowProfile( - this, getMultiWindowDisplaySize()); - } + mDeviceProfile = isInMultiWindowMode() + ? mDeviceProfile.getMultiWindowProfile(this, getMultiWindowDisplaySize()) + : idp.getDeviceProfile(this); onDeviceProfileInitiated(); mModelWriter = mModel.getWriter(getDeviceProfile().isVerticalBarLayout(), true, this); From bb0305614c255a0ae6eb9aee4049f500e8100ee7 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 19 Jul 2021 16:28:39 -0700 Subject: [PATCH 2/7] Preventing workspace scroll over QSB area Bug: 189792966 Test: Manual Change-Id: Ie2fe8e7fb6c80b9cc19d517fe828cf26f54f6f09 --- src/com/android/launcher3/Launcher.java | 2 +- src/com/android/launcher3/PagedView.java | 2 +- src/com/android/launcher3/Workspace.java | 40 +++++++++++++++--------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 6ea7b17871..0669176aa5 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1195,7 +1195,7 @@ public class Launcher extends StatefulActivity implements Launche // Until the workspace is bound, ensure that we keep the wallpaper offset locked to the // default state, otherwise we will update to the wrong offsets in RTL mWorkspace.lockWallpaperToDefaultPage(); - mWorkspace.bindAndInitFirstWorkspaceScreen(null /* recycled qsb */); + mWorkspace.bindAndInitFirstWorkspaceScreen(); mDragController.addDragListener(mWorkspace); // Get the search/delete/uninstall bar diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 696e89716f..2f9b5af050 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -1046,7 +1046,7 @@ public abstract class PagedView extends ViewGrou /** * If being flinged and user touches the screen, initiate drag; otherwise don't. */ - private void updateIsBeingDraggedOnTouchDown(MotionEvent ev) { + protected void updateIsBeingDraggedOnTouchDown(MotionEvent ev) { // mScroller.isFinished should be false when being flinged. final int xDist = Math.abs(mScroller.getFinalX() - mScroller.getCurrX()); final boolean finishedScrolling = (mScroller.isFinished() || xDist < mPageSlop / 3); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 94ec903b86..b197e1cb08 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -223,6 +223,9 @@ public class Workspace extends PagedView // Variables relating to touch disambiguation (scrolling workspace vs. scrolling a widget) private float mXDown; private float mYDown; + private View mQsb; + private boolean mIsEventOverQsb; + final static float START_DAMPING_TOUCH_SLOP_ANGLE = (float) Math.PI / 6; final static float MAX_SWIPE_ANGLE = (float) Math.PI / 3; final static float TOUCH_SLOP_DAMPING_FACTOR = 4; @@ -548,9 +551,8 @@ public class Workspace extends PagedView /** * Initializes and binds the first page - * @param qsb an existing qsb to recycle or null. */ - public void bindAndInitFirstWorkspaceScreen(View qsb) { + public void bindAndInitFirstWorkspaceScreen() { if (!FeatureFlags.QSB_ON_FIRST_SCREEN) { return; } @@ -558,10 +560,10 @@ public class Workspace extends PagedView // Add the first page CellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, getChildCount()); // Always add a QSB on the first screen. - if (qsb == null) { + if (mQsb == null) { // In transposed layout, we add the QSB in the Grid. As workspace does not touch the // edges, we do not need a full width QSB. - qsb = LayoutInflater.from(getContext()) + mQsb = LayoutInflater.from(getContext()) .inflate(R.layout.search_container_workspace, firstPage, false); } @@ -570,8 +572,9 @@ public class Workspace extends PagedView CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, firstPage.getCountX(), cellVSpan); lp.canReorder = false; - if (!firstPage.addViewToCellLayout(qsb, 0, R.id.search_container_workspace, lp, true)) { + if (!firstPage.addViewToCellLayout(mQsb, 0, R.id.search_container_workspace, lp, true)) { Log.e(TAG, "Failed to add to item at (0, 0) to CellLayout"); + mQsb = null; } } @@ -581,9 +584,8 @@ public class Workspace extends PagedView disableLayoutTransitions(); // Recycle the QSB widget - View qsb = findViewById(R.id.search_container_workspace); - if (qsb != null) { - ((ViewGroup) qsb.getParent()).removeView(qsb); + if (mQsb != null) { + ((ViewGroup) mQsb.getParent()).removeView(mQsb); } // Remove the pages and clear the screen models @@ -596,7 +598,7 @@ public class Workspace extends PagedView mLauncher.mHandler.removeCallbacksAndMessages(DeferredWidgetRefresh.class); // Ensure that the first page is always present - bindAndInitFirstWorkspaceScreen(qsb); + bindAndInitFirstWorkspaceScreen(); // Re-enable the layout transitions enableLayoutTransitions(); @@ -922,17 +924,25 @@ public class Workspace extends PagedView } @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { - if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) { - mXDown = ev.getX(); - mYDown = ev.getY(); + protected void updateIsBeingDraggedOnTouchDown(MotionEvent ev) { + super.updateIsBeingDraggedOnTouchDown(ev); + + mXDown = ev.getX(); + mYDown = ev.getY(); + if (mQsb != null) { + mTempFXY[0] = mXDown + getScrollX(); + mTempFXY[1] = mYDown + getScrollY(); + Utilities.mapCoordInSelfToDescendant(mQsb, this, mTempFXY); + mIsEventOverQsb = mQsb.getLeft() <= mTempFXY[0] && mQsb.getRight() >= mTempFXY[0] + && mQsb.getTop() <= mTempFXY[1] && mQsb.getBottom() >= mTempFXY[1]; + } else { + mIsEventOverQsb = false; } - return super.onInterceptTouchEvent(ev); } @Override protected void determineScrollingStart(MotionEvent ev) { - if (!isFinishedSwitchingState()) return; + if (!isFinishedSwitchingState() || mIsEventOverQsb) return; float deltaX = ev.getX() - mXDown; float absDeltaX = Math.abs(deltaX); From b922452bf5d1572bea0cbdcb8b91e247a5d29a0e Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 31 Aug 2021 09:46:32 -0700 Subject: [PATCH 3/7] Fix NPEs when swiping up from keyguard - In onRecentsAnimationCanceled - In applyLoadPlan Test: Lock screen from home screen, swipe up from bottom of keyguard Fixes: 197622171 Change-Id: Ibb6b292cb99ad2f08e402c1a6e311b819c5f7d73 --- quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java | 4 +++- quickstep/src/com/android/quickstep/views/RecentsView.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 6e90a3a5a7..4c46683a50 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -805,7 +805,9 @@ public abstract class AbsSwipeUpHandler, mActivityInitListener.unregister(); mStateCallback.setStateOnUiThread(STATE_GESTURE_CANCELLED | STATE_HANDLER_INVALIDATED); - TaskViewUtils.setDividerBarShown(mRecentsAnimationTargets.nonApps, true); + if (mRecentsAnimationTargets != null) { + TaskViewUtils.setDividerBarShown(mRecentsAnimationTargets.nonApps, true); + } // Defer clearing the controller and the targets until after we've updated the state mRecentsAnimationController = null; diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 810eccea8a..6aa7e061e6 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1351,8 +1351,10 @@ public abstract class RecentsView Date: Tue, 31 Aug 2021 10:41:36 -0700 Subject: [PATCH 4/7] Fix some taskbar stashing issues - Don't allow long press to stash between taskbar icons - Ensure taskbar_icon_touch_size is respected; previously it wasn't, because BubbleTextView@shouldIgnoreTouchDown() was returning true in the padding region. For taskbar, we want the whole icon size to be touchable. - Cancel long press when passing touch slop to avoid swipe down being detected as long press Test: long press on taskbar background, both between icons and not; swipe down on taskbar Fixes: 198305464 Change-Id: I36f1d792e91da9a3bf57a2bef1e974b299c4e25c --- .../com/android/launcher3/taskbar/TaskbarView.java | 14 +++++++++++++- .../launcher3/taskbar/TaskbarViewController.java | 8 +++++++- src/com/android/launcher3/BubbleTextView.java | 4 ++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index 5144d9a5f5..59393d7b5b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -243,7 +243,19 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar if (!mTouchEnabled) { return true; } - mControllerCallbacks.onTouchEvent(event); + if (mIconLayoutBounds.contains((int) event.getX(), (int) event.getY())) { + // Don't allow long pressing between icons. + return true; + } + if (mControllerCallbacks.onTouchEvent(event)) { + int oldAction = event.getAction(); + try { + event.setAction(MotionEvent.ACTION_CANCEL); + return super.onTouchEvent(event); + } finally { + event.setAction(oldAction); + } + } return super.onTouchEvent(event); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 40b0e18d27..f1748afce3 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -223,7 +223,11 @@ public class TaskbarViewController { return view -> mControllers.taskbarStashController.updateAndAnimateIsStashedInApp(true); } - public void onTouchEvent(MotionEvent motionEvent) { + /** + * Get the first chance to handle TaskbarView#onTouchEvent, and return whether we want to + * consume the touch so TaskbarView treats it as an ACTION_CANCEL. + */ + public boolean onTouchEvent(MotionEvent motionEvent) { final float x = motionEvent.getRawX(); final float y = motionEvent.getRawY(); switch (motionEvent.getAction()) { @@ -239,6 +243,7 @@ public class TaskbarViewController { mControllers.taskbarStashController.startStashHint( /* animateForward= */ false); mCanceledStashHint = true; + return true; } break; case MotionEvent.ACTION_UP: @@ -249,6 +254,7 @@ public class TaskbarViewController { } break; } + return false; } } } diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 02ec5e8a8b..e52d1be18c 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -409,6 +409,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, * Returns true if the touch down at the provided position be ignored */ protected boolean shouldIgnoreTouchDown(float x, float y) { + if (mDisplay == DISPLAY_TASKBAR) { + // Allow touching within padding on taskbar, given icon sizes are smaller. + return false; + } return y < getPaddingTop() || x < getPaddingLeft() || y > getHeight() - getPaddingBottom() From c12b7355b1105f294f6704b15438957d53c4c576 Mon Sep 17 00:00:00 2001 From: Evan Rosky Date: Tue, 31 Aug 2021 15:10:47 -0700 Subject: [PATCH 5/7] Fix NPE that happens occasionally on start-up Was not checking if topActivity was null. Bug: 189935087 Test: boot phone thousands of times. Change-Id: I3c779be5f09d82d52a3df9478c801a1963e0a5c2 --- .../src/com/android/launcher3/QuickstepTransitionManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index f06447bfc5..494b953e53 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1124,6 +1124,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener if (target.mode == mode && target.taskInfo != null // Compare component name instead of task-id because transitions will promote // the target up to the root task while getTaskId returns the leaf. + && target.taskInfo.topActivity != null && target.taskInfo.topActivity.equals(mLauncher.getComponentName())) { return true; } From 5cca2265b6ec71d2c6d701dec3005729bf005bc5 Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 31 Aug 2021 18:01:50 -0700 Subject: [PATCH 6/7] Revert "Band-aid for getHomeActivities returning null" This reverts commit 42a7d1af83b317076afc16f5ff8e142c828bf613. REASON FOR REVERT: the underlying framework bug is fixed Test: presubmit Bug: 187080582 Change-Id: If580a35196ba9a9c5e3a5da642a2ea3aa3d9048e --- .../quickstep/OverviewComponentObserver.java | 13 ------------- src/com/android/launcher3/testing/TestProtocol.java | 1 - 2 files changed, 14 deletions(-) diff --git a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java index 780032e11b..0efe6666a8 100644 --- a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java +++ b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java @@ -33,11 +33,8 @@ import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.os.SystemClock; -import android.util.Log; import android.util.SparseIntArray; -import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.tracing.OverviewComponentObserverProto; import com.android.launcher3.tracing.TouchInteractionServiceProto; import com.android.launcher3.util.SimpleBroadcastReceiver; @@ -132,16 +129,6 @@ public final class OverviewComponentObserver { private void updateOverviewTargets() { ComponentName defaultHome = PackageManagerWrapper.getInstance() .getHomeActivities(new ArrayList<>()); - if (TestProtocol.sDebugTracing && defaultHome == null) { - Log.d(TestProtocol.THIRD_PARTY_LAUNCHER_NOT_SET, "getHomeActivities returned null"); - while ((defaultHome = - PackageManagerWrapper.getInstance().getHomeActivities(new ArrayList<>())) - == null) { - SystemClock.sleep(10); - } - Log.d(TestProtocol.THIRD_PARTY_LAUNCHER_NOT_SET, - "getHomeActivities returned non-null: " + defaultHome); - } mIsHomeDisabled = mDeviceState.isHomeDisabled(); mIsDefaultHome = Objects.equals(mMyHomeIntent.getComponent(), defaultHome); diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index c4848112ef..42a38b6271 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -117,7 +117,6 @@ public final class TestProtocol { public static final String PERMANENT_DIAG_TAG = "TaplTarget"; public static final String WORK_PROFILE_REMOVED = "b/159671700"; public static final String FALLBACK_ACTIVITY_NO_SET = "b/181019015"; - public static final String THIRD_PARTY_LAUNCHER_NOT_SET = "b/187080582"; public static final String TASK_VIEW_ID_CRASH = "b/195430732"; public static final String L3_SWIPE_TO_HOME = "b/192018189"; } From f0b8ef9dfd26960b867cf5dd8a0d8351f8d668fd Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Wed, 1 Sep 2021 15:10:37 +0100 Subject: [PATCH 7/7] Only restore previous currentPage in applyLoadPlan if mCurrentPage is outdated Bug: 197493120 Test: manual Change-Id: I196088c848f9fa8ec23f6c803226d674ba3e088b --- quickstep/src/com/android/quickstep/views/RecentsView.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 6aa7e061e6..e99835e0c8 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1367,7 +1367,10 @@ public abstract class RecentsView