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 行,並將任何已擷取的事件 (已透過 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)

會封鎖至收到事件為止。

公用建構函式

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 (如果已達到逾時期限)