Loading packages/NeuralNetworks/framework/platform/java/android/app/ondeviceintelligence/IResponseCallback.aidl +2 −0 Original line number Diff line number Diff line package android.app.ondeviceintelligence; import android.app.ondeviceintelligence.InferenceInfo; import android.os.PersistableBundle; import android.os.Bundle; import android.os.RemoteCallback; Loading @@ -13,4 +14,5 @@ oneway interface IResponseCallback { void onSuccess(in Bundle resultBundle) = 1; void onFailure(int errorCode, in String errorMessage, in PersistableBundle errorParams) = 2; void onDataAugmentRequest(in Bundle processedContent, in RemoteCallback responseCallback) = 3; void onInferenceInfo(in InferenceInfo info) = 4; } packages/NeuralNetworks/framework/platform/java/android/app/ondeviceintelligence/IStreamingResponseCallback.aidl +2 −0 Original line number Diff line number Diff line package android.app.ondeviceintelligence; import android.app.ondeviceintelligence.InferenceInfo; import android.os.PersistableBundle; import android.os.RemoteCallback; import android.os.Bundle; Loading @@ -15,4 +16,5 @@ oneway interface IStreamingResponseCallback { void onSuccess(in Bundle result) = 2; void onFailure(int errorCode, in String errorMessage, in PersistableBundle errorParams) = 3; void onDataAugmentRequest(in Bundle processedContent, in RemoteCallback responseCallback) = 4; void onInferenceInfo(in InferenceInfo info) = 5; } packages/NeuralNetworks/framework/platform/java/android/app/ondeviceintelligence/OnDeviceIntelligenceManager.java +25 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,16 @@ public final class OnDeviceIntelligenceManager { public static final String AUGMENT_REQUEST_CONTENT_BUNDLE_KEY = "AugmentRequestContentBundleKey"; /** * The key for a boolean extra in the request {@link Bundle} to indicate if the caller wants to * receive {@link InferenceInfo} in the {@link ProcessingCallback#onInferenceInfo} callback. * * @hide */ @SystemApi @FlaggedApi(FLAG_ON_DEVICE_INTELLIGENCE_25Q4) public static final String KEY_REQUEST_INFERENCE_INFO = "request_inference_info"; private static final String TAG = "OnDeviceIntelligence"; private final Context mContext; private final IOnDeviceIntelligenceManager mService; Loading Loading @@ -440,6 +450,13 @@ public final class OnDeviceIntelligenceManager { callbackExecutor.execute(() -> contentCallback.sendResult(bundle)); }))); } @Override public void onInferenceInfo(InferenceInfo info) { Binder.withCleanCallingIdentity( () -> callbackExecutor.execute( () -> processingCallback.onInferenceInfo(info))); } }; Loading Loading @@ -525,6 +542,14 @@ public final class OnDeviceIntelligenceManager { () -> contentCallback.sendResult(bundle)); }))); } @Override public void onInferenceInfo(InferenceInfo info) { Binder.withCleanCallingIdentity(() -> { callbackExecutor.execute( () -> streamingProcessingCallback.onInferenceInfo(info)); }); } }; mService.processRequestStreaming( Loading packages/NeuralNetworks/framework/platform/java/android/app/ondeviceintelligence/ProcessingCallback.java +15 −0 Original line number Diff line number Diff line Loading @@ -17,10 +17,12 @@ package android.app.ondeviceintelligence; import static android.app.ondeviceintelligence.flags.Flags.FLAG_ENABLE_ON_DEVICE_INTELLIGENCE; import static android.app.ondeviceintelligence.flags.Flags.FLAG_ON_DEVICE_INTELLIGENCE_25Q4; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.SystemApi; import android.app.ondeviceintelligence.InferenceInfo; import android.os.Bundle; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.InferenceParams; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.ResponseParams; Loading Loading @@ -69,4 +71,17 @@ public interface ProcessingCallback { @NonNull Consumer<@InferenceParams Bundle> contentConsumer) { contentConsumer.accept(Bundle.EMPTY); } /** * Invoked when inference info is available for the given request. * This callback is invoked only when the * {@link OnDeviceIntelligenceManager#KEY_REQUEST_INFERENCE_INFO} * is set to true in the associated request {@link Bundle}. * * @param info the inference info associated with the request. * @see InferenceInfo */ @FlaggedApi(FLAG_ON_DEVICE_INTELLIGENCE_25Q4) default void onInferenceInfo(@NonNull InferenceInfo info) { } } packages/NeuralNetworks/framework/platform/java/android/service/ondeviceintelligence/OnDeviceSandboxedInferenceService.java +19 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.app.Service; import android.app.ondeviceintelligence.Feature; import android.app.ondeviceintelligence.InferenceInfo; import android.app.ondeviceintelligence.IProcessingSignal; import android.app.ondeviceintelligence.IResponseCallback; import android.app.ondeviceintelligence.IStreamingResponseCallback; Loading Loading @@ -532,6 +533,15 @@ public abstract class OnDeviceSandboxedInferenceService extends Service { Slog.e(TAG, "Error sending augment request: " + e); } } @Override public void onInferenceInfo(@NonNull InferenceInfo info) { try { callback.onInferenceInfo(info); } catch (RemoteException e) { Slog.e(TAG, "Error sending inference info: " + e); } } }; } Loading Loading @@ -577,6 +587,15 @@ public abstract class OnDeviceSandboxedInferenceService extends Service { Slog.e(TAG, "Error sending augment request: " + e); } } @Override public void onInferenceInfo(@NonNull InferenceInfo info) { try { callback.onInferenceInfo(info); } catch (RemoteException e) { Slog.e(TAG, "Error sending inference info: " + e); } } }; } Loading Loading
packages/NeuralNetworks/framework/platform/java/android/app/ondeviceintelligence/IResponseCallback.aidl +2 −0 Original line number Diff line number Diff line package android.app.ondeviceintelligence; import android.app.ondeviceintelligence.InferenceInfo; import android.os.PersistableBundle; import android.os.Bundle; import android.os.RemoteCallback; Loading @@ -13,4 +14,5 @@ oneway interface IResponseCallback { void onSuccess(in Bundle resultBundle) = 1; void onFailure(int errorCode, in String errorMessage, in PersistableBundle errorParams) = 2; void onDataAugmentRequest(in Bundle processedContent, in RemoteCallback responseCallback) = 3; void onInferenceInfo(in InferenceInfo info) = 4; }
packages/NeuralNetworks/framework/platform/java/android/app/ondeviceintelligence/IStreamingResponseCallback.aidl +2 −0 Original line number Diff line number Diff line package android.app.ondeviceintelligence; import android.app.ondeviceintelligence.InferenceInfo; import android.os.PersistableBundle; import android.os.RemoteCallback; import android.os.Bundle; Loading @@ -15,4 +16,5 @@ oneway interface IStreamingResponseCallback { void onSuccess(in Bundle result) = 2; void onFailure(int errorCode, in String errorMessage, in PersistableBundle errorParams) = 3; void onDataAugmentRequest(in Bundle processedContent, in RemoteCallback responseCallback) = 4; void onInferenceInfo(in InferenceInfo info) = 5; }
packages/NeuralNetworks/framework/platform/java/android/app/ondeviceintelligence/OnDeviceIntelligenceManager.java +25 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,16 @@ public final class OnDeviceIntelligenceManager { public static final String AUGMENT_REQUEST_CONTENT_BUNDLE_KEY = "AugmentRequestContentBundleKey"; /** * The key for a boolean extra in the request {@link Bundle} to indicate if the caller wants to * receive {@link InferenceInfo} in the {@link ProcessingCallback#onInferenceInfo} callback. * * @hide */ @SystemApi @FlaggedApi(FLAG_ON_DEVICE_INTELLIGENCE_25Q4) public static final String KEY_REQUEST_INFERENCE_INFO = "request_inference_info"; private static final String TAG = "OnDeviceIntelligence"; private final Context mContext; private final IOnDeviceIntelligenceManager mService; Loading Loading @@ -440,6 +450,13 @@ public final class OnDeviceIntelligenceManager { callbackExecutor.execute(() -> contentCallback.sendResult(bundle)); }))); } @Override public void onInferenceInfo(InferenceInfo info) { Binder.withCleanCallingIdentity( () -> callbackExecutor.execute( () -> processingCallback.onInferenceInfo(info))); } }; Loading Loading @@ -525,6 +542,14 @@ public final class OnDeviceIntelligenceManager { () -> contentCallback.sendResult(bundle)); }))); } @Override public void onInferenceInfo(InferenceInfo info) { Binder.withCleanCallingIdentity(() -> { callbackExecutor.execute( () -> streamingProcessingCallback.onInferenceInfo(info)); }); } }; mService.processRequestStreaming( Loading
packages/NeuralNetworks/framework/platform/java/android/app/ondeviceintelligence/ProcessingCallback.java +15 −0 Original line number Diff line number Diff line Loading @@ -17,10 +17,12 @@ package android.app.ondeviceintelligence; import static android.app.ondeviceintelligence.flags.Flags.FLAG_ENABLE_ON_DEVICE_INTELLIGENCE; import static android.app.ondeviceintelligence.flags.Flags.FLAG_ON_DEVICE_INTELLIGENCE_25Q4; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.SystemApi; import android.app.ondeviceintelligence.InferenceInfo; import android.os.Bundle; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.InferenceParams; import android.app.ondeviceintelligence.OnDeviceIntelligenceManager.ResponseParams; Loading Loading @@ -69,4 +71,17 @@ public interface ProcessingCallback { @NonNull Consumer<@InferenceParams Bundle> contentConsumer) { contentConsumer.accept(Bundle.EMPTY); } /** * Invoked when inference info is available for the given request. * This callback is invoked only when the * {@link OnDeviceIntelligenceManager#KEY_REQUEST_INFERENCE_INFO} * is set to true in the associated request {@link Bundle}. * * @param info the inference info associated with the request. * @see InferenceInfo */ @FlaggedApi(FLAG_ON_DEVICE_INTELLIGENCE_25Q4) default void onInferenceInfo(@NonNull InferenceInfo info) { } }
packages/NeuralNetworks/framework/platform/java/android/service/ondeviceintelligence/OnDeviceSandboxedInferenceService.java +19 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.app.Service; import android.app.ondeviceintelligence.Feature; import android.app.ondeviceintelligence.InferenceInfo; import android.app.ondeviceintelligence.IProcessingSignal; import android.app.ondeviceintelligence.IResponseCallback; import android.app.ondeviceintelligence.IStreamingResponseCallback; Loading Loading @@ -532,6 +533,15 @@ public abstract class OnDeviceSandboxedInferenceService extends Service { Slog.e(TAG, "Error sending augment request: " + e); } } @Override public void onInferenceInfo(@NonNull InferenceInfo info) { try { callback.onInferenceInfo(info); } catch (RemoteException e) { Slog.e(TAG, "Error sending inference info: " + e); } } }; } Loading Loading @@ -577,6 +587,15 @@ public abstract class OnDeviceSandboxedInferenceService extends Service { Slog.e(TAG, "Error sending augment request: " + e); } } @Override public void onInferenceInfo(@NonNull InferenceInfo info) { try { callback.onInferenceInfo(info); } catch (RemoteException e) { Slog.e(TAG, "Error sending inference info: " + e); } } }; } Loading