Loading core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -52812,6 +52812,7 @@ package android.view.translation { field @NonNull public static final android.os.Parcelable.Creator<android.view.translation.TranslationCapability> CREATOR; field public static final int STATE_AVAILABLE_TO_DOWNLOAD = 1; // 0x1 field public static final int STATE_DOWNLOADING = 2; // 0x2 field public static final int STATE_NOT_AVAILABLE = 4; // 0x4 field public static final int STATE_ON_DEVICE = 3; // 0x3 } core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10407,6 +10407,7 @@ package android.service.translation { method public abstract void onFinishTranslationSession(int); method public abstract void onTranslationCapabilitiesRequest(int, int, @NonNull java.util.function.Consumer<java.util.Set<android.view.translation.TranslationCapability>>); method public abstract void onTranslationRequest(@NonNull android.view.translation.TranslationRequest, int, @Nullable android.os.CancellationSignal, @NonNull android.service.translation.TranslationService.OnTranslationResultCallback); method public final void updateTranslationCapability(@NonNull android.view.translation.TranslationCapability); field public static final String SERVICE_INTERFACE = "android.service.translation.TranslationService"; field public static final String SERVICE_META_DATA = "android.translation_service"; } core/java/android/service/translation/ITranslationService.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.service.translation; import android.os.IBinder; import android.os.ResultReceiver; import android.view.translation.TranslationContext; import com.android.internal.os.IResultReceiver; Loading @@ -30,7 +31,7 @@ import com.android.internal.os.IResultReceiver; * @hide */ oneway interface ITranslationService { void onConnected(); void onConnected(in IBinder callback); void onDisconnected(); void onCreateTranslationSession(in TranslationContext translationContext, int sessionId, in IResultReceiver receiver); Loading core/java/android/service/translation/TranslationService.java +33 −3 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.os.ResultReceiver; import android.util.ArraySet; import android.util.Log; import android.view.translation.ITranslationDirectManager; import android.view.translation.ITranslationServiceCallback; import android.view.translation.TranslationCapability; import android.view.translation.TranslationContext; import android.view.translation.TranslationManager; Loading @@ -50,6 +51,7 @@ import android.view.translation.TranslationSpec; import com.android.internal.os.IResultReceiver; import java.util.Objects; import java.util.Set; import java.util.function.Consumer; Loading Loading @@ -84,15 +86,17 @@ public abstract class TranslationService extends Service { public static final String SERVICE_META_DATA = "android.translation_service"; private Handler mHandler; private ITranslationServiceCallback mCallback; /** * Binder to receive calls from system server. */ private final ITranslationService mInterface = new ITranslationService.Stub() { @Override public void onConnected() { mHandler.sendMessage(obtainMessage(TranslationService::onConnected, TranslationService.this)); public void onConnected(IBinder callback) { mHandler.sendMessage(obtainMessage(TranslationService::handleOnConnected, TranslationService.this, callback)); } @Override Loading Loading @@ -275,6 +279,32 @@ public abstract class TranslationService extends Service { @TranslationSpec.DataFormat int targetFormat, @NonNull Consumer<Set<TranslationCapability>> callback); /** * Called by the service to notify an update in existing {@link TranslationCapability}s. * * @param capability the updated {@link TranslationCapability} with its new states and flags. */ public final void updateTranslationCapability(@NonNull TranslationCapability capability) { Objects.requireNonNull(capability, "translation capability should not be null"); final ITranslationServiceCallback callback = mCallback; if (callback == null) { Log.w(TAG, "updateTranslationCapability(): no server callback"); return; } try { callback.updateTranslationCapability(capability); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } private void handleOnConnected(@NonNull IBinder callback) { mCallback = ITranslationServiceCallback.Stub.asInterface(callback); onConnected(); } // TODO(b/176464808): Need to handle client dying case private void handleOnCreateTranslationSession(@NonNull TranslationContext translationContext, Loading core/java/android/view/translation/ITranslationServiceCallback.aidl 0 → 100644 +28 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view.translation; import android.view.translation.TranslationCapability; /** * Interface from the Translation service to the system. * * @hide */ oneway interface ITranslationServiceCallback { void updateTranslationCapability(in TranslationCapability capability); } Loading
core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -52812,6 +52812,7 @@ package android.view.translation { field @NonNull public static final android.os.Parcelable.Creator<android.view.translation.TranslationCapability> CREATOR; field public static final int STATE_AVAILABLE_TO_DOWNLOAD = 1; // 0x1 field public static final int STATE_DOWNLOADING = 2; // 0x2 field public static final int STATE_NOT_AVAILABLE = 4; // 0x4 field public static final int STATE_ON_DEVICE = 3; // 0x3 }
core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10407,6 +10407,7 @@ package android.service.translation { method public abstract void onFinishTranslationSession(int); method public abstract void onTranslationCapabilitiesRequest(int, int, @NonNull java.util.function.Consumer<java.util.Set<android.view.translation.TranslationCapability>>); method public abstract void onTranslationRequest(@NonNull android.view.translation.TranslationRequest, int, @Nullable android.os.CancellationSignal, @NonNull android.service.translation.TranslationService.OnTranslationResultCallback); method public final void updateTranslationCapability(@NonNull android.view.translation.TranslationCapability); field public static final String SERVICE_INTERFACE = "android.service.translation.TranslationService"; field public static final String SERVICE_META_DATA = "android.translation_service"; }
core/java/android/service/translation/ITranslationService.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.service.translation; import android.os.IBinder; import android.os.ResultReceiver; import android.view.translation.TranslationContext; import com.android.internal.os.IResultReceiver; Loading @@ -30,7 +31,7 @@ import com.android.internal.os.IResultReceiver; * @hide */ oneway interface ITranslationService { void onConnected(); void onConnected(in IBinder callback); void onDisconnected(); void onCreateTranslationSession(in TranslationContext translationContext, int sessionId, in IResultReceiver receiver); Loading
core/java/android/service/translation/TranslationService.java +33 −3 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.os.ResultReceiver; import android.util.ArraySet; import android.util.Log; import android.view.translation.ITranslationDirectManager; import android.view.translation.ITranslationServiceCallback; import android.view.translation.TranslationCapability; import android.view.translation.TranslationContext; import android.view.translation.TranslationManager; Loading @@ -50,6 +51,7 @@ import android.view.translation.TranslationSpec; import com.android.internal.os.IResultReceiver; import java.util.Objects; import java.util.Set; import java.util.function.Consumer; Loading Loading @@ -84,15 +86,17 @@ public abstract class TranslationService extends Service { public static final String SERVICE_META_DATA = "android.translation_service"; private Handler mHandler; private ITranslationServiceCallback mCallback; /** * Binder to receive calls from system server. */ private final ITranslationService mInterface = new ITranslationService.Stub() { @Override public void onConnected() { mHandler.sendMessage(obtainMessage(TranslationService::onConnected, TranslationService.this)); public void onConnected(IBinder callback) { mHandler.sendMessage(obtainMessage(TranslationService::handleOnConnected, TranslationService.this, callback)); } @Override Loading Loading @@ -275,6 +279,32 @@ public abstract class TranslationService extends Service { @TranslationSpec.DataFormat int targetFormat, @NonNull Consumer<Set<TranslationCapability>> callback); /** * Called by the service to notify an update in existing {@link TranslationCapability}s. * * @param capability the updated {@link TranslationCapability} with its new states and flags. */ public final void updateTranslationCapability(@NonNull TranslationCapability capability) { Objects.requireNonNull(capability, "translation capability should not be null"); final ITranslationServiceCallback callback = mCallback; if (callback == null) { Log.w(TAG, "updateTranslationCapability(): no server callback"); return; } try { callback.updateTranslationCapability(capability); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } private void handleOnConnected(@NonNull IBinder callback) { mCallback = ITranslationServiceCallback.Stub.asInterface(callback); onConnected(); } // TODO(b/176464808): Need to handle client dying case private void handleOnCreateTranslationSession(@NonNull TranslationContext translationContext, Loading
core/java/android/view/translation/ITranslationServiceCallback.aidl 0 → 100644 +28 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view.translation; import android.view.translation.TranslationCapability; /** * Interface from the Translation service to the system. * * @hide */ oneway interface ITranslationServiceCallback { void updateTranslationCapability(in TranslationCapability capability); }