Allow to report finsh/pause state if Activity isn't resume.

Currently, we only report the ui translation state if the Activity is
resumed. But in the real use case, the developer may call
finishTranslation when the Activity moves to background or lock screen
is shown. We should allow the finish/pause state can be updated for
these cases.

Bug: 183980346
Test: manual. Use sample app, press home and call APIs.
Test: atest CtsTranslationTestCases
Change-Id: I4a5cfab9d272e4d5dc23b2f679b4fbeb4a6c9d20
This commit is contained in:
Joanne Chung
2021-03-30 22:55:02 +08:00
parent f3258c35c0
commit 8aef79f2b5

View File

@@ -100,7 +100,8 @@ public class UiTranslationController {
*/
public void updateUiTranslationState(@UiTranslationState int state, TranslationSpec sourceSpec,
TranslationSpec destSpec, List<AutofillId> views) {
if (!mActivity.isResumed()) {
if (!mActivity.isResumed() && (state == STATE_UI_TRANSLATION_STARTED
|| state == STATE_UI_TRANSLATION_RESUMED)) {
return;
}
Log.i(TAG, "updateUiTranslationState state: " + stateToString(state)