-
Notifications
You must be signed in to change notification settings - Fork 0
/
adb.py
34 lines (23 loc) · 1.15 KB
/
adb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import subprocess
import inquirer
from utils import remove_empty_items, select_in_list
def adb(command_args, device_id, stderr=None):
return subprocess.run("adb -s " + device_id + " " + command_args,
stdout=subprocess.PIPE,
stderr=stderr,
shell=True,
universal_newlines=True)
def select_device():
out = subprocess.run("adb devices", stdout=subprocess.PIPE, shell=True, universal_newlines=True)
devices = remove_empty_items(out.stdout.split("\n")[1:])
return select_in_list("What device would you like to use?", devices).split("\t")[0]
def get_all_devices():
out = subprocess.run("adb devices", stdout=subprocess.PIPE, shell=True, universal_newlines=True)
devices = remove_empty_items(out.stdout.split("\n")[1:])
device_ids = [device.split("\t")[0] for device in devices]
return device_ids
def close_app(device_id):
adb("shell am force-stop com.infomaniak.mail", device_id)
def open_app(device_id):
adb("shell monkey -p com.infomaniak.mail -c android.intent.category.LAUNCHER 1", device_id,
stderr=subprocess.DEVNULL)