Loading packages/NeuralNetworks/framework/platform/java/android/service/ondeviceintelligence/OnDeviceSandboxedInferenceService.java +23 −4 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import static android.app.ondeviceintelligence.OnDeviceIntelligenceManager.AUGME 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 static android.app.ondeviceintelligence.flags.Flags.FLAG_ON_DEVICE_INTELLIGENCE_25Q4; import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage; import android.annotation.CallSuper; Loading Loading @@ -147,11 +146,26 @@ public abstract class OnDeviceSandboxedInferenceService extends Service { */ public static final String MODEL_UNLOADED_BROADCAST_INTENT = "android.service.ondeviceintelligence.MODEL_UNLOADED"; /** * Defines keys for the {@link #updateProcessingState(Bundle, OutcomeReceiver)} * bundle in {@link #onUpdateProcessingState(Bundle, OutcomeReceiver)}. * * @hide */ public static final String DEVICE_CONFIG_UPDATE_BUNDLE_KEY = "device_config_update"; @FlaggedApi(FLAG_ON_DEVICE_INTELLIGENCE_25Q4) @SystemApi public static final class UpdateProcessingStateKeys { private UpdateProcessingStateKeys() {} /** * Key for the {@code processingState} bundle in * {@link #onUpdateProcessingState(Bundle, OutcomeReceiver)}, where the value is a * {@link PersistableBundle} containing the device config flags matching the * configured device-config namespace under * {@link R.string.config_defaultOnDeviceIntelligenceDeviceConfigNamespace}. */ public static final String KEY_DEVICE_CONFIG_UPDATE = "device_config_update"; } /** * Listener for inference service lifecycle events. Loading Loading @@ -411,7 +425,12 @@ public abstract class OnDeviceSandboxedInferenceService extends Service { * configuration, files or state. * * @param processingState contains updated state and params that are to be applied to the * processing environmment, * processing environment. * The expected keys are constants defined * in {@link UpdateProcessingStateKeys}. * There can be other custom keys sent via * {@link OnDeviceIntelligenceService} but these would be * specific to configured remote package implementation. * @param callback callback to populate the update status and if there are params * associated with the status. */ Loading packages/NeuralNetworks/service/platform/java/com/android/server/ondeviceintelligence/OnDeviceIntelligenceManagerService.java +4 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package com.android.server.ondeviceintelligence; import static android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService.DEVICE_CONFIG_UPDATE_BUNDLE_KEY; import static android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService.UpdateProcessingStateKeys.KEY_DEVICE_CONFIG_UPDATE; import static android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService.MODEL_LOADED_BUNDLE_KEY; import static android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService.MODEL_UNLOADED_BUNDLE_KEY; import static android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService.MODEL_LOADED_BROADCAST_INTENT; Loading Loading @@ -735,6 +735,8 @@ public class OnDeviceIntelligenceManagerService extends SystemService { callbackExecutor.execute(() -> { AndroidFuture<Void> result = null; try { // Reserved for use by system-server. processingState.remove(KEY_DEVICE_CONFIG_UPDATE); sanitizeStateParams(processingState); ensureRemoteInferenceServiceInitialized(); result = mRemoteInferenceService.post( Loading Loading @@ -898,7 +900,7 @@ public class OnDeviceIntelligenceManagerService extends SystemService { persistableBundle.putString(key, props.getString(key, "")); } Bundle bundle = new Bundle(); bundle.putParcelable(DEVICE_CONFIG_UPDATE_BUNDLE_KEY, persistableBundle); bundle.putParcelable(KEY_DEVICE_CONFIG_UPDATE, persistableBundle); ensureRemoteInferenceServiceInitialized(); mRemoteInferenceService.run(service -> service.updateProcessingState( bundle, Loading Loading
packages/NeuralNetworks/framework/platform/java/android/service/ondeviceintelligence/OnDeviceSandboxedInferenceService.java +23 −4 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import static android.app.ondeviceintelligence.OnDeviceIntelligenceManager.AUGME 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 static android.app.ondeviceintelligence.flags.Flags.FLAG_ON_DEVICE_INTELLIGENCE_25Q4; import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage; import android.annotation.CallSuper; Loading Loading @@ -147,11 +146,26 @@ public abstract class OnDeviceSandboxedInferenceService extends Service { */ public static final String MODEL_UNLOADED_BROADCAST_INTENT = "android.service.ondeviceintelligence.MODEL_UNLOADED"; /** * Defines keys for the {@link #updateProcessingState(Bundle, OutcomeReceiver)} * bundle in {@link #onUpdateProcessingState(Bundle, OutcomeReceiver)}. * * @hide */ public static final String DEVICE_CONFIG_UPDATE_BUNDLE_KEY = "device_config_update"; @FlaggedApi(FLAG_ON_DEVICE_INTELLIGENCE_25Q4) @SystemApi public static final class UpdateProcessingStateKeys { private UpdateProcessingStateKeys() {} /** * Key for the {@code processingState} bundle in * {@link #onUpdateProcessingState(Bundle, OutcomeReceiver)}, where the value is a * {@link PersistableBundle} containing the device config flags matching the * configured device-config namespace under * {@link R.string.config_defaultOnDeviceIntelligenceDeviceConfigNamespace}. */ public static final String KEY_DEVICE_CONFIG_UPDATE = "device_config_update"; } /** * Listener for inference service lifecycle events. Loading Loading @@ -411,7 +425,12 @@ public abstract class OnDeviceSandboxedInferenceService extends Service { * configuration, files or state. * * @param processingState contains updated state and params that are to be applied to the * processing environmment, * processing environment. * The expected keys are constants defined * in {@link UpdateProcessingStateKeys}. * There can be other custom keys sent via * {@link OnDeviceIntelligenceService} but these would be * specific to configured remote package implementation. * @param callback callback to populate the update status and if there are params * associated with the status. */ Loading
packages/NeuralNetworks/service/platform/java/com/android/server/ondeviceintelligence/OnDeviceIntelligenceManagerService.java +4 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package com.android.server.ondeviceintelligence; import static android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService.DEVICE_CONFIG_UPDATE_BUNDLE_KEY; import static android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService.UpdateProcessingStateKeys.KEY_DEVICE_CONFIG_UPDATE; import static android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService.MODEL_LOADED_BUNDLE_KEY; import static android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService.MODEL_UNLOADED_BUNDLE_KEY; import static android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService.MODEL_LOADED_BROADCAST_INTENT; Loading Loading @@ -735,6 +735,8 @@ public class OnDeviceIntelligenceManagerService extends SystemService { callbackExecutor.execute(() -> { AndroidFuture<Void> result = null; try { // Reserved for use by system-server. processingState.remove(KEY_DEVICE_CONFIG_UPDATE); sanitizeStateParams(processingState); ensureRemoteInferenceServiceInitialized(); result = mRemoteInferenceService.post( Loading Loading @@ -898,7 +900,7 @@ public class OnDeviceIntelligenceManagerService extends SystemService { persistableBundle.putString(key, props.getString(key, "")); } Bundle bundle = new Bundle(); bundle.putParcelable(DEVICE_CONFIG_UPDATE_BUNDLE_KEY, persistableBundle); bundle.putParcelable(KEY_DEVICE_CONFIG_UPDATE, persistableBundle); ensureRemoteInferenceServiceInitialized(); mRemoteInferenceService.run(service -> service.updateProcessingState( bundle, Loading