Esempio n. 1
0
    def __init__(self, voltage=3.8, serial=None):  # noqa: D102,D107
        self.monsoon = None
        self.serial = serial
        self.voltage = voltage
        self.monsoon_reader = None
        self.monsoon_data = None
        self.engine = None
        self.setup_monsoon()

        click.secho("Monsoon is ready.", fg='green')
        if not android.is_android_device_available():
            click.secho("You can now turn the phone on.", fg='blue')
        for i in range(180):
            time.sleep(1)
            if android.is_android_device_available():
                time.sleep(2)
                click.secho("Found a {}!".format(android.get_device_model()),
                            fg='green')
                break
            if i % 15 == 0:
                click.secho("Waiting for an Android device...", fg='blue')
            if i == 180:
                raise Exception("Could not find device.")
        android.connect_adb_through_wifi()
        self.monsoon_usb_enabled(False)
        if android.is_locked():
            click.secho(
                "Device seems to be locked. "
                "Disabling Passlock is recommended!",
                fg='yellow')
Esempio n. 2
0
    def setup_monsoon(self):
        """Set up monsoon.

        Args:
            voltage: Voltage output of the power monitor.
            serial: serial number of the power monitor.
        """
        click.secho("Setting up Monsoon {} with {}V...".format(
            self.serial, self.voltage),
                    fg='blue')
        self.monsoon = LVPM.Monsoon()
        self.monsoon.setup_usb(self.serial)
        set_voltage_if_different(self.monsoon, self.voltage)
        self.engine = SampleEngine(self.monsoon)
        self.engine.ConsoleOutput(False)
        if android.is_android_device_available():
            android.reconnect_adb_through_usb()
        self.monsoon_usb_enabled(True)