def _RestartDevice()

in tools/android/emulator/unified_launcher.py [0:0]


def _RestartDevice(device,
                   enable_display,
                   start_vnc_on_port,
                   net_type,
                   system_image_files,
                   input_image_file,
                   proto_filepath,
                   new_process_group=False,
                   window_scale=None,
                   with_audio=False,
                   with_boot_anim=False,
                   emulator_tmp_dir=None,
                   open_gl_driver=None,
                   experimental_open_gl=False,
                   snapshot_file=None):
  """Restarts a emulated device from persisted images and snapshots.

  Args:
    device: an unstarted emulated_device.EmulatedDevice
    enable_display: if true emulator starts in display mode
    start_vnc_on_port: if a port is specified, starts vnc server at that port.
    net_type: the type of network to use while starting the emulator.
    system_image_files: list of system image files and other support files.
    input_image_file: a tar gz archive of the userdata dir.
    proto_filepath: (optional) a path to the emulator metadata proto.
    new_process_group: (optional) launches emulator in a new process group.
    window_scale: (optional) Scale factor of emulator window in percent.
    with_audio: (optional) indicates the emulator should turn on audio.
    with_boot_anim: (optional) Enables boot animation.
    emulator_tmp_dir: temporary directory where system_images/sockets/ramdisk
      files are placed while starting the emulator
    open_gl_driver: (optional) name of opengl driver to use.
    experimental_open_gl: (optional) if true - disables many opengl checks
    snapshot_file: The path of snapshot file generated in boot phase.
  Raises:
    Exception: if the emulated device cannot be started.
  """
  assert proto_filepath and os.path.exists(proto_filepath), 'No metadata found!'

  system_images_dir = _FindSystemImagesDir(system_image_files)

  proto_file = open(proto_filepath, 'rb')
  proto = emulator_meta_data_pb2.EmulatorMetaDataPb()
  proto.ParseFromString(proto_file.read())
  proto_file.close()

  assert not (proto.with_kvm and not _IsKvmPresent()), (
      'Try to run snapshot images with KVM support on non-KVM machine.')

  if 'x86' == proto.emulator_architecture:
    if not _IsKvmPresent():
      print ''
      print '=' * 80
      print ('= By activating KVM on your local host you can increase the '
             'speed of the emulator.      =')
      print '=' * 80
    elif not proto.with_kvm:
      print ''
      print '=' * 80
      print ('= Please add --no to your bazel command line, to create '
             'snapshot images   =')
      print ('= local with KVM support. This will increase the speed of the '
             'emulator.        =')
      print '=' * 80
  else:
    print ''
    print '=' * 80
    print ('= By using x86 with KVM on your local host you can increase the '
           'speed of the emulator.')
    print '=' * 80

  proto.system_image_dir = system_images_dir
  sysimg = (
      _ExtractSuffixFile(system_image_files, 'system.img.tar.gz') or
      _ExtractSuffixFile(system_image_files, 'system.img'))
  dataimg = (_ExtractSuffixFile(system_image_files, 'userdata.img.tar.gz') or
             _ExtractSuffixFile(system_image_files, 'userdata.img'))
  vendorimg_path = (_ExtractSuffixFile(system_image_files, 'vendor.img.tar.gz')
                    or _ExtractSuffixFile(system_image_files, 'vendor.img'))
  encryptionkeyimg_path = _ExtractSuffixFile(system_image_files,
                                             'encryptionkey.img')
  advanced_features_ini = _ExtractSuffixFile(system_image_files,
                                             'advancedFeatures.ini')
  build_prop_path = _ExtractSuffixFile(system_image_files, 'build.prop')

  data_files = _ExtractDataFiles(system_image_files)

  # TODO: Move data to another field in the proto.
  images_dict = device.BuildImagesDict(sysimg, dataimg, vendorimg_path,
                                       encryptionkeyimg_path,
                                       advanced_features_ini, build_prop_path,
                                       data_files)
  proto.system_image_path = json.dumps(images_dict)
  device._metadata_pb = proto
  device.StartDevice(enable_display,
                     start_vnc_on_port=start_vnc_on_port,
                     net_type=net_type,
                     userdata_tarball=input_image_file,
                     new_process_group=new_process_group,
                     window_scale=window_scale,
                     with_audio=with_audio,
                     with_boot_anim=with_boot_anim,
                     emulator_tmp_dir=emulator_tmp_dir,
                     open_gl_driver=open_gl_driver,
                     allow_experimental_open_gl=experimental_open_gl,
                     save_snapshot=FLAGS.save_snapshot,
                     snapshot_file=snapshot_file)