Fix NPE if no AutofillId when traversing the view tree.

Bug: 415172066
Test: atest CtsTranslationTestCases
Change-Id: Ic4d7fac7348199d4752c622036d6b57c186816e5
This commit is contained in:
Joanne Chung
2021-12-09 14:12:59 +08:00
parent 24b5601177
commit 7ebd5f7c3b

View File

@@ -623,7 +623,7 @@ public class UiTranslationController {
private void addViewIfNeeded(IntArray sourceViewIds, View view) {
final AutofillId autofillId = view.getAutofillId();
if ((sourceViewIds.indexOf(autofillId.getViewId()) >= 0)
if (autofillId != null && (sourceViewIds.indexOf(autofillId.getViewId()) >= 0)
&& !mViews.containsKey(autofillId)) {
mViews.put(autofillId, new WeakReference<>(view));
}