DeviceManager

public class DeviceManager
extends Object implements IDeviceManager

java.lang.Object
   ↳ com.android.tradefed.device.DeviceManager


概要

ネストされたクラス

class DeviceManager.FastbootDevice

Fastboot モードのデバイスの表現。 

定数

String UNKNOWN_DISPLAY_STRING

不明なプロパティの表示文字列

フィールド

protected DeviceMonitorMultiplexer mDvcMon

protected boolean mFastbootEnabled

パブリック コンストラクタ

DeviceManager()

DeviceManager は GlobalConfiguration から取得する必要があります。

パブリック メソッド

void addAvailableDevice(IDevice stubDevice)
void addAvailableNativeDevice(IDevice stubDevice)
void addDeviceMonitor(IDeviceMonitor mon)

IDeviceMonitor を追加します。

void addFastbootDevice(DeviceManager.FastbootDevice fastbootDevice)
void addFastbootListener(IDeviceManager.IFastbootListener listener)

リスナーが fastboot 状態の変更に関心があることをマネージャーに通知します。

void addMonitoringTcpFastbootDevice(String serial, String fastbootSerial)

fastboot モニターにデバイスを追加します。

ITestDevice allocateDevice(IDeviceSelection options, boolean isTemporary)

特定の条件を満たすテスト用のデバイスをリクエストします。

ITestDevice allocateDevice(IDeviceSelection options)

特定の条件を満たすテスト用のデバイスをリクエストします。

ITestDevice allocateDevice()

テスト用の実機をリクエストする

ITestDevice connectToTcpDevice(String ipAndPort)

adb-over-tcp でデバイスに接続する

このメソッドは新しいデバイスを割り当てます。このデバイスは最終的に disconnectFromTcpDevice(com.android.tradefed.device.ITestDevice) を介して解放される必要があります。

返された ITestDevice はオンラインになりますが、応答しない可能性があります。

boolean disconnectFromTcpDevice(ITestDevice tcpDevice)

adb-over-tcp で接続されたデバイスとの接続を解除します。

void displayDevicesInfo(PrintWriter stream, boolean includeStub)

既知のデバイスのリスト、その状態、よく使用される IDeviceSelection オプションの値を含む、わかりやすい説明を出力します。

CommandResult executeCmdOnAvailableDevice(String serial, String command, long timeout, TimeUnit timeUnit)

利用可能なデバイスでシェルコマンドを実行するヘルパー メソッド。

String executeGlobalAdbCommand(String... cmdArgs)

特定のデバイスを対象としない adb コマンドを実行します(例:

ITestDevice forceAllocateDevice(String serial)

現在利用できないデバイスでも、強引に割り当てます。

void freeDevice(ITestDevice device, FreeDeviceState deviceState)

デバイスをプールに戻す

以前に割り当てられていないデバイスを返そうとしても無視されます。

String getAdbPath()

使用する adb バイナリへのパスを返します。

String getAdbVersion()

デバイス マネージャーが現在使用している adb バージョンを取得します。

DeviceDescriptor getDeviceDescriptor(String serial)

指定されたシリアル番号の DeviceDescriptor を返します。

String getFastbootPath()

使用する fastboot バイナリへのパスを返します。

void init(IDeviceSelection globalDeviceFilter, globalDeviceMonitors, IManagedTestDeviceFactory deviceFactory)

デバイス マネージャーを初期化します。

void init(IDeviceSelection globalDeviceFilter, globalDeviceMonitors)

デバイス マネージャーを初期化します。

void init()

デバイス マネージャーを初期化します。

boolean isEmulator(String serial)

指定されたシリアル番号がエミュレータを表すかどうかを判断します。

boolean isFileSystemMountCheckEnabled()

ファイル システムが正しくマウントされているかどうかを NativeDeviceStateMonitor で確認する必要があるかどうかを返します。

boolean isNullDevice(String serial)

指定されたシリアルが null デバイスを表すかどうかを判断します。

void killEmulator(ITestDevice device)

指定されたエミュレータをシャットダウンします。

void launchEmulator(ITestDevice device, long bootTimeout, IRunUtil runUtil, emulatorArgs)

エミュレータを起動するヘルパー メソッド。

listAllDevices(boolean shortDescriptor)

既知のすべてのデバイスの DeviceDescriptor のリストを返します。

listAllDevices()

既知のすべてのデバイスの DeviceDescriptor のリストを返します。

ITestDevice reconnectDeviceToTcp(ITestDevice usbDevice)

指定された USB デバイスを adb-over-tcp モードに切り替え、connectToTcpDevice(String) を介して接続するヘルパー メソッド。

void removeDeviceMonitor(IDeviceMonitor mon)

以前に追加された IDeviceMonitor を削除します。

void removeFastbootListener(IDeviceManager.IFastbootListener listener)

リスナーが fastboot 状態の変更に関心を持たなくなったことをマネージャーに通知します。

void removeMonitoringTcpFastbootDevice(String serial)

void restartAdbBridge()

adb ブリッジとサービスは、adb 接続に依存するため、再起動します(stopAdbBridge() が呼び出された場合)。

void stopAdbBridge()

adb ブリッジと adb 接続に依存するサービスを停止します。

void terminate()

デバイス モニタリング サービスを停止し、ddm ライブラリを終了します。

void terminateDeviceMonitor()

デバイス モニターを停止します。

void terminateDeviceRecovery()

デバイス復元スレッドを停止します。

void terminateHard(String reason)

terminateHard() に類似。

void terminateHard()

terminate() と同様ですが、adb の強制シャットダウンも試みます。

boolean waitForFirstDeviceAdded(long timeout)

最初の物理デバイスが接続されるまで待機します。

定数

UNKNOWN_DISPLAY_STRING

public static final String UNKNOWN_DISPLAY_STRING

不明なプロパティの表示文字列

定数値: "unknown"

フィールド

mDvcMon

protected DeviceMonitorMultiplexer mDvcMon

mFastbootEnabled

protected boolean mFastbootEnabled

パブリック コンストラクタ

DeviceManager

public DeviceManager ()

DeviceManager は GlobalConfiguration から取得する必要があります

パブリック メソッド

addAvailableDevice

public void addAvailableDevice (IDevice stubDevice)

パラメータ
stubDevice IDevice

addAvailableNativeDevice

public void addAvailableNativeDevice (IDevice stubDevice)

パラメータ
stubDevice IDevice

addDeviceMonitor

public void addDeviceMonitor (IDeviceMonitor mon)

IDeviceMonitor を追加

パラメータ
mon IDeviceMonitor

addFastbootDevice

public void addFastbootDevice (DeviceManager.FastbootDevice fastbootDevice)

パラメータ
fastbootDevice DeviceManager.FastbootDevice

addFastbootListener

public void addFastbootListener (IDeviceManager.IFastbootListener listener)

リスナーが fastboot 状態の変更に関心があることをマネージャーに通知します。

現在、IDeviceManager は、1 つ以上のアクティブなリスナーがある場合にのみ、fastboot のデバイスをモニタリングします。

TODO: これはハックです。より良い解決策を見つけてください

addMonitoringTcpFastbootDevice

public void addMonitoringTcpFastbootDevice (String serial, 
                String fastbootSerial)

fastboot モニターにデバイスを追加します。fastboot モニターは、デバイスとの通信に「fastboot_serial」を使用します。

パラメータ
serial String: デバイスのシリアル番号。

fastbootSerial String: デバイスの fastboot モードのシリアル番号。

allocateDevice

public ITestDevice allocateDevice (IDeviceSelection options, 
                boolean isTemporary)

特定の条件を満たすテスト用デバイスをリクエストします。

パラメータ
options IDeviceSelection: デバイスが満たすべき IDeviceSelection

isTemporary boolean: 一時的な NullDevice を作成するかどうか。

戻り値
ITestDevice テスト用の ITestDevice。利用できない場合は null

allocateDevice

public ITestDevice allocateDevice (IDeviceSelection options)

特定の条件を満たすテスト用デバイスをリクエストします。

パラメータ
options IDeviceSelection: デバイスが満たすべき IDeviceSelection

戻り値
ITestDevice テスト用の ITestDevice。利用できない場合は null

allocateDevice

public ITestDevice allocateDevice ()

テスト用の実機をリクエストする

戻り値
ITestDevice テスト用の ITestDevice。利用できない場合は null

connectToTcpDevice

public ITestDevice connectToTcpDevice (String ipAndPort)

adb-over-tcp でデバイスに接続する

このメソッドは新しいデバイスを割り当てます。このデバイスは最終的に disconnectFromTcpDevice(com.android.tradefed.device.ITestDevice) を介して解放される必要があります。

返された ITestDevice はオンラインになりますが、応答しない場合があります。

tcp 接続されたデバイスで再起動などのアクションを実行すると、デバイスへの tcp 接続が切断され、DeviceNotAvailableException が発生します。

パラメータ
ipAndPort String: 接続するデバイスの元の IP アドレスとポート

戻り値
ITestDevice tcp 接続を確立できなかった場合は ITestDevice または null

disconnectFromTcpDevice

public boolean disconnectFromTcpDevice (ITestDevice tcpDevice)

adb-over-tcp で接続されたデバイスとの接続を解除します。

デバイスを USB モードに戻し、解放します。

パラメータ
tcpDevice ITestDevice: 現在 tcp モードのデバイス。以前に connectToTcpDevice(String) で割り当てられた

戻り値
boolean USB モードへの切り替えが成功した場合は true

displayDevicesInfo

public void displayDevicesInfo (PrintWriter stream, 
                boolean includeStub)

既知のデバイスのリスト、その状態、よく使用される IDeviceSelection オプションの値を含む、ユーザーフレンドリーな説明を出力します。

パラメータ
stream PrintWriter: 説明を出力する ERROR(/PrintWriter)

includeStub boolean: スタブ デバイスも表示するかどうか。

executeCmdOnAvailableDevice

public CommandResult executeCmdOnAvailableDevice (String serial, 
                String command, 
                long timeout, 
                TimeUnit timeUnit)

利用可能なデバイスでシェルコマンドを実行するヘルパー メソッド。

パラメータ
serial String: デバイスのシリアル番号。

command String: シェルコマンド。

timeout long: コマンドが完了するまでの時間。

timeUnit TimeUnit: タイムアウトの単位。

戻り値
CommandResult CommandResult

executeGlobalAdbCommand

public String executeGlobalAdbCommand (String... cmdArgs)

特定のデバイスを対象としない adb コマンドを実行します(例: 「adb connect」

戻り値
String コマンドが成功した場合は標準出力、それ以外の場合は null。

forceAllocateDevice

public ITestDevice forceAllocateDevice (String serial)

現在利用できないデバイスでも、強引に割り当てます。

デバイスがすでに割り当てられている場合、効果はありません。

パラメータ
serial String: 割り当てるデバイスのシリアル番号

戻り値
ITestDevice ITestDevice。割り当てられなかった場合は null

freeDevice

public void freeDevice (ITestDevice device, 
                FreeDeviceState deviceState)

デバイスをプールに戻す

以前に割り当てられていないデバイスを返そうとしても、無視されます。

パラメータ
device ITestDevice: 解放する ITestDevice

deviceState FreeDeviceState: FreeDeviceState。デバイスが利用可能なデバイス プールに戻されるかどうかを制御するために使用されます。

getAdbPath

public String getAdbPath ()

使用する adb バイナリへのパスを返します。

戻り値
String

getAdbVersion

public String getAdbVersion ()

デバイス マネージャーが現在使用している adb のバージョンを取得します。

戻り値
String

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor (String serial)

指定されたシリアル番号の DeviceDescriptor を返します。

パラメータ
serial String: 取得するデバイスのシリアル番号

戻り値
DeviceDescriptor 選択したデバイスの DeviceDescriptor。シリアル番号が既知のデバイスと一致しない場合は null。

getFastbootPath

public String getFastbootPath ()

使用する fastboot バイナリへのパスを返します。

戻り値
String

init

public void init (IDeviceSelection globalDeviceFilter, 
                 globalDeviceMonitors, 
                IManagedTestDeviceFactory deviceFactory)

デバイス マネージャーを初期化します。このメソッドは、他のメソッドが呼び出される前に 1 回だけ呼び出す必要があります。

パラメータ
globalDeviceFilter IDeviceSelection

globalDeviceMonitors

deviceFactory IManagedTestDeviceFactory

init

public void init (IDeviceSelection globalDeviceFilter, 
                 globalDeviceMonitors)

デバイス マネージャーを初期化します。このメソッドは、他のメソッドが呼び出される前に 1 回だけ呼び出す必要があります。

パラメータ
globalDeviceFilter IDeviceSelection: デバイス フィルタ

globalDeviceMonitors

init

public void init ()

デバイス マネージャーを初期化します。このメソッドは、他のメソッドが呼び出される前に一度だけ呼び出す必要があります。

isEmulator

public boolean isEmulator (String serial)

指定されたシリアル番号がエミュレータを表しているかどうかを判断します

パラメータ
serial String

戻り値
boolean

isFileSystemMountCheckEnabled

public boolean isFileSystemMountCheckEnabled ()

ファイル システムが正しくマウントされているかどうかを NativeDeviceStateMonitor で確認する必要があるかどうかを返します。

戻り値
boolean

isNullDevice

public boolean isNullDevice (String serial)

指定されたシリアルが null デバイスを表すかどうかを判断する

パラメータ
serial String

戻り値
boolean

killEmulator

public void killEmulator (ITestDevice device)

指定されたエミュレータをシャットダウンします。

エミュレータが adb から消えるまでブロックします。エミュレータがすでに使用できない場合、効果はありません。

パラメータ
device ITestDevice: シャットダウンするエミュレータを表す ITestDevice

例外
DeviceNotAvailableException

launchEmulator

public void launchEmulator (ITestDevice device, 
                long bootTimeout, 
                IRunUtil runUtil, 
                 emulatorArgs)

エミュレータを起動するヘルパー メソッド。

呼び出し元で指定されたエミュレータを起動します。

パラメータ
device ITestDevice: 割り当てられたエミュレータ デバイスを表すプレースホルダ ITestDevice

bootTimeout long: エミュレータの起動を待つ時間(ミリ秒単位)

emulatorArgs : エミュレータを起動するためのコマンドライン引数

例外
DeviceNotAvailableException

listAllDevices

public  listAllDevices (boolean shortDescriptor)

既知のすべてのデバイスの DeviceDescriptor のリストを返します

パラメータ
shortDescriptor boolean: ディスクリプタを最小限の情報に制限するかどうか

戻り値
既知のすべてのデバイスの DeviceDescriptor のリスト

listAllDevices

public  listAllDevices ()

既知のすべてのデバイスの DeviceDescriptor のリストを返します

戻り値
既知のすべてのデバイスの DeviceDescriptor のリスト

reconnectDeviceToTcp

public ITestDevice reconnectDeviceToTcp (ITestDevice usbDevice)

指定された USB デバイスを adb-over-tcp モードに切り替え、connectToTcpDevice(String) を介して接続するヘルパー メソッド。

パラメータ
usbDevice ITestDevice: 現在 USB モードのデバイス

戻り値
ITestDevice tcp モードで新しく割り当てられた ITestDevice。tcp 接続を確立できなかった場合は null

例外
DeviceNotAvailableException

removeDeviceMonitor

public void removeDeviceMonitor (IDeviceMonitor mon)

以前に追加された IDeviceMonitor を削除します。mon が追加されていない場合は効果がありません。

パラメータ
mon IDeviceMonitor

removeFastbootListener

public void removeFastbootListener (IDeviceManager.IFastbootListener listener)

リスナーが fastboot 状態の変更に関心がないことをマネージャーに通知します。

removeMonitoringTcpFastbootDevice

public void removeMonitoringTcpFastbootDevice (String serial)

パラメータ
serial String

restartAdbBridge

public void restartAdbBridge ()

adb ブリッジとサービスは adb 接続に依存するため、adb ブリッジとサービスを再起動します(stopAdbBridge() が呼び出された場合)。

stopAdbBridge

public void stopAdbBridge ()

adb ブリッジと adb 接続に依存するサービスを停止します。

おしまい 終了 終わり

public void terminate ()

デバイス モニタリング サービスを停止し、ddm ライブラリを終了します。

これは、アプリの終了時に呼び出す必要があります。

terminateDeviceMonitor

public void terminateDeviceMonitor ()

デバイス モニターを停止します。

terminateDeviceRecovery

public void terminateDeviceRecovery ()

デバイス復元スレッドを停止します。

terminateHard

public void terminateHard (String reason)

terminateHard() と同様です。

パラメータ
reason String: 終了の理由(省略可)。

terminateHard

public void terminateHard ()

terminate() と同様ですが、adb の強制シャットダウンも試みます。

waitForFirstDeviceAdded

public boolean waitForFirstDeviceAdded (long timeout)

最初の物理デバイスが接続されるまで待ちます。デバイスが以前に接続されていた場合は、直接 True を返します。デバイスが追加されなかった場合、タイムアウト後に false を返します。

パラメータ
timeout long: false を返すまでの待機時間(ミリ秒単位)。

戻り値
boolean