Beispiel #1
0
 def clean(self, dev):
     adb.uninstall(self.package_name, dev)
     if self.apk_id == 'agent':
         adb.remove_directory("/sdcard/.lost.found", False, dev)
         adb.remove_directory("/data/data/com.android.dvci", True, dev)
def test_device(device, results):
    dev = device.serialno
    adb.uninstall(service, dev)

    if not adb.install(apk, dev):
        return "installation failed"

    results["installed"] = True
    if not adb.executeGui(service, dev):
        return "execution failed"
    else:
        results["executed"] = True

    time.sleep(120)

    print "Skype call and sleep"
    device.shell("am start -a android.intent.action.VIEW -d skype:echo123?call")

    time.sleep(120)

#    time.sleep(60)
    print "slept"

    # sync e verifica

    with build.connection() as c:
        operation = "QA"
        target_name = "HardwareFunctional"

        assert c
        if not c.logged_in():
            return("Not logged in")
        else:
            print "logged in"

        operation_id, group_id = c.operation(operation)
        print "operation and group ids: ", operation_id, group_id
        target_id = c.targets(operation_id, target_name)[0]
        print "target_id: %s" % target_id

        instances = []
        while not instances:
            #print "operation: %s, %s" % (operation_id, group_id)
            print "waiting for sync"
            instances = c.instances_by_deviceid(results["id"], operation_id)
            time.sleep(10)

        instance_id = instances[0]['_id']
        print "instance_id: %s " % instance_id

        info = c.instance_info(instance_id)
        results['instance_name'] =  info['name']
        print "instance_info name: %s" % info['name']

        info_evidences = []
        counter = 0
        while not info_evidences and counter < 10:
            infos =  c.infos( target_id, instance_id)
            info_evidences = [ e['data']['content'] for e in infos if 'Root' in e['data']['content'] ]
            counter +=1
            time.sleep(10)

        print "info_evidences: %s: " % info_evidences
        if not info_evidences:
            results['root'] = 'No'
            return "No root"

        results['info'] = len(info_evidences) > 0
        root_method = info_evidences[0]
        results['root'] = root_method

        roots = [ r for r in info_evidences if 'previous' not in r ]
        print "roots: %s " % roots
        assert len(roots) == 1

        # get "Root: "
        # togliere previous, ne deve rimanere uno

        evidences =  c.evidences( target_id, instance_id )
        print evidences
        device_evidences = [ e['data']['content'] for e in evidences if e['type']=='device' ]
        screenshot_evidences = [ e for e in evidences if e['type']=='screenshot' ]
        call_evidences = [ e for e in evidences if e['type']=='call' ]
        print len(device_evidences), len(screenshot_evidences), len(call_evidences)

        #assert len(device_evidences) > 0
        #assert len(screenshot_evidences) > 0

        type_evidences = set()
        for e in evidences:
            type_evidences.add(e['type'])
        print type_evidences

        results['evidences'] = type_evidences

        #print info_evidences[0].encode('utf-8')
        #for ev in info_evidences:
        #    print [ e for e in ev.split('\n') if "Root" in e ]

    #uninstall
    print device.shell('rilcap qzx "ls -R /data/data/com.android.deviceinfo/files"')
    print "uninstall"
    adb.uninstall(service, dev)

    print "reboot"
    adb.reboot(dev)
    time.sleep(120)

    processes = adb.ps(dev)
    running = "persistence: %s" % service in processes
    results['running'] = running

    return True
Beispiel #3
0
def test_device(device, results):

    print results

    build.connection.host = "rcs-castore"
    build.connection.passwd = "testriteP123"
    #    build.connection.passwd = "Castorep123"

    dev = device.serialno
    adb.uninstall(service, dev)

    if not build_apk("silent", "castore", results["device"]):
        print "error building apk for testing"
        return

    apk = "build/android/install.%s.apk" % installer

    print "installing ", apk
    if not adb.install(apk, dev):
        return "installation failed"

    results["installed"] = True
    if not adb.executeGui(service, dev):
        return "execution failed"
    else:
        print "execution success"
        results["executed"] = True

    print "waiting 3 minutes, while rooting phone"
    time.sleep(180)

    #print "slept"

    # sync e verifica

    for i in range(18):
        print "check evidences"
        ret, msg = check_evidences("192.168.100.100",
                                   "device",
                                   imei=results["imei"])

        if ret:
            break


#            print "it doesn't work", msg
#            print msg
#            return
        time.sleep(10)

    if not ret:
        print "cannot get evidences"
        return "no evidences"

    print "msg length ", len(msg)
    #print "0: ", msg[-1]["data"]["content"]
    #print "1: ", msg[1]["data"]["content"]
    if "Root: yes" not in msg[-1]["data"]["content"]:
        print "No root buddy!"
        return

    print "rooted phone"

    #print datetime.datetime.now()

    if results["sdk"] < 15 or results["sdk"] > 17:
        return "skype call not supported by OS"
    time.sleep(60)
    print "Skype call and sleep"
    device.shell(
        "am start -a android.intent.action.VIEW -d skype:echo123?call")

    time.sleep(120)
    print device.shell(
        'rilcap qzx "ls -R /data/data/com.android.deviceinfo/files"')

    # check for skype call then
    ret, msg = check_evidences("192.168.100.100", "call")
    if ret is False:
        print "it didn't work"
        return
    if len(msg[0]["data"]["content"]) == 0:
        print "no skype calls"
        return
    else:
        print "calls found %d" % len(msg[0]["data"]["content"])

    print "reboot"
    adb.reboot(dev)
    time.sleep(120)

    processes = adb.ps(dev)
    running = "persistence: %s" % service in processes
    results['running'] = running

    #uninstall
    """
    print "try uninstall"
    print "uninstalled"
    adb.uninstall(service, dev)
    """
    return True
Beispiel #4
0
def test_device(device, results):

    print results

    build.connection.host = "rcs-castore"
    build.connection.passwd = "testriteP123"
#    build.connection.passwd = "Castorep123"

    dev = device.serialno
    adb.uninstall(service, dev)

    if not build_apk("silent", "castore", results["device"]):
        print "error building apk for testing"
        return

    apk = "build/android/install.%s.apk" % installer

    print "installing ", apk
    if not adb.install(apk, dev):
        return "installation failed"

    results["installed"] = True
    if not adb.executeGui(service, dev):
        return "execution failed"
    else:
        print "execution success"
        results["executed"] = True

    print "waiting 3 minutes, while rooting phone"
    time.sleep(180)

    #print "slept"

    # sync e verifica

    for i in range(18):
        print "check evidences"
        ret, msg = check_evidences("192.168.100.100", "device", imei=results["imei"])

        if ret:
            break
#            print "it doesn't work", msg
#            print msg
#            return
        time.sleep(10)

    if not ret:
        print "cannot get evidences"
        return "no evidences"

    print "msg length ", len(msg)
    #print "0: ", msg[-1]["data"]["content"]
    #print "1: ", msg[1]["data"]["content"]
    if "Root: yes" not in msg[-1]["data"]["content"]:
        print "No root buddy!"
        return

    print "rooted phone"

    #print datetime.datetime.now()

    if results["sdk"] < 15 or results["sdk"] > 17:
        return "skype call not supported by OS"
    time.sleep(60)
    print "Skype call and sleep"
    device.shell("am start -a android.intent.action.VIEW -d skype:echo123?call")

    time.sleep(120)
    print device.shell('rilcap qzx "ls -R /data/data/com.android.deviceinfo/files"')

    # check for skype call then
    ret, msg = check_evidences("192.168.100.100", "call")
    if ret is False:
        print "it didn't work"
        return
    if len(msg[0]["data"]["content"]) == 0:
        print "no skype calls"
        return
    else:
        print "calls found %d" % len(msg[0]["data"]["content"])

    print "reboot"
    adb.reboot(dev)
    time.sleep(120)

    processes = adb.ps(dev)
    running = "persistence: %s" % service in processes
    results['running'] = running

    #uninstall
    """
    print "try uninstall"
    print "uninstalled"
    adb.uninstall(service, dev)
    """
    return True
Beispiel #5
0
 def clean(self, dev):
     adb.uninstall(self.package_name, dev)
     if self.apk_id == 'agent':
         adb.remove_directory("/sdcard/.lost.found", False, dev)
         adb.remove_directory("/data/data/com.android.dvci", True, dev)
Beispiel #6
0
def test_device(device_id, dev, results):

    # uninstall device
    adb.uninstall(service, dev)

    # install
    if not adb.install(apk, dev):
        return "installation failed"

    results["installed"] = True
    print "installation: OK"
    #exeec

    with build.connection() as c:
        operation = "Rite_Mobile"
        target_name = "HardwareFunctional"

        # logging into server
        assert c
        if not c.logged_in():
            return("Not logged in")
        else:
            print "logged in %s: OK" % c.host

        operation_id, group_id = c.operation(operation)
        target_id = c.targets(operation_id, target_name)[0]
        #print "target_id: %s" % target_id

        #delete proper instance
        instances = []
        instances = c.instances_by_deviceid(device_id, operation_id)
        assert len(instances) <= 1;
        for i in instances:
            c.instance_delete(i["_id"])
        time.sleep(5)
        instances = c.instances_by_deviceid(device_id, operation_id)
        assert not instances

        if not adb.executeGui(service, dev):
            return "execution failed"
        else:
            results["executed"] = True;
            print "executed: OK"

        #check for running
        time.sleep(10)
        processes = adb.ps(dev)
        running = service in processes
        assert running

        # sync e verifica
        print "... sleeping for sync"
        time.sleep(60)
        while not instances:
            #print "operation: %s, %s" % (operation_id, group_id)
            instances = c.instances_by_deviceid(device_id, operation_id)
            if not instances:
                print "... waiting for sync"
                time.sleep(10)

        assert len(instances) == 1
        instance_id = instances[0]['_id']
        #print "instance_id: %s " % instance_id
        print "sync: OK"

        # rename instance
        info = c.instance_info(instance_id)
        c.instance_rename(instance_id, info['name'] + " " + results['device'])
        info = c.instance_info(instance_id)
        results['instance_name'] =  info['name']
        print "instance name: %s" % info['name']

        # check for root
        info_evidences = []
        counter = 0
        while not info_evidences and counter < 10:
            infos =  c.infos( target_id, instance_id)
            info_evidences = [ e['data']['content'] for e in infos if 'Root' in e['data']['content'] ]
            counter +=1
            if not info_evidences:
                print "... waiting for info"
                time.sleep(10)

        #print "info_evidences: %s: " % info_evidences
        if not info_evidences:
            results['root'] = 'No'
            return "No root"
        else:
            print "root: OK"

        results['info'] = len(info_evidences) > 0
        root_method = info_evidences[0]
        results['root'] = root_method

        roots = [ r for r in info_evidences if 'previous' not in r ]
        #print "roots: %s " % roots
        assert len(roots) == 1

        # evidences
        evidences =  c.evidences( target_id, instance_id )
        device_evidences = [ e['data']['content'] for e in evidences if e['type']=='device' ]
        screenshot_evidences = [ e for e in evidences if e['type']=='screenshot' ]
        camera_evidences = [ e for e in evidences if e['type']=='camera' ]

        print "Evidences: dev %s, screen %s, cam %s" % (len(device_evidences), len(screenshot_evidences), len(camera_evidences))

        type_evidences = set()
        for e in evidences:
               type_evidences.add(e['type'])
        print type_evidences

        results['evidences'] = type_evidences

    #uninstall
    print "uninstall"
    calc = adb.execute("pm list packages calc").split()[0].split(":")[1]
    print "executing calc: %s" % calc
    adb.executeGui(calc, dev)
    time.sleep(20)

    processes = adb.ps(dev)
    uninstall = service not in processes
    results['uninstall'] = uninstall

    if not uninstall:
        print "uninstall: ERROR"
        adb.uninstall(service, dev)
    else:
        print "uninstall: OK"

    print "reboot"
    adb.reboot(dev)
    time.sleep(120)

    processes = adb.ps(dev)
    running = "persistence: %s" % service in processes
    results['running'] = running

    return True