2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
TF でデバイスと連携する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Trade Federation は、ITestDevice
という抽象化を使用してテストを実行します。この抽象化は、次のような特徴を持つ最大公約数的な Android デバイスを対象にしています。
- シリアル番号がある
- 状態が、オンライン、使用可能、リカバリ、または使用不可のいずれか
- 信頼性の概念がある。これは、たとえばコマンドを実行する場合、コマンドがまだ終了していないケース、コマンドの実行をデバイスがサポートしていないケース、コマンドの実行中にデバイスが応答しなくなったケースを区別できることを意味します。
デバイス クラス
ITestDevice
の 3 つの主な実装は、3 つの一般的なユースケースを表します。
物理デバイス
これは、USB または adb の TCP 機能のいずれかを使用して TF ホストマシンに接続されている実際のハードウェア機器です。TestDevice クラスは、adb に対する Java インターフェースである ddmlib ライブラリ上にあります。そのため、adb devices
にリストされている物理デバイスはすべてインスタンス化が可能で、TestDevice
として使用できます。
エミュレータ
エミュレータは別のプロセスに存在するため、TF によって特別に処理されます。エミュレータを操作するには、コマンドの --emulator
引数を指定します。詳細については、LocalSdkBuildProvider と SdkAvdPreparer をご覧ください。
デバイスなし
デバイスをまったく操作しないテストがあります。たとえば、あるサービスからファイルをダウンロードし、ファイル自体が有効かどうかを確認するだけの場合などです。NullDevice は、単なるスタブの ITestDevice
です。null-device-N
のようなシリアル番号を持ち、試行されるオペレーションのほとんどは、黙示的に何もしないか、例外をスローします。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# Work with devices in TF\n\nTrade Federation uses an abstraction called\n[ITestDevice](/reference/com/android/tradefed/device/ITestDevice) to\nrun tests. This abstraction objectifies the lowest-common-denominator Android device:\n\n- It has a serial number\n- It has a state: Online, Available, Recovery, or Not Available\n- It has some notion of reliability. For instance, if we run a command, we can differentiate between the case where the command hasn't finished yet, the case where the device doesn't support running commands, and the case where the device has become unresponsive while running the command.\n\nDevice classes\n--------------\n\nThe three primary implementations of `ITestDevice` represent three common\nusecases.\n\n### Physical device\n\nThis is an actual piece of hardware, connected to the TF host machine either by USB, or by using\nadb's TCP feature. The [TestDevice](/reference/com/android/tradefed/device/TestDevice) class sits atop the ddmlib library, which is a Java interface to adb. So any\nphysical device listed in `adb devices` can be instantiated and used as a\n`TestDevice`.\n\n### Emulator\n\nEmulators are handled specially by TF because they live in another process. To interact with an\nEmulator, specify the `--emulator` argument for the command. See\n[LocalSdkBuildProvider](/reference/com/android/tradefed/build/LocalSdkBuildProvider) and\n[SdkAvdPreparer](/reference/com/android/tradefed/targetprep/SdkAvdPreparer) for more info.\n\n### No device\n\nSuppose you have a test that doesn't interact with a device at all. For instance, it might just\ndownload a file from some service and verify that the file itself is valid. The\n[NullDevice](/reference/com/android/tradefed/device/NullDevice) is an `ITestDevice` that is just a stub. It has a serial number like\n`null-device-N`, and most attempted operations either no-op silently or throw."]]