Exemple #1
0
def debug_app(dev_uuid, args):
    device = adb.get_dev(dev_uuid)
    pkg_name = args.extra_args[0]

    device.stop_app(pkg_name)
    # Start app while waiting for debugger
    device.execute(["shell", "am set-debug-app -w %s" % pkg_name])
    device.launch_app(pkg_name)

    sleep(0.1)

    pid = device.pidof_activity(pkg_name)

    if pid < 0:
        raise RuntimeError("Failed to get PID of application")

    device.execute([
        "forward", "tcp:5039",
        "localfilesystem:/data/data/%s/debug-socket" % pkg_name
    ])

    instructSet = device.isaof_activity(pkg_name)

    device.execute([
        "shell",
        "run-as %s chmod a+x /data/data/%s %s" %
        (pkg_name, pkg_name, device.nlpof_activity(pkg_name))
    ])

    device.exec_shell([
        "shell",
        "run-as %s %s/libgdbserver.so +%s --attach %s" %
        (pkg_name, device.nlpof_activity(pkg_name),
         '/data/data/%s/debug-socket' % pkg_name, pid)
    ])
Exemple #2
0
def screenshot_device(dev_uuid, args):
    target = args.extra_args[0].replace("%DEVICE_UUID%", dev_uuid)

    device = adb.get_dev(dev_uuid)
    # if device.get_screen_state():
    #     device.unlock_device()
    device.get_screenshot(target)
Exemple #3
0
def display_device(dev_uuid, args):
    device = adb.get_dev(dev_uuid)
    abi_string = ""
    for abi in device.abi_support:
        abi_string += abi + ","

    if len(abi_string) > 0:
        abi_string = abi_string[:abi_string.rfind(",")]

    print(
        """uuid=%s;abi=%s;sdk=%s;sdk-rel=%s;board=%s;platform=%s;product=%s;name=%s"""
        % (device.dev, abi_string, device.sdk_ver, device.sdk_rel,
           device.board, device.platform, device.product_name, device.name))
Exemple #4
0
def simulate_input(dev_uuid, args):
    device = adb.get_dev(dev_uuid)
    print_output(device.execute(["shell", "input"] + args.extra_args))
Exemple #5
0
def stop_activity(dev_uuid, args):
    activity_name = args.extra_args[0]

    device = adb.get_dev(dev_uuid)
    device.stop_app(activity_name)
Exemple #6
0
def uninstall_device(dev_uuid, args):
    apps = args.extra_args

    device = adb.get_dev(dev_uuid)
    for app in apps:
        device.uninstall_app(app)
Exemple #7
0
def install_device(dev_uuid, args):
    apks = args.extra_args

    device = adb.get_dev(dev_uuid)
    for apk in apks:
        device.install_apk(apk)