Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 497dadea authored by Joanne Chung's avatar Joanne Chung Committed by Android (Google) Code Review
Browse files

Merge "Remove the deprecated APIs in UiTranslationManager." into sc-dev

parents 3deea321 108cec2f
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -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);
  }

}
+0 −3
Original line number Diff line number Diff line
@@ -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);
+0 −112
Original line number Diff line number Diff line
@@ -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.
+0 −17
Original line number Diff line number Diff line
@@ -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,
+3 −24
Original line number Diff line number Diff line
@@ -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);
        }