-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadb_utils.py
More file actions
25 lines (15 loc) · 775 Bytes
/
adb_utils.py
File metadata and controls
25 lines (15 loc) · 775 Bytes
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
import subprocess as subp
def get_installed_apps(device):
return map(lambda x: x.replace("package:", ""), device.shell("pm list packages").split("\n"))
def uninstall_package(package, device):
device.shell("pm uninstall " + package)
def install_apks(*files):
for file in files:
print "Installing '%s'" % file
subp.check_call("adb install -t " + file, stderr=subp.STDOUT, shell=True)
def start_app(device, package):
device.shell("am force-stop %s" % package)
device.shell("monkey -p %s -c android.intent.category.LAUNCHER 1" % package)
def wait_for_log(log_message):
subp.check_call("adb logcat -c", stderr=subp.STDOUT, shell=True)
subp.check_call("adb logcat -e \"%s\" -m 1" % log_message, stderr=subp.STDOUT, shell=True)