Snap for 10038995 from 5b9ed74a19ffdb4ee24370d4e42554f8b23fc86f to udc-release
Change-Id: Ia342fdf3317378bca006f9c1487dd63887aa4d19
diff --git a/src/com/android/car/rotary/Navigator.java b/src/com/android/car/rotary/Navigator.java
index a493a2f..c417958 100644
--- a/src/com/android/car/rotary/Navigator.java
+++ b/src/com/android/car/rotary/Navigator.java
@@ -559,11 +559,8 @@
}
boolean hasFocusableDescendant = false;
for (AccessibilityNodeInfo webView : webViews) {
- AccessibilityNodeInfo focusableDescendant = mTreeTraverser.depthFirstSearch(webView,
- Utils::canPerformFocus);
- if (focusableDescendant != null) {
+ if (webViewHasFocusableDescendants(webView)) {
hasFocusableDescendant = true;
- focusableDescendant.recycle();
break;
}
}
@@ -571,6 +568,20 @@
return hasFocusableDescendant;
}
+ private boolean webViewHasFocusableDescendants(@NonNull AccessibilityNodeInfo webView) {
+ AccessibilityNodeInfo focusableDescendant = mTreeTraverser.depthFirstSearch(webView,
+ Utils::canPerformFocus);
+ if (focusableDescendant == null) {
+ return false;
+ }
+ focusableDescendant.recycle();
+ return true;
+ }
+
+ private boolean isWebViewWithFocusableDescendants(@NonNull AccessibilityNodeInfo node) {
+ return Utils.isWebView(node) && webViewHasFocusableDescendants(node);
+ }
+
/**
* Adds all the {@code windows} in the given {@code direction} of the given {@code source}
* window to the given list if the {@code source} window is not an overlay. If it's an overlay
@@ -815,7 +826,7 @@
if (Utils.isFocusArea(node) || Utils.isFocusParkingView(node)) {
return bounds;
}
- if (Utils.canTakeFocus(node) || containsWebViewWithFocusableDescendants(node)) {
+ if (Utils.canTakeFocus(node) || isWebViewWithFocusableDescendants(node)) {
return Utils.getBoundsInScreen(node);
}
for (int i = 0; i < node.getChildCount(); i++) {