Esempio n. 1
0
    def boot(self,
             port: Optional[int] = None,
             adb_port: Optional[int] = None) -> None:
        verbose_level = RequiredFeature('verbose_level').request()

        Device.boot(self)

        # ensure the emulator configuration is correct
        self.port = port if port is not None else self.device_manager.get_next_available_emulator_port(
        )
        self.avd_name = self.avd_manager.get_avd_name_for_emulator_port(
            self.port)
        if not self.avd_manager.avd_name_exists(self.avd_name):
            raise Exception(
                f"AVD name {self.avd_name} doesn't exist. "
                f"Check that the provided AVD series ({self.avd_manager.avd_series}) is correct."
            )

        # start custom abd server for this emulator
        self.adb_port = adb_port if adb_port is not None else self.device_manager.get_next_available_adb_server_port(
        )
        adb.restart_server(self.adb_port)

        # start emulator
        self.name = f"emulator-{str(self.port)}"

        emulator_cmd = f"{self.get_adb_server_port_prefix()} QEMU_AUDIO_DRV=none $ANDROID_HOME/emulator/emulator"

        flags: str = f" -no-snapshot -wipe-data -no-boot-anim -writable-system -port {str(self.port)}"

        if verbose_level < 3:
            # -no-window flag can't be at the end
            flags = f" -no-window{flags}"

        logs = " >/dev/null 2>/dev/null"

        if verbose_level > 0:
            logs = f" >logs/{self.avd_name}.log 2>logs/{self.avd_name}.err"
            flags = f"{flags} -verbose -debug all"

        cmd: str = f'{emulator_cmd} -avd {self.avd_name}{flags}{logs}'

        if verbose_level > 1:
            logger.log_progress(f"\nFiring up emulator with command: {cmd}")

        sub.Popen(cmd, shell=True)
Esempio n. 2
0
 def boot(self, port: Optional[int] = None) -> None:
     """There is no way to contact a real device if it's shutdown."""
     Device.boot(self)