[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  
Summary:[Methods](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/OnDevicePersonalizationManager#pubmethods)\|[Inherited Methods](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/OnDevicePersonalizationManager#inhmethods)  

# OnDevicePersonalizationManager

`
public


class
OnDevicePersonalizationManager
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|---------------------------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.adservices.ondevicepersonalization.OnDevicePersonalizationManager |

<br />

*** ** * ** ***

OnDevicePersonalizationManager provides APIs for apps to load an[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService)in an isolated process and interact with it. An app can request an[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService)to generate content for display within an[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView)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

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[execute](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/OnDevicePersonalizationManager#execute(android.content.ComponentName,%20android.os.PersistableBundle,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.util.List<android.adservices.ondevicepersonalization.SurfacePackageToken>,java.lang.Exception>))`(`[ComponentName](https://developer.android.com/reference/android/content/ComponentName)` handler, `[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)` params, `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)` executor, `[OutcomeReceiver](https://developer.android.com/reference/android/os/OutcomeReceiver)`<`[List](https://developer.android.com/reference/java/util/List)`<`[SurfacePackageToken](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/SurfacePackageToken)`>, `[Exception](https://developer.android.com/reference/java/lang/Exception)`> receiver) ` Executes an[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService)in the OnDevicePersonalization sandbox.                                                                                                                                           |
| ` void` | ` `[requestSurfacePackage](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/OnDevicePersonalizationManager#requestSurfacePackage(android.adservices.ondevicepersonalization.SurfacePackageToken,%20android.os.IBinder,%20int,%20int,%20int,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<android.view.SurfaceControlViewHost.SurfacePackage,java.lang.Exception>))`(`[SurfacePackageToken](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/SurfacePackageToken)` surfacePackageToken, `[IBinder](https://developer.android.com/reference/android/os/IBinder)` surfaceViewHostToken, int displayId, int width, int height, `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)` executor, `[OutcomeReceiver](https://developer.android.com/reference/android/os/OutcomeReceiver)`<`[SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage)`, `[Exception](https://developer.android.com/reference/java/lang/Exception)`> receiver) ` Requests a[SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage)to be inserted into a[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView)inside the calling app. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public methods

### execute

[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  

```
public void execute (ComponentName handler, 
                PersistableBundle params, 
                Executor executor, 
                OutcomeReceiver<List<SurfacePackageToken>, Exception> receiver)
```

Executes an[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService)in the OnDevicePersonalization sandbox. The platform binds to the specified[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService)in an isolated process and calls[IsolatedWorker#onExecute(ExecuteInput, java.util.function.Consumer)](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedWorker#onExecute(android.adservices.ondevicepersonalization.ExecuteInput,%20java.util.function.Consumer<android.adservices.ondevicepersonalization.ExecuteOutput>))with the caller-provided parameters. When the[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/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[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView)within the calling app.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `handler`  | `ComponentName`: The[ComponentName](https://developer.android.com/reference/android/content/ComponentName)of the[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService). This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `params`   | `PersistableBundle`: a[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)that is passed from the calling app to the[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService). The expected contents of this parameter are defined by the[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService). The platform does not interpret this parameter. This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `executor` | `Executor`: the[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)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/java/util/concurrent/Executor), 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/android/content/Context#getMainExecutor()). Otherwise, provide an[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)that dispatches to an appropriate thread. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `receiver` | `OutcomeReceiver`: This returns a list of[SurfacePackageToken](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/SurfacePackageToken)objects, each of which is an opaque reference to a[RenderingConfig](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/RenderingConfig)returned by an[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService), or an[Exception](https://developer.android.com/reference/java/lang/Exception)on failure. The returned[SurfacePackageToken](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/SurfacePackageToken)objects 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/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/OnDevicePersonalizationManager#requestSurfacePackage(android.adservices.ondevicepersonalization.SurfacePackageToken,%20android.os.IBinder,%20int,%20int,%20int,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<android.view.SurfaceControlViewHost.SurfacePackage,java.lang.Exception>))call to display the result in a view. The calling app and the[IsolatedService](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService)must agree on the expected size of this list. An entry in the returned list of[SurfacePackageToken](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/SurfacePackageToken)objects may be null to indicate that the service has no output for that specific surface. In case of an error, the receiver returns one of the following exceptions: Returns a[PackageManager.NameNotFoundException](https://developer.android.com/reference/android/content/pm/PackageManager.NameNotFoundException)if the handler package is not installed or does not have a valid ODP manifest. Returns[ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException)if the handler class is not found. Returns an[OnDevicePersonalizationException](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/OnDevicePersonalizationException)if execution of the handler fails. <br /> |

### requestSurfacePackage

[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  

```
public void requestSurfacePackage (SurfacePackageToken surfacePackageToken, 
                IBinder surfaceViewHostToken, 
                int displayId, 
                int width, 
                int height, 
                Executor executor, 
                OutcomeReceiver<SurfaceControlViewHost.SurfacePackage, Exception> receiver)
```

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

<br />

|                                                                                                                                                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                                                                                                                                                ||
|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `surfacePackageToken`  | `SurfacePackageToken`: a reference to a[SurfacePackageToken](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/SurfacePackageToken)returned by a prior call to`#execute(ComponentName, PersistableBundle, Executor, OutcomeReceiver)`. This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                            |
| `surfaceViewHostToken` | `IBinder`: the hostToken of the[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView), which is returned by[SurfaceView.getHostToken()](https://developer.android.com/reference/android/view/SurfaceView#getHostToken())after the[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView)has been added to the view hierarchy. This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                               |
| `displayId`            | `int`: the integer ID of the logical display on which to display the[SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage), returned by`Context.getDisplay().getDisplayId()`. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `width`                | `int`: the width of the[SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage)in pixels. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `height`               | `int`: the height of the[SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage)in pixels. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `executor`             | `Executor`: the[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)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/java/util/concurrent/Executor), 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/android/content/Context#getMainExecutor()). Otherwise, provide an[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)that dispatches to an appropriate thread. <br /> |
| `receiver`             | `OutcomeReceiver`: This either returns a[SurfaceControlViewHost.SurfacePackage](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage)on success, or[Exception](https://developer.android.com/reference/java/lang/Exception)on failure. The exception type is[OnDevicePersonalizationException](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/OnDevicePersonalizationException)if execution of the handler fails. This value cannot be`null`. <br />                                                                                                                                                        |