Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4425632f authored by Sandeep Bandaru's avatar Sandeep Bandaru
Browse files

Remove inner class for bundle key to follow conventions


- Update constant value as per go/android-api-guidelines#constants-keys.
- Also adding a deprecated version that the manager still publishes for backward
compatibility with older app implementations depending on this hidden key, like AICore.

Bug: 430118901
Test: CTS
Flag: android.app.ondeviceintelligence.flags.on_device_intelligence_25q4
Change-Id: Ie78c9cb78ccd72871c5f784562d8483a22a2969e
parent 69dfa3b4
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -146,26 +146,27 @@ 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)}.
     * 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 com.android.internal.R.string#config_defaultOnDeviceIntelligenceDeviceConfigNamespace}.
     *
     * @hide
     */
    @FlaggedApi(FLAG_ON_DEVICE_INTELLIGENCE_25Q4)
    @SystemApi
    public static final class UpdateProcessingStateKeys {
        private UpdateProcessingStateKeys() {}
    public static final String KEY_DEVICE_CONFIG_UPDATE =
            "android.service.ondeviceintelligence.KEY_DEVICE_CONFIG_UPDATE";

    /**
         * 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}.
     * @deprecated Use {@link #KEY_DEVICE_CONFIG_UPDATE} instead.
     * @hide
     */
        public static final String KEY_DEVICE_CONFIG_UPDATE = "device_config_update";
    }
    @Deprecated
    public static final String DEPRECATED_KEY_DEVICE_CONFIG_UPDATE = "device_config_update";

    /**
     * Listener for inference service lifecycle events.
@@ -425,11 +426,10 @@ 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 environment.
     *                        The expected keys are constants defined
     *                        in {@link UpdateProcessingStateKeys}.
     *                        There can be other custom keys sent via
     *                        {@link OnDeviceIntelligenceService} but these would be
     *                        processing environment. The expected keys are constants defined in
     *                        this class, for e.g. {@link #KEY_DEVICE_CONFIG_UPDATE}.
     *                        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.
+10 −4
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.server.ondeviceintelligence;

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;
@@ -133,7 +132,6 @@ public class OnDeviceIntelligenceManagerService extends SystemService {
    private static final String SYSTEM_PACKAGE = "android";
    private static final long MAX_AGE_MS = TimeUnit.HOURS.toMillis(3);


    private final Executor resourceClosingExecutor = Executors.newCachedThreadPool();
    private final Executor callbackExecutor = Executors.newCachedThreadPool();
    private final Executor broadcastExecutor = Executors.newCachedThreadPool();
@@ -737,7 +735,10 @@ public class OnDeviceIntelligenceManagerService extends SystemService {
                    AndroidFuture<Void> result = null;
                    try {
                        // Reserved for use by system-server.
                        processingState.remove(KEY_DEVICE_CONFIG_UPDATE);
                        processingState.remove(
                                OnDeviceSandboxedInferenceService.KEY_DEVICE_CONFIG_UPDATE);
                        processingState.remove(
                                OnDeviceSandboxedInferenceService.DEPRECATED_KEY_DEVICE_CONFIG_UPDATE);
                        ensureRemoteInferenceServiceInitialized();
                        result = mRemoteInferenceService.post(
                                service -> service.updateProcessingState(
@@ -900,7 +901,12 @@ public class OnDeviceIntelligenceManagerService extends SystemService {
            persistableBundle.putString(key, props.getString(key, ""));
        }
        Bundle bundle = new Bundle();
        bundle.putParcelable(KEY_DEVICE_CONFIG_UPDATE, persistableBundle);
        bundle.putParcelable(OnDeviceSandboxedInferenceService
                .KEY_DEVICE_CONFIG_UPDATE,
                persistableBundle);
        bundle.putParcelable(OnDeviceSandboxedInferenceService
                .DEPRECATED_KEY_DEVICE_CONFIG_UPDATE,
                persistableBundle);
        ensureRemoteInferenceServiceInitialized();
        mRemoteInferenceService.run(service -> service.updateProcessingState(
                bundle,