# Path: android_env/components/log_stream.py
# class LogStream(metaclass=abc.ABCMeta):
#   def __init__(self, verbose: bool = False):
#   def get_stream_output(self):
#   def _get_stream_output(self):
#   def stop_stream(self):
#   def set_log_filters(self, log_filters: List[str]):
# 
# Path: android_env/components/thread_function.py
# class ThreadFunction(metaclass=abc.ABCMeta):
#   class Signal(enum.IntEnum):
#     KILL = 1
#   def __init__(self, block_input: bool, block_output: bool, name: str):
#   def read(self, block: bool = True, timeout: Optional[float] = None):
#   def write(self, value, block: bool = True, timeout: Optional[float] = None):
#   def main(self):
#   def kill(self):
#   def _run(self):
#   def _read_value(self):
#   def _write_value(self, value):


import re
import threading
from typing import Callable, Match, NamedTuple, Optional, Pattern
from absl import logging
from android_env.components import log_stream as log_stream_lib
from android_env.components import thread_function
from android_env.proto import task_pb2
    logline_re = re.compile(regexp, re.VERBOSE)

    for line in self._stdout:
      # We never hand back control to ThreadFunction._run() so we need to
      # explicitly check for self._should_run here.
      if not self._should_run:
        break

      if not line:  # Skip empty lines.
        continue

      # We're currently only consuming `message`, but we may use the other
      # fields in the future.
      matches = logline_re.match(line)
      if not matches or len(matches.groups()) != 6:
        continue

      content = matches.group('message')
      for ev, listeners in self._listeners.items():
        ev_matches = ev.match(content)
        if ev_matches:
          # Unblock consumers that may be waiting for events.
          if not self._thread_event.is_set():
            if self._desired_event:
              if self._desired_event == ev:
                self._thread_event.set()
            else:
              self._thread_event.set()

          # Notify listeners.

# Path: android_env/components/log_stream.py
# class LogStream(metaclass=abc.ABCMeta):
#   def __init__(self, verbose: bool = False):
#   def get_stream_output(self):
#   def _get_stream_output(self):
#   def stop_stream(self):
#   def set_log_filters(self, log_filters: List[str]):
# 
# Path: android_env/components/thread_function.py
# class ThreadFunction(metaclass=abc.ABCMeta):
#   class Signal(enum.IntEnum):
#     KILL = 1
#   def __init__(self, block_input: bool, block_output: bool, name: str):
#   def read(self, block: bool = True, timeout: Optional[float] = None):
#   def write(self, value, block: bool = True, timeout: Optional[float] = None):
#   def main(self):
#   def kill(self):
#   def _run(self):
#   def _read_value(self):
#   def _write_value(self, value):


# Path: android_env/components/logcat_thread.py
import re
import threading
from typing import Callable, Match, NamedTuple, Optional, Pattern
from absl import logging
from android_env.components import log_stream as log_stream_lib
from android_env.components import thread_function
from android_env.proto import task_pb2

    logline_re = re.compile(regexp, re.VERBOSE)

    for line in self._stdout:
      # We never hand back control to ThreadFunction._run() so we need to
      # explicitly check for self._should_run here.
      if not self._should_run:
        break

      if not line:  # Skip empty lines.
        continue

      # We're currently only consuming `message`, but we may use the other
      # fields in the future.
      matches = logline_re.match(line)
      if not matches or len(matches.groups()) != 6:
        continue

      content = matches.group('message')
      for ev, listeners in self._listeners.items():
        ev_matches = ev.match(content)
        if ev_matches:
          # Unblock consumers that may be waiting for events.
          if not self._thread_event.is_set():
            if self._desired_event:
              if self._desired_event == ev:
                self._thread_event.set()
            else:
              self._thread_event.set()

          # Notify listeners.

          for listener in listeners: