|
5 | 5 | import os
|
6 | 6 | import re
|
7 | 7 | from serializable import Serializable
|
8 |
| -from adb import fastboot,common,usb_exceptions,adb_commands, sign_m2crypto |
| 8 | +from adb import fastboot,common,usb_exceptions,adb_commands, sign_pycryptodome |
9 | 9 | from log import *
|
10 | 10 | from config import Config
|
11 | 11 | from enum import Enum
|
@@ -132,11 +132,19 @@ def wait_for_fastboot(self):
|
132 | 132 | self.wait_for_device()
|
133 | 133 |
|
134 | 134 | def adb(self):
|
135 |
| - signer = sign_m2crypto.M2CryptoSigner(os.path.expanduser(Config.adb_key_path)) |
136 |
| - return adb_commands.AdbCommands.Connect(self.usbdev, rsa_keys=[signer]) |
| 135 | + signer = sign_pycryptodome.PycryptodomeAuthSigner(os.path.expanduser(Config.adb_key_path)) |
| 136 | + device = adb_commands.AdbCommands() |
| 137 | + return device.ConnectDevice(rsa_keys=[signer]) |
137 | 138 |
|
138 | 139 | def fastboot(self):
|
139 |
| - return fastboot.FastbootCommands(self.usbdev) |
| 140 | + cmds = fastboot.FastbootCommands() |
| 141 | + while True: |
| 142 | + try: |
| 143 | + dev = cmds.ConnectDevice() |
| 144 | + return dev |
| 145 | + except: |
| 146 | + print("Device offline, go back to bootloader!") |
| 147 | + time.sleep(3) |
140 | 148 |
|
141 | 149 | def serial_number(self):
|
142 | 150 | self.wait_for_device()
|
@@ -222,7 +230,7 @@ def oem(self, cmd, allow_timeout=False, allow_usb_error = False):
|
222 | 230 | raise FastbootCommandNotFound()
|
223 | 231 | raise FastbootTimeoutException
|
224 | 232 |
|
225 |
| - except FastbootRemoteFailure, e: |
| 233 | + except FastbootRemoteFailure as e: |
226 | 234 | r = self.get_last_fb_output()
|
227 | 235 | error = e.msg
|
228 | 236 | if self.is_fb_error(error+r, cmd):
|
|
0 commit comments