Loading core/api/current.txt +3 −1 Original line number Diff line number Diff line Loading @@ -52375,6 +52375,7 @@ package android.view.translation { method @NonNull public android.util.SparseArray<android.view.translation.TranslationResponseValue> getTranslationResponseValues(); method public int getTranslationStatus(); method @NonNull public android.util.SparseArray<android.view.translation.ViewTranslationResponse> getViewTranslationResponses(); method public boolean isFinalResponse(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.view.translation.TranslationResponse> CREATOR; field public static final int TRANSLATION_STATUS_CONTEXT_UNSUPPORTED = 2; // 0x2 Loading @@ -52385,6 +52386,7 @@ package android.view.translation { public static final class TranslationResponse.Builder { ctor public TranslationResponse.Builder(int); method @NonNull public android.view.translation.TranslationResponse build(); method @NonNull public android.view.translation.TranslationResponse.Builder setFinalResponse(boolean); method @NonNull public android.view.translation.TranslationResponse.Builder setTranslationResponseValue(int, @NonNull android.view.translation.TranslationResponseValue); method @NonNull public android.view.translation.TranslationResponse.Builder setTranslationResponseValues(@NonNull android.util.SparseArray<android.view.translation.TranslationResponseValue>); method @NonNull public android.view.translation.TranslationResponse.Builder setTranslationStatus(int); Loading Loading @@ -52426,7 +52428,7 @@ package android.view.translation { public class Translator { method public void destroy(); method public boolean isDestroyed(); method @Nullable @WorkerThread public android.view.translation.TranslationResponse translate(@NonNull android.view.translation.TranslationRequest); method @Nullable public void translate(@NonNull android.view.translation.TranslationRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.view.translation.TranslationResponse>); } public final class UiTranslationManager { core/java/android/service/translation/ITranslationCallback.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,6 @@ import android.view.translation.TranslationResponse; * @hide */ oneway interface ITranslationCallback { void onTranslationComplete(in TranslationResponse translationResponse); void onTranslationResponse(in TranslationResponse translationResponse); void onError(); } core/java/android/service/translation/OnTranslationResultCallbackWrapper.java +3 −3 Original line number Diff line number Diff line Loading @@ -51,12 +51,12 @@ final class OnTranslationResultCallbackWrapper implements @Override public void onTranslationSuccess(@Nullable TranslationResponse response) { assertNotCalled(); if (mCalled.getAndSet(true)) { throw new IllegalStateException("Already called"); if (mCalled.getAndSet(response.isFinalResponse())) { throw new IllegalStateException("Already called with complete response"); } try { mCallback.onTranslationComplete(response); mCallback.onTranslationResponse(response); } catch (RemoteException e) { if (e instanceof DeadObjectException) { Log.w(TAG, "Process is dead, ignore."); Loading core/java/android/service/translation/TranslationService.java +2 −23 Original line number Diff line number Diff line Loading @@ -42,7 +42,6 @@ import android.view.translation.TranslationResponse; import android.view.translation.TranslationSpec; import com.android.internal.os.IResultReceiver; import com.android.internal.util.SyncResultReceiver; /** * Service for translating text. Loading Loading @@ -139,30 +138,10 @@ public abstract class TranslationService extends Service { @Override public void onTranslationRequest(TranslationRequest request, int sessionId, ITranslationCallback callback, IResultReceiver receiver) ITranslationCallback callback) throws RemoteException { // TODO(b/176464808): Currently, the API is used for both sync and async case. // It may work now, but maybe two methods is more cleaner. To think how to // define the APIs for these two cases. final ITranslationCallback cb = callback != null ? callback : new ITranslationCallback.Stub() { @Override public void onTranslationComplete( TranslationResponse translationResponse) throws RemoteException { receiver.send(0, SyncResultReceiver.bundleFor(translationResponse)); } @Override public void onError() throws RemoteException { //TODO: implement default error callback } }; // TODO(b/176464808): make it a private member of client final OnTranslationResultCallback translationResultCallback = new OnTranslationResultCallbackWrapper(cb); new OnTranslationResultCallbackWrapper(callback); mHandler.sendMessage(obtainMessage(TranslationService::onTranslationRequest, TranslationService.this, request, sessionId, mCancellationSignal, translationResultCallback)); Loading core/java/android/view/translation/ITranslationDirectManager.aidl +1 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.view.translation; import android.view.translation.TranslationRequest; import android.service.translation.ITranslationCallback; import com.android.internal.os.IResultReceiver; /** * Interface between an app (TranslationManager / Translator) and the remote TranslationService Loading @@ -28,6 +27,6 @@ import com.android.internal.os.IResultReceiver; */ oneway interface ITranslationDirectManager { void onTranslationRequest(in TranslationRequest request, int sessionId, in ITranslationCallback callback, in IResultReceiver receiver); in ITranslationCallback callback); void onFinishTranslationSession(int sessionId); } Loading
core/api/current.txt +3 −1 Original line number Diff line number Diff line Loading @@ -52375,6 +52375,7 @@ package android.view.translation { method @NonNull public android.util.SparseArray<android.view.translation.TranslationResponseValue> getTranslationResponseValues(); method public int getTranslationStatus(); method @NonNull public android.util.SparseArray<android.view.translation.ViewTranslationResponse> getViewTranslationResponses(); method public boolean isFinalResponse(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.view.translation.TranslationResponse> CREATOR; field public static final int TRANSLATION_STATUS_CONTEXT_UNSUPPORTED = 2; // 0x2 Loading @@ -52385,6 +52386,7 @@ package android.view.translation { public static final class TranslationResponse.Builder { ctor public TranslationResponse.Builder(int); method @NonNull public android.view.translation.TranslationResponse build(); method @NonNull public android.view.translation.TranslationResponse.Builder setFinalResponse(boolean); method @NonNull public android.view.translation.TranslationResponse.Builder setTranslationResponseValue(int, @NonNull android.view.translation.TranslationResponseValue); method @NonNull public android.view.translation.TranslationResponse.Builder setTranslationResponseValues(@NonNull android.util.SparseArray<android.view.translation.TranslationResponseValue>); method @NonNull public android.view.translation.TranslationResponse.Builder setTranslationStatus(int); Loading Loading @@ -52426,7 +52428,7 @@ package android.view.translation { public class Translator { method public void destroy(); method public boolean isDestroyed(); method @Nullable @WorkerThread public android.view.translation.TranslationResponse translate(@NonNull android.view.translation.TranslationRequest); method @Nullable public void translate(@NonNull android.view.translation.TranslationRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.view.translation.TranslationResponse>); } public final class UiTranslationManager {
core/java/android/service/translation/ITranslationCallback.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,6 @@ import android.view.translation.TranslationResponse; * @hide */ oneway interface ITranslationCallback { void onTranslationComplete(in TranslationResponse translationResponse); void onTranslationResponse(in TranslationResponse translationResponse); void onError(); }
core/java/android/service/translation/OnTranslationResultCallbackWrapper.java +3 −3 Original line number Diff line number Diff line Loading @@ -51,12 +51,12 @@ final class OnTranslationResultCallbackWrapper implements @Override public void onTranslationSuccess(@Nullable TranslationResponse response) { assertNotCalled(); if (mCalled.getAndSet(true)) { throw new IllegalStateException("Already called"); if (mCalled.getAndSet(response.isFinalResponse())) { throw new IllegalStateException("Already called with complete response"); } try { mCallback.onTranslationComplete(response); mCallback.onTranslationResponse(response); } catch (RemoteException e) { if (e instanceof DeadObjectException) { Log.w(TAG, "Process is dead, ignore."); Loading
core/java/android/service/translation/TranslationService.java +2 −23 Original line number Diff line number Diff line Loading @@ -42,7 +42,6 @@ import android.view.translation.TranslationResponse; import android.view.translation.TranslationSpec; import com.android.internal.os.IResultReceiver; import com.android.internal.util.SyncResultReceiver; /** * Service for translating text. Loading Loading @@ -139,30 +138,10 @@ public abstract class TranslationService extends Service { @Override public void onTranslationRequest(TranslationRequest request, int sessionId, ITranslationCallback callback, IResultReceiver receiver) ITranslationCallback callback) throws RemoteException { // TODO(b/176464808): Currently, the API is used for both sync and async case. // It may work now, but maybe two methods is more cleaner. To think how to // define the APIs for these two cases. final ITranslationCallback cb = callback != null ? callback : new ITranslationCallback.Stub() { @Override public void onTranslationComplete( TranslationResponse translationResponse) throws RemoteException { receiver.send(0, SyncResultReceiver.bundleFor(translationResponse)); } @Override public void onError() throws RemoteException { //TODO: implement default error callback } }; // TODO(b/176464808): make it a private member of client final OnTranslationResultCallback translationResultCallback = new OnTranslationResultCallbackWrapper(cb); new OnTranslationResultCallbackWrapper(callback); mHandler.sendMessage(obtainMessage(TranslationService::onTranslationRequest, TranslationService.this, request, sessionId, mCancellationSignal, translationResultCallback)); Loading
core/java/android/view/translation/ITranslationDirectManager.aidl +1 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.view.translation; import android.view.translation.TranslationRequest; import android.service.translation.ITranslationCallback; import com.android.internal.os.IResultReceiver; /** * Interface between an app (TranslationManager / Translator) and the remote TranslationService Loading @@ -28,6 +27,6 @@ import com.android.internal.os.IResultReceiver; */ oneway interface ITranslationDirectManager { void onTranslationRequest(in TranslationRequest request, int sessionId, in ITranslationCallback callback, in IResultReceiver receiver); in ITranslationCallback callback); void onFinishTranslationSession(int sessionId); }