GenericLogcatEventParser
public
class
GenericLogcatEventParser
extends Object
java.lang.Object | |
↳ | com.android.tradefed.util.GenericLogcatEventParser<LogcatEventType> |
解析事件的 Logcat 输入。
此类会解读 Logcat 消息,并可以以阻塞和轮询方式通知监听器事件。
摘要
嵌套类 | |
---|---|
class |
GenericLogcatEventParser.LogcatEvent
用于存储包含事件类型和触发 logcat 消息的 logcat 事件的结构体 |
公共构造函数 | |
---|---|
GenericLogcatEventParser(ITestDevice device)
实例化新的 LogcatEventParser |
公共方法 | |
---|---|
void
|
close()
停止监听 Logcat。 |
void
|
parseEvents(String[] lines)
解析 Logcat 行,并将所有捕获的事件(已通过 |
GenericLogcatEventParser.LogcatEvent
|
pollForEvent()
轮询事件队列。 |
void
|
registerEventTrigger(String tag, String msg, LogcatEventType response)
注册给定 Logcat 标记和消息的事件,并提供所需的响应。 |
void
|
registerEventTrigger(Log.LogLevel logLevel, String tag, String msg, LogcatEventType response)
注册具有给定 Logcat 级别、标记和消息的事件,并提供所需的响应。 |
void
|
start()
开始监听 Logcat 并解析事件。 |
GenericLogcatEventParser.LogcatEvent
|
waitForEvent(long timeoutMs)
会阻塞,直到收到事件。 |
公共构造函数
GenericLogcatEventParser
public GenericLogcatEventParser (ITestDevice device)
实例化新的 LogcatEventParser
参数 | |
---|---|
device |
ITestDevice :用于从中读取 logcat |
公共方法
关闭
public void close ()
停止监听 logcat。
parseEvents
public void parseEvents (String[] lines)
解析 Logcat 行,并将所有捕获的事件(已通过 registerEventTrigger(String, String, LogcatEventType)
注册)添加到事件队列。
参数 | |
---|---|
lines |
String |
pollForEvent
public GenericLogcatEventParser.LogcatEvent pollForEvent ()
轮询事件队列。立即返回。
返回 | |
---|---|
GenericLogcatEventParser.LogcatEvent |
事件或 null (如果找不到匹配的事件) |
registerEventTrigger
public void registerEventTrigger (String tag, String msg, LogcatEventType response)
注册给定 Logcat 标记和消息的事件,并提供所需的响应。消息可能只有部分内容。
参数 | |
---|---|
tag |
String |
msg |
String |
response |
LogcatEventType |
registerEventTrigger
public void registerEventTrigger (Log.LogLevel logLevel, String tag, String msg, LogcatEventType response)
注册具有给定 Logcat 级别、标记和消息的事件,并提供所需的响应。消息可能会是部分内容。
参数 | |
---|---|
logLevel |
Log.LogLevel |
tag |
String |
msg |
String |
response |
LogcatEventType |
start
public void start ()
开始监听 Logcat 并解析事件。
waitForEvent
public GenericLogcatEventParser.LogcatEvent waitForEvent (long timeoutMs)
会阻塞,直到收到事件。
参数 | |
---|---|
timeoutMs |
long :等待时间(以毫秒为单位) |
返回 | |
---|---|
GenericLogcatEventParser.LogcatEvent |
事件或 null (如果超时) |