Merge "Add logging for non-sending "end scrolled" event for Widgets" into ub-launcher3-master

This commit is contained in:
TreeHugger Robot
2020-06-30 20:26:09 +00:00
committed by Android (Google) Code Review
6 changed files with 69 additions and 3 deletions

View File

@@ -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);
}
}
}
}

View File

@@ -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;

View File

@@ -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";
}

View File

@@ -292,6 +292,9 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
@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) {

View File

@@ -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);
}

View File

@@ -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();
}
}