TestDevice
  public
  
  
  
  class
  TestDevice
  
  
  
  
    extends NativeDevice
  
  
  
  
  
  
| java.lang.Object | ||
| ↳ | com.android.tradefed.device.NativeDevice | |
| ↳ | com.android.tradefed.device.TestDevice | |
為完整堆疊 Android 裝置實作 ITestDevice
摘要
| 巢狀類別 | |
|---|---|
| 
        
        
        
        
        class | TestDevice.MicrodroidBuilder用於建立 Microdroid TestDevice 的建構工具。 | 
| 欄位 | |
|---|---|
| 
    public
    static
    final
    String | DISMISS_KEYGUARD_CMD可用來關閉螢幕鎖定畫面的指令。 | 
| 公用建構函式 | |
|---|---|
| 
      TestDevice(IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)
       | |
| 公用方法 | |
|---|---|
| 
        
        
        
        
        
        boolean | 
      canSwitchToHeadlessSystemUser()
      傳回是否允許切換至無介面系統使用者。 | 
| 
        
        
        
        
        
        boolean | 
      clearErrorDialogs()
      嘗試關閉目前在裝置 UI 上顯示的任何錯誤對話方塊。 | 
| 
        
        
        
        
        
        int | 
      createUser(String name)
      使用指定名稱和預設標記 0 建立使用者。 | 
| 
        
        
        
        
        
        int | 
      createUser(String name, boolean guest, boolean ephemeral, boolean forTesting)
      使用指定名稱和提供的標記建立使用者 | 
| 
        
        
        
        
        
        int | 
      createUser(String name, boolean guest, boolean ephemeral)
      使用指定名稱和提供的標記建立使用者 | 
| 
        
        
        
        
        
        int | 
      createUserNoThrow(String name)
      使用指定名稱和預設標記 0 建立使用者。 | 
| 
        
        
        
        
        
        void | 
      disableKeyguard()
      嘗試停用鎖定畫面。 | 
| 
        
        
        
        
        
        boolean | 
      doesFileExist(String deviceFilePath)
      輔助方法,用於判斷裝置上是否有檔案。 | 
| 
        
        
        
        
        
        boolean | 
      doesFileExist(String deviceFilePath, int userId)
      輔助方法,用於判斷裝置上是否有特定使用者的檔案。 | 
| 
        
        
        
        
        
        File | 
      dumpHeap(String process, String devicePath)
      嘗試從 system_server 傾印堆積。 | 
| 
        
        
        
        
        
         | 
      getActiveApexes()
      擷取裝置上已啟用的 APEX 相關資訊。 | 
| 
        
        
        
        
        
         | 
      getAllSettings(String namespace)
      傳回要求命名空間的鍵/值組合。 | 
| 
        
        
        
        
        
        String | 
      getAndroidId(int userId)
      尋找並傳回與 userId 相關聯的 android-id,如果找不到則傳回 null。 | 
| 
        
        
        
        
        
         | 
      getAndroidIds()
      建立地圖,找出與使用者 ID 相符的 Android ID。 | 
| 
        
        
        
        
        
        PackageInfo | 
      getAppPackageInfo(String packageName)
      擷取裝置上已安裝套件的相關資訊。 | 
| 
        
        
        
        
        
         | 
      getAppPackageInfos()
      擷取裝置上已安裝套件的相關資訊。 | 
| 
        
        
        
        
        
        InputStreamSource | 
      getBugreport()
      從裝置擷取錯誤報告。 | 
| 
        
        
        
        
        
        InputStreamSource | 
      getBugreportz()
      從裝置擷取 bugreportz。 | 
| 
        
        
        
        
        
        DeviceFoldableState | 
      getCurrentFoldableState()
      傳回裝置目前的折疊狀態,如果發生問題,則傳回 null。 | 
| 
        
        
        
        
        
        int | 
      getCurrentUser()
      傳回目前執行中的使用者 ID。 | 
| 
        
        
        
        
        
         | 
      getFoldableStates()
      傳回裝置上的摺疊式狀態清單。 | 
| 
        
        
        
        
        
         | 
      getInstalledPackageNames()
      擷取裝置上的應用程式套件名稱。 | 
| 
        
        
        
        
        
        KeyguardControllerState | 
      getKeyguardState()
      傳回物件,以取得 Keyguard 的目前狀態;如果不支援,則傳回空值。 | 
| 
        
        
        
        
        
        Integer | 
      getMainUserId()
      傳回主要使用者 ID。 | 
| 
        
        
        
        
        
         | 
      getMainlineModuleInfo()
      取得裝置上已安裝的主線程模組相關資訊。 | 
| 
        
        
        
        
        
        int | 
      getMaxNumberOfRunningUsersSupported()
      取得支援的同時執行使用者人數上限。 | 
| 
        
        
        
        
        
        int | 
      getMaxNumberOfUsersSupported()
      取得支援的使用者人數上限。 | 
| 
        
        
        
        
        
        Integer | 
      getPrimaryUserId()
      傳回主要使用者 ID。 | 
| 
        
        
        
        
        
        InputStreamSource | 
      getScreenshot()
      擷取裝置的螢幕截圖。 | 
| 
        
        
        
        
        
        InputStreamSource | 
      getScreenshot(String format, boolean rescale)
      擷取裝置的螢幕截圖。 | 
| 
        
        
        
        
        
        InputStreamSource | 
      getScreenshot(long displayId)
      從裝置的指定顯示 ID 擷取螢幕截圖。 | 
| 
        
        
        
        
        
        InputStreamSource | 
      getScreenshot(String format)
      擷取裝置的螢幕截圖。 | 
| 
        
        
        
        
        
        String | 
      getSetting(String namespace, String key)
      請參閱  | 
| 
        
        
        
        
        
        String | 
      getSetting(int userId, String namespace, String key)
      傳回所要求設定的值。 | 
| 
        
        
        
        
        
         | 
      getUninstallablePackageNames()
      擷取可解除安裝的應用程式套件名稱。 | 
| 
        
        
        
        
        
        int | 
      getUserFlags(int userId)
      尋找並傳回特定使用者的標記。 | 
| 
        
        
        
        
        
         | 
      getUserInfos()
      取得裝置上 useId 到  | 
| 
        
        
        
        
        
        int | 
      getUserSerialNumber(int userId)
      如果找到,則傳回與 userId 相關聯的序號,否則傳回 -10000。 | 
| 
        
        
        
        
        
        boolean | 
      hasFeature(String feature)
      檢查裝置是否支援某項功能。 | 
| 
        
        
        
        
        
        String | 
      installPackage(File packageFile, boolean reinstall, String... extraArgs)
      在裝置上安裝 Android 套件。 | 
| 
        
        
        
        
        
        String | 
      installPackage(File packageFile, boolean reinstall, boolean grantPermissions, String... extraArgs)
      在裝置上安裝 Android 套件。 | 
| 
        
        
        
        
        
        String | 
      installPackage(File packageFile, File certFile, boolean reinstall, String... extraArgs)
      在裝置上安裝 Android 套件。 | 
| 
        
        
        
        
        
        String | 
      installPackageForUser(File packageFile, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs)
      為特定使用者在裝置上安裝 Android 套件。 | 
| 
        
        
        
        
        
        String | 
      installPackageForUser(File packageFile, boolean reinstall, int userId, String... extraArgs)
      為特定使用者在裝置上安裝 Android 套件。 | 
| 
        
        
        
        
        
        String | 
      installPackages(
 | 
| 
        
        
        
        
        
        String | 
      installPackages(
 | 
| 
        
        
        
        
        
        String | 
      installPackagesForUser(
 | 
| 
        
        
        
        
        
        String | 
      installPackagesForUser(
 | 
| 
        
        
        
        
        
        String | 
      installRemotePackages(
 | 
| 
        
        
        
        
        
        String | 
      installRemotePackages(
 | 
| 
        
        
        
        
        
        boolean | 
      isAppEnumerationSupported()
      檢查裝置上的平台是否支援應用程式列舉 | 
| 
        
        
        
        
        
        boolean | 
      isHeadlessSystemUserMode()
      傳回裝置是否使用無頭系統使用者模式。 | 
| 
        
        
        
        
        
        boolean | 
      isMainUserPermanentAdmin()
      傳回主使用者是否為永久管理員,且無法刪除或降級為非管理員狀態。 | 
| 
        
        
        
        
        
        boolean | 
      isMultiUserSupported()
      判斷是否支援多位使用者。 | 
| 
        
        
        
        
        
        boolean | 
      isPackageInstalled(String packageName)
      針對裝置中的特定套件名稱執行查詢,確認該套件目前是否已安裝。 | 
| 
        
        
        
        
        
        boolean | 
      isPackageInstalled(String packageName, String userId)
      針對裝置查詢指定的套件名稱和使用者 ID,檢查該使用者目前是否已安裝該套件。 | 
| 
        
        
        
        
        
        boolean | 
      isUserRunning(int userId)
      檢查特定使用者是否正在執行。 | 
| 
        
        
        
        
        
        boolean | 
      isUserSecondary(int userId)
      根據指定使用者的標記,傳回該使用者是否為次要使用者。 | 
| 
        
        
        
        
        
        boolean | 
      isUserVisible(int userId)
      檢查指定使用者是否可見。 | 
| 
        
        
        
        
        
        boolean | 
      isUserVisibleOnDisplay(int userId, int displayId)
      檢查指定使用者是否在指定顯示畫面中顯示。 | 
| 
        
        
        
        
        
        boolean | 
      isVisibleBackgroundUsersOnDefaultDisplaySupported()
      傳回裝置是否允許使用者在  | 
| 
        
        
        
        
        
        boolean | 
      isVisibleBackgroundUsersSupported()
      傳回裝置是否允許使用者在背景啟動。 | 
| 
        
        
        
        
        
         | 
      listDisplayIds()
      收集裝置上可用顯示器 ID 的清單,並由「dumpsys SurfaceFlinger」回報。 | 
| 
        
        
        
        
        
         | 
      listDisplayIdsForStartingVisibleBackgroundUsers()
      取得可用於  | 
| 
        
        
        
        
        
         | 
      listUsers()
      取得裝置上的使用者清單。 | 
| 
        
        
        
        
        
        boolean | 
      logBugreport(String dataName, ITestLogger listener)
      輔助方法,可取得錯誤報告並記錄至記錄器。 | 
| 
        
        
        
        
        
        void | 
      notifySnapuserd(SnapuserdWaitPhase waitPhase)
       | 
| 
        
        
        
        
        
        void | 
      postInvocationTearDown(Throwable exception)
      針對裝置特定的必要清理作業,在呼叫完成後執行額外步驟。 | 
| 
        
        
        
        
        
        boolean | 
      removeAdmin(String componentName, int userId)
      從指定使用者移除指定裝置管理員,如果成功,則傳回  | 
| 
        
        
        
        
        
        void | 
      removeOwners()
      盡力移除所有現有的裝置設定檔擁有者。 | 
| 
        
        
        
        
        
        boolean | 
      removeUser(int userId)
      從裝置中移除特定使用者。 | 
| 
        
        
        
        
        
        boolean | 
      setDeviceOwner(String componentName, int userId)
      將裝置管理員元件設為特定使用者的裝置擁有者。 | 
| 
        
        
        
        
        
        void | 
      setFirstBootloaderReboot()
       | 
| 
        
        
        
        
        
        void | 
      setSetting(String namespace, String key, String value)
      請參閱  | 
| 
        
        
        
        
        
        void | 
      setSetting(int userId, String namespace, String key, String value)
      將設定值新增至特定使用者的命名空間。 | 
| 
        
        
        
        
        
        void | 
      shutdownMicrodroid(ITestDevice microdroidDevice)
      關閉 MicroDroid 裝置 (如果有)。 | 
| 
        
        
        
        
        
        boolean | 
      startUser(int userId)
      如果使用者目前已停止,則在背景啟動該使用者。 | 
| 
        
        
        
        
        
        boolean | 
      startUser(int userId, boolean waitFlag)
      如果使用者目前已停止,則在背景啟動該使用者。 | 
| 
        
        
        
        
        
        boolean | 
      startVisibleBackgroundUser(int userId, int displayId, boolean waitFlag)
      在背景啟動特定使用者,並在指定螢幕上顯示 (也就是允許使用者在該螢幕上啟動活動)。 | 
| 
        
        
        
        
        
        boolean | 
      stopUser(int userId, boolean waitFlag, boolean forceFlag)
      停止特定使用者。 | 
| 
        
        
        
        
        
        boolean | 
      stopUser(int userId)
      停止特定使用者。 | 
| 
        
        
        
        
        
        boolean | 
      supportsMicrodroid()
      檢查執行 microdroid 的先決條件。 | 
| 
        
        
        
        
        
        boolean | 
      supportsMicrodroid(boolean protectedVm)
      檢查執行 microdroid 的先決條件。 | 
| 
        
        
        
        
        
        boolean | 
      switchUser(int userId)
      切換至另一個使用者 ID,並設定預設逾時時間。 | 
| 
        
        
        
        
        
        boolean | 
      switchUser(int userId, long timeout)
      以提供的逾時期限做為期限,切換至其他使用者 ID。 | 
| 
        
        
        
        
        
        Bugreport | 
      takeBugreport()
      取得 bugreport,並在  | 
| 
        
        
        
        
        
        String | 
      uninstallPackage(String packageName)
      從裝置解除安裝 Android 套件。 | 
| 
        
        
        
        
        
        String | 
      uninstallPackageForUser(String packageName, int userId)
      為特定使用者從裝置上解除安裝 Android 套件。 | 
| 
        
        
        
        
        
        void | 
      waitForSnapuserd(SnapuserdWaitPhase currentPhase)
       | 
| 受保護的方法 | |
|---|---|
| 
        
        
        
        
        
        AaptParser | 
      createParser(File appFile)
       | 
| 
        
        
        
        
        
        void | 
      doAdbReboot(NativeDevice.RebootMode rebootMode, String reason)
      執行 ADB 重新啟動。 | 
| 
        
        
        
        
        
        InputStreamSource | 
      getBugreportInternal()
       | 
| 
        
        
        
        
        
        File | 
      getBugreportzInternal()
      內部輔助方法,可取得 bugreportz ZIP 檔案做為  | 
| 
        
        
        
        
        
        long | 
      getCheckNewUserSleep()
      供測試使用。 | 
| 
        
        
        
        
        
        long | 
      getHostCurrentTime()
      已公開測試 | 
| 
        
        
        
        
        
        void | 
      prePostBootSetup()
      允許每個裝置類型 (AndroidNativeDevice、TestDevice) 針對特定的開機後設定覆寫此方法。 | 
欄位
DISMISS_KEYGUARD_CMD
public static final String DISMISS_KEYGUARD_CMD
可用來關閉螢幕鎖定畫面的指令。
公用建構函式
TestDevice
public TestDevice (IDevice device, 
                IDeviceStateMonitor stateMonitor, 
                IDeviceMonitor allocationMonitor)公用方法
canSwitchToHeadlessSystemUser
public boolean canSwitchToHeadlessSystemUser ()
會傳回是否允許切換至無介面系統使用者。
| 傳回 | |
|---|---|
| boolean | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
clearErrorDialogs
public boolean clearErrorDialogs ()
嘗試關閉目前在裝置 UI 上顯示的任何錯誤對話方塊。
| 傳回 | |
|---|---|
| boolean | true,如果沒有對話方塊或已成功清除對話方塊。否則傳回false。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
createUser
public int createUser (String name)
建立使用者,使用指定名稱和預設標記 0。
| 參數 | |
|---|---|
| name | String:在裝置上建立的使用者 | 
| 傳回 | |
|---|---|
| int | 建立的使用者 ID 整數 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
createUser
public int createUser (String name, 
                boolean guest, 
                boolean ephemeral, 
                boolean forTesting)使用指定名稱和提供的旗標建立使用者
| 參數 | |
|---|---|
| name | String:在裝置上建立的使用者 | 
| guest | boolean:在建立時啟用使用者標記 --guest | 
| ephemeral | boolean:在建立時啟用使用者標記 --ephemeral | 
| forTesting | boolean:在建立期間啟用測試標記 --for-testing | 
| 傳回 | |
|---|---|
| int | 已建立使用者的 ID | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
createUser
public int createUser (String name, 
                boolean guest, 
                boolean ephemeral)使用指定名稱和提供的旗標建立使用者
| 參數 | |
|---|---|
| name | String:在裝置上建立的使用者 | 
| guest | boolean:在建立時啟用使用者標記 --guest | 
| ephemeral | boolean:在建立時啟用使用者標記 --ephemeral | 
| 傳回 | |
|---|---|
| int | 已建立使用者的 ID | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
createUserNoThrow
public int createUserNoThrow (String name)
建立使用者,使用指定名稱和預設標記 0。
| 參數 | |
|---|---|
| name | String:在裝置上建立的使用者 | 
| 傳回 | |
|---|---|
| int | 建立的使用者 ID 整數,或 -1 代表錯誤。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
disableKeyguard
public void disableKeyguard ()
嘗試停用鎖定畫面。
首先等待輸入調度作業就緒,這會在裝置回報 BOOT_COMPLETE 時發生,且顯然是非同步的,因為目前的架構實作有偶發的競爭狀態。然後傳送指令來關閉螢幕鎖定畫面 (僅適用於非安全的螢幕鎖定畫面)
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
doesFileExist
public boolean doesFileExist (String deviceFilePath)
輔助方法,用於判斷裝置上是否有檔案。
| 參數 | |
|---|---|
| deviceFilePath | String:要檢查的裝置檔案絕對路徑 | 
| 傳回 | |
|---|---|
| boolean | 如果檔案存在,則傳回 true;否則傳回false。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
doesFileExist
public boolean doesFileExist (String deviceFilePath, 
                int userId)輔助方法,用於判斷裝置上是否有特定使用者的檔案。
| 參數 | |
|---|---|
| deviceFilePath | String:要檢查的裝置檔案絕對路徑 | 
| userId | int:用於檢查檔案是否存在的使用者 ID | 
| 傳回 | |
|---|---|
| boolean | 如果檔案存在,則傳回 true;否則傳回false。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
dumpHeap
public File dumpHeap (String process, 
                String devicePath)嘗試從 system_server 傾印堆積。呼叫端有責任清理傾印檔案。
| 參數 | |
|---|---|
| process | String:要傾印堆積的裝置程序名稱。 | 
| devicePath | String:裝置上放置傾印檔案的路徑。必須是權限允許的位置。 | 
| 傳回 | |
|---|---|
| File | 包含報表的 ERROR(/File)。如果失敗,則為空值。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getActiveApexes
publicgetActiveApexes () 
擷取裝置上已啟用的 APEX 相關資訊。
| 傳回 | |
|---|---|
|  | 目前在裝置上啟用的 ApexInfo的ERROR(/Set) | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getAllSettings
publicgetAllSettings (String namespace) 
傳回要求命名空間的鍵/值組合。
| 參數 | |
|---|---|
| namespace | String:必須是 {"system", "secure", "global"} 其中之一 | 
| 傳回 | |
|---|---|
|  | 鍵/值組合的對應關係。如果不支援命名空間,則為空值。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getAndroidId
public String getAndroidId (int userId)
尋找並傳回與 userId 相關聯的 Android ID,如果找不到,則傳回 null。
| 參數 | |
|---|---|
| userId | int | 
| 傳回 | |
|---|---|
| String | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getAndroidIds
publicgetAndroidIds () 
建立與使用者 ID 相符的 Android ID 對應圖表。並沒有保證每個使用者 ID 都能在這個函式中找到相關聯的 Android ID,因此部分使用者 ID 可能會比對為空值。
| 傳回 | |
|---|---|
|  | 找到相符使用者 ID 的 Android ID 對應表。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getAppPackageInfo
public PackageInfo getAppPackageInfo (String packageName)
擷取裝置上已安裝套件的相關資訊。
| 參數 | |
|---|---|
| packageName | String | 
| 傳回 | |
|---|---|
| PackageInfo | PackageInfo或null(如果無法擷取資訊) | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getAppPackageInfos
publicgetAppPackageInfos () 
擷取裝置上已安裝套件的相關資訊。
| 傳回 | |
|---|---|
|  | 裝置上安裝的 PackageInfoERROR(/List)。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getBugreport
public InputStreamSource getBugreport ()
從裝置擷取錯誤報告。
這項功能的實作方式保證可在沒有 SD 卡 (或尚未掛載 SD 卡) 的裝置上繼續運作。
| 傳回 | |
|---|---|
| InputStreamSource | InputStreamSource會視需求產生錯誤報告內容。如果失敗,InputStreamSource會產生空白ERROR(/InputStream)。 | 
getBugreportz
public InputStreamSource getBugreportz ()
從裝置擷取 bugreportz。ZIP 格式錯誤報告包含主要錯誤報告和其他有助於偵錯的記錄檔案。
僅支援「adb 版本」> 1.0.36
| 傳回 | |
|---|---|
| InputStreamSource | 包含 bugreportz 的 ZIP 檔案的 InputStreamSource,如果失敗,則會傳回 null。 | 
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
傳回裝置目前的折疊狀態,如果發生問題,則傳回 null。
| 傳回 | |
|---|---|
| DeviceFoldableState | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getCurrentUser
public int getCurrentUser ()
傳回目前執行中的使用者 ID。如果發生錯誤,請傳回 -10000。
| 傳回 | |
|---|---|
| int | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getFoldableStates
publicgetFoldableStates () 
傳回裝置上的摺疊式狀態清單。可使用「cmd device_state print-states」取得。
| 傳回 | |
|---|---|
|  | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getInstalledPackageNames
publicgetInstalledPackageNames () 
擷取裝置上的應用程式套件名稱。
| 傳回 | |
|---|---|
|  | 目前裝置上已安裝的 String套件名稱的ERROR(/Set)。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getKeyguardState
public KeyguardControllerState getKeyguardState ()
傳回物件,以取得 Keyguard 的目前狀態;如果不支援,則傳回空值。
| 傳回 | |
|---|---|
| KeyguardControllerState | KeyguardControllerState包含 Keyguard 狀態的快照,如果系統不支援 Keyguard 查詢,則會傳回空值。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getMainUserId
public Integer getMainUserId ()
傳回主要使用者 ID。
| 傳回 | |
|---|---|
| Integer | 主要使用者的 userId (如果有),如果沒有主要使用者,則為空值。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getMainlineModuleInfo
publicgetMainlineModuleInfo () 
取得裝置上安裝的主線程式模組相關資訊。
| 傳回 | |
|---|---|
|  | String主線模組目前在裝置上安裝的ERROR(/Set)。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getMaxNumberOfRunningUsersSupported
public int getMaxNumberOfRunningUsersSupported ()
取得支援的同時執行使用者人數上限。預設為 0。
| 傳回 | |
|---|---|
| int | 整數,表示同時執行的使用者人數 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getMaxNumberOfUsersSupported
public int getMaxNumberOfUsersSupported ()
取得支援的使用者人數上限。預設為 0。
| 傳回 | |
|---|---|
| int | 整數,用來指定支援的使用者人數 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getPrimaryUserId
public Integer getPrimaryUserId ()
傳回主要使用者 ID。
| 傳回 | |
|---|---|
| Integer | 主要使用者的 userId (如果有),如果沒有主要使用者,則為空值。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getScreenshot
public InputStreamSource getScreenshot ()
擷取裝置的螢幕截圖。
| 傳回 | |
|---|---|
| InputStreamSource | 以 PNG 格式提供螢幕截圖的 InputStreamSource,如果螢幕截圖未成功,則提供null。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getScreenshot
public InputStreamSource getScreenshot (String format, boolean rescale)
擷取裝置的螢幕截圖。建議改用 getScreenshot(String) 搭配 JPEG 編碼,以縮小檔案大小。
| 參數 | |
|---|---|
| format | String:支援 PNG、JPEG | 
| rescale | boolean:是否應重新調整螢幕截圖,以縮小產生的圖片大小 | 
| 傳回 | |
|---|---|
| InputStreamSource | 螢幕截圖的 InputStreamSource格式,如果螢幕截圖失敗,則為null。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getScreenshot
public InputStreamSource getScreenshot (long displayId)
從裝置的指定顯示 ID 擷取螢幕截圖。格式為 PNG。
TODO:擴充上述實作項目,以支援「format」和「rescale」
| 參數 | |
|---|---|
| displayId | long:要擷取螢幕截圖的螢幕顯示 ID。 | 
| 傳回 | |
|---|---|
| InputStreamSource | 螢幕截圖的 InputStreamSource格式,如果螢幕截圖失敗,則為null。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getScreenshot
public InputStreamSource getScreenshot (String format)
擷取裝置的螢幕截圖。建議改用 getScreenshot(format) 搭配 JPEG 編碼,以縮減檔案大小
| 參數 | |
|---|---|
| format | String:支援 PNG、JPEG | 
| 傳回 | |
|---|---|
| InputStreamSource | 螢幕截圖的 InputStreamSource格式,如果螢幕截圖失敗,則為null。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getSetting
public String getSetting (String namespace, 
                String key)請參閱 getSetting(int, String, String),並在系統使用者上執行。
| 參數 | |
|---|---|
| namespace | String | 
| key | String | 
| 傳回 | |
|---|---|
| String | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getSetting
public String getSetting (int userId, 
                String namespace, 
                String key)傳回所要求設定的值。命名空間必須為下列其中之一:{"system", "secure", "global"}
| 參數 | |
|---|---|
| userId | int | 
| namespace | String | 
| key | String | 
| 傳回 | |
|---|---|
| String | 與使用者 namespace:key 相關聯的值。如果找不到,則為空值。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getUninstallablePackageNames
publicgetUninstallablePackageNames () 
擷取可解除安裝的應用程式套件名稱。目前定義為非系統套件和更新的系統套件。
| 傳回 | |
|---|---|
|  | ERROR(/Set)目前已安裝在裝置上的可解除安裝String套件名稱。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getUserFlags
public int getUserFlags (int userId)
尋找並傳回特定使用者的標記。旗標是在 Android 開放原始碼計畫的「android.content.pm.UserInfo」類別中定義。
| 參數 | |
|---|---|
| userId | int | 
| 傳回 | |
|---|---|
| int | 與提供的 userId 相關聯的標記 (如果找到),否則為 -10000。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getUserInfos
publicgetUserInfos () 
取得裝置上 useId 到 UserInfo 的對應表。如果裝置的輸出內容與預期不符,就會擲回 DeviceRuntimeException。
| 傳回 | |
|---|---|
|  | UserInfo 物件清單。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
getUserSerialNumber
public int getUserSerialNumber (int userId)
如果找到,則傳回與 userId 相關聯的序號,否則傳回 -10000。
| 參數 | |
|---|---|
| userId | int | 
| 傳回 | |
|---|---|
| int | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
hasFeature
public boolean hasFeature (String feature)
檢查裝置是否支援某項功能。
| 參數 | |
|---|---|
| feature | String:應直接使用「feature: | 
| 傳回 | |
|---|---|
| boolean | 如果找到功能,則傳回「是」;否則傳回「否」。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installPackage
public String installPackage (File packageFile, 
                boolean reinstall, 
                String... extraArgs)在裝置上安裝 Android 套件。
| 參數 | |
|---|---|
| packageFile | File:要安裝的 APK 檔案 | 
| reinstall | boolean:true(如果應執行重新安裝作業) | 
| extraArgs | String:要傳遞的選用額外引數。如要瞭解可用的選項,請參閱「adb shell pm -h」。 | 
| 傳回 | |
|---|---|
| String | String(含有錯誤代碼),或null(成功時)。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installPackage
public String installPackage (File packageFile, 
                boolean reinstall, 
                boolean grantPermissions, 
                String... extraArgs)在裝置上安裝 Android 套件。
注意:只有需要在安裝時明確控制授予執行階段權限的用途,才應呼叫此函式。
| 參數 | |
|---|---|
| packageFile | File:要安裝的 APK 檔案 | 
| reinstall | boolean:true(如果應執行重新安裝作業) | 
| grantPermissions | boolean:是否應在安裝時授予所有執行階段權限 | 
| extraArgs | String:要傳遞的選用額外引數。如要瞭解可用的選項,請參閱「adb shell pm -h」。 | 
| 傳回 | |
|---|---|
| String | String(含有錯誤代碼),或null(成功時)。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installPackage
public String installPackage (File packageFile, 
                File certFile, 
                boolean reinstall, 
                String... extraArgs)在裝置上安裝 Android 套件。
注意:只有需要在安裝時明確控制授予執行階段權限的用途,才應呼叫此函式。
| 參數 | |
|---|---|
| packageFile | File:要安裝的 APK 檔案 | 
| certFile | File:true(如果應執行重新安裝作業) | 
| reinstall | boolean:是否應在安裝時授予所有執行階段權限 | 
| extraArgs | String:要傳遞的選用額外引數。如要瞭解可用的選項,請參閱「adb shell pm -h」。 | 
| 傳回 | |
|---|---|
| String | String(含有錯誤代碼),或null(成功時)。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installPackageForUser
public String installPackageForUser (File packageFile, 
                boolean reinstall, 
                boolean grantPermissions, 
                int userId, 
                String... extraArgs)為特定使用者在裝置上安裝 Android 套件。
注意:只有需要在安裝時明確控制授予執行階段權限的用途,才應呼叫此函式。
| 參數 | |
|---|---|
| packageFile | File:要安裝的 APK 檔案 | 
| reinstall | boolean:true(如果應執行重新安裝作業) | 
| grantPermissions | boolean:是否應在安裝時授予所有執行階段權限 | 
| userId | int:要為其安裝的整數使用者 ID。 | 
| extraArgs | String:要傳遞的選用額外引數。如要瞭解可用的選項,請參閱「adb shell pm -h」。 | 
| 傳回 | |
|---|---|
| String | String(含有錯誤代碼),或null(成功時)。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installPackageForUser
public String installPackageForUser (File packageFile, 
                boolean reinstall, 
                int userId, 
                String... extraArgs)為特定使用者在裝置上安裝 Android 套件。
| 參數 | |
|---|---|
| packageFile | File:要安裝的 APK 檔案 | 
| reinstall | boolean:true(如果應執行重新安裝作業) | 
| userId | int:要為其安裝的整數使用者 ID。 | 
| extraArgs | String:要傳遞的選用額外引數。如要瞭解可用的選項,請參閱「adb shell pm -h」。 | 
| 傳回 | |
|---|---|
| String | String(含有錯誤代碼),或null(成功時)。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installPackages
public String installPackages (packageFiles, boolean reinstall, String... extraArgs) 
| 參數 | |
|---|---|
| packageFiles |  | 
| reinstall | boolean | 
| extraArgs | String | 
| 傳回 | |
|---|---|
| String | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installPackages
public String installPackages (packageFiles, boolean reinstall, boolean grantPermissions, String... extraArgs) 
| 參數 | |
|---|---|
| packageFiles |  | 
| reinstall | boolean | 
| grantPermissions | boolean | 
| extraArgs | String | 
| 傳回 | |
|---|---|
| String | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installPackagesForUser
public String installPackagesForUser (packageFiles, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs) 
| 參數 | |
|---|---|
| packageFiles |  | 
| reinstall | boolean | 
| grantPermissions | boolean | 
| userId | int | 
| extraArgs | String | 
| 傳回 | |
|---|---|
| String | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installPackagesForUser
public String installPackagesForUser (packageFiles, boolean reinstall, int userId, String... extraArgs) 
| 參數 | |
|---|---|
| packageFiles |  | 
| reinstall | boolean | 
| userId | int | 
| extraArgs | String | 
| 傳回 | |
|---|---|
| String | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installRemotePackages
public String installRemotePackages (remoteApkPaths, boolean reinstall, String... extraArgs) 
| 參數 | |
|---|---|
| remoteApkPaths |  | 
| reinstall | boolean | 
| extraArgs | String | 
| 傳回 | |
|---|---|
| String | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
installRemotePackages
public String installRemotePackages (remoteApkPaths, boolean reinstall, boolean grantPermissions, String... extraArgs) 
| 參數 | |
|---|---|
| remoteApkPaths |  | 
| reinstall | boolean | 
| grantPermissions | boolean | 
| extraArgs | String | 
| 傳回 | |
|---|---|
| String | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isAppEnumerationSupported
public boolean isAppEnumerationSupported ()
檢查裝置上的平台是否支援應用程式列舉
| 傳回 | |
|---|---|
| boolean | 如果支援應用程式列舉,則傳回「是」;否則傳回「否」 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isHeadlessSystemUserMode
public boolean isHeadlessSystemUserMode ()
傳回裝置是否使用無頭系統使用者模式。
| 傳回 | |
|---|---|
| boolean | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isMainUserPermanentAdmin
public boolean isMainUserPermanentAdmin ()
傳回主要使用者是否為永久管理員,且無法刪除或降級為非管理員狀態。
| 傳回 | |
|---|---|
| boolean | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isMultiUserSupported
public boolean isMultiUserSupported ()
判斷是否支援多位使用者。
| 傳回 | |
|---|---|
| boolean | 如果支援多用戶,則傳回 true;否則傳回 false | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isPackageInstalled
public boolean isPackageInstalled (String packageName)
針對裝置中的特定套件名稱執行查詢,確認目前是否已安裝該套件。
| 參數 | |
|---|---|
| packageName | String | 
| 傳回 | |
|---|---|
| boolean | 如果套件已回報為已安裝,則為 True。否則為 False。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isPackageInstalled
public boolean isPackageInstalled (String packageName, 
                String userId)針對裝置中的特定套件名稱和使用者 ID 執行查詢,確認該使用者目前是否已安裝該套件。
| 參數 | |
|---|---|
| packageName | String:我們要檢查的套件是否已安裝。 | 
| userId | String:我們要檢查套件安裝的使用者 ID。如果為空值,系統會使用主要使用者零。 | 
| 傳回 | |
|---|---|
| boolean | 如果套件已回報為已安裝,則為 True。否則為 False。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isUserRunning
public boolean isUserRunning (int userId)
檢查特定使用者是否正在執行。
| 參數 | |
|---|---|
| userId | int | 
| 傳回 | |
|---|---|
| boolean | 如果使用者正在執行,則為 True;否則為 False。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isUserSecondary
public boolean isUserSecondary (int userId)
根據指定使用者的標記,傳回該使用者是否為次要使用者。
| 參數 | |
|---|---|
| userId | int | 
| 傳回 | |
|---|---|
| boolean | 如果使用者是次要使用者,則傳回 true;否則傳回 false。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isUserVisible
public boolean isUserVisible (int userId)
檢查指定使用者是否可見。
「可見」使用者是指與「人類」使用者互動的使用者,因此能夠啟動活動 (通常是在預設顯示畫面中)。
| 參數 | |
|---|---|
| userId | int | 
| 傳回 | |
|---|---|
| boolean | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isUserVisibleOnDisplay
public boolean isUserVisibleOnDisplay (int userId, 
                int displayId)檢查指定使用者是否會顯示在指定顯示畫面中。
「可見」使用者是指與「人類」使用者互動的使用者,因此可在該顯示畫面中啟動活動。
| 參數 | |
|---|---|
| userId | int | 
| displayId | int | 
| 傳回 | |
|---|---|
| boolean | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isVisibleBackgroundUsersOnDefaultDisplaySupported
public boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()
傳回裝置是否允許使用者在 ERROR(/java.android.view.Display#DEFAULT_DISPLAY) 中以背景方式啟動。
如果是,您可以呼叫 startVisibleBackgroundUser(int, int, boolean),傳遞 listDisplayIdsForStartingVisibleBackgroundUsers() 傳回的顯示內容 (應包含 ERROR(/java.android.view.Display#DEFAULT_DISPLAY))。
| 傳回 | |
|---|---|
| boolean | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
isVisibleBackgroundUsersSupported
public boolean isVisibleBackgroundUsersSupported ()
傳回裝置是否允許使用者在背景啟動。
如果是,您可以呼叫 startVisibleBackgroundUser(int, int, boolean),傳遞 listDisplayIdsForStartingVisibleBackgroundUsers() 傳回的顯示內容。
| 傳回 | |
|---|---|
| boolean | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
listDisplayIds
publiclistDisplayIds () 
收集裝置上可用顯示器 ID 的清單,並由「dumpsys SurfaceFlinger」回報。
| 傳回 | |
|---|---|
|  | 螢幕清單。預設值一律會傳回預設顯示值 0。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
listDisplayIdsForStartingVisibleBackgroundUsers
publiclistDisplayIdsForStartingVisibleBackgroundUsers () 
取得可用於 start a user visible in the background 的螢幕清單。
| 傳回 | |
|---|---|
|  | |
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
listUsers
publiclistUsers () 
取得裝置上的使用者清單。如果裝置的輸出內容不如預期,系統會擲回 DeviceRuntimeException。
| 傳回 | |
|---|---|
|  | 使用者 ID 清單。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
logBugreport
public boolean logBugreport (String dataName, 
                ITestLogger listener)輔助方法,可取得錯誤報告並記錄至記錄器。
| 參數 | |
|---|---|
| dataName | String:BugReport 回報的名稱。 | 
| listener | ITestLogger:用於記錄錯誤報告的ITestLogger。 | 
| 傳回 | |
|---|---|
| boolean | 如果記錄成功,則傳回 True,否則傳回 false。 | 
notifySnapuserd
public void notifySnapuserd (SnapuserdWaitPhase waitPhase)
| 參數 | |
|---|---|
| waitPhase | SnapuserdWaitPhase | 
postInvocationTearDown
public void postInvocationTearDown (Throwable exception)
針對裝置特定的必要清理作業,在叫用完成後執行額外步驟。
| 參數 | |
|---|---|
| exception | Throwable:如果有,則為叫用失敗所引發的最終例外狀況。 | 
removeAdmin
public boolean removeAdmin (String componentName, 
                int userId)從指定使用者中移除指定的裝置管理員,如果成功則傳回 true,否則傳回 false。
| 參數 | |
|---|---|
| componentName | String:要移除的裝置管理員。 | 
| userId | int:裝置管理員所在的使用者。 | 
| 傳回 | |
|---|---|
| boolean | 如果成功,則傳回 True,否則傳回 False。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
removeUser
public boolean removeUser (int userId)
從裝置中移除特定使用者。
| 參數 | |
|---|---|
| userId | int:要移除的使用者 | 
| 傳回 | |
|---|---|
| boolean | 如果移除使用者成功,則傳回 true,否則傳回 false。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
setDeviceOwner
public boolean setDeviceOwner (String componentName, 
                int userId)將裝置管理員元件設為特定使用者的裝置擁有者。
| 參數 | |
|---|---|
| componentName | String:裝置管理員為裝置擁有者。 | 
| userId | int:裝置擁有者所在國家/地區的使用者。 | 
| 傳回 | |
|---|---|
| boolean | 如果成功,則傳回 True,否則傳回 False。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
setFirstBootloaderReboot
public void setFirstBootloaderReboot ()
setSetting
public void setSetting (String namespace, 
                String key, 
                String value)請參閱 setSetting(int, String, String, String),並在系統使用者上執行。
| 參數 | |
|---|---|
| namespace | String | 
| key | String | 
| value | String | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
setSetting
public void setSetting (int userId, 
                String namespace, 
                String key, 
                String value)將設定值新增至特定使用者的命名空間。部分設定必須重新啟動後才能使用。命名空間必須為下列其中之一:{"system", "secure", "global"}
| 參數 | |
|---|---|
| userId | int | 
| namespace | String | 
| key | String | 
| value | String | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
shutdownMicrodroid
public void shutdownMicrodroid (ITestDevice microdroidDevice)
關閉 microdroid 裝置 (如果有的話)。
| 參數 | |
|---|---|
| microdroidDevice | ITestDevice | 
| 擲回 | |
|---|---|
|  | com.android.tradefed.device.DeviceNotAvailableException | 
| DeviceNotAvailableException | |
startUser
public boolean startUser (int userId)
如果使用者目前已停止,則在背景啟動該使用者。如果使用者已在背景執行,這個方法就是 NOOP。
| 參數 | |
|---|---|
| userId | int:要以背景方式啟動的使用者 | 
| 傳回 | |
|---|---|
| boolean | 如果使用者已成功在背景啟動,則為 true。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
startUser
public boolean startUser (int userId, 
                boolean waitFlag)如果使用者目前已停止,則在背景啟動該使用者。如果使用者已在背景執行,這個方法就是 NOOP。可提供額外旗標,等待作業生效。
| 參數 | |
|---|---|
| userId | int:要以背景方式啟動的使用者 | 
| waitFlag | boolean:會讓指令等待使用者啟動並解鎖。 | 
| 傳回 | |
|---|---|
| boolean | 如果使用者已成功在背景啟動,則為 true。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
startVisibleBackgroundUser
public boolean startVisibleBackgroundUser (int userId, 
                int displayId, 
                boolean waitFlag)在背景啟動特定使用者,並在指定螢幕上顯示 (也就是允許使用者在該螢幕上啟動活動)。
注意: 這個指令不會檢查使用者是否存在、是否可顯示 device supports such feature 等。
| 參數 | |
|---|---|
| userId | int:要以背景方式啟動的使用者 | 
| displayId | int:顯示給啟動使用者看 | 
| waitFlag | boolean:會讓指令等待使用者啟動並解鎖。 | 
| 傳回 | |
|---|---|
| boolean | true:如果使用者已成功在背景啟動可見。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
stopUser
public boolean stopUser (int userId, 
                boolean waitFlag, 
                boolean forceFlag)停止特定使用者。您可以提供額外的旗標,等待作業生效,並強制終止使用者。無法停止目前和系統使用者。
| 參數 | |
|---|---|
| userId | int:要停止的使用者。 | 
| waitFlag | boolean:會讓指令等待使用者停止。 | 
| forceFlag | boolean:會強制停止使用者。 | 
| 傳回 | |
|---|---|
| boolean | 如果使用者已成功停止,則傳回 true。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
stopUser
public boolean stopUser (int userId)
停止特定使用者。如果使用者已停止,這個方法就是 NOOP。無法停止目前和系統使用者。
| 參數 | |
|---|---|
| userId | int:要停止的使用者。 | 
| 傳回 | |
|---|---|
| boolean | 如果使用者已成功停止,則傳回 true。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
支援 Microdroid
public boolean supportsMicrodroid ()
檢查執行微型機器人的先決條件。
| 傳回 | |
|---|---|
| boolean | 如果滿足前置條件,則傳回 true,否則傳回 false。 | 
支援 Microdroid
public boolean supportsMicrodroid (boolean protectedVm)
檢查執行微型機器人的先決條件。
| 參數 | |
|---|---|
| protectedVm | boolean:如果 microdroid 要在受保護的 VM 上執行,則為 true。 | 
| 傳回 | |
|---|---|
| boolean | 如果滿足前置條件,則傳回 true,否則傳回 false。 | 
switchUser
public boolean switchUser (int userId)
切換至另一個使用者 ID,並設定預設逾時時間。switchUser(int, long)。
| 參數 | |
|---|---|
| userId | int | 
| 傳回 | |
|---|---|
| boolean | 如果新 userId 與 userId 供應工具相符,則為「是」。否則為 False。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
switchUser
public boolean switchUser (int userId, 
                long timeout)以提供的逾時期限為期限,切換至其他 userId。在使用者變更成功後,嘗試停用螢幕鎖定。
| 參數 | |
|---|---|
| userId | int | 
| timeout | long:等待後再傳回 false,表示切換使用者失敗。 | 
| 傳回 | |
|---|---|
| boolean | 如果新 userId 與 userId 供應工具相符,則為「是」。否則為 False。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
takeBugreport
public Bugreport takeBugreport ()
取得 bugreport,並將其傳回至 Bugreport 物件中加以處理。發生問題時傳回空值。您必須透過 Bugreport.close() 清除 Bugreport 物件中參照的檔案。
| 傳回 | |
|---|---|
| Bugreport | |
uninstallPackage
public String uninstallPackage (String packageName)
從裝置上解除安裝 Android 套件。
| 參數 | |
|---|---|
| packageName | String:要解除安裝的 Android 套件 | 
| 傳回 | |
|---|---|
| String | String(含有錯誤代碼),或null(成功時)。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
uninstallPackageForUser
public String uninstallPackageForUser (String packageName, 
                int userId)針對特定使用者,從裝置上解除安裝 Android 套件。
| 參數 | |
|---|---|
| packageName | String:要解除安裝的 Android 套件 | 
| userId | int:要解除安裝的整數使用者 ID。 | 
| 傳回 | |
|---|---|
| String | String(含有錯誤代碼),或null(成功時)。 | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
waitForSnapuserd
public void waitForSnapuserd (SnapuserdWaitPhase currentPhase)
| 參數 | |
|---|---|
| currentPhase | SnapuserdWaitPhase | 
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
受保護的方法
doAdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode, String reason)
執行 ADB 重新啟動。
| 參數 | |
|---|---|
| rebootMode | NativeDevice.RebootMode:此重新啟動模式。 | 
| reason | String:針對這次重新啟動。 | 
| 擲回 | |
|---|---|
|  | com.android.tradefed.device.DeviceNotAvailableException | 
| DeviceNotAvailableException | |
getBugreportzInternal
protected File getBugreportzInternal ()
內部輔助程式方法,可取得 bugreportz ZIP 檔案做為 ERROR(/File)。
| 傳回 | |
|---|---|
| File | |
getCheckNewUserSleep
protected long getCheckNewUserSleep ()
公開測試。
| 傳回 | |
|---|---|
| long | |
getHostCurrentTime
protected long getHostCurrentTime ()
已公開供測試
| 傳回 | |
|---|---|
| long | |
prePostBootSetup
protected void prePostBootSetup ()
允許每個裝置類型 (AndroidNativeDevice、TestDevice) 針對特定的開機後設定覆寫此方法。
| 擲回 | |
|---|---|
| DeviceNotAvailableException | |
