Пример #1
0
    def do(self):
        if self.device_info.device_type == "tab":
            self.logger.error("Unsupported API, as it only support in "
                              "greater than or equal to Android O IVI "
                              "platform")
        else:
            # Todo need to replace pixel with uiobject
            # currently pixel is used because activity is not dumped through
            # uiautomator
            info = self.uidevice.info
            # Todo x has to be dynamic based on the screen size
            x = 410
            activity_bar_single_element_width = x / 6
            # In P dessert Car(All apps icon) resides at 5 position and click
            # has to be done at the center
            car_x_coordinate = activity_bar_single_element_width * \
                6 - activity_bar_single_element_width / 2
            self.view_to_check = {"text": "All apps"}

            # Default acitivity bar resides at the bottom, so y coordinate
            # can be used and to click at the center reducing the value by 30
            y = info['displaySizeDpY']
            car_y_coordinate = y - 30

            for i in range(0, 5):
                cmd = "input tap {0} {1}".format(car_x_coordinate,
                                                 car_y_coordinate)
                adb_connection = Adb(serial=self.serial)
                adb_connection.run_cmd(cmd)
                time.sleep(1)
                if self.check_view():
                    self.step_data = True
                    break
Пример #2
0
    def do(self):
        if self.device_info.device_type == "tab":
            self.logger.error("Unsupported API, as it only support in "
                              "greater than or equal to Android O IVI "
                              "platform")
        else:
            # Todo need to replace pixel with uiobject
            # currently pixel is used because activity is not dumped through
            # uiautomator
            info = self.uidevice.info
            # Todo x has to be dynamic based on the screen size
            x = 410
            activity_bar_single_element_width = x / 6
            # In P dessert Dialer resides at 4 position and click has to be
            # done at the center
            dialer_x_coordinate = activity_bar_single_element_width * \
                5 - activity_bar_single_element_width / 2

            # Default acitivity bar resides at the bottom, so y coordinate
            # can be used and to click at the center reducing the value by 30
            y = info['displaySizeDpY']
            dialer_y_coordinate = y - 30

            cmd = "input tap {0} {1}".format(dialer_x_coordinate,
                                             dialer_y_coordinate)
            adb_connection = Adb(serial=self.serial)
            adb_subprocess_object = adb_connection.run_cmd(cmd)
            if adb_subprocess_object.poll() == 0:
                self.step_data = True
class CheckSDCardMount(StorageUsbStep):
    def __init__(self, **kwargs):
        StorageUsbStep.__init__(self, **kwargs)
        self.sdcard = False
        self.adb = Adb(serial=self.serial)
        self.uuid = ""

    def do(self):
        self.adb.adb_root()
        blkid_out = self.adb.run_cmd('blkid')
        for line in blkid_out.stdout.read().split('\n'):
            if 'mmcblk0p1' in line:
                self.sdcard = True
                self.uuid = line.split(' ')[1].split('=')[1].strip('"')
                break

    def check_condition(self):
        if self.sdcard:
            vol = self.adb.run_cmd("sm list-volumes")
            for line in vol.stdout.read().strip().split('\n'):
                if self.uuid in line:
                    if 'mounted' in line.split()[-2]:
                        self.set_passm("SD Card Mounted with UUID: " +
                                       self.uuid)
                        return True
        self.set_errorm("", "SD Card Not Mounted")
        return False
Пример #4
0
def set_eavb_mode(serial, mode):
    try:
        adb_connection = Adb(serial=serial)
        adb_connection.set_prop(prop="persist.eavb.mode", value=mode.lower())
        return True
    except Exception as e:
        print "[{0}] Failed to set eavb mode '{1}'".format(serial, mode)
        print e.message
        return False
Пример #5
0
def set_eavb_audio_on_speaker(serial, state):
    try:
        state = "true" if state.lower() == "on" else "false"
        adb_connection = Adb(serial=serial)
        adb_connection.run_cmd(command="audio_system_setparameters "
                               "is_eavb_stream={0}".format(state))
        return True
    except Exception as e:
        print "[{0}] Failed to set is_eavb_stream={1}".format(serial, state)
        print e.message
        return False
Пример #6
0
def set_gptp_automotive_profile(serial, state):
    try:
        state = "y" if state.lower() == "on" else "n"
        adb_connection = Adb(serial=serial)
        adb_connection.set_prop(prop="persist.gptp.automotive_profile",
                                value=state)
        return True
    except Exception as e:
        print "[{0}] Failed to set gptp automotive profile to {1}".format(
            serial, state)
        print e.message
        return False
Пример #7
0
 def do(self):
     # if self.home_state:
     #    self.logger.info("Home screen already present [ {0} ]".format(
     # self.serial))
     info = self.uidevice.info
     x = 410
     activity_bar_single_element_width = x / 6
     # In P dessert home resides at 1st position and click has to be done at
     # the center
     home_x_coordinate = activity_bar_single_element_width * 2 - \
         activity_bar_single_element_width / 2
     y = info['displaySizeDpY']
     home_y_coordinate = y - 30
     # cmd = "input tap 405 1050"
     cmd = "input tap {0} {1}".format(home_x_coordinate, home_y_coordinate)
     adb_connection = Adb(serial=self.serial)
     adb_connection.run_cmd(cmd)
     time.sleep(2)
     ui_steps.wait_for_view_common(view_to_find={"text": "Let's Drive"},
                                   serial=self.serial)()
     self.step_data = True
Пример #8
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
Пример #9
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
Пример #10
0
def gptp(serial):
    try:
        adb_connection = Adb(serial=serial)
        adb_connection.run_cmd(command="stop gptp")
        if (check_gptp_service(serial=serial) == "stopped"):
            adb_connection.run_cmd(command="start gptp")
            if (check_gptp_service(serial=serial) == "running"):
                return True
    except Exception as e:
        print "[{0}] Failed to start gptp services".format(serial)
        print e.message
        return False
Пример #11
0
def avb_stream_handler(serial):
    try:
        adb_connection = Adb(serial=serial)
        adb_connection.run_cmd(command="stop avbstreamhandler")
        if (check_avb_service(serial=serial) == "stopped"):
            adb_connection.run_cmd(command="start avbstreamhandler")
            if (check_avb_service(serial=serial) == "running"):
                return True
    except Exception as e:
        print "[{0}] Failed to start AVB stream handler services".format(
            serial)
        print e.message
        return False
 def __init__(self, **kwargs):
     StorageUsbStep.__init__(self, **kwargs)
     self.sdcard = False
     self.adb = Adb(serial=self.serial)
     self.uuid = ""
Пример #13
0
def check_avb_service(serial):
    adb_connection = Adb(serial=serial)
    return adb_connection.get_prop("init.svc.avbstreamhandler")
Пример #14
0
def check_gptp_service(serial):
    adb_connection = Adb(serial=serial)
    if check_eavb_mode(serial=serial) == "m":
        return adb_connection.get_prop("init.svc.gptp_a")
    else:
        return adb_connection.get_prop("init.svc.gptp_as")
Пример #15
0
    serial=serial)()

# wait until the device connects to a wifi network
wifi_generic_steps.wait_until_connected(serial=serial)()

# check we are connected to the correct network
wifi_generic_steps.check_connection_info(serial=serial,
                                         SSID="SSG_LAB_VAL_S3",
                                         state='CONNECTED/CONNECTED',
                                         Security="WPA_PSK")()
#pairwise_cipher=pairwise_cipher)()

#Download from external network SED network

uidevice = ui_device(serial=serial)
dut = Adb(serial=serial)
#Download a big file over wifi.

download = "am start -a android.intent.action.VIEW -d ftp://speedtest.tele2.net/100MB.zip"
#dut.run_cmd(download)
if uidevice(packageName="com.estrongs.android.pop").exists:
    uidevice(packageName="com.estrongs.android.pop", text="Hide").click()


def cam_landing_page():
    btn = ['Allow', 'NEXT']
    for b in btn:
        ui_steps.click_button_if_exists(serial=serial,
                                        view_to_find={"text": b})()
        #sleep(2)
    return True
Пример #16
0
def check_gptp_automotive_profile(serial):
    adb_connection = Adb(serial=serial)
    return adb_connection.get_prop("persist.gptp.automotive_profile")
from time import sleep
from threading import Thread
from subprocess import Popen, PIPE, STDOUT
import Queue

globals().update(vars(get_args(sys.argv)))

adb_steps.connect_device(serial=serial, port=adb_server_port)()

args = {}
for entry in script_args:
    key, val = entry.split("=")
    args[key] = val

uidevice = ui_device(serial=serial)
dut = Adb(serial=serial)

list_vol = "sm list-volumes"
test_file = "test_adb_copy.dat"

dut.adb_root()
uuid = ""


def check_sdcard():
    global uuid
    p = dut.run_cmd('blkid')
    sdcard = False
    for line in p.stdout.read().split('\n'):
        if 'mmcblk0p1' in line:
            sdcard = True
from testlib.utils.ui.uiandroid import UIDevice as ui_device
from time import sleep

globals().update(vars(get_args(sys.argv)))

adb_steps.connect_device(serial=serial, port=adb_server_port)()

args = {}
for entry in script_args:
    key, val = entry.split("=")
    args[key] = val

#stdout =  adb_steps.command(serial=serial, command= "ls", mode = "async",stdout_grep= 'proc')()
#adb_steps.open_users_settings(serial=serial)
uidevice = ui_device(serial=serial)
dut = Adb(serial=serial)

fileManager_pkg = 'com.estrongs.android.pop'
app_launch = 'com.estrongs.android.pop/.app.openscreenad.NewSplashActivity'
check_box = 'android.widget.CheckBox'
test_file = 'CS.dat'

#Create and transfer 1G of file to Download
create_file = "fallocate -l 1G {0}".format(test_file)
print os.getcwd()

os.system(create_file)
dut.put_file(test_file, '/sdcard/Download/', timeout=200)
os.system("rm -rf %s" % test_file)

#Launch ES file explorer
Пример #19
0
def check_eavb_mode(serial):
    adb_connection = Adb(serial=serial)
    return adb_connection.get_prop("persist.eavb.mode")