解决办法:
from adb_shell.auth.sign_pythonrsa import PythonRSASigner
class AutoScreenProp:
def __init__(self, ip, adbkey):
# Load the public and private keys
# adbkey = 'path/to/adbkey'
with open(adbkey) as f:
priv = f.read()
with open(adbkey + '.pub') as f:
pub = f.read()
signer = PythonRSASigner(pub, priv)
self.device1 = AdbDeviceTcp(ip, 5555, default_transport_timeout_s=9.)
self.device1.connect(rsa_keys=[signer], auth_timeout_s=5.1)
if name == "__main__":
ip = '10.192.35.17'
AutoScreen = AutoScreenProp(ip,r'C:\Users\24308\adbkey')
#cmd上执行下生成key
#adb keygen C:\Users\24308\adbkey
AutoScreen.shell_command('echo 1')
参考文档:
https://github.com/JeffLIrion/adb_shell