Skip to content

Commit 7b9bbdd

Browse files
committed
Updated fastboot api to conform to new python-adb changes. Switched to pycryptodome
1 parent 56346cb commit 7b9bbdd

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

device.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import re
77
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
99
from log import *
1010
from config import Config
1111
from enum import Enum
@@ -132,11 +132,19 @@ def wait_for_fastboot(self):
132132
self.wait_for_device()
133133

134134
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])
137138

138139
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)
140148

141149
def serial_number(self):
142150
self.wait_for_device()
@@ -222,7 +230,7 @@ def oem(self, cmd, allow_timeout=False, allow_usb_error = False):
222230
raise FastbootCommandNotFound()
223231
raise FastbootTimeoutException
224232

225-
except FastbootRemoteFailure, e:
233+
except FastbootRemoteFailure as e:
226234
r = self.get_last_fb_output()
227235
error = e.msg
228236
if self.is_fb_error(error+r, cmd):

0 commit comments

Comments
 (0)