Merge "Rename destSpecs to targetSpecs" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-04-20 01:21:06 +00:00
committed by Android (Google) Code Review
8 changed files with 33 additions and 33 deletions

View File

@@ -8792,11 +8792,11 @@ public class Activity extends ContextThemeWrapper
* @hide
*/
public void updateUiTranslationState(int state, TranslationSpec sourceSpec,
TranslationSpec destSpec, List<AutofillId> viewIds) {
TranslationSpec targetSpec, List<AutofillId> viewIds) {
if (mUiTranslationController == null) {
mUiTranslationController = new UiTranslationController(this, getApplicationContext());
}
mUiTranslationController.updateUiTranslationState(state, sourceSpec, destSpec, viewIds);
mUiTranslationController.updateUiTranslationState(state, sourceSpec, targetSpec, viewIds);
}
class HostCallbacks extends FragmentHostCallback<Activity> {

View File

@@ -1835,12 +1835,12 @@ public final class ActivityThread extends ClientTransactionHandler
@Override
public void updateUiTranslationState(IBinder activityToken, int state,
TranslationSpec sourceSpec, TranslationSpec destSpec, List<AutofillId> viewIds) {
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds) {
SomeArgs args = SomeArgs.obtain();
args.arg1 = activityToken;
args.arg2 = state;
args.arg3 = sourceSpec;
args.arg4 = destSpec;
args.arg4 = targetSpec;
args.arg5 = viewIds;
sendMessage(H.UPDATE_UI_TRANSLATION_STATE, args);
}
@@ -4169,13 +4169,13 @@ public final class ActivityThread extends ClientTransactionHandler
}
private void updateUiTranslationState(IBinder activityToken, int state,
TranslationSpec sourceSpec, TranslationSpec destSpec, List<AutofillId> viewIds) {
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds) {
final ActivityClientRecord r = mActivities.get(activityToken);
if (r == null) {
Log.w(TAG, "updateUiTranslationState(): no activity for " + activityToken);
return;
}
r.activity.updateUiTranslationState(state, sourceSpec, destSpec, viewIds);
r.activity.updateUiTranslationState(state, sourceSpec, targetSpec, viewIds);
}
private static final ThreadLocal<Intent> sCurrentBroadcastIntent = new ThreadLocal<Intent>();

View File

@@ -160,5 +160,5 @@ oneway interface IApplicationThread {
IUiAutomationConnection instrumentationUiConnection,
in ApplicationInfo targetInfo);
void updateUiTranslationState(IBinder activityToken, int state, in TranslationSpec sourceSpec,
in TranslationSpec destSpec, in List<AutofillId> viewIds);
in TranslationSpec targetSpec, in List<AutofillId> viewIds);
}

View File

@@ -283,6 +283,5 @@ public abstract class TranslationService extends Service {
resultReceiver.send(TranslationManager.STATUS_SYNC_CALL_SUCCESS, bundle);
}
});
}
}

View File

@@ -87,7 +87,7 @@ public final class TranslationResponse implements Parcelable {
/**
* Adds {@link TranslationResponseValue} to be translated. The input
* TranslationResponseValue format should match those provided by the
* {@link android.view.translation.Translator}'s destSpec.
* {@link android.view.translation.Translator}'s targetSpec.
*
* @param value the translated value.
* @return this Builder.
@@ -109,7 +109,7 @@ public final class TranslationResponse implements Parcelable {
/**
* Sets the list of {@link ViewTranslationResponse} to be translated. The input
* ViewTranslationResponse contains {@link TranslationResponseValue}s whose format should
* match those provided by the {@link android.view.translation.Translator}'s destSpec.
* match those provided by the {@link android.view.translation.Translator}'s targetSpec.
*
* @param response the translated response.
* @return this Builder.

View File

@@ -100,7 +100,7 @@ public class UiTranslationController {
* Update the Ui translation state.
*/
public void updateUiTranslationState(@UiTranslationState int state, TranslationSpec sourceSpec,
TranslationSpec destSpec, List<AutofillId> views) {
TranslationSpec targetSpec, List<AutofillId> views) {
if (!mActivity.isResumed() && (state == STATE_UI_TRANSLATION_STARTED
|| state == STATE_UI_TRANSLATION_RESUMED)) {
return;
@@ -113,11 +113,11 @@ public class UiTranslationController {
switch (state) {
case STATE_UI_TRANSLATION_STARTED:
final Pair<TranslationSpec, TranslationSpec> specs =
new Pair<>(sourceSpec, destSpec);
new Pair<>(sourceSpec, targetSpec);
if (!mTranslators.containsKey(specs)) {
mWorkerHandler.sendMessage(PooledLambda.obtainMessage(
UiTranslationController::createTranslatorAndStart,
UiTranslationController.this, sourceSpec, destSpec, views));
UiTranslationController.this, sourceSpec, targetSpec, views));
} else {
onUiTranslationStarted(mTranslators.get(specs), views);
}
@@ -386,12 +386,13 @@ public class UiTranslationController {
* translation when the Translator is created successfully.
*/
@WorkerThread
private void createTranslatorAndStart(TranslationSpec sourceSpec, TranslationSpec destSpec,
private void createTranslatorAndStart(TranslationSpec sourceSpec, TranslationSpec targetSpec,
List<AutofillId> views) {
final Translator translator = createTranslatorIfNeeded(sourceSpec, destSpec);
// Create Translator
final Translator translator = createTranslatorIfNeeded(sourceSpec, targetSpec);
if (translator == null) {
Log.w(TAG, "Can not create Translator for sourceSpec:" + sourceSpec + " destSpec:"
+ destSpec);
Log.w(TAG, "Can not create Translator for sourceSpec:" + sourceSpec + " targetSpec:"
+ targetSpec);
return;
}
onUiTranslationStarted(translator, views);

View File

@@ -124,7 +124,7 @@ public final class UiTranslationManager {
* ActivityId)} instead.
*
* @param sourceSpec {@link TranslationSpec} for the data to be translated.
* @param destSpec {@link TranslationSpec} for the translated data.
* @param targetSpec {@link TranslationSpec} for the translated data.
* @param viewIds A list of the {@link View}'s {@link AutofillId} which needs to be translated
* @param taskId the Activity Task id which needs ui translation
* @deprecated Use {@code startTranslation(TranslationSpec, TranslationSpec, List<AutofillId>,
@@ -137,17 +137,17 @@ public final class UiTranslationManager {
@RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION)
@SystemApi
public void startTranslation(@NonNull TranslationSpec sourceSpec,
@NonNull TranslationSpec destSpec, @NonNull List<AutofillId> viewIds,
@NonNull TranslationSpec targetSpec, @NonNull List<AutofillId> viewIds,
int taskId) {
Objects.requireNonNull(sourceSpec);
Objects.requireNonNull(destSpec);
Objects.requireNonNull(targetSpec);
Objects.requireNonNull(viewIds);
if (viewIds.size() == 0) {
throw new IllegalArgumentException("Invalid empty views: " + viewIds);
}
try {
mService.updateUiTranslationStateByTaskId(STATE_UI_TRANSLATION_STARTED, sourceSpec,
destSpec, viewIds, taskId, mContext.getUserId());
targetSpec, viewIds, taskId, mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -157,11 +157,11 @@ public final class UiTranslationManager {
* Request ui translation for a given Views.
*
* @param sourceSpec {@link TranslationSpec} for the data to be translated.
* @param destSpec {@link TranslationSpec} for the translated data.
* @param targetSpec {@link TranslationSpec} for the translated data.
* @param viewIds A list of the {@link View}'s {@link AutofillId} which needs to be translated
* @param activityId the identifier for the Activity which needs ui translation
* @throws IllegalArgumentException if the no {@link View}'s {@link AutofillId} in the list
* @throws NullPointerException the sourceSpec, destSpec, viewIds, activityId or
* @throws NullPointerException the sourceSpec, targetSpec, viewIds, activityId or
* {@link android.app.assist.ActivityId#getToken()} is {@code null}
*
* @hide
@@ -169,11 +169,11 @@ public final class UiTranslationManager {
@RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION)
@SystemApi
public void startTranslation(@NonNull TranslationSpec sourceSpec,
@NonNull TranslationSpec destSpec, @NonNull List<AutofillId> viewIds,
@NonNull TranslationSpec targetSpec, @NonNull List<AutofillId> viewIds,
@NonNull ActivityId activityId) {
// TODO(b/177789967): Return result code or find a way to notify the status.
Objects.requireNonNull(sourceSpec);
Objects.requireNonNull(destSpec);
Objects.requireNonNull(targetSpec);
Objects.requireNonNull(viewIds);
Objects.requireNonNull(activityId);
Objects.requireNonNull(activityId.getToken());
@@ -182,7 +182,7 @@ public final class UiTranslationManager {
}
try {
mService.updateUiTranslationState(STATE_UI_TRANSLATION_STARTED, sourceSpec,
destSpec, viewIds, activityId.getToken(), activityId.getTaskId(),
targetSpec, viewIds, activityId.getToken(), activityId.getTaskId(),
mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -208,7 +208,7 @@ public final class UiTranslationManager {
public void finishTranslation(int taskId) {
try {
mService.updateUiTranslationStateByTaskId(STATE_UI_TRANSLATION_FINISHED,
null /* sourceSpec */, null /* destSpec*/, null /* viewIds */, taskId,
null /* sourceSpec */, null /* targetSpec */, null /* viewIds */, taskId,
mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -232,7 +232,7 @@ public final class UiTranslationManager {
Objects.requireNonNull(activityId);
Objects.requireNonNull(activityId.getToken());
mService.updateUiTranslationState(STATE_UI_TRANSLATION_FINISHED,
null /* sourceSpec */, null /* destSpec*/, null /* viewIds */,
null /* sourceSpec */, null /* targetSpec */, null /* viewIds */,
activityId.getToken(), activityId.getTaskId(), mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -257,7 +257,7 @@ public final class UiTranslationManager {
public void pauseTranslation(int taskId) {
try {
mService.updateUiTranslationStateByTaskId(STATE_UI_TRANSLATION_PAUSED,
null /* sourceSpec */, null /* destSpec*/, null /* viewIds */, taskId,
null /* sourceSpec */, null /* targetSpec */, null /* viewIds */, taskId,
mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -281,7 +281,7 @@ public final class UiTranslationManager {
Objects.requireNonNull(activityId);
Objects.requireNonNull(activityId.getToken());
mService.updateUiTranslationState(STATE_UI_TRANSLATION_PAUSED,
null /* sourceSpec */, null /* destSpec*/, null /* viewIds */,
null /* sourceSpec */, null /* targetSpec */, null /* viewIds */,
activityId.getToken(), activityId.getTaskId(), mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -306,7 +306,7 @@ public final class UiTranslationManager {
public void resumeTranslation(int taskId) {
try {
mService.updateUiTranslationStateByTaskId(STATE_UI_TRANSLATION_RESUMED,
null /* sourceSpec */, null /* destSpec*/, null /* viewIds */,
null /* sourceSpec */, null /* targetSpec */, null /* viewIds */,
taskId, mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -330,7 +330,7 @@ public final class UiTranslationManager {
Objects.requireNonNull(activityId);
Objects.requireNonNull(activityId.getToken());
mService.updateUiTranslationState(STATE_UI_TRANSLATION_RESUMED,
null /* sourceSpec */, null /* destSpec*/, null /* viewIds */,
null /* sourceSpec */, null /* targetSpec */, null /* viewIds */,
activityId.getToken(), activityId.getTaskId(), mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();

View File

@@ -693,7 +693,7 @@ public class TransactionParcelTests {
@Override
public void updateUiTranslationState(IBinder activityToken, int state,
TranslationSpec sourceSpec, TranslationSpec destSpec, List<AutofillId> viewIds) {
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds) {
}
}