OnDevicePersonalizationManager
  public
  
  
  
  class
  OnDevicePersonalizationManager
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.adservices.ondevicepersonalization.OnDevicePersonalizationManager | 
OnDevicePersonalizationManager provides APIs for apps to load an
 IsolatedService in an isolated process and interact with it.
 An app can request an IsolatedService to generate content for display
 within an 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(ComponentName handler, PersistableBundle params, Executor executor, OutcomeReceiver<List<SurfacePackageToken>, Exception> receiver)
      Executes an  | 
| 
        
        
        
        
        
        void | 
      requestSurfacePackage(SurfacePackageToken surfacePackageToken, IBinder surfaceViewHostToken, int displayId, int width, int height, Executor executor, OutcomeReceiver<SurfaceControlViewHost.SurfacePackage, Exception> receiver)
      Requests a  | 
| Inherited methods | |
|---|---|
Public methods
execute
public void execute (ComponentName handler, PersistableBundle params, Executor executor, OutcomeReceiver<List<SurfacePackageToken>, Exception> receiver)
Executes an IsolatedService in the OnDevicePersonalization sandbox. The
 platform binds to the specified IsolatedService in an isolated process
 and calls IsolatedWorker#onExecute(ExecuteInput, java.util.function.Consumer)
 with the caller-provided parameters. When the 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 within the calling app.
| Parameters | |
|---|---|
| handler | ComponentName: TheComponentNameof theIsolatedService.
 This value cannot benull. | 
| params | PersistableBundle: aPersistableBundlethat is passed from the calling app to theIsolatedService. The expected contents of this parameter are defined
     by theIsolatedService. The platform does not interpret this parameter.
 This value cannot benull. | 
| executor | Executor: theExecutoron which to invoke the callback.
 This value cannot benull.
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| receiver | OutcomeReceiver: This returns a list ofSurfacePackageTokenobjects, each of which is
     an opaque reference to aRenderingConfigreturned by anIsolatedService, or anExceptionon failure. The returnedSurfacePackageTokenobjects can be used in a subsequentrequestSurfacePackage(android.adservices.ondevicepersonalization.SurfacePackageToken, android.os.IBinder, int, int, int, java.util.concurrent.Executor, android.os.OutcomeReceiver)call to display the result in a view. The calling app and
     theIsolatedServicemust agree on the expected size of this list.
     An entry in the returned list ofSurfacePackageTokenobjects 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 aPackageManager.NameNotFoundExceptionif the handler
     package is not installed or does not have a valid ODP manifest.
     ReturnsClassNotFoundExceptionif the handler class is not found.
     Returns anOnDevicePersonalizationExceptionif execution of the handler fails. | 
requestSurfacePackage
public void requestSurfacePackage (SurfacePackageToken surfacePackageToken, IBinder surfaceViewHostToken, int displayId, int width, int height, Executor executor, OutcomeReceiver<SurfaceControlViewHost.SurfacePackage, Exception> receiver)
Requests a SurfaceControlViewHost.SurfacePackage to be inserted into a
 SurfaceView inside the calling app. The surface package will contain an
 View with the content from a result of a prior call to
 #execute(ComponentName, PersistableBundle, Executor, OutcomeReceiver) running in
 the OnDevicePersonalization sandbox.
| Parameters | |
|---|---|
| surfacePackageToken | SurfacePackageToken: a reference to aSurfacePackageTokenreturned by a prior
     call to#execute(ComponentName, PersistableBundle, Executor, OutcomeReceiver).
 This value cannot benull. | 
| surfaceViewHostToken | IBinder: the hostToken of theSurfaceView, which is
     returned bySurfaceView.getHostToken()after theSurfaceViewhas been added to the view hierarchy.
 This value cannot benull. | 
| displayId | int: the integer ID of the logical display on which to display theSurfaceControlViewHost.SurfacePackage, returned byContext.getDisplay().getDisplayId(). | 
| width | int: the width of theSurfaceControlViewHost.SurfacePackagein pixels. | 
| height | int: the height of theSurfaceControlViewHost.SurfacePackagein pixels. | 
| executor | Executor: theExecutoron which to invoke the callback
 This value cannot benull.
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| receiver | OutcomeReceiver: This either returns aSurfaceControlViewHost.SurfacePackageon success, orExceptionon failure. The exception type isOnDevicePersonalizationExceptionif execution of the handler fails.
 
 This value cannot benull. | 
