Clear the ViewTranslationResponse on finishing UiTranslation.

Stored state should be cleared here.

This fixes a bug where the views cannot be re-translated after
UiTranslationManager#finishTranslation was called. Some of the state was
cleared, so the translations cannot be re-shown. And that state cannot
be recreated because we find the same ViewTranslationResponse stored and
do not recreate the other state.

Fix: 189892928
Test: manual - translate an app, go to the home screen (triggers
 finish), go back to the app and re-translate
Test: atest CtsTranslationTestCases
Change-Id: Ic81fbce7ee09eb72352071c8bdd94a2731826009
This commit is contained in:
Ahaan Ugale
2021-06-09 13:53:38 -07:00
parent 33f8e11606
commit f922300a2d
2 changed files with 11 additions and 0 deletions

View File

@@ -30942,6 +30942,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
mViewTranslationResponse = response;
}
/**
* Clears the ViewTranslationResponse stored by the default implementation of {@link
* #onViewTranslationResponse}.
*
* @hide
*/
public void clearViewTranslationResponse() {
mViewTranslationResponse = null;
}
/**
* Called when the content from {@link View#onCreateVirtualViewTranslationRequests} had been
* translated by the TranslationService.

View File

@@ -155,6 +155,7 @@ public class UiTranslationController {
destroyTranslators();
runForEachView((view, callback) -> {
callback.onClearTranslation(view);
view.clearViewTranslationResponse();
if (view.hasTranslationTransientState()) {
view.setHasTransientState(false);
view.setHasTranslationTransientState(false);