From 629e52b9d9f65cb6f5109e43e9f8b209c919a7e7 Mon Sep 17 00:00:00 2001 From: liangguihao1 Date: Wed, 31 May 2023 11:37:27 +0800 Subject: [PATCH] Fix the problem that AccessibilityNodeInfo maybe null and cause a crash. If the mAccessibilityDelegate of a view is not null, the mAccessibilityDelegate also has a corresponding AccessibilityNodeProvider object. If the AccessibilityNodeProvider does not overload the createAccessibilityNodeInfo(int virtualViewId) method, the app will crash. This bugfix is to add a non-null judgment here. Bug:285078234 Change-Id: Iaccca83e9e47cfeb271186d0a4344555d6b433b6 Signed-off-by: liangguihao1 --- core/java/android/view/View.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index b1008919a1253..06e96ef58cdaa 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -9097,8 +9097,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final AccessibilityNodeInfo info = createAccessibilityNodeInfo(); structure.setChildCount(1); final ViewStructure root = structure.newChild(0); - populateVirtualStructure(root, provider, info, forAutofill); - info.recycle(); + if (info != null) { + populateVirtualStructure(root, provider, info, forAutofill); + info.recycle(); + } else { + Log.w(AUTOFILL_LOG_TAG, "AccessibilityNodeInfo is null."); + } } }