commit | 0c3f6981d42435b10493c80a46fcb6f3d5290987 | [log] [tgz] |
---|---|---|
author | Daniel Peykov <peykov@google.com> | Tue May 14 20:04:33 2024 +0000 |
committer | Daniel Peykov <peykov@google.com> | Tue May 14 20:04:33 2024 +0000 |
tree | a371337890a762e4de108313b90776015def1f00 | |
parent | 400a6e0c749a4ef321fc82d455aea15de56b53a9 [diff] |
Fix potential NPE when dumping child nodes * This brings the childNafCheck method in line with the version in androidx.test.uiautomator. Bug: 315023780 Test: manual Change-Id: Ie5ba2340bedabc31f346c6e717353c7a5db0e90e
diff --git a/cmds/uiautomator/library/core-src/com/android/uiautomator/core/AccessibilityNodeInfoDumper.java b/cmds/uiautomator/library/core-src/com/android/uiautomator/core/AccessibilityNodeInfoDumper.java index 488292d..f726361 100644 --- a/cmds/uiautomator/library/core-src/com/android/uiautomator/core/AccessibilityNodeInfoDumper.java +++ b/cmds/uiautomator/library/core-src/com/android/uiautomator/core/AccessibilityNodeInfoDumper.java
@@ -292,13 +292,17 @@ int childCount = node.getChildCount(); for (int x = 0; x < childCount; x++) { AccessibilityNodeInfo childNode = node.getChild(x); - + if (childNode == null) { + continue; + } if (!safeCharSeqToString(childNode.getContentDescription()).isEmpty() - || !safeCharSeqToString(childNode.getText()).isEmpty()) + || !safeCharSeqToString(childNode.getText()).isEmpty()) { return true; + } - if (childNafCheck(childNode)) + if (childNafCheck(childNode)) { return true; + } } return false; }