OnDevicePersonalizationManager
  public
  
  
  
  class
  OnDevicePersonalizationManager
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.adservices.ondevicepersonalization.OnDevicePersonalizationManager | 
OnDevicePersonalizationManager 可為應用程式提供用於載入
 IsolatedService 的獨立程序,並與之互動。
 應用程式可以要求 IsolatedService 來產生要顯示的內容
 應用程式檢視區塊階層的 SurfaceView 內,並寫入
 裝置端儲存空間的永久性結果,聯合分析可用來
 跨裝置統計分析或聯合學習進行模型訓練。顯示
 呼叫應用程式無法直接存取內容和永久輸出內容。
摘要
公用方法 | |
|---|---|
        
        
        
        
        
        void
     | 
  
    
      
      execute(ComponentName handler, PersistableBundle params, Executor executor, OutcomeReceiver<List<SurfacePackageToken>, Exception> receiver)
      
      
        在 OnDevicePersonalization 沙箱中執行   | 
  
        
        
        
        
        
        void
     | 
  
    
      
      requestSurfacePackage(SurfacePackageToken surfacePackageToken, IBinder surfaceViewHostToken, int displayId, int width, int height, Executor executor, OutcomeReceiver<SurfaceControlViewHost.SurfacePackage, Exception> receiver)
      
      
        要求將   | 
  
繼承方法 | |
|---|---|
公用方法
執行
public void execute (ComponentName handler, PersistableBundle params, Executor executor, OutcomeReceiver<List<SurfacePackageToken>, Exception> receiver)
在 OnDevicePersonalization 沙箱中執行 IsolatedService。
 平台會透過獨立程序繫結至指定的 IsolatedService
 並呼叫 IsolatedWorker#onExecute(ExecuteInput, java.util.function.Consumer)
 並搭配呼叫端提供的參數IsolatedService 執行完畢後,
 平台會傳回參照服務結果的權杖給呼叫端。
 這些符記隨後可用於在
 SurfaceView。
| 參數 | |
|---|---|
handler | 
        
          ComponentName:IsolatedService 的 ComponentName。
 此值不能為 null。 | 
      
params | 
        
          PersistableBundle:從呼叫應用程式傳遞至應用程式的 PersistableBundle
     IsolatedService。系統已定義這個參數的預期內容
     IsolatedService。平台不會解讀這個參數。
 此值不能為 null。 | 
      
executor | 
        
          Executor:叫用回呼的 Executor。
 此值不能為 null。
 回呼和事件監聽器事件會透過這個
 Executor,可讓您輕鬆控制
 如何透過應用程式的主執行緒分派事件
 可以使用
 Context.getMainExecutor()。
 否則,請提供會調度至適當執行緒的 Executor。 | 
      
receiver | 
        
          OutcomeReceiver:傳回 SurfacePackageToken 物件清單,
     不透明參照,RenderingConfig
     IsolatedService 或 Exception 失敗時失敗。傳回的
     SurfacePackageToken 物件可用於後續的
     requestSurfacePackage(android.adservices.ondevicepersonalization.SurfacePackageToken, android.os.IBinder, int, int, int, java.util.concurrent.Executor, android.os.OutcomeReceiver) 呼叫,在檢視畫面中顯示結果。發出呼叫的應用程式
     IsolatedService 必須同意這份清單的預期大小。
     SurfacePackageToken 物件所傳回清單中的項目,可以是空值,
     表示服務沒有該特定介面的輸出內容。
     如果發生錯誤,接收端會傳回下列其中一種例外狀況:
     如果處理常式,則傳回 PackageManager.NameNotFoundException
     未安裝套件,或套件的 ODP 資訊清單無效。
     如果找不到處理常式類別,會傳回 ClassNotFoundException。
     如果處理常式執行作業失敗,會傳回 OnDevicePersonalizationException。 | 
      
requestSurfacePackage
public void requestSurfacePackage (SurfacePackageToken surfacePackageToken, IBinder surfaceViewHostToken, int displayId, int width, int height, Executor executor, OutcomeReceiver<SurfaceControlViewHost.SurfacePackage, Exception> receiver)
要求將 SurfaceControlViewHost.SurfacePackage 插入
 呼叫應用程式中的 SurfaceView。表面套件會包含
 將 View 替換為先前呼叫
 執行時間:#execute(ComponentName, PersistableBundle, Executor, OutcomeReceiver)
 進入裝置個人化沙箱。
| 參數 | |
|---|---|
surfacePackageToken | 
        
          SurfacePackageToken:先前 SurfacePackageToken 傳回的 SurfacePackageToken 參照
     呼叫 #execute(ComponentName, PersistableBundle, Executor, OutcomeReceiver)。
 此值不能為 null。 | 
      
surfaceViewHostToken | 
        
          IBinder:SurfaceView 的 hostToken,
     由 SurfaceView.getHostToken() 傳回 (在
     已將 SurfaceView 新增至檢視區塊階層。
 此值不能為 null。 | 
      
displayId | 
        
          int:要在其中顯示邏輯的邏輯顯示畫面的整數 ID
     SurfaceControlViewHost.SurfacePackage,由 傳回
     Context.getDisplay().getDisplayId()。 | 
      
width | 
        
          int:SurfaceControlViewHost.SurfacePackage 的寬度
     單位。 | 
      
height | 
        
          int:SurfaceControlViewHost.SurfacePackage 的高度
     單位。 | 
      
executor | 
        
          Executor:叫用回呼的 Executor
 此值不能為 null。
 回呼和事件監聽器事件會透過這個
 Executor,可讓您輕鬆控制
 如何透過應用程式的主執行緒分派事件
 可以使用
 Context.getMainExecutor()。
 否則,請提供會調度至適當執行緒的 Executor。 | 
      
receiver | 
        
          OutcomeReceiver:這會傳回
     SurfaceControlViewHost.SurfacePackage 是成功的關鍵,或
     失敗時則為 Exception。例外狀況類型為
     如果處理常式的執行作業失敗,則為 OnDevicePersonalizationException。
 
 此值不能為 null。 |