Google is committed to advancing racial equity for Black communities. See how.

LogcatEventParser

public class LogcatEventParser
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.LogcatEventParser


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 LogcatEventParser.LogcatEvent

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

Public constructors

LogcatEventParser(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, com.android.tradefed.util.LogcatEventType)) to the event queue.

LogcatEventParser.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 start()

Start listening to logcat and parsing events.

LogcatEventParser.LogcatEvent waitForEvent(long timeoutMs)

Blocks until it receives an event.

Public constructors

LogcatEventParser

public LogcatEventParser (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, com.android.tradefed.util.LogcatEventType)) to the event queue.

Parameters
lines String

pollForEvent

public LogcatEventParser.LogcatEvent pollForEvent ()

Polls the event queue. Returns immediately.

Returns
LogcatEventParser.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

start

public void start ()

Start listening to logcat and parsing events.

waitForEvent

public LogcatEventParser.LogcatEvent waitForEvent (long timeoutMs)

Blocks until it receives an event.

Parameters
timeoutMs long: Time to wait in milliseconds

Returns
LogcatEventParser.LogcatEvent The event or null if the timeout is reached