Loading core/java/android/app/ondeviceintelligence/OnDeviceIntelligenceManager.java +44 −15 Original line number Diff line number Diff line Loading @@ -365,7 +365,6 @@ public final class OnDeviceIntelligenceManager { * associated params. */ @RequiresPermission(Manifest.permission.USE_ON_DEVICE_INTELLIGENCE) public void processRequest(@NonNull Feature feature, @NonNull @InferenceParams Bundle request, @RequestType int requestType, @Nullable CancellationSignal cancellationSignal, Loading Loading @@ -430,7 +429,7 @@ public final class OnDeviceIntelligenceManager { * @param cancellationSignal signal to invoke cancellation. * @param processingSignal signal to send custom signals in the * remote implementation. * @param streamingResponseCallback streaming callback to populate the response content and * @param streamingProcessingCallback streaming callback to populate the response content and * associated params. * @param callbackExecutor executor to run the callback on. */ Loading Loading @@ -528,19 +527,18 @@ public final class OnDeviceIntelligenceManager { /** * {@link Bundle}s annotated with this type will be validated that they are in-effect read-only * when passed to inference service via Binder IPC. Following restrictions apply : * when passed via Binder IPC. Following restrictions apply : * <ul> * <li> No Nested Bundles are allowed.</li> * <li> {@link PersistableBundle}s are allowed.</li> * <li> Any primitive types or their collections can be added as usual.</li> * <li>IBinder objects should *not* be added.</li> * <li>Parcelable data which has no active-objects, should be added as * {@link Bundle#putByteArray}</li> * <li>Parcelables have active-objects, only following types will be allowed</li> * <ul> * <li>{@link Bitmap} set as {@link Bitmap#setImmutable()}</li> * <li>{@link android.database.CursorWindow}</li> * <li>{@link android.os.ParcelFileDescriptor} opened in * {@link android.os.ParcelFileDescriptor#MODE_READ_ONLY}</li> * <li>{@link android.os.SharedMemory} set to {@link OsConstants#PROT_READ}</li> * </ul> * </ul> * Loading @@ -550,9 +548,40 @@ public final class OnDeviceIntelligenceManager { * @hide */ @Target({ElementType.PARAMETER, ElementType.FIELD}) public @interface StateParams { } /** * This is an extension of {@link StateParams} but for purpose of inference few other types are * also allowed as read-only, as listed below. * * <li>{@link Bitmap} set as immutable.</li> * <li>{@link android.database.CursorWindow}</li> * <li>{@link android.os.SharedMemory} set to {@link OsConstants#PROT_READ}</li> * </ul> * </ul> * * In all other scenarios the system-server might throw a * {@link android.os.BadParcelableException} if the Bundle validation fails. * * @hide */ @Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.TYPE_USE}) public @interface InferenceParams { } /** * This is an extension of {@link StateParams} with the exception that it allows writing * {@link Bitmap} as part of the response. * * In all other scenarios the system-server might throw a * {@link android.os.BadParcelableException} if the Bundle validation fails. * * @hide */ @Target({ElementType.PARAMETER, ElementType.FIELD}) public @interface ResponseParams { } @Nullable private static AndroidFuture<IBinder> configureRemoteCancellationFuture( Loading core/java/android/app/ondeviceintelligence/ProcessingCallback.java +4 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.Bundle; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.InferenceParams; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.ResponseParams; import java.util.function.Consumer; Loading @@ -43,7 +44,7 @@ public interface ProcessingCallback { * * @param result Response to be passed as a result. */ void onResult(@NonNull @InferenceParams Bundle result); void onResult(@NonNull @ResponseParams Bundle result); /** * Called when the request processing fails. The failure details are indicated by the Loading @@ -64,8 +65,8 @@ public interface ProcessingCallback { * expected to be non-null or EMPTY when there is no response. */ default void onDataAugmentRequest( @NonNull @InferenceParams Bundle processedContent, @NonNull Consumer<Bundle> contentConsumer) { @NonNull @ResponseParams Bundle processedContent, @NonNull Consumer<@InferenceParams Bundle> contentConsumer) { contentConsumer.accept(Bundle.EMPTY); } } core/java/android/app/ondeviceintelligence/StreamingProcessingCallback.java +2 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.Bundle; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.InferenceParams; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.ResponseParams; /** * Streaming variant of {@link ProcessingCallback} to populate response while processing a given Loading @@ -37,5 +37,5 @@ public interface StreamingProcessingCallback extends ProcessingCallback { * Callback that would be invoked when a part of the response i.e. some response is * already processed, and needs to be passed onto the caller. */ void onPartialResult(@NonNull @InferenceParams Bundle partialResult); void onPartialResult(@NonNull @ResponseParams Bundle partialResult); } core/java/android/service/ondeviceintelligence/IOnDeviceIntelligenceService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ oneway interface IOnDeviceIntelligenceService { void getReadOnlyFileDescriptor(in String fileName, in AndroidFuture<ParcelFileDescriptor> future); void getReadOnlyFeatureFileDescriptorMap(in Feature feature, in RemoteCallback remoteCallback); void requestFeatureDownload(int callerUid, in Feature feature, in AndroidFuture<ICancellationSignal> cancellationSignal, in AndroidFuture cancellationSignal, in IDownloadCallback downloadCallback); void registerRemoteServices(in IRemoteProcessingService remoteProcessingService); void notifyInferenceServiceConnected(); Loading core/java/android/service/ondeviceintelligence/IOnDeviceSandboxedInferenceService.aidl +5 −5 Original line number Diff line number Diff line Loading @@ -36,15 +36,15 @@ import android.service.ondeviceintelligence.IProcessingUpdateStatusCallback; oneway interface IOnDeviceSandboxedInferenceService { void registerRemoteStorageService(in IRemoteStorageService storageService); void requestTokenInfo(int callerUid, in Feature feature, in Bundle request, in AndroidFuture<ICancellationSignal> cancellationSignal, in AndroidFuture cancellationSignal, in ITokenInfoCallback tokenInfoCallback); void processRequest(int callerUid, in Feature feature, in Bundle request, in int requestType, in AndroidFuture<ICancellationSignal> cancellationSignal, in AndroidFuture<IProcessingSignal> processingSignal, in AndroidFuture cancellationSignal, in AndroidFuture processingSignal, in IResponseCallback callback); void processRequestStreaming(int callerUid, in Feature feature, in Bundle request, in int requestType, in AndroidFuture<ICancellationSignal> cancellationSignal, in AndroidFuture<IProcessingSignal> processingSignal, in AndroidFuture cancellationSignal, in AndroidFuture processingSignal, in IStreamingResponseCallback callback); void updateProcessingState(in Bundle processingState, in IProcessingUpdateStatusCallback callback); Loading Loading
core/java/android/app/ondeviceintelligence/OnDeviceIntelligenceManager.java +44 −15 Original line number Diff line number Diff line Loading @@ -365,7 +365,6 @@ public final class OnDeviceIntelligenceManager { * associated params. */ @RequiresPermission(Manifest.permission.USE_ON_DEVICE_INTELLIGENCE) public void processRequest(@NonNull Feature feature, @NonNull @InferenceParams Bundle request, @RequestType int requestType, @Nullable CancellationSignal cancellationSignal, Loading Loading @@ -430,7 +429,7 @@ public final class OnDeviceIntelligenceManager { * @param cancellationSignal signal to invoke cancellation. * @param processingSignal signal to send custom signals in the * remote implementation. * @param streamingResponseCallback streaming callback to populate the response content and * @param streamingProcessingCallback streaming callback to populate the response content and * associated params. * @param callbackExecutor executor to run the callback on. */ Loading Loading @@ -528,19 +527,18 @@ public final class OnDeviceIntelligenceManager { /** * {@link Bundle}s annotated with this type will be validated that they are in-effect read-only * when passed to inference service via Binder IPC. Following restrictions apply : * when passed via Binder IPC. Following restrictions apply : * <ul> * <li> No Nested Bundles are allowed.</li> * <li> {@link PersistableBundle}s are allowed.</li> * <li> Any primitive types or their collections can be added as usual.</li> * <li>IBinder objects should *not* be added.</li> * <li>Parcelable data which has no active-objects, should be added as * {@link Bundle#putByteArray}</li> * <li>Parcelables have active-objects, only following types will be allowed</li> * <ul> * <li>{@link Bitmap} set as {@link Bitmap#setImmutable()}</li> * <li>{@link android.database.CursorWindow}</li> * <li>{@link android.os.ParcelFileDescriptor} opened in * {@link android.os.ParcelFileDescriptor#MODE_READ_ONLY}</li> * <li>{@link android.os.SharedMemory} set to {@link OsConstants#PROT_READ}</li> * </ul> * </ul> * Loading @@ -550,9 +548,40 @@ public final class OnDeviceIntelligenceManager { * @hide */ @Target({ElementType.PARAMETER, ElementType.FIELD}) public @interface StateParams { } /** * This is an extension of {@link StateParams} but for purpose of inference few other types are * also allowed as read-only, as listed below. * * <li>{@link Bitmap} set as immutable.</li> * <li>{@link android.database.CursorWindow}</li> * <li>{@link android.os.SharedMemory} set to {@link OsConstants#PROT_READ}</li> * </ul> * </ul> * * In all other scenarios the system-server might throw a * {@link android.os.BadParcelableException} if the Bundle validation fails. * * @hide */ @Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.TYPE_USE}) public @interface InferenceParams { } /** * This is an extension of {@link StateParams} with the exception that it allows writing * {@link Bitmap} as part of the response. * * In all other scenarios the system-server might throw a * {@link android.os.BadParcelableException} if the Bundle validation fails. * * @hide */ @Target({ElementType.PARAMETER, ElementType.FIELD}) public @interface ResponseParams { } @Nullable private static AndroidFuture<IBinder> configureRemoteCancellationFuture( Loading
core/java/android/app/ondeviceintelligence/ProcessingCallback.java +4 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.Bundle; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.InferenceParams; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.ResponseParams; import java.util.function.Consumer; Loading @@ -43,7 +44,7 @@ public interface ProcessingCallback { * * @param result Response to be passed as a result. */ void onResult(@NonNull @InferenceParams Bundle result); void onResult(@NonNull @ResponseParams Bundle result); /** * Called when the request processing fails. The failure details are indicated by the Loading @@ -64,8 +65,8 @@ public interface ProcessingCallback { * expected to be non-null or EMPTY when there is no response. */ default void onDataAugmentRequest( @NonNull @InferenceParams Bundle processedContent, @NonNull Consumer<Bundle> contentConsumer) { @NonNull @ResponseParams Bundle processedContent, @NonNull Consumer<@InferenceParams Bundle> contentConsumer) { contentConsumer.accept(Bundle.EMPTY); } }
core/java/android/app/ondeviceintelligence/StreamingProcessingCallback.java +2 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.Bundle; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.InferenceParams; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.ResponseParams; /** * Streaming variant of {@link ProcessingCallback} to populate response while processing a given Loading @@ -37,5 +37,5 @@ public interface StreamingProcessingCallback extends ProcessingCallback { * Callback that would be invoked when a part of the response i.e. some response is * already processed, and needs to be passed onto the caller. */ void onPartialResult(@NonNull @InferenceParams Bundle partialResult); void onPartialResult(@NonNull @ResponseParams Bundle partialResult); }
core/java/android/service/ondeviceintelligence/IOnDeviceIntelligenceService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ oneway interface IOnDeviceIntelligenceService { void getReadOnlyFileDescriptor(in String fileName, in AndroidFuture<ParcelFileDescriptor> future); void getReadOnlyFeatureFileDescriptorMap(in Feature feature, in RemoteCallback remoteCallback); void requestFeatureDownload(int callerUid, in Feature feature, in AndroidFuture<ICancellationSignal> cancellationSignal, in AndroidFuture cancellationSignal, in IDownloadCallback downloadCallback); void registerRemoteServices(in IRemoteProcessingService remoteProcessingService); void notifyInferenceServiceConnected(); Loading
core/java/android/service/ondeviceintelligence/IOnDeviceSandboxedInferenceService.aidl +5 −5 Original line number Diff line number Diff line Loading @@ -36,15 +36,15 @@ import android.service.ondeviceintelligence.IProcessingUpdateStatusCallback; oneway interface IOnDeviceSandboxedInferenceService { void registerRemoteStorageService(in IRemoteStorageService storageService); void requestTokenInfo(int callerUid, in Feature feature, in Bundle request, in AndroidFuture<ICancellationSignal> cancellationSignal, in AndroidFuture cancellationSignal, in ITokenInfoCallback tokenInfoCallback); void processRequest(int callerUid, in Feature feature, in Bundle request, in int requestType, in AndroidFuture<ICancellationSignal> cancellationSignal, in AndroidFuture<IProcessingSignal> processingSignal, in AndroidFuture cancellationSignal, in AndroidFuture processingSignal, in IResponseCallback callback); void processRequestStreaming(int callerUid, in Feature feature, in Bundle request, in int requestType, in AndroidFuture<ICancellationSignal> cancellationSignal, in AndroidFuture<IProcessingSignal> processingSignal, in AndroidFuture cancellationSignal, in AndroidFuture processingSignal, in IStreamingResponseCallback callback); void updateProcessingState(in Bundle processingState, in IProcessingUpdateStatusCallback callback); Loading