From d84643adcc2dbbfdbe0ca92c9000b226bdbd7210 Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Fri, 22 Jan 2021 15:29:47 -0500 Subject: [PATCH] Avoid detecting WebView as TYPE_RECYCLING Currently ScrollCaptureIntrnal only checks for >1 child views but not >0 child views. Because of this, WebView is considered a RecyclerView, but this will not work without any Views to track. This change classifies these as "OPAQUE" so they can be handled specially. Until support for these is implemented they will be skipped as targets. Bug: 179253269 Test: Open Chrome to a scrollable page, take screenshot Change-Id: I0b00598031879d2fa7c1295440b3de1e0e453031 --- .../internal/view/ScrollCaptureInternal.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/view/ScrollCaptureInternal.java b/core/java/com/android/internal/view/ScrollCaptureInternal.java index ae1a815910ed4..4b9a1606975b3 100644 --- a/core/java/com/android/internal/view/ScrollCaptureInternal.java +++ b/core/java/com/android/internal/view/ScrollCaptureInternal.java @@ -58,6 +58,11 @@ public class ScrollCaptureInternal { */ public static final int TYPE_RECYCLING = 2; + /** + * The ViewGroup scrolls, but has no child views in + */ + private static final int TYPE_OPAQUE = 3; + /** * Performs tests on the given View and determines: * 1. If scrolling is possible @@ -95,8 +100,15 @@ public class ScrollCaptureInternal { } return TYPE_RECYCLING; } + // At least one child view is required. + if (((ViewGroup) view).getChildCount() < 1) { + if (DEBUG_VERBOSE) { + Log.v(TAG, "scrollable with no children"); + } + return TYPE_OPAQUE; + } if (DEBUG_VERBOSE) { - Log.v(TAG, "hint: less than two child views"); + Log.v(TAG, "hint: single child view"); } //Because recycling containers don't use scrollY, a non-zero value means Scroll view. if (view.getScrollY() != 0) {