Removing launcher dependency when logging quickstep interaction
as Launcher may not be ready when the touch gesture completes.
Change-Id: Ia69eb7bfb0340f7b7ce9b6c67be8851e5429f867
diff --git a/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java b/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java
index 3d2830d..541c6bb 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java
@@ -128,7 +128,7 @@
// Add user event logging for launcher pipeline
int direction = Direction.UP;
- if (mLauncher.getDeviceProfile().isLandscape) {
+ if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
direction = Direction.LEFT;
if (mLauncher.getDeviceProfile().isSeascape()) {
direction = Direction.RIGHT;
diff --git a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
index 9c3f0d4..75d8619 100644
--- a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
+++ b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
@@ -97,7 +97,7 @@
@Override
public View.OnClickListener getOnClickListener(Launcher launcher, TaskView taskView) {
- if (launcher.getDeviceProfile().inMultiWindowMode()) {
+ if (launcher.getDeviceProfile().isMultiWindowMode) {
return null;
}
final Task task = taskView.getTask();
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index ab564ed..ac253c7 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -61,9 +61,11 @@
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;
+import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.TouchConsumer.InteractionType;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -179,6 +181,7 @@
private float mCurrentDisplacement;
private boolean mGestureStarted;
+ private int mLogAction = Touch.SWIPE;
private @InteractionType int mInteractionType = INTERACTION_NORMAL;
@@ -619,6 +622,7 @@
final float endShift;
if (!isFling) {
endShift = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW ? 1 : 0;
+ mLogAction = Touch.SWIPE;
} else {
endShift = endVelocity < 0 ? 1 : 0;
float minFlingVelocity = res.getDimension(R.dimen.quickstep_fling_min_velocity);
@@ -630,31 +634,24 @@
// derivative of the scroll interpolator at zero, ie. 5.
duration = 5 * Math.round(1000 * Math.abs(distanceToTravel / endVelocity));
}
+ mLogAction = Touch.FLING;
}
animateToProgress(endShift, duration);
- int direction = Direction.UP;
- if (mLauncher.getDeviceProfile().isLandscape) {
- direction = Direction.LEFT;
- if (mLauncher.getDeviceProfile().isSeascape()) {
- direction = Direction.RIGHT;
- }
+ }
+
+ private void doLogGesture(boolean toLauncher) {
+ final int direction;
+ if (mDp.isVerticalBarLayout()) {
+ direction = (mDp.isSeascape() ^ toLauncher) ? Direction.LEFT : Direction.RIGHT;
+ } else {
+ direction = toLauncher ? Direction.UP : Direction.DOWN;
}
- int dstContainerType = LauncherLogProto.ContainerType.TASKSWITCHER;
- if (Float.compare(endShift, 0) == 0) {
- direction = Direction.DOWN;
- if (mLauncher.getDeviceProfile().isLandscape) {
- direction = Direction.RIGHT;
- if (mLauncher.getDeviceProfile().isSeascape()) {
- direction = Direction.LEFT;
- }
- }
- dstContainerType = LauncherLogProto.ContainerType.APP;
- }
- mLauncher.getUserEventDispatcher().logStateChangeAction(
- isFling ? Touch.FLING : Touch.SWIPE, direction,
- LauncherLogProto.ContainerType.NAVBAR,
- LauncherLogProto.ContainerType.APP,
+
+ int dstContainerType = toLauncher ? ContainerType.TASKSWITCHER : ContainerType.APP;
+ UserEventDispatcher.newInstance(mContext, mDp).logStateChangeAction(
+ mLogAction, direction,
+ ContainerType.NAVBAR, ContainerType.APP,
dstContainerType,
0);
}
@@ -676,6 +673,7 @@
@UiThread
private void resumeLastTask() {
mRecentsAnimationWrapper.finish(false /* toHome */, null);
+ doLogGesture(false /* toLauncher */);
}
public void reset() {
@@ -736,6 +734,7 @@
}
mRecentsAnimationWrapper.finish(true /* toHome */,
() -> setStateOnUiThread(STATE_SWITCH_TO_SCREENSHOT_COMPLETE));
+ doLogGesture(true /* toLauncher */);
}
private void setupLauncherUiAfterSwipeUpAnimation() {
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index 4a0f52d..12db3b6 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -48,8 +48,7 @@
public final UserEventDispatcher getUserEventDispatcher() {
if (mUserEventDispatcher == null) {
- mUserEventDispatcher = UserEventDispatcher.newInstance(this,
- mDeviceProfile.isLandscape, isInMultiWindowModeCompat());
+ mUserEventDispatcher = UserEventDispatcher.newInstance(this, mDeviceProfile);
}
return mUserEventDispatcher;
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 950c7f7..ba55b36 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -40,7 +40,9 @@
public final boolean transposeLayoutWithOrientation;
// Device properties in current orientation
- public final boolean isLandscape;
+ private final boolean isLandscape;
+ public final boolean isMultiWindowMode;
+
public final int widthPx;
public final int heightPx;
public final int availableWidthPx;
@@ -121,10 +123,11 @@
public DeviceProfile(Context context, InvariantDeviceProfile inv,
Point minSize, Point maxSize,
- int width, int height, boolean isLandscape) {
+ int width, int height, boolean isLandscape, boolean isMultiWindowMode) {
this.inv = inv;
this.isLandscape = isLandscape;
+ this.isMultiWindowMode = isMultiWindowMode;
Resources res = context.getResources();
DisplayMetrics dm = res.getDisplayMetrics();
@@ -214,7 +217,8 @@
public DeviceProfile copy(Context context) {
Point size = new Point(availableWidthPx, availableHeightPx);
- return new DeviceProfile(context, inv, size, size, widthPx, heightPx, isLandscape);
+ return new DeviceProfile(context, inv, size, size, widthPx, heightPx, isLandscape,
+ isMultiWindowMode);
}
public DeviceProfile getMultiWindowProfile(Context context, Point mwSize) {
@@ -226,7 +230,7 @@
// and heightPx = availableHeightPx because Launcher uses the InvariantDeviceProfiles'
// widthPx and heightPx values where it's needed.
DeviceProfile profile = new DeviceProfile(context, inv, mwSize, mwSize, mwSize.x, mwSize.y,
- isLandscape);
+ isLandscape, true);
// If there isn't enough vertical cell padding with the labels displayed, hide the labels.
float workspaceCellPaddingY = profile.getCellSize().y - profile.iconSizePx
@@ -288,7 +292,7 @@
+ Utilities.calculateTextHeight(iconTextSizePx);
int cellYPadding = (getCellSize().y - cellHeightPx) / 2;
if (iconDrawablePaddingPx > cellYPadding && !isVerticalLayout
- && !inMultiWindowMode()) {
+ && !isMultiWindowMode) {
// Ensures that the label is closer to its corresponding icon. This is not an issue
// with vertical bar layout or multi-window mode since the issue is handled separately
// with their calls to {@link #adjustToHideWorkspaceLabels}.
@@ -503,14 +507,10 @@
}
}
- public boolean inMultiWindowMode() {
- return this != inv.landscapeProfile && this != inv.portraitProfile;
- }
-
public boolean shouldIgnoreLongPressToOverview(float touchX) {
boolean touchedLhsEdge = mInsets.left == 0 && touchX < edgeMarginPx;
boolean touchedRhsEdge = mInsets.right == 0 && touchX > (widthPx - edgeMarginPx);
- return !inMultiWindowMode() && (touchedLhsEdge || touchedRhsEdge);
+ return !isMultiWindowMode && (touchedLhsEdge || touchedRhsEdge);
}
private static Context getContext(Context c, int orientation) {
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 246fa74..e460911 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -162,9 +162,9 @@
int largeSide = Math.max(realSize.x, realSize.y);
landscapeProfile = new DeviceProfile(context, this, smallestSize, largestSize,
- largeSide, smallSide, true /* isLandscape */);
+ largeSide, smallSide, true /* isLandscape */, false /* isMultiWindowMode */);
portraitProfile = new DeviceProfile(context, this, smallestSize, largestSize,
- smallSide, largeSide, false /* isLandscape */);
+ smallSide, largeSide, false /* isLandscape */, false /* isMultiWindowMode */);
// We need to ensure that there is enough extra space in the wallpaper
// for the intended parallax effects
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index b7de400..db3826b 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -27,6 +27,7 @@
import android.view.View;
import android.view.ViewParent;
+import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DropTarget;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.R;
@@ -65,8 +66,7 @@
FeatureFlags.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT);
private static final String UUID_STORAGE = "uuid";
- public static UserEventDispatcher newInstance(Context context, boolean isInLandscapeMode,
- boolean isInMultiWindowMode) {
+ public static UserEventDispatcher newInstance(Context context, DeviceProfile dp) {
SharedPreferences sharedPrefs = Utilities.getDevicePrefs(context);
String uuidStr = sharedPrefs.getString(UUID_STORAGE, null);
if (uuidStr == null) {
@@ -75,8 +75,8 @@
}
UserEventDispatcher ued = Utilities.getOverrideObject(UserEventDispatcher.class,
context.getApplicationContext(), R.string.user_event_dispatcher_class);
- ued.mIsInLandscapeMode = isInLandscapeMode;
- ued.mIsInMultiWindowMode = isInMultiWindowMode;
+ ued.mIsInLandscapeMode = dp.isVerticalBarLayout();
+ ued.mIsInMultiWindowMode = dp.isMultiWindowMode;
ued.mUuidStr = uuidStr;
return ued;
}