Merge "Remove the deprecated APIs in UiTranslationManager." into sc-dev
This commit is contained in:
@@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ oneway interface ITranslationManager {
|
|||||||
void updateUiTranslationState(int state, in TranslationSpec sourceSpec,
|
void updateUiTranslationState(int state, in TranslationSpec sourceSpec,
|
||||||
in TranslationSpec targetSpec, in List<AutofillId> viewIds, IBinder token, int taskId,
|
in TranslationSpec targetSpec, in List<AutofillId> viewIds, IBinder token, int taskId,
|
||||||
int userId);
|
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 registerUiTranslationStateCallback(in IRemoteCallback callback, int userId);
|
||||||
void unregisterUiTranslationStateCallback(in IRemoteCallback callback, int userId);
|
void unregisterUiTranslationStateCallback(in IRemoteCallback callback, int userId);
|
||||||
|
|||||||
@@ -117,42 +117,6 @@ public final class UiTranslationManager {
|
|||||||
mService = service;
|
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.
|
* 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
|
* Request to disable the ui translation. It will destroy all the {@link Translator}s and no
|
||||||
* longer to show to show the translated text.
|
* 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
|
* Request to pause the current ui translation's {@link Translator} which will switch back to
|
||||||
* the original language.
|
* 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
|
* Request to resume the paused ui translation's {@link Translator} which will switch to the
|
||||||
* translated language if the text had been translated.
|
* translated language if the text had been translated.
|
||||||
|
|||||||
@@ -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
|
@Override
|
||||||
public void updateUiTranslationState(@UiTranslationState int state,
|
public void updateUiTranslationState(@UiTranslationState int state,
|
||||||
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds,
|
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds,
|
||||||
|
|||||||
@@ -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")
|
@GuardedBy("mLock")
|
||||||
public void updateUiTranslationStateLocked(@UiTranslationState int state,
|
public void updateUiTranslationStateLocked(@UiTranslationState int state,
|
||||||
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds,
|
TranslationSpec sourceSpec, TranslationSpec targetSpec, List<AutofillId> viewIds,
|
||||||
@@ -171,16 +156,10 @@ final class TranslationManagerServiceImpl extends
|
|||||||
+ "translation state for token=" + token + " taskId=" + taskId);
|
+ "translation state for token=" + token + " taskId=" + taskId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateUiTranslationStateByActivityTokens(taskTopActivityTokens, state, sourceSpec,
|
|
||||||
targetSpec, viewIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateUiTranslationStateByActivityTokens(ActivityTokens tokens,
|
|
||||||
@UiTranslationState int state, TranslationSpec sourceSpec, TranslationSpec targetSpec,
|
|
||||||
List<AutofillId> viewIds) {
|
|
||||||
try {
|
try {
|
||||||
tokens.getApplicationThread().updateUiTranslationState(tokens.getActivityToken(), state,
|
taskTopActivityTokens.getApplicationThread().updateUiTranslationState(
|
||||||
sourceSpec, targetSpec, viewIds);
|
taskTopActivityTokens.getActivityToken(), state, sourceSpec, targetSpec,
|
||||||
|
viewIds);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "Update UiTranslationState fail: " + e);
|
Slog.w(TAG, "Update UiTranslationState fail: " + e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user