# OnDevicePersonalizationManager

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# OnDevicePersonalizationManager

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager "View this page in Java")  

```
open class OnDevicePersonalizationManager
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                                                         ||
| ↳ | [android.adservices.ondevicepersonalization.OnDevicePersonalizationManager](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#) |

OnDevicePersonalizationManager provides APIs for apps to load an[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)in an isolated process and interact with it. An app can request an[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)to generate content for display within an[android.view.SurfaceView](https://developer.android.com/reference/kotlin/android/view/SurfaceView.html#)within the app's view hierarchy, and also write persistent results to on-device storage which can be consumed by Federated Analytics for cross-device statistical analysis or by Federated Learning for model training. The displayed content and the persistent output are both not directly accessible by the calling app.

## Summary

|                                                                                                                                                                                                                                                Nested classes                                                                                                                                                                                                                                                ||
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open | [ExecuteResult](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult) The result of a call to[OnDevicePersonalizationManager.execute(ComponentName,](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#execute(android.content.ComponentName,%20android.os.PersistableBundle,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver)) |

|                                                                                                                                                         Constants                                                                                                                                                          ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FEATURE_DISABLED](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#FEATURE_DISABLED:kotlin.Int) Indicates that a feature is present but disabled on the device. |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FEATURE_ENABLED](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#FEATURE_ENABLED:kotlin.Int) Indicates that a feature is present and enabled on the device.    |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FEATURE_UNSUPPORTED](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#FEATURE_UNSUPPORTED:kotlin.Int) Indicates that a feature is not supported on the device.  |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [execute](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#execute(android.content.ComponentName,%20android.os.PersistableBundle,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver))`(`service:` `[ComponentName](https://developer.android.com/reference/kotlin/android/content/ComponentName.html#)`, `params:` `[PersistableBundle](https://developer.android.com/reference/kotlin/android/os/PersistableBundle.html#)`, `executor:` `[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)`, `receiver:` `[OutcomeReceiver](https://developer.android.com/reference/kotlin/android/os/OutcomeReceiver.html#)<[OnDevicePersonalizationManager.ExecuteResult](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult)!,` `[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)!>`)` Executes an[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)in the OnDevicePersonalization sandbox.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [executeInIsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#executeInIsolatedService(android.adservices.ondevicepersonalization.ExecuteInIsolatedServiceRequest,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver))`(`request:` `[ExecuteInIsolatedServiceRequest](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceRequest)`, `executor:` `[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)`, `receiver:` `[OutcomeReceiver](https://developer.android.com/reference/kotlin/android/os/OutcomeReceiver.html#)<[ExecuteInIsolatedServiceResponse](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceResponse)!,` `[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)!>`)` Executes an[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)in the OnDevicePersonalization sandbox.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [queryFeatureAvailability](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#queryFeatureAvailability(kotlin.String,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver))`(`featureName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `executor:` `[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)`, `receiver:` `[OutcomeReceiver](https://developer.android.com/reference/kotlin/android/os/OutcomeReceiver.html#)<[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!,` `[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)!>`)` Get the status of a specific OnDevicePersonalization feature.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [requestSurfacePackage](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#requestSurfacePackage(android.adservices.ondevicepersonalization.SurfacePackageToken,%20android.os.IBinder,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver))`(`surfacePackageToken:` `[SurfacePackageToken](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/SurfacePackageToken)`, `surfaceViewHostToken:` `[IBinder](https://developer.android.com/reference/kotlin/android/os/IBinder.html#)`, `displayId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `width:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `height:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `executor:` `[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)`, `receiver:` `[OutcomeReceiver](https://developer.android.com/reference/kotlin/android/os/OutcomeReceiver.html#)<[SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/kotlin/android/view/SurfaceControlViewHost.SurfacePackage.html#)!,` `[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)!>`)` Requests a[android.view.SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/kotlin/android/view/SurfaceControlViewHost.SurfacePackage.html#)to be inserted into a[android.view.SurfaceView](https://developer.android.com/reference/kotlin/android/view/SurfaceView.html#)inside the calling app. |

## Constants

### FEATURE_DISABLED

Added in[API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FEATURE_DISABLED: Int
```

Indicates that a feature is present but disabled on the device.  

    Value: 1

### FEATURE_ENABLED

Added in[API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FEATURE_ENABLED: Int
```

Indicates that a feature is present and enabled on the device.  

    Value: 0

### FEATURE_UNSUPPORTED

Added in[API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FEATURE_UNSUPPORTED: Int
```

Indicates that a feature is not supported on the device.  

    Value: 2

## Public methods

### execute

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun execute(
    service: ComponentName, 
    params: PersistableBundle, 
    executor: Executor, 
    receiver: OutcomeReceiver<OnDevicePersonalizationManager.ExecuteResult!, Exception!>
): Unit
```

Executes an[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)in the OnDevicePersonalization sandbox. The platform binds to the specified[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)in an isolated process and calls[android.adservices.ondevicepersonalization.IsolatedWorker#onExecute(android.adservices.ondevicepersonalization.ExecuteInput,android.os.OutcomeReceiver)](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedWorker#onExecute(android.adservices.ondevicepersonalization.ExecuteInput,%20android.os.OutcomeReceiver))with the caller-provided parameters. When the[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)finishes execution, the platform returns tokens that refer to the results from the service to the caller. These tokens can be subsequently used to display results in a[android.view.SurfaceView](https://developer.android.com/reference/kotlin/android/view/SurfaceView.html#)within the calling app.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `service`  | [ComponentName](https://developer.android.com/reference/kotlin/android/content/ComponentName.html#):The[ComponentName](https://developer.android.com/reference/kotlin/android/content/ComponentName.html#)of the[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService). This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `params`   | [PersistableBundle](https://developer.android.com/reference/kotlin/android/os/PersistableBundle.html#):a[PersistableBundle](https://developer.android.com/reference/kotlin/android/os/PersistableBundle.html#)that is passed from the calling app to the[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService). The expected contents of this parameter are defined by the[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService). The platform does not interpret this parameter. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `executor` | [Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#):the[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)on which to invoke the callback. This value cannot be`null`. Callback and listener events are dispatched through this[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#), providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use[Context.getMainExecutor()](https://developer.android.com/reference/kotlin/android/content/Context.html#getMainExecutor()). Otherwise, provide an[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)that dispatches to an appropriate thread.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `receiver` | [OutcomeReceiver](https://developer.android.com/reference/kotlin/android/os/OutcomeReceiver.html#)\<[OnDevicePersonalizationManager.ExecuteResult](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult)!,[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)!\>:This returns a[ExecuteResult](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult)object on success or an[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)on failure. If the[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)returned a[RenderingConfig](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/RenderingConfig)to be displayed,[ExecuteResult.getSurfacePackageToken()](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult#getSurfacePackageToken())will return a non-null[SurfacePackageToken](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/SurfacePackageToken). The[SurfacePackageToken](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/SurfacePackageToken)object can be used in a subsequent[requestSurfacePackage(android.adservices.ondevicepersonalization.SurfacePackageToken,android.os.IBinder,int,int,int,java.util.concurrent.Executor,android.os.OutcomeReceiver)](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#requestSurfacePackage(android.adservices.ondevicepersonalization.SurfacePackageToken,%20android.os.IBinder,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver))call to display the result in a view. The returned[SurfacePackageToken](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/SurfacePackageToken)may be null to indicate that no output is expected to be displayed for this request. If the[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)has returned any output data and the calling app is allowlisted to receive data from this service, the[android.adservices.ondevicepersonalization.OnDevicePersonalizationManager.ExecuteResult#getOutputData()](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult#getOutputData())will return a non-null byte array. In case of an error, the receiver returns one of the following exceptions: Returns a[android.content.pm.PackageManager.NameNotFoundException](https://developer.android.com/reference/kotlin/android/content/pm/PackageManager.NameNotFoundException.html#)if the handler package is not installed or does not have a valid ODP manifest. Returns[ClassNotFoundException](https://developer.android.com/reference/kotlin/java/lang/ClassNotFoundException.html#)if the handler class is not found. Returns an[OnDevicePersonalizationException](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationException)if execution of the handler fails. |

### executeInIsolatedService

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun executeInIsolatedService(
    request: ExecuteInIsolatedServiceRequest, 
    executor: Executor, 
    receiver: OutcomeReceiver<ExecuteInIsolatedServiceResponse!, Exception!>
): Unit
```

Executes an[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)in the OnDevicePersonalization sandbox. The platform binds to the specified[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)in an isolated process and calls[android.adservices.ondevicepersonalization.IsolatedWorker#onExecute(android.adservices.ondevicepersonalization.ExecuteInput,android.os.OutcomeReceiver)](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedWorker#onExecute(android.adservices.ondevicepersonalization.ExecuteInput,%20android.os.OutcomeReceiver))with the caller-provided parameters. When the[IsolatedService](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/IsolatedService)finishes execution, the platform returns tokens that refer to the results from the service to the caller. These tokens can be subsequently used to display results in a[android.view.SurfaceView](https://developer.android.com/reference/kotlin/android/view/SurfaceView.html#)within the calling app.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `request`  | [ExecuteInIsolatedServiceRequest](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceRequest):the[ExecuteInIsolatedServiceRequest](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceRequest)request This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `executor` | [Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#):the[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)on which to invoke the callback. This value cannot be`null`. Callback and listener events are dispatched through this[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#), providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use[Context.getMainExecutor()](https://developer.android.com/reference/kotlin/android/content/Context.html#getMainExecutor()). Otherwise, provide an[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)that dispatches to an appropriate thread.                                                                                                                                                                                                                                                                                |
| `receiver` | [OutcomeReceiver](https://developer.android.com/reference/kotlin/android/os/OutcomeReceiver.html#)\<[ExecuteInIsolatedServiceResponse](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceResponse)!,[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)!\>:This returns a[ExecuteInIsolatedServiceResponse](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceResponse)object on success or an[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)on failure. For success case, refer to[ExecuteInIsolatedServiceResponse](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceResponse). For error case, the receiver returns an[OnDevicePersonalizationException](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationException)if execution of the handler fails. This value cannot be`null`. |

### queryFeatureAvailability

Added in[API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun queryFeatureAvailability(
    featureName: String, 
    executor: Executor, 
    receiver: OutcomeReceiver<Int!, Exception!>
): Unit
```

Get the status of a specific OnDevicePersonalization feature.

|                                                                                                                                                                                                                                                                                                                                                                                                                          Parameters                                                                                                                                                                                                                                                                                                                                                                                                                           ||
|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `featureName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the name of the specific feature to check the availability of. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `executor`    | [Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#):the[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)on which to invoke the callback This value cannot be`null`. Callback and listener events are dispatched through this[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#), providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use[Context.getMainExecutor()](https://developer.android.com/reference/kotlin/android/content/Context.html#getMainExecutor()). Otherwise, provide an[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)that dispatches to an appropriate thread. |
| `receiver`    | [OutcomeReceiver](https://developer.android.com/reference/kotlin/android/os/OutcomeReceiver.html#)\<[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!,[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)!\>:this either returns a value of`FeatureStatus`on success or[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)on failure. The exception type is[IllegalStateException](https://developer.android.com/reference/kotlin/java/lang/IllegalStateException.html#)if the service is not available. This value cannot be`null`.                                                                                                                                                                                                             |

### requestSurfacePackage

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun requestSurfacePackage(
    surfacePackageToken: SurfacePackageToken, 
    surfaceViewHostToken: IBinder, 
    displayId: Int, 
    width: Int, 
    height: Int, 
    executor: Executor, 
    receiver: OutcomeReceiver<SurfaceControlViewHost.SurfacePackage!, Exception!>
): Unit
```

Requests a[android.view.SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/kotlin/android/view/SurfaceControlViewHost.SurfacePackage.html#)to be inserted into a[android.view.SurfaceView](https://developer.android.com/reference/kotlin/android/view/SurfaceView.html#)inside the calling app. The surface package will contain an[android.view.View](https://developer.android.com/reference/kotlin/android/view/View.html#)with the content from a result of a prior call to`execute(ComponentName, PersistableBundle, Executor, OutcomeReceiver)`running in the OnDevicePersonalization sandbox.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                        Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                         ||
|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `surfacePackageToken`  | [SurfacePackageToken](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/SurfacePackageToken):a reference to a[SurfacePackageToken](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/SurfacePackageToken)returned by a prior call to`execute(ComponentName, PersistableBundle, Executor, OutcomeReceiver)`. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `surfaceViewHostToken` | [IBinder](https://developer.android.com/reference/kotlin/android/os/IBinder.html#):the hostToken of the[android.view.SurfaceView](https://developer.android.com/reference/kotlin/android/view/SurfaceView.html#), which is returned by[android.view.SurfaceView#getHostToken()](https://developer.android.com/reference/kotlin/android/view/SurfaceView.html#getHostToken())after the[android.view.SurfaceView](https://developer.android.com/reference/kotlin/android/view/SurfaceView.html#)has been added to the view hierarchy. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                   |
| `displayId`            | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the integer ID of the logical display on which to display the[android.view.SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/kotlin/android/view/SurfaceControlViewHost.SurfacePackage.html#), returned by`Context.getDisplay().getDisplayId()`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `width`                | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the width of the[android.view.SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/kotlin/android/view/SurfaceControlViewHost.SurfacePackage.html#)in pixels.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `height`               | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the height of the[android.view.SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/kotlin/android/view/SurfaceControlViewHost.SurfacePackage.html#)in pixels.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `executor`             | [Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#):the[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)on which to invoke the callback This value cannot be`null`. Callback and listener events are dispatched through this[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#), providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use[Context.getMainExecutor()](https://developer.android.com/reference/kotlin/android/content/Context.html#getMainExecutor()). Otherwise, provide an[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)that dispatches to an appropriate thread.                                                    |
| `receiver`             | [OutcomeReceiver](https://developer.android.com/reference/kotlin/android/os/OutcomeReceiver.html#)\<[SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/kotlin/android/view/SurfaceControlViewHost.SurfacePackage.html#)!,[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)!\>:This either returns a[android.view.SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/kotlin/android/view/SurfaceControlViewHost.SurfacePackage.html#)on success, or[Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)on failure. The exception type is[OnDevicePersonalizationException](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationException)if execution of the handler fails. This value cannot be`null`. |