Remove the deprecated APIs in UiTranslationManager.

We introduced some APIs for initial demo but we dropped these APIs.
To avoid to break the client app, we keep the API until the client
moves to new APIs. It's ok to delete these API now.

Bug: 185448758
Test: manual
Test: atest android.translation.cts.UiTranslationManagerTest

Change-Id: I5ea71d4658246f52610e1f62412d60c6c58bb31e
This commit is contained in:
Joanne Chung
2021-04-15 18:40:56 +08:00
parent ad73e49262
commit 108cec2f17
5 changed files with 3 additions and 167 deletions

View File

@@ -189,14 +189,3 @@ package android.telephony.data {
}
package android.view.translation {
public final class UiTranslationManager {
method @Deprecated @RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION) public void finishTranslation(int);
method @Deprecated @RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION) public void pauseTranslation(int);
method @Deprecated @RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION) public void resumeTranslation(int);
method @Deprecated @RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION) public void startTranslation(@NonNull android.view.translation.TranslationSpec, @NonNull android.view.translation.TranslationSpec, @NonNull java.util.List<android.view.autofill.AutofillId>, int);
}
}

View File

@@ -40,9 +40,6 @@ oneway interface ITranslationManager {
void updateUiTranslationState(int state, in TranslationSpec sourceSpec,
in TranslationSpec targetSpec, in List<AutofillId> viewIds, IBinder token, int taskId,
int userId);
// deprecated
void updateUiTranslationStateByTaskId(int state, in TranslationSpec sourceSpec,
in TranslationSpec targetSpec, in List<AutofillId> viewIds, int taskId, int userId);
void registerUiTranslationStateCallback(in IRemoteCallback callback, int userId);
void unregisterUiTranslationStateCallback(in IRemoteCallback callback, int userId);

View File

@@ -117,42 +117,6 @@ public final class UiTranslationManager {
mService = service;
}
/**
* Request ui translation for a given Views.
*
* NOTE: Please use {@code startTranslation(TranslationSpec, TranslationSpec, List<AutofillId>,
* ActivityId)} instead.
*
* @param sourceSpec {@link TranslationSpec} for the data to be translated.
* @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>,
* ActivityId)} instead.
*
* @hide
* @removed
*/
@Deprecated
@RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION)
@SystemApi
public void startTranslation(@NonNull TranslationSpec sourceSpec,
@NonNull TranslationSpec targetSpec, @NonNull List<AutofillId> viewIds,
int taskId) {
Objects.requireNonNull(sourceSpec);
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,
targetSpec, viewIds, taskId, mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Request ui translation for a given Views.
*
@@ -189,32 +153,6 @@ public final class UiTranslationManager {
}
}
/**
* Request to disable the ui translation. It will destroy all the {@link Translator}s and no
* longer to show to show the translated text.
*
* NOTE: Please use {@code finishTranslation(ActivityId)} instead.
*
* @param taskId the Activity Task id which needs ui translation
* @deprecated Use {@code finishTranslation(ActivityId)} instead.
*
* @hide
* @removed
*
*/
@Deprecated
@RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION)
@SystemApi
public void finishTranslation(int taskId) {
try {
mService.updateUiTranslationStateByTaskId(STATE_UI_TRANSLATION_FINISHED,
null /* sourceSpec */, null /* targetSpec */, null /* viewIds */, taskId,
mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Request to disable the ui translation. It will destroy all the {@link Translator}s and no
* longer to show to show the translated text.
@@ -239,31 +177,6 @@ public final class UiTranslationManager {
}
}
/**
* Request to pause the current ui translation's {@link Translator} which will switch back to
* the original language.
*
* NOTE: Please use {@code pauseTranslation(ActivityId)} instead.
*
* @param taskId the Activity Task id which needs ui translation
* @deprecated Use {@code pauseTranslation(ActivityId)} instead.
*
* @hide
* @removed
*/
@Deprecated
@RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION)
@SystemApi
public void pauseTranslation(int taskId) {
try {
mService.updateUiTranslationStateByTaskId(STATE_UI_TRANSLATION_PAUSED,
null /* sourceSpec */, null /* targetSpec */, null /* viewIds */, taskId,
mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Request to pause the current ui translation's {@link Translator} which will switch back to
* the original language.
@@ -288,31 +201,6 @@ public final class UiTranslationManager {
}
}
/**
* Request to resume the paused ui translation's {@link Translator} which will switch to the
* translated language if the text had been translated.
*
* NOTE: Please use {@code resumeTranslation(ActivityId)} instead.
*
* @param taskId the Activity Task id which needs ui translation
* @deprecated Use {@code resumeTranslation(ActivityId)} instead.
*
* @hide
* @removed
*/
@Deprecated
@RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION)
@SystemApi
public void resumeTranslation(int taskId) {
try {
mService.updateUiTranslationStateByTaskId(STATE_UI_TRANSLATION_RESUMED,
null /* sourceSpec */, null /* targetSpec */, null /* viewIds */,
taskId, mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Request to resume the paused ui translation's {@link Translator} which will switch to the
* translated language if the text had been translated.

View File

@@ -184,23 +184,6 @@ public final class TranslationManagerService
}
}
@Override
public void updateUiTranslationStateByTaskId(@UiTranslationState int state,
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds,
int taskId, int userId) {
// deprecated
enforceCallerHasPermission(MANAGE_UI_TRANSLATION);
synchronized (mLock) {
final TranslationManagerServiceImpl service = getServiceForUserLocked(userId);
if (service != null && (isDefaultServiceLocked(userId)
|| isCalledByServiceAppLocked(userId,
"updateUiTranslationStateByTaskId"))) {
service.updateUiTranslationStateLocked(state, sourceSpec, targetSpec, viewIds,
taskId);
}
}
}
@Override
public void updateUiTranslationState(@UiTranslationState int state,
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds,

View File

@@ -143,21 +143,6 @@ final class TranslationManagerServiceImpl extends
}
}
@GuardedBy("mLock")
public void updateUiTranslationStateLocked(@UiTranslationState int state,
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds,
int taskId) {
// deprecated
final ActivityTokens taskTopActivityTokens =
mActivityTaskManagerInternal.getTopActivityForTask(taskId);
if (taskTopActivityTokens == null) {
Slog.w(TAG, "Unknown activity to query for update translation state.");
return;
}
updateUiTranslationStateByActivityTokens(taskTopActivityTokens, state, sourceSpec,
targetSpec, viewIds);
}
@GuardedBy("mLock")
public void updateUiTranslationStateLocked(@UiTranslationState int state,
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds,
@@ -171,16 +156,10 @@ final class TranslationManagerServiceImpl extends
+ "translation state for token=" + token + " taskId=" + taskId);
return;
}
updateUiTranslationStateByActivityTokens(taskTopActivityTokens, state, sourceSpec,
targetSpec, viewIds);
}
private void updateUiTranslationStateByActivityTokens(ActivityTokens tokens,
@UiTranslationState int state, TranslationSpec sourceSpec, TranslationSpec targetSpec,
List<AutofillId> viewIds) {
try {
tokens.getApplicationThread().updateUiTranslationState(tokens.getActivityToken(), state,
sourceSpec, targetSpec, viewIds);
taskTopActivityTokens.getApplicationThread().updateUiTranslationState(
taskTopActivityTokens.getActivityToken(), state, sourceSpec, targetSpec,
viewIds);
} catch (RemoteException e) {
Slog.w(TAG, "Update UiTranslationState fail: " + e);
}