通用Logcat事件解析器

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 行並將任何捕獲的事件(使用registerEventTrigger(String, String, LogcatEventType)註冊的事件)新增至事件佇列。

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)

阻塞直到收到事件。

公共構造函數

通用Logcat事件解析器

public GenericLogcatEventParser (ITestDevice device)

實例化一個新的 LogcatEventParser

參數
device ITestDevice :從中讀取 logcat

公共方法

關閉

public void close ()

停止監聽 logcat。

解析事件

public void parseEvents (String[] lines)

解析 logcat 行並將任何捕獲的事件(使用registerEventTrigger(String, String, LogcatEventType)註冊的事件)新增至事件佇列。

參數
lines String

輪詢事件

public GenericLogcatEventParser.LogcatEvent pollForEvent ()

輪詢事件隊列。立即返回。

退貨
GenericLogcatEventParser.LogcatEvent如果沒有找到符合的事件,則該事件或null

註冊事件觸發器

public void registerEventTrigger (String tag, 
                String msg, 
                LogcatEventType response)

註冊給定 logcat 標記的事件和具有所需回應的訊息。訊息可能不完整。

參數
tag String

msg String

response LogcatEventType

註冊事件觸發器

public void registerEventTrigger (Log.LogLevel logLevel, 
                String tag, 
                String msg, 
                LogcatEventType response)

註冊給定 logcat 等級、標籤和訊息以及所需回應的事件。訊息可能不完整。

參數
logLevel Log.LogLevel

tag String

msg String

response LogcatEventType

開始

public void start ()

開始監聽logcat並解析事件。

等待事件

public GenericLogcatEventParser.LogcatEvent waitForEvent (long timeoutMs)

阻塞直到收到事件。

參數
timeoutMs long :等待時間(以毫秒為單位)

退貨
GenericLogcatEventParser.LogcatEvent如果達到超時,則該事件或null