2024-08-18 11:14:10 -04:00

38 lines
1.0 KiB
Python

import os, time
from ppadb.client import Client as AdbClient
def connect_device():
os.system('adb start-server')
client = AdbClient(host="127.0.0.1", port=5037)
devices = client.devices()
if len(devices) == 1:
device = client.device(devices[0].serial)
return device
elif len(devices) == 0:
raise ConnectionError
else:
n = 1
for device in devices:
print(f'[{n}] {device.serial}')
n += 1
choice = input('Please enter the number of the device you would like\
to connect to: ')
device = client.device(devices[choice-1].serial)
return device
def shell(device, command):
return device.shell(command)
def serialno():
return os.popen("adb get-serialno").read()
def pull(device, ipath, opath):
print(f"Pulling {ipath} to {opath}...")
os.system(f'adb pull {ipath} {opath}')
def reboot_bootloader():
print("Rebooting to Bootloader...")
os.system('adb reboot-bootloader')
def backup():
os.system('adb backup -all')