def _KillAllEmulators():
  """Kill all running emulators that look like ones we started.

  There are odd 'sticky' cases where there can be no emulator process
  running but a device slot is taken.  A little bot trouble and and
  we're out of room forever.
  """
  emulators = android_commands.GetEmulators()
  if not emulators:
    return
  for emu_name in emulators:
    cmd_helper.GetCmdOutput(['adb', '-s', emu_name, 'emu', 'kill'])
  logging.info('Emulator killing is async; give a few seconds for all to die.')
  for i in range(5):
    if not android_commands.GetEmulators():
      return
    time.sleep(1)
Beispiel #2
0
def _GetAvailablePort():
    """Returns an available TCP port for the console."""
    used_ports = []
    emulators = android_commands.GetEmulators()
    for emulator in emulators:
        used_ports.append(emulator.split('-')[1])
    for port in PortPool.port_range():
        if str(port) not in used_ports:
            return port
Beispiel #3
0
def _GetAvailablePort():
    """Returns an available TCP port for the console."""
    used_ports = []
    emulators = android_commands.GetEmulators()
    for emulator in emulators:
        used_ports.append(emulator.split('-')[1])
    # The port must be an even number between 5554 and 5584.
    for port in range(5554, 5585, 2):
        if str(port) not in used_ports:
            return port