From 9e84e0c1c1e375e11ea6fa81b448dfe1cddd8b20 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 3 Apr 2019 16:44:32 -0700 Subject: [PATCH 1/7] Removing SWIPE_HOME flag and using sysUI mode instead Bug: 129873705 Change-Id: Ieaa7d7928427daed98538c616bdf58b28d295829 --- .../uioverrides/RecentsUiFactory.java | 4 +-- .../states/BackgroundAppState.java | 5 ++-- .../QuickSwitchTouchController.java | 5 ++-- .../TaskViewTouchController.java | 2 +- .../LauncherActivityControllerHelper.java | 12 ++++---- .../quickstep/OtherActivityInputConsumer.java | 6 ++-- .../WindowTransformSwipeHandler.java | 13 +++++---- .../quickstep/views/LauncherRecentsView.java | 2 +- .../launcher3/uioverrides/UiFactory.java | 12 ++++++++ .../quickstep/OverviewInteractionState.java | 4 --- .../quickstep/SysUINavigationMode.java | 4 +++ .../android/quickstep/util/LayoutUtils.java | 4 ++- .../quickstep/views/ShelfScrimView.java | 28 +++++++++++++++++-- src/com/android/launcher3/LauncherState.java | 7 +---- .../android/launcher3/config/BaseFlags.java | 4 --- .../launcher3/uioverrides/UiFactory.java | 6 ++++ 16 files changed, 78 insertions(+), 40 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java index f507d0f9db..518a2a6851 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java @@ -59,7 +59,7 @@ public abstract class RecentsUiFactory { private static final float RECENTS_PREPARE_SCALE = 1.33f; public static TouchController[] createTouchControllers(Launcher launcher) { - Mode mode = SysUINavigationMode.INSTANCE.get(launcher).getMode(); + Mode mode = SysUINavigationMode.getMode(launcher); ArrayList list = new ArrayList<>(); list.add(launcher.getDragController()); @@ -106,7 +106,7 @@ public abstract class RecentsUiFactory { * @param launcher the launcher activity */ public static void prepareToShowOverview(Launcher launcher) { - if (FeatureFlags.SWIPE_HOME.get()) { + if (SysUINavigationMode.getMode(launcher) == Mode.NO_BUTTON) { // Overview lives on the side, so doesn't scale in from above. return; } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java index d8f1628079..225ae8450a 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java @@ -20,8 +20,9 @@ import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS; import android.os.RemoteException; import com.android.launcher3.Launcher; import com.android.launcher3.allapps.AllAppsTransitionController; -import com.android.launcher3.config.FeatureFlags; import com.android.quickstep.RecentsModel; +import com.android.quickstep.SysUINavigationMode; +import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.recents.ISystemUiProxy; @@ -76,7 +77,7 @@ public class BackgroundAppState extends OverviewState { @Override public int getVisibleElements(Launcher launcher) { - if (FeatureFlags.SWIPE_HOME.get()) { + if (SysUINavigationMode.getMode(launcher) == Mode.NO_BUTTON) { return super.getVisibleElements(launcher); } // Hide shelf content (e.g. QSB) because we fade it in when swiping up. diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java index 91a31ddfe1..81090c1c90 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java @@ -36,11 +36,12 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorSetBuilder; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.touch.AbstractStateChangeTouchController; import com.android.launcher3.touch.SwipeDetector; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; +import com.android.quickstep.SysUINavigationMode; +import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; @@ -105,7 +106,7 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll private void setupInterpolators(AnimatorSetBuilder animatorSetBuilder) { animatorSetBuilder.setInterpolator(ANIM_WORKSPACE_FADE, DEACCEL_2); animatorSetBuilder.setInterpolator(ANIM_ALL_APPS_FADE, DEACCEL_2); - if (FeatureFlags.SWIPE_HOME.get()) { + if (SysUINavigationMode.getMode(mLauncher) == Mode.NO_BUTTON) { // Overview lives to the left of workspace, so translate down later than over animatorSetBuilder.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCEL_2); animatorSetBuilder.setInterpolator(ANIM_VERTICAL_PROGRESS, ACCEL_2); diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java index 62d954beb8..8b4aa07d79 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java @@ -123,7 +123,7 @@ public abstract class TaskViewTouchController if (mRecentsView.isTaskViewVisible(view) && mActivity.getDragLayer() .isEventOverView(view, ev)) { mTaskBeingDragged = view; - if (!SysUINavigationMode.INSTANCE.get(mActivity).getMode().hasGestures) { + if (!SysUINavigationMode.getMode(mActivity).hasGestures) { // Don't allow swipe down to open if we don't support swipe up // to enter overview. directionsToDetectScroll = SwipeDetector.DIRECTION_POSITIVE; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java index 766f4844ca..e903b6f3f3 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java @@ -16,6 +16,7 @@ package com.android.quickstep; import static android.view.View.TRANSLATION_Y; + import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherState.BACKGROUND_APP; import static com.android.launcher3.LauncherState.NORMAL; @@ -24,7 +25,6 @@ import static com.android.launcher3.allapps.AllAppsTransitionController.SPRING_D import static com.android.launcher3.allapps.AllAppsTransitionController.SPRING_STIFFNESS; import static com.android.launcher3.anim.Interpolators.DEACCEL_3; import static com.android.launcher3.anim.Interpolators.LINEAR; -import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -45,16 +45,15 @@ import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherInitListener; import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager; -import com.android.launcher3.Workspace; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.anim.SpringObjectAnimator; import com.android.launcher3.compat.AccessibilityManagerCompat; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.views.FloatingIconView; +import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.util.ClipAnimationHelper; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.views.RecentsView; @@ -76,8 +75,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe @Override public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) { LayoutUtils.calculateLauncherTaskSize(context, dp, outRect); - if (dp.isVerticalBarLayout() - && SysUINavigationMode.INSTANCE.get(context).getMode() != NO_BUTTON) { + if (dp.isVerticalBarLayout() && SysUINavigationMode.getMode(context) != Mode.NO_BUTTON) { Rect targetInsets = dp.getInsets(); int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right; return dp.hotseatBarSizePx + hotseatInset; @@ -254,8 +252,8 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe AnimatorSet anim = new AnimatorSet(); if (!activity.getDeviceProfile().isVerticalBarLayout() - && !FeatureFlags.SWIPE_HOME.get()) { - // Don't animate the shelf when SWIPE_HOME is true, because we update it atomically. + && SysUINavigationMode.getMode(activity) != Mode.NO_BUTTON) { + // Don't animate the shelf when the mode is NO_BUTTON, because we update it atomically. Animator shiftAnim = createShelfProgressAnim(activity, fromState.getVerticalProgress(activity), endState.getVerticalProgress(activity)); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java index aada84fbbe..990bcff51e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java @@ -45,10 +45,10 @@ import android.view.VelocityTracker; import android.view.ViewConfiguration; import android.view.WindowManager; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.RaceConditionTracker; import com.android.launcher3.util.TraceHelper; +import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget; import com.android.quickstep.util.CachedEventDispatcher; import com.android.quickstep.util.MotionPauseDetector; @@ -83,6 +83,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC private final InputConsumerController mInputConsumer; private final SwipeSharedState mSwipeSharedState; private final InputMonitorCompat mInputMonitorCompat; + private final SysUINavigationMode.Mode mMode; private final int mDisplayRotation; private final Rect mStableInsets = new Rect(); @@ -127,6 +128,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC mRunningTask = runningTaskInfo; mRecentsModel = recentsModel; mHomeIntent = homeIntent; + mMode = SysUINavigationMode.getMode(base); mMotionPauseDetector = new MotionPauseDetector(base); mOnCompleteCallback = onCompleteCallback; @@ -250,7 +252,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC // Move mInteractionHandler.updateDisplacement(displacement - mStartDisplacement); - if (FeatureFlags.SWIPE_HOME.get()) { + if (mMode == Mode.NO_BUTTON) { boolean isLandscape = isNavBarOnLeft() || isNavBarOnRight(); float orthogonalDisplacement = !isLandscape ? ev.getX() - mDownPos.x diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java index b1db780838..a974135be3 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -25,7 +25,6 @@ import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS; -import static com.android.launcher3.config.FeatureFlags.SWIPE_HOME; import static com.android.launcher3.util.RaceConditionTracker.ENTER; import static com.android.launcher3.util.RaceConditionTracker.EXIT; import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION; @@ -85,6 +84,7 @@ import com.android.quickstep.ActivityControlHelper.ActivityInitListener; import com.android.quickstep.ActivityControlHelper.AnimationFactory; import com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState; import com.android.quickstep.ActivityControlHelper.HomeAnimationFactory; +import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.util.ClipAnimationHelper; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.RemoteAnimationTargetSet; @@ -232,6 +232,8 @@ public class WindowTransformSwipeHandler private final ActivityControlHelper mActivityControlHelper; private final ActivityInitListener mActivityInitListener; + private final SysUINavigationMode.Mode mMode; + private final int mRunningTaskId; private ThumbnailData mTaskSnapshot; @@ -272,6 +274,7 @@ public class WindowTransformSwipeHandler mClipAnimationHelper = new ClipAnimationHelper(context); mTransformParams = new ClipAnimationHelper.TransformParams(); + mMode = SysUINavigationMode.getMode(context); initStateCallbacks(); } @@ -584,7 +587,7 @@ public class WindowTransformSwipeHandler final boolean passed = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW; if (passed != mPassedOverviewThreshold) { mPassedOverviewThreshold = passed; - if (mRecentsView != null && !SWIPE_HOME.get()) { + if (mRecentsView != null && mMode != Mode.NO_BUTTON) { mRecentsView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } @@ -744,7 +747,7 @@ public class WindowTransformSwipeHandler } final boolean reachedOverviewThreshold = currentShift >= MIN_PROGRESS_FOR_OVERVIEW; if (!isFling) { - if (SWIPE_HOME.get()) { + if (mMode == Mode.NO_BUTTON) { if (mIsShelfPeeking) { endTarget = RECENTS; } else if (goingToNewTask) { @@ -766,7 +769,7 @@ public class WindowTransformSwipeHandler startShift = currentShift; interpolator = endTarget == RECENTS ? OVERSHOOT_1_2 : DEACCEL; } else { - if (SWIPE_HOME.get() && endVelocity < 0 && !mIsShelfPeeking) { + if (mMode == Mode.NO_BUTTON && endVelocity < 0 && !mIsShelfPeeking) { // If swiping at a diagonal, base end target on the faster velocity. endTarget = goingToNewTask && Math.abs(velocity.x) > Math.abs(endVelocity) ? NEW_TASK : HOME; @@ -817,7 +820,7 @@ public class WindowTransformSwipeHandler if (mRecentsView != null) { duration = Math.max(duration, mRecentsView.getScroller().getDuration()); } - if (SWIPE_HOME.get()) { + if (mMode == Mode.NO_BUTTON) { setShelfState(ShelfAnimState.OVERVIEW, interpolator, duration); } } else if (endTarget == NEW_TASK || endTarget == LAST_TASK) { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java index 329436b4c4..1ccc3f16df 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java @@ -130,7 +130,7 @@ public class LauncherRecentsView extends RecentsView { ClipAnimationHelper helper) { AnimatorSet anim = super.createAdjacentPageAnimForTaskLaunch(tv, helper); - if (!SysUINavigationMode.INSTANCE.get(mActivity).getMode().hasGestures) { + if (!SysUINavigationMode.getMode(mActivity).hasGestures) { // Hotseat doesn't move when opening recents with the button, // so don't animate it here either. return anim; diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java index 6d730b6d65..482bbdee1a 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java @@ -37,14 +37,17 @@ import android.util.Base64; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; +import com.android.launcher3.LauncherState.ScaleAndTranslation; import com.android.launcher3.LauncherStateManager; import com.android.launcher3.LauncherStateManager.StateHandler; import com.android.launcher3.QuickstepAppTransitionManagerImpl; import com.android.launcher3.Utilities; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragLayer; import com.android.quickstep.OverviewInteractionState; import com.android.quickstep.RecentsModel; import com.android.quickstep.SysUINavigationMode; +import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener; import com.android.quickstep.util.RemoteFadeOutAnimationListener; import com.android.systemui.shared.system.ActivityCompat; @@ -186,4 +189,13 @@ public class UiFactory extends RecentsUiFactory { out.toByteArray(), Base64.NO_WRAP | Base64.NO_PADDING)); return true; } + + public static ScaleAndTranslation getOverviewScaleAndTranslationForNormalState(Launcher l) { + if (SysUINavigationMode.getMode(l) == Mode.NO_BUTTON) { + float offscreenTranslationX = l.getDragLayer().getWidth() + - l.getOverviewPanel().getPaddingStart(); + return new ScaleAndTranslation(1f, offscreenTranslationX, 0f); + } + return new ScaleAndTranslation(1.1f, 0f, 0f); + } } diff --git a/quickstep/src/com/android/quickstep/OverviewInteractionState.java b/quickstep/src/com/android/quickstep/OverviewInteractionState.java index ce472c6671..286ddc043e 100644 --- a/quickstep/src/com/android/quickstep/OverviewInteractionState.java +++ b/quickstep/src/com/android/quickstep/OverviewInteractionState.java @@ -27,10 +27,8 @@ import android.util.Log; import com.android.launcher3.Utilities; import com.android.launcher3.allapps.DiscoveryBounce; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.UiThreadHelper; -import com.android.quickstep.SysUINavigationMode.Mode; import com.android.systemui.shared.recents.ISystemUiProxy; import androidx.annotation.WorkerThread; @@ -150,8 +148,6 @@ public class OverviewInteractionState { } private void onNavigationModeChanged(SysUINavigationMode.Mode mode) { - FeatureFlags.SWIPE_HOME.updateStorage(mContext, mode == Mode.NO_BUTTON); - mSwipeUpEnabled = mode.hasGestures; resetHomeBounceSeenOnQuickstepEnabledFirstTime(); mBgHandler.obtainMessage(MSG_APPLY_FLAGS).sendToTarget(); diff --git a/quickstep/src/com/android/quickstep/SysUINavigationMode.java b/quickstep/src/com/android/quickstep/SysUINavigationMode.java index 1953ecb85f..dbae794e04 100644 --- a/quickstep/src/com/android/quickstep/SysUINavigationMode.java +++ b/quickstep/src/com/android/quickstep/SysUINavigationMode.java @@ -48,6 +48,10 @@ public class SysUINavigationMode { } } + public static Mode getMode(Context context) { + return INSTANCE.get(context).getMode(); + } + public static MainThreadInitializedObject INSTANCE = new MainThreadInitializedObject<>(SysUINavigationMode::new); diff --git a/quickstep/src/com/android/quickstep/util/LayoutUtils.java b/quickstep/src/com/android/quickstep/util/LayoutUtils.java index a06209ac46..bfe31d1311 100644 --- a/quickstep/src/com/android/quickstep/util/LayoutUtils.java +++ b/quickstep/src/com/android/quickstep/util/LayoutUtils.java @@ -27,6 +27,8 @@ import androidx.annotation.IntDef; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.config.FeatureFlags; +import com.android.quickstep.SysUINavigationMode; +import com.android.quickstep.SysUINavigationMode.Mode; import java.lang.annotation.Retention; @@ -116,7 +118,7 @@ public class LayoutUtils { } public static int getShelfTrackingDistance(Context context, DeviceProfile dp) { - if (FeatureFlags.SWIPE_HOME.get()) { + if (SysUINavigationMode.getMode(context) == Mode.NO_BUTTON) { // Track the bottom of the window rather than the top of the shelf. int shelfHeight = dp.hotseatBarSizePx + dp.getInsets().bottom; int spaceBetweenShelfAndRecents = (int) context.getResources().getDimension( diff --git a/quickstep/src/com/android/quickstep/views/ShelfScrimView.java b/quickstep/src/com/android/quickstep/views/ShelfScrimView.java index fe05c4f828..d74e880a21 100644 --- a/quickstep/src/com/android/quickstep/views/ShelfScrimView.java +++ b/quickstep/src/com/android/quickstep/views/ShelfScrimView.java @@ -34,9 +34,11 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.anim.Interpolators; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.Themes; import com.android.launcher3.views.ScrimView; +import com.android.quickstep.SysUINavigationMode; +import com.android.quickstep.SysUINavigationMode.Mode; +import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener; /** * Scrim used for all-apps and shelf in Overview @@ -45,7 +47,7 @@ import com.android.launcher3.views.ScrimView; * From normal state to overview state, the shelf just fades in and does not move * From overview state to all-apps state the shelf moves up and fades in to cover the screen */ -public class ShelfScrimView extends ScrimView { +public class ShelfScrimView extends ScrimView implements NavigationModeChangeListener { // If the progress is more than this, shelf follows the finger, otherwise it moves faster to // cover the whole screen @@ -78,6 +80,8 @@ public class ShelfScrimView extends ScrimView { private final Path mRemainingScreenPath = new Path(); private boolean mRemainingScreenPathValid = false; + private Mode mSysUINavigationMode; + public ShelfScrimView(Context context, AttributeSet attrs) { super(context, attrs); mMaxScrimAlpha = Math.round(OVERVIEW.getWorkspaceScrimAlpha(mLauncher) * 255); @@ -97,6 +101,24 @@ public class ShelfScrimView extends ScrimView { mRemainingScreenPathValid = false; } + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + onNavigationModeChanged(SysUINavigationMode.INSTANCE.get(getContext()) + .addModeChangeListener(this)); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + SysUINavigationMode.INSTANCE.get(getContext()).removeModeChangeListener(this); + } + + @Override + public void onNavigationModeChanged(Mode newMode) { + mSysUINavigationMode = newMode; + } + @Override public void reInitUi() { DeviceProfile dp = mLauncher.getDeviceProfile(); @@ -137,7 +159,7 @@ public class ShelfScrimView extends ScrimView { if (mProgress >= 1) { mRemainingScreenColor = 0; mShelfColor = 0; - if (FeatureFlags.SWIPE_HOME.get() + if (mSysUINavigationMode == Mode.NO_BUTTON && mLauncher.getStateManager().getState() == BACKGROUND_APP) { // Show the shelf background when peeking during swipe up. mShelfColor = setColorAlphaBound(mEndScrim, mMidAlpha); diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index c65a871b6c..124574cc0b 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -199,12 +199,7 @@ public class LauncherState { } public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) { - if (FeatureFlags.SWIPE_HOME.get()) { - float offscreenTranslationX = launcher.getDragLayer().getWidth() - - launcher.getOverviewPanel().getPaddingStart(); - return new ScaleAndTranslation(1f, offscreenTranslationX, 0f); - } - return new ScaleAndTranslation(1.1f, 0f, 0f); + return UiFactory.getOverviewScaleAndTranslationForNormalState(launcher); } public void onStateEnabled(Launcher launcher) { diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java index 656151f7a9..5150b7c677 100644 --- a/src/com/android/launcher3/config/BaseFlags.java +++ b/src/com/android/launcher3/config/BaseFlags.java @@ -110,10 +110,6 @@ abstract class BaseFlags { public static final TogglableFlag ENABLE_QUICKSTEP_LIVE_TILE = new TogglableFlag( "ENABLE_QUICKSTEP_LIVE_TILE", false, "Enable live tile in Quickstep overview"); - public static final ToggleableGlobalSettingsFlag SWIPE_HOME - = new ToggleableGlobalSettingsFlag("SWIPE_HOME", false, - "Swiping up on the nav bar goes home. Swipe and hold goes to recent apps."); - public static final TogglableFlag ENABLE_HINTS_IN_OVERVIEW = new TogglableFlag( "ENABLE_HINTS_IN_OVERVIEW", false, "Show chip hints and gleams on the overview screen"); diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java index 9939c25c88..c01b54a6dc 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java @@ -21,6 +21,7 @@ import android.content.Context; import android.os.CancellationSignal; import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherState.ScaleAndTranslation; import com.android.launcher3.LauncherStateManager.StateHandler; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.util.TouchController; @@ -67,4 +68,9 @@ public class UiFactory { public static void prepareToShowOverview(Launcher launcher) { } public static void setBackButtonAlpha(Launcher launcher, float alpha, boolean animate) { } + + + public static ScaleAndTranslation getOverviewScaleAndTranslationForNormalState(Launcher l) { + return new ScaleAndTranslation(1.1f, 0f, 0f); + } } From 19f996d7d7825e5919690d3b8fef74470d25d9de Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 3 Apr 2019 16:03:15 -0700 Subject: [PATCH 2/7] Exiting tests after a test fails to deinitialize This avoid confusion when following tests get affected by failures in earlier tests. Change-Id: I44abcb38d5de222e48b0c33f062044280305750e --- .../launcher3/ui/AbstractLauncherUiTest.java | 27 ++++++++++++++----- .../launcher3/ui/widget/BindWidgetTest.java | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index dd768fd88d..8a2e816161 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -20,6 +20,8 @@ import static androidx.test.InstrumentationRegistry.getInstrumentation; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static java.lang.System.exit; + import android.app.Instrumentation; import android.content.BroadcastReceiver; import android.content.Context; @@ -29,6 +31,7 @@ import android.content.pm.LauncherActivityInfo; import android.content.pm.PackageManager; import android.os.Process; import android.os.RemoteException; +import android.util.Log; import android.view.Surface; import androidx.test.InstrumentationRegistry; @@ -78,9 +81,10 @@ public abstract class AbstractLauncherUiTest { public static final long DEFAULT_ACTIVITY_TIMEOUT = TimeUnit.SECONDS.toMillis(10); public static final long DEFAULT_BROADCAST_TIMEOUT_SECS = 5; - public static final long SHORT_UI_TIMEOUT= 300; + public static final long SHORT_UI_TIMEOUT = 300; public static final long DEFAULT_UI_TIMEOUT = 10000; protected static final int LONG_WAIT_TIME_MS = 60000; + private static final String TAG = "AbstractLauncherUiTest"; protected MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor(); protected final UiDevice mDevice; @@ -107,10 +111,12 @@ public abstract class AbstractLauncherUiTest { @Rule public LauncherActivityRule mActivityMonitor = new LauncherActivityRule(); - @Rule public ShellCommandRule mDefaultLauncherRule = + @Rule + public ShellCommandRule mDefaultLauncherRule = TestHelpers.isInLauncherProcess() ? ShellCommandRule.setDefaultLauncher() : null; - @Rule public ShellCommandRule mDisableHeadsUpNotification = + @Rule + public ShellCommandRule mDisableHeadsUpNotification = ShellCommandRule.disableHeadsUpNotification(); // Annotation for tests that need to be run in portrait and landscape modes. @@ -164,9 +170,17 @@ public abstract class AbstractLauncherUiTest { } @After - public void tearDown() throws Exception { - // Limits UI tests affecting tests running after them. - waitForModelLoaded(); + public void tearDown() { + try { + // Limits UI tests affecting tests running after them. + waitForModelLoaded(); + } catch (Throwable t) { + Log.e(TAG, + "Couldn't deinit after a test, exiting tests, see logs for failures that " + + "could have caused this", + t); + exit(1); + } } protected void lockRotation(boolean naturalOrientation) throws RemoteException { @@ -189,6 +203,7 @@ public abstract class AbstractLauncherUiTest { /** * Scrolls the {@param container} until it finds an object matching {@param condition}. + * * @return the matching object. */ protected UiObject2 scrollAndFind(UiObject2 container, BySelector condition) { diff --git a/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java index 68b16d6db5..c8e7786b1f 100644 --- a/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java +++ b/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java @@ -95,7 +95,7 @@ public class BindWidgetTest extends AbstractLauncherUiTest { } @After - public void tearDown() throws Exception { + public void tearDown() { if (mCursor != null) { mCursor.close(); } From 5b58d5f7b263482d9a23e56590bd29cd60234afb Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 3 Apr 2019 18:10:54 -0700 Subject: [PATCH 3/7] Fix SwipeDetectorTest Change-Id: Ic2ef1f73b7381b31cf495ea505794c0689da9ac9 --- tests/src/com/android/launcher3/touch/SwipeDetectorTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java index 4ebf54c7bf..e042357083 100644 --- a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java +++ b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java @@ -17,6 +17,7 @@ package com.android.launcher3.touch; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyFloat; +import static org.mockito.Matchers.anyObject; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -149,7 +150,7 @@ public class SwipeDetectorTest { mGenerator.put(0, 100, 100); mGenerator.move(0, 100, 100 + mTouchSlop); // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener).onDrag(anyFloat()); + verify(mMockListener).onDrag(anyFloat(), anyObject()); } @Test From f1855521088572def7e31245cc506e785c8b1751 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 3 Apr 2019 18:31:43 -0700 Subject: [PATCH 4/7] Not using Play Store app in tests As it magically misses from some devices Change-Id: I7765d987ef996dc2f515b9a0023b6f545f9cb534 --- .../com/android/quickstep/TaplTestsQuickstep.java | 2 +- .../android/launcher3/ui/TaplTestsLauncher3.java | 14 +++++++------- .../tapl/com/android/launcher3/tapl/Workspace.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 4112ccf714..1709516fc7 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -60,7 +60,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { } private void startTestApps() throws Exception { - startAppFast(resolveSystemApp(Intent.CATEGORY_APP_MARKET)); + startAppFast(resolveSystemApp(Intent.CATEGORY_APP_BROWSER)); startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CONTACTS)); diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index d29d29c2d3..c2e6749d59 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -207,8 +207,8 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { // Test that ensureWorkspaceIsScrollable adds a page by dragging an icon there. executeOnLauncher(launcher -> assertFalse("Initial workspace state is scrollable", isWorkspaceScrollable(launcher))); - assertNull("Play Store app was found on empty workspace", - workspace.tryGetWorkspaceAppIcon("Play Store")); + assertNull("Chrome app was found on empty workspace", + workspace.tryGetWorkspaceAppIcon("Chrome")); workspace.ensureWorkspaceIsScrollable(); @@ -218,8 +218,8 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { executeOnLauncher( launcher -> assertTrue("ensureScrollable didn't make workspace scrollable", isWorkspaceScrollable(launcher))); - assertNotNull("ensureScrollable didn't add Play Store app", - workspace.tryGetWorkspaceAppIcon("Play Store")); + assertNotNull("ensureScrollable didn't add Chrome app", + workspace.tryGetWorkspaceAppIcon("Chrome")); // Test flinging workspace. workspace.flingBackward(); @@ -235,10 +235,10 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { assertTrue("Launcher internal state is not Home", isInState(LauncherState.NORMAL)); // Test starting a workspace app. - final AppIcon app = workspace.tryGetWorkspaceAppIcon("Play Store"); - assertNotNull("No Play Store app in workspace", app); + final AppIcon app = workspace.tryGetWorkspaceAppIcon("Chrome"); + assertNotNull("No Chrome app in workspace", app); assertNotNull("AppIcon.launch returned null", - app.launch(resolveSystemApp(Intent.CATEGORY_APP_MARKET))); + app.launch(resolveSystemApp(Intent.CATEGORY_APP_BROWSER))); executeOnLauncher(launcher -> assertTrue( "Launcher activity is the top activity; expecting another activity to be the top " + "one", diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index 91443d0a0a..68b007e2cb 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -114,7 +114,7 @@ public final class Workspace extends Home { if (!isWorkspaceScrollable(workspace)) { dragIconToWorkspace( mLauncher, - getHotseatAppIcon("Play Store"), + getHotseatAppIcon("Chrome"), new Point(mLauncher.getDevice().getDisplayWidth(), workspace.getVisibleBounds().centerY()), (int) (ICON_DRAG_SPEED * mLauncher.getDisplayDensity())); From 471115589eb2647ca4962cc6f5dce0653f0b9a78 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 3 Apr 2019 19:09:59 -0700 Subject: [PATCH 5/7] Diagnosing phone locked state in TAPL Change-Id: I4bc678b35ca373015eaf476901694aee4df348f3 --- .../launcher3/tapl/LauncherInstrumentation.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index a4b4171928..ef3cb1f8dc 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -36,6 +36,7 @@ import android.view.MotionEvent; import android.view.Surface; import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.test.uiautomator.By; @@ -44,15 +45,18 @@ import androidx.test.uiautomator.Configurator; import androidx.test.uiautomator.UiDevice; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; + import com.android.launcher3.TestProtocol; import com.android.systemui.shared.system.QuickStepContract; + +import org.junit.Assert; + import java.io.IOException; import java.lang.ref.WeakReference; import java.util.Deque; import java.util.LinkedList; import java.util.List; import java.util.concurrent.TimeoutException; -import org.junit.Assert; /** * The main tapl object. The only object that can be explicitly constructed by the using code. It @@ -149,6 +153,8 @@ public final class LauncherInstrumentation { } catch (IOException e) { fail(e.toString()); } + + assertTrue("Phone is locked", !hasSystemUiObject("keyguard_status_view")); } Context getContext() { @@ -245,10 +251,10 @@ public final class LauncherInstrumentation { final NavigationModel navigationModel = getNavigationModel(); assertTrue("Presence of recents button doesn't match the interaction mode", (navigationModel == NavigationModel.THREE_BUTTON) == - mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, "recent_apps"))); + hasSystemUiObject("recent_apps")); assertTrue("Presence of home button doesn't match the interaction mode", (navigationModel != NavigationModel.ZERO_BUTTON) == - mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, "home"))); + hasSystemUiObject("home")); log("verifyContainerType: " + containerType); try (Closable c = addContextLayer( @@ -477,6 +483,10 @@ public final class LauncherInstrumentation { WAIT_TIME_MS)); } + private boolean hasSystemUiObject(String resId) { + return mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, resId)); + } + @NonNull UiObject2 waitForSystemUiObject(String resId) { final UiObject2 object = mDevice.wait( From 3f8544af9ad308b6093b70cf34eb4109e1e6dbb6 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Wed, 3 Apr 2019 23:05:55 -0700 Subject: [PATCH 6/7] Move PlubinLib to prebuilts/frameworks_intermediates Bug: 129423457 Change-Id: I7ed06609efa33ae98ffcd6f937a76a6b772c3fc1 --- Android.mk | 15 +++++---------- libs/plugin_core.jar | Bin 5057 -> 0 bytes 2 files changed, 5 insertions(+), 10 deletions(-) delete mode 100644 libs/plugin_core.jar diff --git a/Android.mk b/Android.mk index 06ee66fdd2..a817415ea6 100644 --- a/Android.mk +++ b/Android.mk @@ -16,15 +16,6 @@ LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := libPluginCore -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := JAVA_LIBRARIES -LOCAL_SRC_FILES := libs/plugin_core.jar -LOCAL_UNINSTALLABLE_MODULE := true -LOCAL_SDK_VERSION := current -include $(BUILD_PREBUILT) - # # Build rule for plugin lib (needed to write a plugin). # @@ -33,7 +24,11 @@ LOCAL_USE_AAPT2 := true LOCAL_AAPT2_ONLY := true LOCAL_MODULE_TAGS := optional -LOCAL_STATIC_JAVA_LIBRARIES:= libPluginCore +ifneq (,$(wildcard frameworks/base)) + LOCAL_STATIC_JAVA_LIBRARIES:= PluginCoreLib +else + LOCAL_STATIC_JAVA_LIBRARIES:= libPluginCore +endif LOCAL_SRC_FILES := \ $(call all-java-files-under, src_plugins) diff --git a/libs/plugin_core.jar b/libs/plugin_core.jar deleted file mode 100644 index dd27f86fa3f803e79353f2e549caa72d9bdbad6b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5057 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 Ee@Xr(!2kdN From 24eb1c9c89f26f2371cc26c1eaa4e647820f2f0b Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 4 Apr 2019 13:16:17 -0700 Subject: [PATCH 7/7] Not using magic constant for edge sensitivity +Some cleanup in TAPL Change-Id: I886a6c4abacf8b806ee5507e633ec21f2e7ad1d4 --- .../quickstep/NavigationModeSwitchRule.java | 20 +++++--- .../android/launcher3/tapl/BaseOverview.java | 6 +-- .../tapl/LauncherInstrumentation.java | 46 ++++++------------- .../com/android/launcher3/tapl/Workspace.java | 6 +-- 4 files changed, 30 insertions(+), 48 deletions(-) diff --git a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java index f5ac9c94ee..895485ddf8 100644 --- a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java +++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java @@ -17,6 +17,7 @@ package com.android.quickstep; import static androidx.test.InstrumentationRegistry.getInstrumentation; + import static com.android.quickstep.NavigationModeSwitchRule.Mode.ALL; import static com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON; import static com.android.quickstep.NavigationModeSwitchRule.Mode.TWO_BUTTON; @@ -26,18 +27,23 @@ import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_ import android.content.Context; import android.util.Log; + import androidx.test.uiautomator.UiDevice; + import com.android.launcher3.tapl.LauncherInstrumentation; import com.android.launcher3.tapl.TestHelpers; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import com.android.systemui.shared.system.QuickStepContract; + import org.junit.Assert; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + /** * Test rule that allows executing a test with Quickstep on and then Quickstep off. * The test should be annotated with @QuickstepOnOff. @@ -72,9 +78,9 @@ public class NavigationModeSwitchRule implements TestRule { @Override public void evaluate() throws Throwable { final Context context = getInstrumentation().getContext(); - final String prevOverlayPkg = LauncherInstrumentation.isGesturalMode(context) + final String prevOverlayPkg = QuickStepContract.isGesturalMode(context) ? NAV_BAR_MODE_GESTURAL_OVERLAY - : LauncherInstrumentation.isSwipeUpMode(context) + : QuickStepContract.isSwipeUpMode(context) ? NAV_BAR_MODE_2BUTTON_OVERLAY : NAV_BAR_MODE_3BUTTON_OVERLAY; final LauncherInstrumentation.NavigationModel originalMode = @@ -144,4 +150,4 @@ public class NavigationModeSwitchRule implements TestRule { return base; } } -} +} \ No newline at end of file diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java index 4205188098..74a17ce349 100644 --- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java +++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java @@ -48,8 +48,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { mLauncher.addContextLayer("want to fling forward in overview")) { LauncherInstrumentation.log("Overview.flingForward before fling"); final UiObject2 overview = verifyActiveContainer(); - final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1; - overview.setGestureMargins(margin, 0, 0, 0); + overview.setGestureMargins(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0); overview.fling(Direction.LEFT, (int) (FLING_SPEED * mLauncher.getDisplayDensity())); mLauncher.waitForIdle(); verifyActiveContainer(); @@ -86,8 +85,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { mLauncher.addContextLayer("want to fling backward in overview")) { LauncherInstrumentation.log("Overview.flingBackward before fling"); final UiObject2 overview = verifyActiveContainer(); - final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1; - overview.setGestureMargins(0, 0, margin, 0); + overview.setGestureMargins(0, 0, mLauncher.getEdgeSensitivityWidth(), 0); overview.fling(Direction.RIGHT, (int) (FLING_SPEED * mLauncher.getDisplayDensity())); mLauncher.waitForIdle(); verifyActiveContainer(); diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index ef3cb1f8dc..c72f7d0b68 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -22,7 +22,6 @@ import android.app.UiAutomation; import android.content.ContentResolver; import android.content.Context; import android.content.pm.PackageManager; -import android.content.res.Resources; import android.graphics.Point; import android.net.Uri; import android.os.Build; @@ -65,8 +64,6 @@ import java.util.concurrent.TimeoutException; public final class LauncherInstrumentation { private static final String TAG = "Tapl"; - private static final String NAV_BAR_INTERACTION_MODE_RES_NAME = - "config_navBarInteractionMode"; private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 20; // Types for launcher containers that the user is interacting with. "Background" is a @@ -175,11 +172,11 @@ public final class LauncherInstrumentation { // Workaround, use constructed context because both the instrumentation context and the // app context are not constructed with resources that take overlays into account final Context ctx = baseContext.createPackageContext("android", 0); - if (isGesturalMode(ctx)) { + if (QuickStepContract.isGesturalMode(ctx)) { return NavigationModel.ZERO_BUTTON; - } else if (isSwipeUpMode(ctx)) { + } else if (QuickStepContract.isSwipeUpMode(ctx)) { return NavigationModel.TWO_BUTTON; - } else if (isLegacyMode(ctx)) { + } else if (QuickStepContract.isLegacyMode(ctx)) { return NavigationModel.THREE_BUTTON; } else { fail("Can't detect navigation mode"); @@ -610,37 +607,20 @@ public final class LauncherInstrumentation { } } - public static boolean isGesturalMode(Context context) { - return QuickStepContract.isGesturalMode( - getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME)); - } - - public static boolean isSwipeUpMode(Context context) { - return QuickStepContract.isSwipeUpMode( - getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME)); - } - - public static boolean isLegacyMode(Context context) { - return QuickStepContract.isLegacyMode( - getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME)); - } - - private static int getSystemIntegerRes(Context context, String resName) { - Resources res = context.getResources(); - int resId = res.getIdentifier(resName, "integer", "android"); - - if (resId != 0) { - return res.getInteger(resId); - } else { - Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?"); - return -1; - } - } - static void sleep(int duration) { try { Thread.sleep(duration); } catch (InterruptedException e) { } } + + int getEdgeSensitivityWidth() { + try { + return QuickStepContract.getEdgeSensitivityWidth( + mInstrumentation.getTargetContext().createPackageContext("android", 0)) + 1; + } catch (PackageManager.NameNotFoundException e) { + fail("Can't get edge sensitivity: " + e); + return 0; + } + } } \ No newline at end of file diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index 68b007e2cb..f04afa05f6 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -148,8 +148,7 @@ public final class Workspace extends Home { */ public void flingForward() { final UiObject2 workspace = verifyActiveContainer(); - final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1; - workspace.setGestureMargins(0, 0, margin, 0); + workspace.setGestureMargins(0, 0, mLauncher.getEdgeSensitivityWidth(), 0); workspace.fling(Direction.RIGHT, (int) (FLING_SPEED * mLauncher.getDisplayDensity())); mLauncher.waitForIdle(); verifyActiveContainer(); @@ -161,8 +160,7 @@ public final class Workspace extends Home { */ public void flingBackward() { final UiObject2 workspace = verifyActiveContainer(); - final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1; - workspace.setGestureMargins(margin, 0, 0, 0); + workspace.setGestureMargins(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0); workspace.fling(Direction.LEFT, (int) (FLING_SPEED * mLauncher.getDisplayDensity())); mLauncher.waitForIdle(); verifyActiveContainer();