From e17d1feb791a383c5c12f1da02055b07eb832f02 Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 21 May 2019 17:19:23 -0700 Subject: [PATCH] Adding tracing for a lab-only flake We had a resolved case in the past where an app's context menu didn't open on a long click (thanks to app updates), now the menu opens, but the drag gesture doesn't drag the icon. Bug: 133009122 Change-Id: I45d104a92fab6556ecd937aef76f0a8147e67f56 --- .../android/quickstep/TestInformationProvider.java | 8 ++++++++ src/com/android/launcher3/LauncherStateManager.java | 8 ++++++++ src/com/android/launcher3/TestProtocol.java | 4 ++++ src/com/android/launcher3/Workspace.java | 8 ++++++++ .../android/launcher3/dragndrop/DragController.java | 12 ++++++++++++ src/com/android/launcher3/views/BaseDragLayer.java | 8 ++++++++ tests/tapl/com/android/launcher3/tapl/Workspace.java | 2 ++ 7 files changed, 50 insertions(+) diff --git a/quickstep/src/com/android/quickstep/TestInformationProvider.java b/quickstep/src/com/android/quickstep/TestInformationProvider.java index b37ddda097..a948570d2a 100644 --- a/quickstep/src/com/android/quickstep/TestInformationProvider.java +++ b/quickstep/src/com/android/quickstep/TestInformationProvider.java @@ -111,6 +111,14 @@ public class TestInformationProvider extends ContentProvider { response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance); break; } + + case TestProtocol.REQUEST_ENABLE_DRAG_LOGGING: + TestProtocol.sDebugTracing = true; + break; + + case TestProtocol.REQUEST_DISABLE_DRAG_LOGGING: + TestProtocol.sDebugTracing = false; + break; } return response; } diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java index b1a3fc992e..49ae33894a 100644 --- a/src/com/android/launcher3/LauncherStateManager.java +++ b/src/com/android/launcher3/LauncherStateManager.java @@ -447,6 +447,10 @@ public class LauncherStateManager { } private void onStateTransitionStart(LauncherState state) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onStateTransitionStart"); + } if (mState != state) { mState.onStateDisabled(mLauncher); } @@ -572,6 +576,10 @@ public class LauncherStateManager { private final AnimatorSet mAnim; public StartAnimRunnable(AnimatorSet anim) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "StartAnimRunnable"); + } mAnim = anim; } diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java index eefecda5d7..081150db04 100644 --- a/src/com/android/launcher3/TestProtocol.java +++ b/src/com/android/launcher3/TestProtocol.java @@ -64,4 +64,8 @@ public final class TestProtocol { "all-apps-to-overview-swipe-height"; public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT = "home-to-all-apps-swipe-height"; + public static boolean sDebugTracing = false; + public static final String REQUEST_ENABLE_DRAG_LOGGING = "enable-drag-logging"; + public static final String REQUEST_DISABLE_DRAG_LOGGING = "disable-drag-logging"; + public static final String NO_DRAG_TAG = "b/133009122"; } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index a508ce52bd..d19f9cd73f 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -371,6 +371,10 @@ public class Workspace extends PagedView @Override public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onDragStart 1"); + } if (ENFORCE_DRAG_EVENT_ORDER) { enforceDragParity("onDragStart", 0, 0); } @@ -421,6 +425,10 @@ public class Workspace extends PagedView } // Always enter the spring loaded mode + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onDragStart 2"); + } mLauncher.getStateManager().goToState(SPRING_LOADED); } diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index f92e00acba..bf692fe472 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -472,6 +472,10 @@ public class DragController implements DragDriver.EventListener, TouchController } private void handleMoveEvent(int x, int y) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "handleMoveEvent 1"); + } mDragObject.dragView.move(x, y); // Drop on someone? @@ -488,6 +492,10 @@ public class DragController implements DragDriver.EventListener, TouchController if (mIsInPreDrag && mOptions.preDragCondition != null && mOptions.preDragCondition.shouldStartDrag(mDistanceSinceScroll)) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "handleMoveEvent 2"); + } callOnDragStart(); } } @@ -525,6 +533,10 @@ public class DragController implements DragDriver.EventListener, TouchController * Call this from a drag source view. */ public boolean onControllerTouchEvent(MotionEvent ev) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onControllerTouchEvent"); + } if (mDragDriver == null || mOptions == null || mOptions.isAccessibleDrag) { return false; } diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index 3c81bcf399..4964182409 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -213,6 +213,10 @@ public abstract class BaseDragLayer @Override public boolean onTouchEvent(MotionEvent ev) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onTouchEvent " + ev); + } int action = ev.getAction(); if (action == ACTION_UP || action == ACTION_CANCEL) { if (mTouchCompleteListener != null) { @@ -222,6 +226,10 @@ public abstract class BaseDragLayer } if (mActiveController != null) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onTouchEvent 1"); + } return mActiveController.onControllerTouchEvent(ev); } else { // In case no child view handled the touch event, we may not get onIntercept anymore diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index 11c07943fe..f1dd0136da 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -148,6 +148,7 @@ public final class Workspace extends Home { static void dragIconToWorkspace( LauncherInstrumentation launcher, Launchable launchable, Point dest, String longPressIndicator) { + launcher.getTestInfo(TestProtocol.REQUEST_ENABLE_DRAG_LOGGING); LauncherInstrumentation.log("dragIconToWorkspace: begin"); final Point launchableCenter = launchable.getObject().getVisibleCenter(); final long downTime = SystemClock.uptimeMillis(); @@ -162,6 +163,7 @@ public final class Workspace extends Home { downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest); LauncherInstrumentation.log("dragIconToWorkspace: end"); launcher.waitUntilGone("drop_target_bar"); + launcher.getTestInfo(TestProtocol.REQUEST_DISABLE_DRAG_LOGGING); } /**