# Path: android_env/components/simulators/emulator/emulator_launcher.py
# _GRPC_KEEPALIVE_MS = 100000
# class EmulatorLauncher():
#   def __init__(
#       self,
#       local_tmp_dir: str = '/tmp',
#       adb_port: Optional[int] = None,
#       adb_server_port: Optional[int] = None,
#       emulator_console_port: Optional[int] = None,
#       grpc_port: int = -1,
#       emulator_path: str = '',
#       android_sdk_root: str = '',
#       avd_name: str = '',
#       run_headless: bool = False,
#       kvm_device: str = '/dev/kvm',
#       gpu_mode: str = 'swiftshader_indirect',
#       android_avd_home: str = '',
#       startup_wait_time_sec: int = 300,
#   ):
#   def launch(self) -> None:
#   def restart(self) -> None:
#   def create_emulator_stub(
#       cls,
#       grpc_port: int,
#       use_async: bool = False,
#   ) -> emulator_controller_pb2_grpc.EmulatorControllerStub:
#   def get_emulator_stub(
#       self) -> emulator_controller_pb2_grpc.EmulatorControllerStub:
#   def _kill_emulator_process(self) -> None:
#   def close(self):
#   def __del__(self):


import builtins
import os
import subprocess
import grpc
import mock
from absl.testing import absltest
from android_env.components.simulators.emulator import emulator_launcher
        '-gpu', 'swiftshader_indirect',
        '-no-audio',
        '-verbose',
        '-avd', self._avd_name,
    ]
    self._ports = ['-ports', f'{self._emulator_console_port},{self._adb_port}']

    base_lib_dir = self._emulator_path[:-8] + 'lib64/'
    ld_library_path = ':'.join([
        base_lib_dir + 'x11/',
        base_lib_dir + 'qt/lib/',
        base_lib_dir + 'gles_swiftshader/',
        base_lib_dir
    ])

    self._expected_env_vars = {
        'ANDROID_HOME': '',
        'ANDROID_SDK_ROOT': '',
        'ANDROID_AVD_HOME': '',
        'ANDROID_EMULATOR_KVM_DEVICE': '/dev/kvm',
        'ANDROID_ADB_SERVER_PORT': '1234',
        'LD_LIBRARY_PATH': ld_library_path,
        'QT_DEBUG_PLUGINS': '1',
        'QT_XKB_CONFIG_ROOT': str(self._emulator_path[:-8] + 'qt_config/'),
    }

  @mock.patch.object(os, 'environ', autospec=True, return_value=dict())
  def test_launch(self, os_environ):
    del os_environ


# Path: android_env/components/simulators/emulator/emulator_launcher.py
# _GRPC_KEEPALIVE_MS = 100000
# class EmulatorLauncher():
#   def __init__(
#       self,
#       local_tmp_dir: str = '/tmp',
#       adb_port: Optional[int] = None,
#       adb_server_port: Optional[int] = None,
#       emulator_console_port: Optional[int] = None,
#       grpc_port: int = -1,
#       emulator_path: str = '',
#       android_sdk_root: str = '',
#       avd_name: str = '',
#       run_headless: bool = False,
#       kvm_device: str = '/dev/kvm',
#       gpu_mode: str = 'swiftshader_indirect',
#       android_avd_home: str = '',
#       startup_wait_time_sec: int = 300,
#   ):
#   def launch(self) -> None:
#   def restart(self) -> None:
#   def create_emulator_stub(
#       cls,
#       grpc_port: int,
#       use_async: bool = False,
#   ) -> emulator_controller_pb2_grpc.EmulatorControllerStub:
#   def get_emulator_stub(
#       self) -> emulator_controller_pb2_grpc.EmulatorControllerStub:
#   def _kill_emulator_process(self) -> None:
#   def close(self):
#   def __del__(self):


# Path: android_env/components/simulators/emulator/emulator_launcher_test.py
import builtins
import os
import subprocess
import grpc
import mock
from absl.testing import absltest
from android_env.components.simulators.emulator import emulator_launcher

        '-gpu', 'swiftshader_indirect',
        '-no-audio',
        '-verbose',
        '-avd', self._avd_name,
    ]
    self._ports = ['-ports', f'{self._emulator_console_port},{self._adb_port}']

    base_lib_dir = self._emulator_path[:-8] + 'lib64/'
    ld_library_path = ':'.join([
        base_lib_dir + 'x11/',
        base_lib_dir + 'qt/lib/',
        base_lib_dir + 'gles_swiftshader/',
        base_lib_dir
    ])

    self._expected_env_vars = {
        'ANDROID_HOME': '',
        'ANDROID_SDK_ROOT': '',
        'ANDROID_AVD_HOME': '',
        'ANDROID_EMULATOR_KVM_DEVICE': '/dev/kvm',
        'ANDROID_ADB_SERVER_PORT': '1234',
        'LD_LIBRARY_PATH': ld_library_path,
        'QT_DEBUG_PLUGINS': '1',
        'QT_XKB_CONFIG_ROOT': str(self._emulator_path[:-8] + 'qt_config/'),
    }

  @mock.patch.object(os, 'environ', autospec=True, return_value=dict())
  def test_launch(self, os_environ):
    del os_environ


    launcher = emulator_launcher.EmulatorLauncher(