DeviceManager

public class DeviceManager
extends Object implements IDeviceManager

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


概要

ネストされたクラス

class DeviceManager.FastbootDevice

Fastboot モードのデバイスを表します。 

フィールド

public static final 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 fastboot_serial)

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 restartAdbBridge()

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

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

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

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 fastboot_serial)

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

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

fastboot_serial String: デバイスのファストブート モードのシリアル番号。

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 ITestDevice または null(TCP 接続を確立できなかった場合)

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: タイムアウトの単位。

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 ()

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

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

launchEmulator

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

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

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

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

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

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

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

removeDeviceMonitor

public void removeDeviceMonitor (IDeviceMonitor mon)

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

パラメータ
mon IDeviceMonitor

removeFastbootListener

public void removeFastbootListener (IDeviceManager.IFastbootListener listener)

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

restartAdbBridge

public void restartAdbBridge ()

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

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