Fix translation doesn't work on ViewGroup

The system will add requested view reference into cache but it is
possible the requested translation view is a viewgroup, we don't add
this into view reference list that cause the translation doesn't work
on ViewGroup.

Bug: 200233857
Test: atest CtsTranslationTestCases
Test: manual. Use a sample code to request translation for a
viewgroup and make sure it is added into view reference list.
Test: manual verify with issue client app, it works.

Change-Id: Ie593a1a436fd046373412ae2955a78057d22b892
This commit is contained in:
Joanne Chung
2021-09-17 17:06:44 +08:00
parent 2e2e4b3ac4
commit ec3f41e70e

View File

@@ -598,9 +598,8 @@ public class UiTranslationController {
final View rootView = roots.get(rootNum).getView();
if (rootView instanceof ViewGroup) {
findViewsTraversalByAutofillIds((ViewGroup) rootView, sourceViewIds);
} else {
addViewIfNeeded(sourceViewIds, rootView);
}
addViewIfNeeded(sourceViewIds, rootView);
}
}
@@ -611,9 +610,8 @@ public class UiTranslationController {
final View child = viewGroup.getChildAt(i);
if (child instanceof ViewGroup) {
findViewsTraversalByAutofillIds((ViewGroup) child, sourceViewIds);
} else {
addViewIfNeeded(sourceViewIds, child);
}
addViewIfNeeded(sourceViewIds, child);
}
}