Snap for 10120310 from ebc1cea517 to udc-qpr1-release

Change-Id: Ic7aee9c309cffd699ab446664a379d55c26d3284
This commit is contained in:
Android Build Coastguard Worker
2023-05-12 03:26:45 +00:00
20 changed files with 103 additions and 61 deletions
@@ -197,6 +197,10 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
return mTaskbarLauncherStateController.applyState(fromInit ? 0 : duration, startAnimation);
}
public void refreshResumedState() {
onLauncherResumedOrPaused(mLauncher.hasBeenResumed());
}
/**
* Create Taskbar animation when going from an app to Launcher as part of recents transition.
* @param toState If known, the state we will end up in when reaching Launcher.
@@ -33,11 +33,13 @@ import android.view.WindowInsets.Type.tappableElement
import android.view.WindowManager
import android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD
import android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION
import androidx.core.graphics.toRegion
import com.android.internal.policy.GestureNavigationSettingsObserver
import com.android.launcher3.DeviceProfile
import com.android.launcher3.R
import com.android.launcher3.anim.AlphaUpdateListener
import com.android.launcher3.taskbar.TaskbarControllers.LoggableTaskbarController
import com.android.launcher3.util.DisplayController
import java.io.PrintWriter
/** Handles the insets that Taskbar provides to underlying apps and the IME. */
@@ -220,7 +222,16 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
controllers.taskbarViewController.areIconsVisible() || context.isNavBarKidsModeActive
) {
// Taskbar has some touchable elements, take over the full taskbar area
insetsInfo.touchableRegion.set(touchableRegion)
if (
controllers.uiController.isInOverview &&
DisplayController.isTransientTaskbar(context)
) {
insetsInfo.touchableRegion.set(
controllers.taskbarActivityContext.dragLayer.lastDrawnTransientRect.toRegion()
)
} else {
insetsInfo.touchableRegion.set(touchableRegion)
}
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
insetsIsTouchableRegion = false
} else {
@@ -207,10 +207,6 @@ public class TaskbarLauncherStateController {
com.android.launcher3.taskbar.Utilities.setOverviewDragState(
mControllers, finalState.disallowTaskbarGlobalDrag(),
disallowLongClick, finalState.allowTaskbarInitialSplitSelection());
// LauncherTaskbarUIController depends on the state when checking whether
// to handle resume, so it should also be poked if current state changes
mLauncher.getTaskbarUIController().onLauncherResumedOrPaused(
mLauncher.hasBeenResumed());
}
};
@@ -424,6 +420,10 @@ public class TaskbarLauncherStateController {
// We're changing state to home, should close open popups e.g. Taskbar AllApps
handleOpenFloatingViews = true;
}
if (mLauncherState == LauncherState.OVERVIEW) {
// Calling to update the insets in TaskbarInsetController#updateInsetsTouchability
mControllers.taskbarActivityContext.notifyUpdateLayoutParams();
}
}
if (hasAnyFlag(changedFlags, FLAGS_LAUNCHER_ACTIVE)) {
@@ -318,4 +318,9 @@ public class TaskbarUIController {
}
return null;
}
/**
* Refreshes the resumed state of this ui controller.
*/
public void refreshResumedState() {}
}
@@ -334,6 +334,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
private boolean mCanSlowSwipeGoHome = true;
// Indicates whether the divider is shown, only used when split screen is activated.
private boolean mIsDividerShown = true;
private boolean mStartMovingTasks;
@Nullable
private RemoteAnimationTargets.ReleaseCheck mSwipePipToHomeReleaseCheck = null;
@@ -1722,12 +1723,19 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
return keepClearArea;
}
/**
* Notifies to start intercepting touches in the app window and hide the divider bar if needed.
* @see RecentsAnimationController#enableInputConsumer()
*/
private void startInterceptingTouchesForGesture() {
if (mRecentsAnimationController == null) {
if (mRecentsAnimationController == null || !mStartMovingTasks) {
return;
}
mRecentsAnimationController.enableInputConsumer();
// Hide the divider as it starts intercepting touches in the app window.
setDividerShown(false);
}
private void computeRecentsScrollIfInvisible() {
@@ -2339,9 +2347,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
boolean setRecentsScroll = mRecentsViewScrollLinked && mRecentsView != null;
float progress = Math.max(mCurrentShift.value, getScaleProgressDueToScroll());
int scrollOffset = setRecentsScroll ? mRecentsView.getScrollOffset() : 0;
if (progress > 0 || scrollOffset != 0) {
// Hide the divider as the tasks start moving.
setDividerShown(false);
if (!mStartMovingTasks && (progress > 0 || scrollOffset != 0)) {
mStartMovingTasks = true;
startInterceptingTouchesForGesture();
}
for (RemoteTargetHandle remoteHandle : mRemoteTargetHandles) {
AnimatorControllerWithResistance playbackController =
@@ -58,6 +58,7 @@ import android.os.SystemProperties;
import android.os.UserManager;
import android.provider.Settings;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import androidx.annotation.BinderThread;
import androidx.annotation.NonNull;
@@ -87,6 +88,10 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener {
static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";
// TODO: Move to quickstep contract
private static final float QUICKSTEP_TOUCH_SLOP_RATIO_TWO_BUTTON = 9;
private static final float QUICKSTEP_TOUCH_SLOP_RATIO_GESTURAL = 2;
private final Context mContext;
private final DisplayController mDisplayController;
private final int mDisplayId;
@@ -577,6 +582,19 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener {
&& ((mSystemUiStateFlags & SYSUI_STATE_IME_SHOWING) != 0);
}
/**
* Returns the touch slop for {@link InputConsumer}s to compare against before pilfering
* pointers. Note that this is squared because it expects to be compared against
* {@link com.android.launcher3.Utilities#squaredHypot} (to avoid square root on each event).
*/
public float getSquaredTouchSlop() {
float slopMultiplier = isFullyGesturalNavMode()
? QUICKSTEP_TOUCH_SLOP_RATIO_GESTURAL
: QUICKSTEP_TOUCH_SLOP_RATIO_TWO_BUTTON;
float touchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
return slopMultiplier * touchSlop * touchSlop;
}
public String getSystemUiStateString() {
return QuickStepContract.getSystemUiStateString(mSystemUiStateFlags);
}
@@ -127,23 +127,16 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
@Override
public void onTaskStageChanged(int taskId, @StageType int stage, boolean visible) {
// If task is not visible but we are tracking it, stop tracking it
if (!visible) {
// If a task is not visible anymore or has been moved to undefined, stop tracking it.
if (!visible || stage == SplitConfigurationOptions.STAGE_TYPE_UNDEFINED) {
if (mMainStagePosition.taskId == taskId) {
resetTaskId(mMainStagePosition);
mMainStagePosition.taskId = INVALID_TASK_ID;
} else if (mSideStagePosition.taskId == taskId) {
resetTaskId(mSideStagePosition);
mSideStagePosition.taskId = INVALID_TASK_ID;
} // else it's an un-tracked child
return;
}
// If stage has moved to undefined, stop tracking the task
if (stage == SplitConfigurationOptions.STAGE_TYPE_UNDEFINED) {
resetTaskId(taskId == mMainStagePosition.taskId
? mMainStagePosition : mSideStagePosition);
return;
}
if (stage == SplitConfigurationOptions.STAGE_TYPE_MAIN) {
mMainStagePosition.taskId = taskId;
} else {
@@ -161,10 +154,6 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
mPinnedTaskId = INVALID_TASK_ID;
}
private void resetTaskId(SplitStageInfo taskPosition) {
taskPosition.taskId = -1;
}
/**
* @return index 0 will be task in left/top position, index 1 in right/bottom position.
* Will return empty array if device is not in staged split
@@ -20,7 +20,6 @@ import static android.view.MotionEvent.ACTION_POINTER_DOWN;
import static android.view.MotionEvent.ACTION_UP;
import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.Utilities.squaredTouchSlop;
import static com.android.launcher3.util.VelocityUtils.PX_PER_MS;
import static com.android.quickstep.AbsSwipeUpHandler.MIN_PROGRESS_FOR_OVERVIEW;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
@@ -115,7 +114,7 @@ public class DeviceLockedInputConsumer implements InputConsumer,
mDeviceState = deviceState;
mTaskAnimationManager = taskAnimationManager;
mGestureState = gestureState;
mTouchSlopSquared = squaredTouchSlop(context);
mTouchSlopSquared = mDeviceState.getSquaredTouchSlop();
mTransformParams = new TransformParams();
mInputMonitorCompat = inputMonitorCompat;
mMaxTranslationY = context.getResources().getDimensionPixelSize(
@@ -21,8 +21,8 @@ import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_UP;
import static com.android.launcher3.testing.shared.ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE;
import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.testing.shared.ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE;
import android.content.Context;
import android.graphics.Point;
@@ -31,7 +31,6 @@ import android.view.MotionEvent;
import com.android.launcher3.R;
import com.android.launcher3.testing.shared.ResourceUtils;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.DisplayController;
import com.android.quickstep.InputConsumer;
import com.android.quickstep.RecentsAnimationDeviceState;
@@ -69,7 +68,7 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
mDeviceState = deviceState;
mDragDistThreshold = context.getResources().getDimensionPixelSize(
R.dimen.gestures_onehanded_drag_threshold);
mSquaredSlop = Utilities.squaredTouchSlop(context);
mSquaredSlop = mDeviceState.getSquaredTouchSlop();
mDisplaySize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize;
mNavBarSize = ResourceUtils.getNavbarSize(NAVBAR_BOTTOM_GESTURE_SIZE,
mContext.getResources());
@@ -80,10 +80,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
public static final String DOWN_EVT = "OtherActivityInputConsumer.DOWN";
private static final String UP_EVT = "OtherActivityInputConsumer.UP";
// TODO: Move to quickstep contract
public static final float QUICKSTEP_TOUCH_SLOP_RATIO_TWO_BUTTON = 9;
public static final float QUICKSTEP_TOUCH_SLOP_RATIO_GESTURAL = 2;
// Minimum angle of a gesture's coordinate where a release goes to overview.
public static final int OVERVIEW_MIN_DEGREES = 15;
@@ -157,11 +153,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
boolean continuingPreviousGesture = mTaskAnimationManager.isRecentsAnimationRunning();
mIsDeferredDownTarget = !continuingPreviousGesture && isDeferredDownTarget;
float slopMultiplier = mDeviceState.isFullyGesturalNavMode()
? QUICKSTEP_TOUCH_SLOP_RATIO_GESTURAL
: QUICKSTEP_TOUCH_SLOP_RATIO_TWO_BUTTON;
mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();
mSquaredTouchSlop = slopMultiplier * mTouchSlop * mTouchSlop;
mSquaredTouchSlop = mDeviceState.getSquaredTouchSlop();
mPassedPilferInputSlop = mPassedWindowMoveSlop = continuingPreviousGesture;
mDisableHorizontalSwipe = !mPassedPilferInputSlop && disableHorizontalSwipe;
@@ -81,6 +81,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
InputMonitorCompat inputMonitor, TaskbarActivityContext taskbarActivityContext) {
super(delegate, inputMonitor);
mTaskbarActivityContext = taskbarActivityContext;
// TODO(b/270395798): remove this when cleaning up old Persistent Taskbar code.
mSquaredTouchSlop = Utilities.squaredTouchSlop(context);
mScreenWidth = taskbarActivityContext.getDeviceProfile().widthPx;
@@ -849,6 +849,13 @@ public class TaskView extends FrameLayout implements Reusable {
// QuickstepTransitionManager.createWallpaperOpenAnimations when launcher
// shows again
getRecentsView().startHome(false /* animated */);
RecentsView rv = getRecentsView();
if (rv != null && rv.mSizeStrategy.getTaskbarController() != null) {
// LauncherTaskbarUIController depends on the launcher state when checking
// whether to handle resume, but that can come in before startHome() changes
// the state, so force-refresh here to ensure the taskbar is updated
rv.mSizeStrategy.getTaskbarController().refreshResumedState();
}
});
}
// Indicate success once the system has indicated that the transition has started
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.Overview;
import com.android.launcher3.tapl.Taskbar;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.ui.TaplTestsLauncher3;
@@ -57,7 +58,10 @@ public class AbstractTaplTestsTaskbar extends AbstractQuickStepTest {
"com.android.launcher3.testcomponent.BaseTestingActivity");
mLauncherLayout = TestUtil.setLauncherDefaultLayout(mTargetContext, layoutBuilder);
TaplTestsLauncher3.initialize(this);
Overview overview = mLauncher.getWorkspace().switchToOverview();
if (overview.hasTasks()) {
overview.dismissAllTasks();
}
startAppFast(CALCULATOR_APP_PACKAGE);
mLauncher.enableBlockTimeout(true);
mLauncher.showTaskbarIfHidden();
@@ -65,7 +69,6 @@ public class AbstractTaplTestsTaskbar extends AbstractQuickStepTest {
@After
public void tearDown() throws Exception {
setTaskbarMode(mLauncher, mTaskbarWasInTransientMode);
mLauncher.enableBlockTimeout(false);
if (mLauncherLayout != null) {
mLauncherLayout.close();
@@ -29,13 +29,6 @@ import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class TaplTestsPersistentTaskbar extends AbstractTaplTestsTaskbar {
@Override
public void setUp() throws Exception {
mTaskbarWasInTransientMode = isTaskbarInTransientMode(mTargetContext);
setTaskbarMode(mLauncher, false);
super.setUp();
}
@Test
@TaskbarModeSwitch(mode = PERSISTENT)
public void testHideShowTaskbar() {
@@ -20,7 +20,6 @@ import static com.android.quickstep.TaplTestsTaskbar.TaskbarMode.TRANSIENT;
import androidx.test.filters.LargeTest;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
import org.junit.Test;
@@ -58,14 +57,19 @@ public class TaplTestsTaskbar extends AbstractTaplTestsTaskbar {
super.setUp();
}
@Override
public void tearDown() throws Exception {
setTaskbarMode(mLauncher, mTaskbarWasInTransientMode);
super.tearDown();
}
@Test
public void testLaunchApp() {
getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
// We are using parameterized test runner to share code between different test cases with
// taskbar variants. But, sometimes we only need to assert things for particular Taskbar
// variants.
if (isTaskbarTestModeTransient() && mLauncher.getNavigationModel()
!= LauncherInstrumentation.NavigationModel.THREE_BUTTON) {
if (isTaskbarTestModeTransient()) {
mLauncher.getLaunchedAppState().assertTaskbarHidden();
}
}
@@ -32,13 +32,6 @@ import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class TaplTestsTransientTaskbar extends AbstractTaplTestsTaskbar {
@Override
public void setUp() throws Exception {
mTaskbarWasInTransientMode = isTaskbarInTransientMode(mTargetContext);
setTaskbarMode(mLauncher, true);
super.setUp();
}
@Test
@TaskbarModeSwitch(mode = TRANSIENT)
public void testShowTaskbarUnstashHintOnHover() {
@@ -97,7 +97,11 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
StatsLogManager statsLogManager) {
mUserManager = userManager;
mAllApps = allApps;
if (FeatureFlags.ENABLE_APP_CLONING_CHANGES_IN_LAUNCHER.get()) {
boolean cloningChanges = FeatureFlags.ENABLE_APP_CLONING_CHANGES_IN_LAUNCHER.get();
if (TestProtocol.sDebugTracing) {
Log.d(WORK_TAB_MISSING, "matcher flag: " + cloningChanges);
}
if (cloningChanges) {
mMatcher = ofWorkProfileUser(userManager);
} else {
mMatcher = mAllApps.mPersonalMatcher.negate();
@@ -95,7 +95,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
mPackages = packages;
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.WORK_TAB_MISSING, "PackageUpdatedTask mOp: " + mOp +
" packageCount: " + mPackages.length);
" packageCount: " + mPackages.length + " user: " + user);
DEBUG = true;
}
}
@@ -229,8 +229,10 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
listener.onAnimationEnd(null);
}
return;
} else if (!mConfig.userControlled && animated && mConfig.targetState == state) {
// We are running the same animation as requested
} else if ((!mConfig.userControlled && animated && mConfig.targetState == state)
|| mState.shouldPreserveDataStateOnReapply()) {
// We are running the same animation as requested, and/or target state should not be
// reset -- allow the current animation to complete instead of canceling it.
if (listener != null) {
mConfig.currentAnimation.addListener(listener);
}
@@ -18,6 +18,7 @@ package com.android.launcher3.util;
import android.content.ComponentName;
import android.os.UserHandle;
import android.util.Log;
import androidx.annotation.NonNull;
@@ -25,6 +26,7 @@ import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.testing.shared.TestProtocol;
import java.util.Collection;
import java.util.HashSet;
@@ -42,7 +44,14 @@ public abstract class ItemInfoMatcher {
private static final ComponentName EMPTY_COMPONENT = new ComponentName("", "");
public static Predicate<ItemInfo> ofUser(UserHandle user) {
return info -> info != null && info.user.equals(user);
return info -> {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.WORK_TAB_MISSING, "userHandle: " + user
+ ", itemUserHandle: " + info.user
+ " package: " + info.getTargetPackage());
}
return info != null && info.user.equals(user);
};
}
public static Predicate<ItemInfo> ofComponents(