Stay organized with collections Save and categorize content based on your preferences.

GenericLogcatEventParser

public class GenericLogcatEventParser
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.GenericLogcatEventParser<LogcatEventType>


Parse logcat input for events.

This class interprets logcat messages and can inform the listener of events in both a blocking and polling fashion.

Summary

Nested classes

class GenericLogcatEventParser.LogcatEvent

Struct to hold a logcat event with the event type and triggering logcat message  

Public constructors

GenericLogcatEventParser(ITestDevice device)

Instantiates a new LogcatEventParser

Public methods

void close()

Stop listening to logcat.

void parseEvents(String[] lines)

Parse logcat lines and add any captured events (that were registered with registerEventTrigger(String, String, LogcatEventType)) to the event queue.

LogcatEvent pollForEvent()

Polls the event queue.

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

Register an event of given logcat tag and message with the desired response.

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

Register an event of given logcat level, tag and message with the desired response.

void start()

Start listening to logcat and parsing events.

LogcatEvent waitForEvent(long timeoutMs)

Blocks until it receives an event.

Public constructors

GenericLogcatEventParser

public GenericLogcatEventParser (ITestDevice device)

Instantiates a new LogcatEventParser

Parameters
device ITestDevice: to read logcat from

Public methods

close

public void close ()

Stop listening to logcat.

parseEvents

public void parseEvents (String[] lines)

Parse logcat lines and add any captured events (that were registered with registerEventTrigger(String, String, LogcatEventType)) to the event queue.

Parameters
lines String

pollForEvent

public LogcatEvent pollForEvent ()

Polls the event queue. Returns immediately.

Returns
LogcatEvent The event or null if no matching event is found

registerEventTrigger

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

Register an event of given logcat tag and message with the desired response. Message may be partial.

Parameters
tag String

msg String

response LogcatEventType

registerEventTrigger

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

Register an event of given logcat level, tag and message with the desired response. Message may be partial.

Parameters
logLevel Log.LogLevel

tag String

msg String

response LogcatEventType

start

public void start ()

Start listening to logcat and parsing events.

waitForEvent

public LogcatEvent waitForEvent (long timeoutMs)

Blocks until it receives an event.

Parameters
timeoutMs long: Time to wait in milliseconds

Returns
LogcatEvent The event or null if the timeout is reached