StubDevice
public
class
StubDevice
extends Object
implements
IDevice
| java.lang.Object | |
| ↳ | com.android.tradefed.device.StubDevice |
IDevice 的預留位置實作。
摘要
公用建構函式 | |
|---|---|
StubDevice(String serial)
|
|
StubDevice(String serial, boolean isEmulator)
|
|
公用方法 | |
|---|---|
boolean
|
arePropertiesSet()
如果屬性已快取,則傳回 |
void
|
createForward(int localPort, String remoteSocketName, IDevice.DeviceUnixSocketNamespace namespace)
在本地 TCP 連接埠和遠端 Unix 網域通訊端之間建立連接埠轉送。 |
void
|
createForward(int localPort, int remotePort)
在本地和遠端通訊埠之間建立通訊埠轉送。 |
void
|
createReverse(int remotePort, int localPort)
在遠端和本機通訊埠之間建立通訊埠反向。 |
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)
在裝置上執行殼層指令,並將結果傳送至 receiver。 |
void
|
executeShellCommand(String command, IShellOutputReceiver receiver)
在裝置上執行殼層指令,並將結果傳送至 receiver 這類似於呼叫 |
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, int maxTimeToOutputResponse)
這個方法已淘汰。
使用 |
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)
在裝置上執行殼層指令,並將結果傳送至 receiver。 |
|
getAbis()
傳回這部裝置支援的 ABI。 |
String
|
getAvdName()
傳回模擬器執行的 AVD 名稱。 |
String
|
getAvdPath()
傳回檔案系統中虛擬裝置的絕對路徑。 |
|
getBattery(long freshnessTime, TimeUnit timeUnit)
傳回裝置的電量,範圍為 0 到 100%。 |
|
getBattery()
傳回裝置的電量,範圍為 0 到 100%。 |
Integer
|
getBatteryLevel(long freshnessMs)
這個方法已淘汰。
請改用 |
Integer
|
getBatteryLevel()
這個方法已淘汰。
請改用 |
Client
|
getClient(String applicationName)
依應用程式名稱傳回 |
String
|
getClientName(int pid)
傳回用戶端名稱 (依據 PID),如果 PID 不明,則傳回 |
Client[]
|
getClients()
傳回用戶端陣列。 |
int
|
getDensity()
讀取系統屬性 |
FileListingService
|
getFileListingService()
傳回這部裝置的 |
String
|
getLanguage()
傳回使用者的語言。 |
String
|
getMountPoint(String name)
傳回掛接點。 |
String
|
getName()
傳回這部裝置的 (可解讀) 名稱。 |
|
getProperties()
這個方法已淘汰。
請改用 |
String
|
getProperty(String name)
便利方法,會嘗試透過 |
String
|
getPropertyCacheOrSync(String name)
這個方法已淘汰。
請改用 |
int
|
getPropertyCount()
這個方法已淘汰。 ddmlib 中已淘汰,原因是「實作詳細資料」。 |
String
|
getPropertySync(String name)
這個方法已淘汰。
請改用 |
String
|
getRegion()
傳回使用者的區域。 |
RawImage
|
getScreenshot()
擷取裝置螢幕截圖,並以 |
RawImage
|
getScreenshot(long timeout, TimeUnit unit)
|
String
|
getSerialNumber()
傳回裝置的序號。 |
IDevice.DeviceState
|
getState()
傳回裝置的狀態。 |
SyncService
|
getSyncService()
傳回 |
ListenableFuture<String>
|
getSystemProperty(String name)
對系統屬性執行潛在的非同步查詢。 |
boolean
|
hasClients()
|
void
|
installPackage(String packageFilePath, boolean reinstall, InstallReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits, String... extraArgs)
在裝置上安裝 Android 應用程式。 |
void
|
installPackage(String packageFilePath, boolean reinstall, InstallReceiver receiver, String... extraArgs)
在裝置上安裝 Android 應用程式。 |
void
|
installPackage(String packageFilePath, boolean reinstall, String... extraArgs)
在裝置上安裝 Android 應用程式。 |
void
|
installPackages(
Installs an Android application made of several APK files (one main and 0..n split packages) |
void
|
installRemotePackage(String remoteFilePath, boolean reinstall, InstallReceiver receiver, String... extraArgs)
安裝已推送至裝置暫時位置的應用程式套件。 |
void
|
installRemotePackage(String remoteFilePath, boolean reinstall, String... extraArgs)
安裝已推送至裝置暫時位置的應用程式套件。 |
void
|
installRemotePackage(String remoteFilePath, boolean reinstall, InstallReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits, String... extraArgs)
安裝已推送至裝置暫時位置的應用程式套件。 |
boolean
|
isBootLoader()
傳回裝置是否處於系統啟動載入程式模式。 |
boolean
|
isEmulator()
如果裝置是模擬器,就會傳回 |
boolean
|
isOffline()
傳回裝置是否離線。 |
boolean
|
isOnline()
傳回裝置是否已準備就緒。 |
boolean
|
isRoot()
查詢裝置目前的 Root 狀態。 |
void
|
pullFile(String remote, String local)
提取單一檔案。 |
void
|
pushFile(String local, String remote)
推送單一檔案。 |
void
|
reboot(String into)
重新啟動裝置。 |
void
|
removeForward(int localPort)
移除本機通訊埠與遠端通訊埠之間的通訊埠轉送。 |
void
|
removeForward(int localPort, int remotePort)
|
void
|
removeForward(int localPort, String remoteSocketName, IDevice.DeviceUnixSocketNamespace namespace)
|
void
|
removeRemotePackage(String remoteFilePath)
從裝置中移除檔案。 |
void
|
removeReverse(int remotePort)
移除遠端通訊埠與本機通訊埠之間的通訊埠反向轉送。 |
boolean
|
root()
要求 adb daemon 在裝置上成為根使用者。 |
void
|
setSerial(String serial)
|
void
|
startScreenRecorder(String remoteFilePath, ScreenRecorderOptions options, IShellOutputReceiver receiver)
如果裝置支援 |
boolean
|
supportsFeature(IDevice.HardwareFeature arg0)
傳回這個裝置是否支援指定的硬體功能。 |
boolean
|
supportsFeature(IDevice.Feature feature)
傳回這個裝置是否支援指定的軟體功能。 |
String
|
syncPackageToDevice(String localFilePath)
將檔案推送至裝置 |
String
|
uninstallApp(String applicationID, String... extraArgs)
從裝置解除安裝應用程式。 |
String
|
uninstallPackage(String packageName)
從裝置解除安裝套件。 |
公用建構函式
StubDevice
public StubDevice (String serial)
| 參數 | |
|---|---|
serial |
String |
StubDevice
public StubDevice (String serial,
boolean isEmulator)| 參數 | |
|---|---|
serial |
String |
isEmulator |
boolean |
公用方法
arePropertiesSet
public boolean arePropertiesSet ()
如果已快取屬性,則傳回 true
| 傳回 | |
|---|---|
boolean |
|
createForward
public void createForward (int localPort,
String remoteSocketName,
IDevice.DeviceUnixSocketNamespace namespace)在本地 TCP 連接埠和遠端 Unix 網域通訊端之間建立連接埠轉送。
| 參數 | |
|---|---|
localPort |
int:要轉送的本機通訊埠 |
remoteSocketName |
String:在裝置上建立的 Unix 網域通訊端名稱 |
namespace |
IDevice.DeviceUnixSocketNamespace:建立 Unix 網域通訊端的命名空間 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
createForward
public void createForward (int localPort,
int remotePort)在本地和遠端通訊埠之間建立通訊埠轉送。
| 參數 | |
|---|---|
localPort |
int:要轉送的本機通訊埠 |
remotePort |
int:遠端通訊埠。 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
createReverse
public void createReverse (int remotePort,
int localPort)在遠端和本機通訊埠之間建立通訊埠反向。
| 參數 | |
|---|---|
remotePort |
int:要反向的遠端通訊埠。 |
localPort |
int:本機通訊埠 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
executeShellCommand
public void executeShellCommand (String command,
IShellOutputReceiver receiver,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits)在裝置上執行殼層指令,並將結果傳送至 receiver。
預期裝置會輸出指令時,maxTimeToOutputResponse 會做為最長等待時間。
在任何時間,如果殼層指令在一段時間內沒有輸出任何內容 (時間長度超過 maxTimeToOutputResponse),這個方法就會擲回 ShellCommandUnresponsiveException。
對於記錄輸出等指令,應使用 maxTimeToOutputResponse 值 0,表示方法絕不會擲回,且會封鎖,直到接收端的 IShellOutputReceiver.isCancelled() 傳回 true 為止。
| 參數 | |
|---|---|
command |
String:要執行的殼層指令 |
receiver |
IShellOutputReceiver:接收殼層指令輸出的 IShellOutputReceiver |
maxTimeToOutputResponse |
long:指令在沒有任何回應的情況下,允許的最長時間。如果值為 0,方法會無限期等待指令輸出內容 (直到 receiver 取消執行),且絕不會擲回。 |
maxTimeUnits |
TimeUnit:非零 maxTimeToOutputResponse 值所用的單位。 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
executeShellCommand
public void executeShellCommand (String command,
IShellOutputReceiver receiver)在裝置上執行殼層指令,並將結果傳送至 receiver
這類似於呼叫
executeShellCommand(command, receiver, DdmPreferences.getTimeOut())。
| 參數 | |
|---|---|
command |
String:要執行的殼層指令 |
receiver |
IShellOutputReceiver:接收殼層指令輸出的 IShellOutputReceiver |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
executeShellCommand
public void executeShellCommand (String command,
IShellOutputReceiver receiver,
int maxTimeToOutputResponse)
這個方法已淘汰。
使用 executeShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit)。
| 參數 | |
|---|---|
command |
String |
receiver |
IShellOutputReceiver |
maxTimeToOutputResponse |
int |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
executeShellCommand
public void executeShellCommand (String command,
IShellOutputReceiver receiver,
long maxTimeout,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits)在裝置上執行殼層指令,並將結果傳送至 receiver。
預期裝置會輸出指令時,maxTimeToOutputResponse 會做為最長等待時間。
在任何時間,如果殼層指令在一段時間內沒有輸出任何內容 (時間長度超過 maxTimeToOutputResponse),這個方法就會擲回 ShellCommandUnresponsiveException。
對於記錄輸出等指令,應使用 maxTimeToOutputResponse 值 0,表示方法絕不會擲回,且會封鎖,直到接收端的 IShellOutputReceiver.isCancelled() 傳回 true 為止。
| 參數 | |
|---|---|
command |
String:要執行的殼層指令 |
receiver |
IShellOutputReceiver:接收殼層指令輸出的 IShellOutputReceiver |
maxTimeout |
long:指令傳回的逾時時間上限。如果值為 0,表示不會套用逾時上限。 |
maxTimeToOutputResponse |
long:指令在沒有任何回應的情況下,允許的最長時間。如果值為 0,方法會無限期等待指令輸出內容 (直到 receiver 取消執行),且絕不會擲回。 |
maxTimeUnits |
TimeUnit:非零 maxTimeout 和 maxTimeToOutputResponse
值的單位。 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
getAbis
publicgetAbis ()
傳回這部裝置支援的 ABI。ABI 會依偏好順序排序,第一個 ABI 是最偏好的。
| 傳回 | |
|---|---|
|
ABI 清單。 |
getAvdName
public String getAvdName ()
傳回模擬器執行的 AVD 名稱。
只有在 isEmulator() 傳回 true 時,這項設定才會生效。
如果模擬器未執行任何 AVD (例如從 Android 來源樹狀結構建構執行),這個方法會傳回「<build>」。
注意:如要控管逾時時間,建議使用 getAvdData()。
| 傳回 | |
|---|---|
String |
AVD 的名稱,或沒有名稱時為 null。 |
getAvdPath
public String getAvdPath ()
傳回檔案系統中虛擬裝置的絕對路徑。路徑取決於作業系統,Linux 使用「/」做為名稱分隔符,Windows 則使用「\」。
注意:如要控管逾時時間,建議使用 getAvdData()。
| 傳回 | |
|---|---|
String |
AVD 路徑,如果這是實體裝置、模擬器控制台子指令失敗,或模擬器版本舊於 30.0.18,則為空值 |
getBattery
publicgetBattery (long freshnessTime, TimeUnit timeUnit)
傳回裝置的電量,範圍為 0 到 100%。
系統可能會快取電池電量,只有在上次成功查詢後,
freshnessTime 已過期時,才會查詢裝置的電池電量。
| 參數 | |
|---|---|
freshnessTime |
long:電池電量的期望近期程度 |
timeUnit |
TimeUnit:ERROR(/TimeUnit) 的 ERROR(/TimeUnit) freshnessTime |
| 傳回 | |
|---|---|
|
可查詢電池電量的 ERROR(/Future)。如果無法擷取電池電量,Future 會傳回 ERROR(/ExecutionException)。 |
getBattery
publicgetBattery ()
傳回裝置的電量,範圍為 0 到 100%。
系統可能會快取電池電量,如果自上次成功查詢後已過 5 分鐘,系統才會查詢裝置的電池電量。
| 傳回 | |
|---|---|
|
可查詢電池電量的 ERROR(/Future)。如果無法擷取電池電量,Future 會傳回 ERROR(/ExecutionException)。 |
getBatteryLevel
public Integer getBatteryLevel (long freshnessMs)
這個方法已淘汰。
請改用 getBattery(long, TimeUnit)。
傳回裝置的電量,範圍為 0 到 100%。
系統可能會快取電池電量,只有在上次成功查詢後經過
freshnessMs 毫秒時,才會查詢裝置的電池電量。
| 傳回 | |
|---|---|
Integer |
電池電量,或null (如果無法擷取) |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
getBatteryLevel
public Integer getBatteryLevel ()
這個方法已淘汰。
請改用 getBattery()。
傳回裝置的電量,範圍為 0 到 100%。
系統可能會快取電池電量,如果自上次成功查詢後已過 5 分鐘,系統才會查詢裝置的電池電量。
| 傳回 | |
|---|---|
Integer |
電池電量,或null (如果無法擷取) |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
getClient
public Client getClient (String applicationName)
依應用程式名稱傳回 Client。
| 參數 | |
|---|---|
applicationName |
String:應用程式名稱 |
| 傳回 | |
|---|---|
Client |
Client 物件或 null (如果找不到相符項目)。 |
getClientName
public String getClientName (int pid)
依據 PID 傳回用戶端名稱,如果 PID 不明則傳回 null
| 參數 | |
|---|---|
pid |
int:用戶端的 PID。 |
| 傳回 | |
|---|---|
String |
|
getDensity
public int getDensity ()
讀取系統屬性 PROP_DEVICE_DENSITY 的值,傳回裝置螢幕的密度值區。
| 傳回 | |
|---|---|
int |
密度,如果無法判斷,則為 -1。 |
getFileListingService
public FileListingService getFileListingService ()
傳回這部裝置的 FileListingService。
| 傳回 | |
|---|---|
FileListingService |
|
getLanguage
public String getLanguage ()
傳回使用者的語言。
| 傳回 | |
|---|---|
String |
使用者的語言,如果不明則為空值 |
getMountPoint
public String getMountPoint (String name)
傳回掛接點。
| 參數 | |
|---|---|
name |
String:要傳回的掛接點名稱 |
| 傳回 | |
|---|---|
String |
|
getName
public String getName ()
傳回這部裝置的 (可讀) 名稱。通常是 AVD 的 AVD 名稱,以及裝置的製造商名稱、型號名稱和序號組合。
| 傳回 | |
|---|---|
String |
|
getProperties
publicgetProperties ()
這個方法已淘汰。
請改用 getSystemProperty(String)。
傳回快取的裝置屬性。其中包含「getprop」的完整輸出內容
| 傳回 | |
|---|---|
|
|
getProperty
public String getProperty (String name)
便利方法,會嘗試透過 IShellEnabledDevice.getSystemProperty(String) 擷取屬性,等待時間非常短,並會忽略例外狀況。
注意:如要控管逾時時間,建議使用 IShellEnabledDevice.getSystemProperty(String)。
| 參數 | |
|---|---|
name |
String:要傳回的值名稱。 |
| 傳回 | |
|---|---|
String |
值,或 null (如果屬性值無法立即取得) |
getPropertyCacheOrSync
public String getPropertyCacheOrSync (String name)
這個方法已淘汰。
請改用 getProperty(String)。
getProperty(String) 和 getPropertySync(String) 的組合,會嘗試從快取中擷取屬性。如果找不到,系統會嘗試直接查詢裝置,並在成功時重新填入快取。
| 參數 | |
|---|---|
name |
String:要傳回的值名稱。 |
| 傳回 | |
|---|---|
String |
如果屬性不存在,則為值或 null |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
getPropertyCount
public int getPropertyCount ()
這個方法已淘汰。
deprecated in ddmlib with "implementation detail" as reason.
傳回這部裝置的屬性數量。
| 傳回 | |
|---|---|
int |
|
getPropertySync
public String getPropertySync (String name)
這個方法已淘汰。
請改用 getProperty(String)。
getProperty(String) 的變體,會嘗試直接從裝置擷取指定屬性,而不使用快取。這個方法「只能」用於任何不穩定的屬性。
| 參數 | |
|---|---|
name |
String:要傳回的值名稱。 |
| 傳回 | |
|---|---|
String |
如果屬性不存在,則為值或 null |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
getRegion
public String getRegion ()
傳回使用者的區域。
| 傳回 | |
|---|---|
String |
使用者的區域,如果不明則為空值 |
getScreenshot
public RawImage getScreenshot ()
擷取裝置螢幕截圖,並以 RawImage 形式傳回。
| 傳回 | |
|---|---|
RawImage |
如果發生錯誤,請提供螢幕截圖 (RawImage 或 null)。 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
getScreenshot
public RawImage getScreenshot (long timeout, TimeUnit unit)
| 參數 | |
|---|---|
timeout |
long |
unit |
TimeUnit |
| 傳回 | |
|---|---|
RawImage |
|
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
getSerialNumber
public String getSerialNumber ()
傳回裝置的序號。
| 傳回 | |
|---|---|
String |
|
getSyncService
public SyncService getSyncService ()
傳回 SyncService 物件,用於將檔案推送/拉取至裝置或從裝置推送/拉取檔案。
| 傳回 | |
|---|---|
SyncService |
null (如果無法建立 SyncService)。如果 adb 拒絕開啟連線,可能是因為 IDevice 無效 (或已中斷連線)。 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
getSystemProperty
public ListenableFuture<String> getSystemProperty (String name)
對系統屬性執行潛在的非同步查詢。
| 參數 | |
|---|---|
name |
String:要傳回的值名稱。 |
| 傳回 | |
|---|---|
ListenableFuture<String> |
ListenableFuture. ERROR(get/Future#get() get) 可能會傳回空值。 |
installPackage
public void installPackage (String packageFilePath,
boolean reinstall,
InstallReceiver receiver,
long maxTimeout,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits,
String... extraArgs)在裝置上安裝 Android 應用程式。這是輔助方法,可合併 syncPackageToDevice、installRemotePackage 和 removePackage 步驟
| 參數 | |
|---|---|
packageFilePath |
String:本機主機上要安裝的檔案的絕對檔案系統路徑 |
reinstall |
boolean:如果應重新安裝應用程式,請設為 true |
receiver |
InstallReceiver:用於監控安裝作業並取得最終狀態的 InstallReceiver。 |
maxTimeout |
long:指令傳回的逾時時間上限。如果值為 0,表示不會套用逾時上限。 |
maxTimeToOutputResponse |
long:指令在沒有任何回應的情況下,允許的最長時間。如果值為 0,方法會無限期等待指令輸出內容 (直到 receiver 取消執行),且絕不會擲回。 |
maxTimeUnits |
TimeUnit:非零 maxTimeout 和 maxTimeToOutputResponse
值的單位。 |
extraArgs |
String:要傳遞的選用額外引數。如要瞭解可用選項,請參閱「adb shell pm install --help」。 |
| 擲回 | |
|---|---|
InstallException |
|
installPackage
public void installPackage (String packageFilePath,
boolean reinstall,
InstallReceiver receiver,
String... extraArgs)在裝置上安裝 Android 應用程式。這是輔助方法,可合併 syncPackageToDevice、installRemotePackage 和 removePackage 步驟
| 參數 | |
|---|---|
packageFilePath |
String:本機主機上要安裝的檔案的絕對檔案系統路徑 |
reinstall |
boolean:如果應重新安裝應用程式,請設為 true |
receiver |
InstallReceiver:用於監控安裝作業並取得最終狀態的 InstallReceiver。 |
extraArgs |
String:要傳遞的選用額外引數。如要瞭解可用選項,請參閱「adb shell pm install --help」。 |
| 擲回 | |
|---|---|
InstallException |
|
installPackage
public void installPackage (String packageFilePath,
boolean reinstall,
String... extraArgs)在裝置上安裝 Android 應用程式。這是輔助方法,可合併 syncPackageToDevice、installRemotePackage 和 removePackage 步驟
| 參數 | |
|---|---|
packageFilePath |
String:本機主機上要安裝的檔案的絕對檔案系統路徑 |
reinstall |
boolean:如果應重新安裝應用程式,請設為 true |
extraArgs |
String:要傳遞的選用額外引數。如要瞭解可用選項,請參閱「adb shell pm install --help」。 |
| 擲回 | |
|---|---|
InstallException |
|
installPackages
public void installPackages (apkFilePaths, boolean reinstall, extraArgs, long timeOutInMs, TimeUnit timeunit)
安裝由多個 APK 檔案組成的 Android 應用程式 (一個主要套件和 0..n 個分割套件)
| 參數 | |
|---|---|
apkFilePaths |
:要安裝的 APK 清單 (1 個主要 APK + 0 到 n 個分割 APK) |
reinstall |
boolean:如果應重新安裝應用程式,請設為 true |
extraArgs |
:要傳遞的選用額外引數。如要瞭解可用選項,請參閱「adb shell pm install --help」。 |
timeOutInMs |
long:安裝逾時 |
timeunit |
TimeUnit:與逾時參數對應的 ERROR(/TimeUnit) |
| 擲回 | |
|---|---|
InstallException |
|
installRemotePackage
public void installRemotePackage (String remoteFilePath,
boolean reinstall,
InstallReceiver receiver,
String... extraArgs)安裝已推送至裝置暫時位置的應用程式套件。
| 參數 | |
|---|---|
remoteFilePath |
String:裝置上套件檔案的絕對檔案路徑 |
reinstall |
boolean:如果應重新安裝應用程式,請設為 true |
receiver |
InstallReceiver:用於監控安裝作業並取得最終狀態的 InstallReceiver。 |
extraArgs |
String:要傳遞的選用額外引數。如要瞭解可用選項,請參閱「adb shell pm install --help」。 |
| 擲回 | |
|---|---|
InstallException |
|
installRemotePackage
public void installRemotePackage (String remoteFilePath,
boolean reinstall,
String... extraArgs)安裝已推送至裝置暫時位置的應用程式套件。
| 參數 | |
|---|---|
remoteFilePath |
String:裝置上套件檔案的絕對檔案路徑 |
reinstall |
boolean:如果應重新安裝應用程式,請設為 true |
extraArgs |
String:要傳遞的選用額外引數。如要瞭解可用選項,請參閱「adb shell pm install --help」。 |
| 擲回 | |
|---|---|
InstallException |
|
installRemotePackage
public void installRemotePackage (String remoteFilePath,
boolean reinstall,
InstallReceiver receiver,
long maxTimeout,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits,
String... extraArgs)安裝已推送至裝置暫時位置的應用程式套件。
| 參數 | |
|---|---|
remoteFilePath |
String:裝置上套件檔案的絕對檔案路徑 |
reinstall |
boolean:如果應重新安裝應用程式,請設為 true |
receiver |
InstallReceiver:用於監控安裝作業並取得最終狀態的 InstallReceiver。 |
maxTimeout |
long:指令傳回的逾時時間上限。如果值為 0,表示不會套用逾時上限。 |
maxTimeToOutputResponse |
long:指令在沒有任何回應的情況下,允許的最長時間。如果值為 0,方法會無限期等待指令輸出內容 (直到 receiver 取消執行),且絕不會擲回。 |
maxTimeUnits |
TimeUnit:非零 maxTimeout 和 maxTimeToOutputResponse
值的單位。 |
extraArgs |
String:要傳遞的選用額外引數。如要瞭解可用選項,請參閱「adb shell pm install --help」。 |
| 擲回 | |
|---|---|
InstallException |
|
isBootLoader
public boolean isBootLoader ()
傳回裝置是否處於系統啟動載入程式模式。
| 傳回 | |
|---|---|
boolean |
如果 getState() 傳回 DeviceState.BOOTLOADER,則為 true。 |
isEmulator
public boolean isEmulator ()
如果裝置是模擬器,則傳回 true。
| 傳回 | |
|---|---|
boolean |
|
isOffline
public boolean isOffline ()
傳回裝置是否離線。
| 傳回 | |
|---|---|
boolean |
如果 getState() 傳回 DeviceState.OFFLINE,則為 true。 |
isOnline
public boolean isOnline ()
傳回裝置是否已準備就緒。
| 傳回 | |
|---|---|
boolean |
如果 getState() 傳回 DeviceState.ONLINE,則為 true。 |
isRoot
public boolean isRoot ()
查詢裝置目前的 Root 狀態。詳情請參閱「adb root」。
| 傳回 | |
|---|---|
boolean |
如果 adb daemon 以根身分執行,則為 true,否則為 false。 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
pullFile
public void pullFile (String remote,
String local)提取單一檔案。
| 參數 | |
|---|---|
remote |
String:遠端檔案的完整路徑 |
local |
String:當地目的地。 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
SyncException |
|
TimeoutException |
|
pushFile
public void pushFile (String local,
String remote)推送單一檔案。
| 參數 | |
|---|---|
local |
String:本機檔案路徑。 |
remote |
String:遠端檔案路徑 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
SyncException |
|
TimeoutException |
|
重開。
public void reboot (String into)
重新啟動裝置。
| 參數 | |
|---|---|
into |
String:要重新啟動的開機載入程式名稱,或設為空值以重新啟動裝置。 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
removeForward
public void removeForward (int localPort)
移除本機通訊埠與遠端通訊埠之間的通訊埠轉送。
| 參數 | |
|---|---|
localPort |
int:要轉送的本機通訊埠 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
removeForward
public void removeForward (int localPort,
int remotePort)| 參數 | |
|---|---|
localPort |
int |
remotePort |
int |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
removeForward
public void removeForward (int localPort,
String remoteSocketName,
IDevice.DeviceUnixSocketNamespace namespace)| 參數 | |
|---|---|
localPort |
int |
remoteSocketName |
String |
namespace |
IDevice.DeviceUnixSocketNamespace |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
removeRemotePackage
public void removeRemotePackage (String remoteFilePath)
從裝置中移除檔案。
| 參數 | |
|---|---|
remoteFilePath |
String:要移除的檔案在裝置上的路徑 |
| 擲回 | |
|---|---|
InstallException |
|
removeReverse
public void removeReverse (int remotePort)
移除遠端通訊埠與本機通訊埠之間的通訊埠反向。
| 參數 | |
|---|---|
remotePort |
int:遠端通訊埠。 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
TimeoutException |
|
根
public boolean root ()
要求 adb daemon 在裝置上成為根使用者。這項作業可能會無聲無息地失敗,而且只能在開發人員建構版本中成功。詳情請參閱「adb root」。
| 傳回 | |
|---|---|
boolean |
如果 adb daemon 以根身分執行,則為 true,否則為 false。 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
setSerial
public void setSerial (String serial)
| 參數 | |
|---|---|
serial |
String |
startScreenRecorder
public void startScreenRecorder (String remoteFilePath,
ScreenRecorderOptions options,
IShellOutputReceiver receiver)如果裝置支援 IDevice.Feature.SCREEN_RECORD,系統就會在裝置上啟動螢幕錄影功能。
| 參數 | |
|---|---|
remoteFilePath |
String |
options |
ScreenRecorderOptions |
receiver |
IShellOutputReceiver |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
ShellCommandUnresponsiveException |
|
TimeoutException |
|
supportsFeature
public boolean supportsFeature (IDevice.HardwareFeature arg0)
傳回這部裝置是否支援指定的硬體功能。
| 參數 | |
|---|---|
arg0 |
IDevice.HardwareFeature |
| 傳回 | |
|---|---|
boolean |
|
supportsFeature
public boolean supportsFeature (IDevice.Feature feature)
傳回這部裝置是否支援指定軟體功能。
| 參數 | |
|---|---|
feature |
IDevice.Feature |
| 傳回 | |
|---|---|
boolean |
|
syncPackageToDevice
public String syncPackageToDevice (String localFilePath)
將檔案推送至裝置
| 參數 | |
|---|---|
localFilePath |
String:本機主機上檔案的絕對路徑 |
| 傳回 | |
|---|---|
String |
String 裝置上的檔案目的地路徑 |
| 擲回 | |
|---|---|
AdbCommandRejectedException |
|
SyncException |
|
TimeoutException |
|
uninstallApp
public String uninstallApp (String applicationID,
String... extraArgs)從裝置解除安裝應用程式。
| 參數 | |
|---|---|
applicationID |
String:要解除安裝的 Android 應用程式 ID |
extraArgs |
String:要傳遞的選用額外引數。如要瞭解可用選項,請參閱「adb shell pm install --help」。 |
| 傳回 | |
|---|---|
String |
如果成功,則為 null;如果失敗,則為含有錯誤代碼的 String。 |
| 擲回 | |
|---|---|
InstallException |
|
uninstallPackage
public String uninstallPackage (String packageName)
從裝置解除安裝套件。
| 參數 | |
|---|---|
packageName |
String:要解除安裝的 Android 應用程式 ID |
| 傳回 | |
|---|---|
String |
如果成功,則為 null;如果失敗,則為含有錯誤代碼的 String。 |
| 擲回 | |
|---|---|
InstallException |
|