Allow translation should also work on non-resume state
Currently, we only allow translation for the resumed Activity. It works fine for full screen Activity. On foldable devices, we may have two Activity in the same time. It is possible one Activity is on the paused state but there is still new incoming message, we should also allow the message can be translated. Bug: 199264898 Test: atest CtsTranslationTestCases Test: manual. Use one Activity targetsdk prior to Q then receiving broadcast to start Ui translation on paused state in split mode. Change-Id: I6720b41d9995c9ced2e3b2b87eb95540101d15a0
This commit is contained in:
@@ -110,11 +110,10 @@ public class UiTranslationController {
|
||||
public void updateUiTranslationState(@UiTranslationState int state, TranslationSpec sourceSpec,
|
||||
TranslationSpec targetSpec, List<AutofillId> views,
|
||||
UiTranslationSpec uiTranslationSpec) {
|
||||
if (!mActivity.isResumed() && (state == STATE_UI_TRANSLATION_STARTED
|
||||
|| state == STATE_UI_TRANSLATION_RESUMED)) {
|
||||
if (mActivity.isDestroyed()) {
|
||||
Log.i(TAG, "Cannot update " + stateToString(state) + " for destroyed " + mActivity);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.i(TAG, "updateUiTranslationState state: " + stateToString(state)
|
||||
+ (DEBUG ? (", views: " + views + ", spec: " + uiTranslationSpec) : ""));
|
||||
synchronized (mLock) {
|
||||
@@ -342,10 +341,8 @@ public class UiTranslationController {
|
||||
*/
|
||||
private void onVirtualViewTranslationCompleted(
|
||||
SparseArray<LongSparseArray<ViewTranslationResponse>> translatedResult) {
|
||||
if (!mActivity.isResumed()) {
|
||||
if (DEBUG) {
|
||||
Log.v(TAG, "onTranslationCompleted: Activity is not resumed.");
|
||||
}
|
||||
if (mActivity.isDestroyed()) {
|
||||
Log.v(TAG, "onTranslationCompleted:" + mActivity + "is destroyed.");
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
@@ -393,10 +390,8 @@ public class UiTranslationController {
|
||||
* The method is used to handle the translation result for non-vertual views.
|
||||
*/
|
||||
private void onTranslationCompleted(SparseArray<ViewTranslationResponse> translatedResult) {
|
||||
if (!mActivity.isResumed()) {
|
||||
if (DEBUG) {
|
||||
Log.v(TAG, "onTranslationCompleted: Activity is not resumed.");
|
||||
}
|
||||
if (mActivity.isDestroyed()) {
|
||||
Log.v(TAG, "onTranslationCompleted:" + mActivity + "is destroyed.");
|
||||
return;
|
||||
}
|
||||
final int resultCount = translatedResult.size();
|
||||
|
||||
Reference in New Issue
Block a user