IsolatedWorker
  public
  
  
  
  interface
  IsolatedWorker
  
  
  
| android.adservices.ondevicepersonalization.IsolatedWorker | 
Interface with methods that need to be implemented to handle requests from the OS to an IsolatedService. The IsolatedService creates an instance of IsolatedWorker on
 each request and calls one of the methods below, depending the type of the request. The IsolatedService calls the method on a Binder thread and the IsolatedWorker should
 offload long running operations to a worker thread. The consumer parameter of each method is used
 to return results.
Summary
| Public methods | |
|---|---|
| 
        
        default
        
        
        
        void | 
      onDownloadCompleted(DownloadCompletedInput input, Consumer<DownloadCompletedOutput> consumer)
      Handles a completed download. | 
| 
        
        default
        
        
        
        void | 
      onEvent(EventInput input, Consumer<EventOutput> consumer)
      Handles an event triggered by a request to a platform-provided tracking URL  | 
| 
        
        default
        
        
        
        void | 
      onExecute(ExecuteInput input, Consumer<ExecuteOutput> consumer)
      Handles a request from an app. | 
| 
        
        default
        
        
        
        void | 
      onRender(RenderInput input, Consumer<RenderOutput> consumer)
      Generates HTML for the results that were returned as a result of
  | 
| 
        
        default
        
        
        
        void | 
      onTrainingExample(TrainingExampleInput input, Consumer<TrainingExampleOutput> consumer)
      Generate a single training example used for federated computation job. | 
Public methods
onDownloadCompleted
public void onDownloadCompleted (DownloadCompletedInput input, Consumer<DownloadCompletedOutput> consumer)
Handles a completed download. The platform downloads content using the parameters defined in
 the package manifest of the IsolatedService, calls this function after the download
 is complete, and updates the REMOTE_DATA table from
 IsolatedService#getRemoteData(RequestToken) with the result of this method.
| Parameters | |
|---|---|
| input | DownloadCompletedInput: Download handler parameters.
 This value cannot benull. | 
| consumer | Consumer: Callback that receives the result. Should be called withnullon
     an error. If called withnull, no updates are made to the REMOTE_DATA table.If this method throws a  | 
onEvent
public void onEvent (EventInput input, Consumer<EventOutput> consumer)
Handles an event triggered by a request to a platform-provided tracking URL EventUrlProvider that was embedded in the HTML output returned by
 onRender(android.adservices.ondevicepersonalization.RenderInput, java.util.function.Consumer). The platform updates the EVENTS table with
 EventOutput#getEventLogRecord().
| Parameters | |
|---|---|
| input | EventInput: The parameters needed to compute event data.
 This value cannot benull. | 
| consumer | Consumer: Callback that receives the result. Should be called withnullon
     an error. If called withnull, no data is written to the EVENTS table.If this method throws a  | 
onExecute
public void onExecute (ExecuteInput input, Consumer<ExecuteOutput> consumer)
Handles a request from an app. This method is called when an app calls OnDevicePersonalizationManager#execute(ComponentName, PersistableBundle,
 java.util.concurrent.Executor, OutcomeReceiver) that refers to a named
 IsolatedService.
| Parameters | |
|---|---|
| input | ExecuteInput: Request Parameters from the calling app.
 This value cannot benull. | 
| consumer | Consumer: Callback that receives the resultExecuteOutput. Should be called
     withnullon an error. The error is propagated to the calling app as anOnDevicePersonalizationExceptionwith error codeOnDevicePersonalizationException.ERROR_ISOLATED_SERVICE_FAILED. To avoid leaking private
     data to the calling app, more detailed error reporting is not available. If theIsolatedServiceneeds to report error stats to its backend, it should populateExecuteOutputwith error data for logging, and rely on Federated Analytics to aggregate
     the error reports.If this method throws a  | 
onRender
public void onRender (RenderInput input, Consumer<RenderOutput> consumer)
Generates HTML for the results that were returned as a result of
 onExecute(android.adservices.ondevicepersonalization.ExecuteInput, java.util.function.Consumer). Called when a client app calls
 OnDevicePersonalizationManager#requestSurfacePackage(SurfacePackageToken, IBinder, int, int, int, java.util.concurrent.Executor, OutcomeReceiver).
 The platform will render this HTML in an WebView inside a fenced
 frame.
| Parameters | |
|---|---|
| input | RenderInput: Parameters for the render request.
 This value cannot benull. | 
| consumer | Consumer: Callback that receives the result. Should be called withnullon
     an error. The error is propagated to the calling app as anOnDevicePersonalizationExceptionwith error codeOnDevicePersonalizationException.ERROR_ISOLATED_SERVICE_FAILED.If this method throws a  | 
onTrainingExample
public void onTrainingExample (TrainingExampleInput input, Consumer<TrainingExampleOutput> consumer)
Generate a single training example used for federated computation job.
| Parameters | |
|---|---|
| input | TrainingExampleInput: The parameters needed to generate the training example.
 This value cannot benull. | 
| consumer | Consumer: Callback to be invoked on completion.
 
 This value cannot benull. | 
