Exemplo n.º 1
0
def sound_card(serial):
    try:
        adb_connection = Adb(serial=serial)
        api_level = adb_connection.get_prop(prop="ro.build.version.sdk")
        if (api_level < 26):
            card = adb_connection.parse_cmd_output("alsa_aplay_32 -l ")
        else:
            card = adb_connection.parse_cmd_output("alsa_aplay -l ")

        for line in card.splitlines():
            #print line
            search_obj = re.search("(.+): Speaker", line)
            if search_obj:
                rest, device = search_obj.group(1).split(",")
                device_name = re.search("\[(.+)\]", rest).group(1)
                print "Sound card present at", device, device_name
                return True
        else:
            raise Exception
    except Exception as e:
        print "[{0}] Failed to list sound card".format(serial)
        print e.message
        return False
Exemplo n.º 2
0
def check_google_account(serial = None):
    """
    description:
        check if a Google account is configured on DUT.
        Return True if the Google account is configured.

    usage:
        gms_utils.check_google_account()

    tags: google account, account, google, check google
    """
    if serial:
        uidevice = uiandroid.UIDevice(serial = serial)
        adb_connection = Adb(serial = serial)
    else:
        uidevice = uiandroid.UIDevice()
        adb_connection = Adb()

    if ( "Starting: Intent { act=android.settings.SYNC_SETTINGS }" in\
        adb_connection.parse_cmd_output(\
        cmd = "am start -a android.settings.SYNC_SETTINGS",\
        grep_for = "Starting: Intent")):
            if uidevice(text = "Google").exists:
                uidevice.pressRecent()
                uidevice.wait.update()
                if uidevice(text = "Accounts").wait.exists(timeout = 5000):
                    uidevice(text = "Accounts").swipe.right()
                return True
            else:
                uidevice.pressRecent()
                uidevice.wait.update()
                if uidevice(text = "Accounts").wait.exists(timeout = 5000):
                    uidevice(text = "Accounts").swipe.right()
                return False
    else:
        print "The settings.SYNC_SETTINGS activity doesn't start"
        return False