自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
LargeOutputReceiver
public
class
LargeOutputReceiver
extends Object
implements
IShellOutputReceiver
java.lang.Object
|
↳ |
com.android.tradefed.device.LargeOutputReceiver
|
一个类,旨在帮助运行长时间运行的命令收集输出。
tmp 文件的大小上限约为 maxFileSize
。为防止在达到上限时丢失数据,此文件会保留一组 tmp 主机文件。
摘要
公共构造函数
LargeOutputReceiver
public LargeOutputReceiver (String descriptor,
String serialNumber,
long maxDataSize)
创建 LargeOutputReceiver
。
参数 |
descriptor |
String :要运行的命令的描述符。仅用于日志记录。 |
serialNumber |
String :设备的序列号。仅用于日志记录。 |
maxDataSize |
long :要保留的大致数据量上限。 |
公共方法
addOutput
public void addOutput (byte[] data,
int offset,
int length)
参数 |
data |
byte |
offset |
int |
length |
int |
取消
public void cancel ()
取消命令。
清除
public void clear ()
删除当前累积的数据,然后重新创建新文件。
删除
public void delete ()
删除所有累积数据。
flush
public void flush ()
getData
public InputStreamSource getData ()
以 InputStreamSource
的形式获取收集的输出。
返回 |
InputStreamSource |
命令收集的输出。 |
getData
public InputStreamSource getData (int maxBytes)
将收集的输出的最后一个 maxBytes 作为 InputStreamSource
获取。
参数 |
maxBytes |
int :要返回的最大数据量。应为能轻松放入内存的数量 |
返回 |
InputStreamSource |
命令收集的输出,存储在内存中
|
getData
public InputStreamSource getData (int maxBytes,
int offset)
将收集的输出的最后一个 maxBytes 作为 InputStreamSource
获取。
参数 |
maxBytes |
int :要返回的最大数据量。应为能轻松放入内存的数量 |
offset |
int :开始从缓冲区获取数据的时间偏移。 |
返回 |
InputStreamSource |
命令收集的输出,存储在内存中
|
isCancelled
public boolean isCancelled ()
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-07-26。"],[],[],null,["# LargeOutputReceiver\n===================\n\n\n`\npublic\n\n\nclass\nLargeOutputReceiver\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\nimplements\n\nIShellOutputReceiver\n\n\n`\n\n|---|-------------------------------------------------|\n| java.lang.Object ||\n| ↳ | com.android.tradefed.device.LargeOutputReceiver |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA class designed to help run long running commands collect output.\n\n\nThe maximum size of the tmp file is limited to approximately `maxFileSize`.\nTo prevent data loss when the limit has been reached, this file keeps set of tmp host\nfiles.\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| ### Public constructors ||\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[LargeOutputReceiver](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html#LargeOutputReceiver(java.lang.String,%20java.lang.String,%20long))`(String descriptor, String serialNumber, long maxDataSize) ` Creates a [LargeOutputReceiver](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html). |\n\n| ### Public methods ||\n|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` void` | ` `[addOutput](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html#addOutput(byte[],%20int,%20int))`(byte[] data, int offset, int length) ` |\n| ` void` | ` `[cancel](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html#cancel())`() ` Cancels the command. |\n| ` void` | ` `[clear](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html#clear())`() ` Delete currently accumulated data, and then re-create a new file. |\n| ` void` | ` `[delete](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html#delete())`() ` Delete all accumulated data. |\n| ` void` | ` `[flush](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html#flush())`() ` |\n| ` InputStreamSource` | ` `[getData](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html#getData())`() ` Gets the collected output as a [InputStreamSource](../../../../../../reference/tradefed/com/android/tradefed/result/InputStreamSource.html). |\n| ` InputStreamSource` | ` `[getData](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html#getData(int))`(int maxBytes) ` Gets the last \u003cvar translate=\"no\"\u003emaxBytes\u003c/var\u003e of collected output as a [InputStreamSource](../../../../../../reference/tradefed/com/android/tradefed/result/InputStreamSource.html). |\n| ` InputStreamSource` | ` `[getData](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html#getData(int,%20int))`(int maxBytes, int offset) ` Gets the last \u003cvar translate=\"no\"\u003emaxBytes\u003c/var\u003e of collected output as a [InputStreamSource](../../../../../../reference/tradefed/com/android/tradefed/result/InputStreamSource.html). |\n| ` boolean` | ` `[isCancelled](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html#isCancelled())`() ` |\n\nPublic constructors\n-------------------\n\n### LargeOutputReceiver\n\n```\npublic LargeOutputReceiver (String descriptor, \n String serialNumber, \n long maxDataSize)\n```\n\nCreates a [LargeOutputReceiver](../../../../../../reference/tradefed/com/android/tradefed/device/LargeOutputReceiver.html).\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------------|--------------------------------------------------------------------------|\n| `descriptor` | `String`: the descriptor of the command to run. For logging only. \u003cbr /\u003e |\n| `serialNumber` | `String`: the serial number of the device. For logging only. \u003cbr /\u003e |\n| `maxDataSize` | `long`: the approximate max amount of data to keep. \u003cbr /\u003e |\n\nPublic methods\n--------------\n\n### addOutput\n\n```\npublic void addOutput (byte[] data, \n int offset, \n int length)\n```\n\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------|---------------|\n| `data` | `byte` \u003cbr /\u003e |\n| `offset` | `int` \u003cbr /\u003e |\n| `length` | `int` \u003cbr /\u003e |\n\n### cancel\n\n```\npublic void cancel ()\n```\n\nCancels the command.\n\n\u003cbr /\u003e\n\n### clear\n\n```\npublic void clear ()\n```\n\nDelete currently accumulated data, and then re-create a new file.\n\n\u003cbr /\u003e\n\n### delete\n\n```\npublic void delete ()\n```\n\nDelete all accumulated data.\n\n\u003cbr /\u003e\n\n### flush\n\n```\npublic void flush ()\n```\n\n\n\u003cbr /\u003e\n\n### getData\n\n```\npublic InputStreamSource getData ()\n```\n\nGets the collected output as a [InputStreamSource](../../../../../../reference/tradefed/com/android/tradefed/result/InputStreamSource.html).\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------|-----------------------------------------------|\n| `InputStreamSource` | The collected output from the command. \u003cbr /\u003e |\n\n### getData\n\n```\npublic InputStreamSource getData (int maxBytes)\n```\n\nGets the last \u003cvar translate=\"no\"\u003emaxBytes\u003c/var\u003e of collected output as a [InputStreamSource](../../../../../../reference/tradefed/com/android/tradefed/result/InputStreamSource.html).\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|------------------------------------------------------------------------------------------------------------|\n| `maxBytes` | `int`: the maximum amount of data to return. Should be an amount that can comfortably fit in memory \u003cbr /\u003e |\n\n| Returns ||\n|---------------------|----------------------------------------------------------------|\n| `InputStreamSource` | The collected output from the command, stored in memory \u003cbr /\u003e |\n\n### getData\n\n```\npublic InputStreamSource getData (int maxBytes, \n int offset)\n```\n\nGets the last \u003cvar translate=\"no\"\u003emaxBytes\u003c/var\u003e of collected output as a [InputStreamSource](../../../../../../reference/tradefed/com/android/tradefed/result/InputStreamSource.html).\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|------------------------------------------------------------------------------------------------------------|\n| `maxBytes` | `int`: the maximum amount of data to return. Should be an amount that can comfortably fit in memory \u003cbr /\u003e |\n| `offset` | `int`: The offset of when to start getting the data from the buffer. \u003cbr /\u003e |\n\n| Returns ||\n|---------------------|----------------------------------------------------------------|\n| `InputStreamSource` | The collected output from the command, stored in memory \u003cbr /\u003e |\n\n### isCancelled\n\n```\npublic boolean isCancelled ()\n```\n\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------|--------|\n| `boolean` | \u003cbr /\u003e |"]]