From 1af70f2729e1001d23783c183d98ce76cca7438c Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 30 Jun 2020 11:50:49 -0700 Subject: [PATCH] Add logging for non-sending "end scrolled" event for Widgets Bug: 160238801 Change-Id: I60a1cb689110c5b22b0a145b3cca7d47d867005e --- .../android/launcher3/BaseRecyclerView.java | 16 +++++++- .../compat/AccessibilityManagerCompat.java | 3 ++ .../launcher3/testing/TestProtocol.java | 1 + .../launcher3/views/BaseDragLayer.java | 3 ++ .../launcher3/widget/WidgetsFullSheet.java | 11 ++++++ .../launcher3/widget/WidgetsRecyclerView.java | 38 ++++++++++++++++++- 6 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java index 8eceec04ec..41eeb78bc7 100644 --- a/src/com/android/launcher3/BaseRecyclerView.java +++ b/src/com/android/launcher3/BaseRecyclerView.java @@ -183,6 +183,10 @@ public abstract class BaseRecyclerView extends RecyclerView { public void onScrollStateChanged(int state) { super.onScrollStateChanged(state); + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "onScrollStateChanged: " + state); + } + if (state == SCROLL_STATE_IDLE) { AccessibilityManagerCompat.sendScrollFinishedEventToTest(getContext()); } @@ -192,6 +196,10 @@ public abstract class BaseRecyclerView extends RecyclerView { public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); if (isLayoutSuppressed()) info.setScrollable(false); + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, + "onInitializeAccessibilityNodeInfo, scrollable: " + info.isScrollable()); + } } @Override @@ -199,8 +207,12 @@ public abstract class BaseRecyclerView extends RecyclerView { final boolean changing = frozen != isLayoutSuppressed(); super.setLayoutFrozen(frozen); if (changing) { - ActivityContext.lookupContext(getContext()).getDragLayer() - .sendAccessibilityEvent(TYPE_WINDOW_CONTENT_CHANGED); + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "setLayoutFrozen " + frozen + + " @ " + Log.getStackTraceString(new Throwable())); + ActivityContext.lookupContext(getContext()).getDragLayer() + .sendAccessibilityEvent(TYPE_WINDOW_CONTENT_CHANGED); + } } } } \ No newline at end of file diff --git a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java index 1d32d1dfa2..737c97b1bc 100644 --- a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java +++ b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java @@ -75,6 +75,9 @@ public class AccessibilityManagerCompat { } public static void sendScrollFinishedEventToTest(Context context) { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "sendScrollFinishedEventToTest"); + } final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context); if (accessibilityManager == null) return; diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 8165627448..2644db8f3c 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -107,4 +107,5 @@ public final class TestProtocol { public static final String PAUSE_NOT_DETECTED = "b/139891609"; public static final String OVERIEW_NOT_ALLAPPS = "b/156095088"; public static final String NO_SWIPE_TO_HOME = "b/158017601"; + public static final String NO_SCROLL_END_WIDGETS = "b/160238801"; } diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index b010b4b94b..2c75c74827 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -292,6 +292,9 @@ public abstract class BaseDragLayer @Override public boolean dispatchTouchEvent(MotionEvent ev) { + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "BaseDragLayer: " + ev); + } switch (ev.getAction()) { case ACTION_DOWN: { if ((mTouchDispatchState & TOUCH_DISPATCHING_TO_VIEW_IN_PROGRESS) != 0) { diff --git a/src/com/android/launcher3/widget/WidgetsFullSheet.java b/src/com/android/launcher3/widget/WidgetsFullSheet.java index 68a3ec51ee..ba55f5adee 100644 --- a/src/com/android/launcher3/widget/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/WidgetsFullSheet.java @@ -24,6 +24,7 @@ import android.animation.PropertyValuesHolder; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; +import android.util.Log; import android.util.Pair; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -38,8 +39,10 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherAppWidgetHost.ProviderChangedListener; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.compat.AccessibilityManagerCompat; +import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.views.RecyclerViewFastScroller; import com.android.launcher3.views.TopRoundedCornerView; @@ -68,6 +71,14 @@ public class WidgetsFullSheet extends BaseWidgetSheet } + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "WidgetsFullSheet: " + ev); + } + return super.dispatchTouchEvent(ev); + } + public WidgetsFullSheet(Context context, AttributeSet attrs) { this(context, attrs, 0); } diff --git a/src/com/android/launcher3/widget/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/WidgetsRecyclerView.java index 82d4110e85..17baa271e2 100644 --- a/src/com/android/launcher3/widget/WidgetsRecyclerView.java +++ b/src/com/android/launcher3/widget/WidgetsRecyclerView.java @@ -158,13 +158,23 @@ public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouch mScrollbar.isHitInParent(e.getX(), e.getY(), mFastScrollerOffset); } if (mTouchDownOnScroller) { - return mScrollbar.handleTouchEvent(e, mFastScrollerOffset); + final boolean result = mScrollbar.handleTouchEvent(e, mFastScrollerOffset); + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "onInterceptTouchEvent 1 " + result); + } + return result; + } + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "onInterceptTouchEvent 2 false"); } return false; } @Override public void onTouchEvent(RecyclerView rv, MotionEvent e) { + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "WidgetsRecyclerView.onTouchEvent"); + } if (mTouchDownOnScroller) { mScrollbar.handleTouchEvent(e, mFastScrollerOffset); } @@ -172,5 +182,31 @@ public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouch @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "onRequestDisallowInterceptTouchEvent " + + disallowIntercept); + } + } + + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + final boolean result = super.dispatchTouchEvent(ev); + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "WidgetsRecyclerView: state: " + + getScrollState() + + " can scroll: " + getLayoutManager().canScrollVertically() + + " result: " + result + + " layout suppressed: " + isLayoutSuppressed() + + " event: " + ev); + } + return result; + } + + @Override + public void stopNestedScroll() { + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "stopNestedScroll"); + } + super.stopNestedScroll(); } } \ No newline at end of file