Example #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
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
Example #3
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
Example #4
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
Example #5
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
Example #6
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
Example #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
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
dut.run_cmd('am start %s' % app_launch)
ui_steps.swipe


def pass_through_guidlines():
    uidevice = ui_device(serial=serial)
    app = uidevice(className='android.widget.FrameLayout')
    x_coord = app.info['bounds']['right']
    y_coord = app.info['bounds']['left']
    print x_coord
    print y_coord
    start_btn = uidevice.exists(className='android.widget.Button',
                                textContains='START NOW')
    while not (start_btn):
        app.swipe('left')
        if start_btn:
        dest = '/storage/' + uuid
        que = Queue.Queue()
        t = Thread(target=lambda q, arg1: q.put(adb_file_transfer(arg1)),
                   args=(que, dest))
        t.start()
        sleep(15)
        unmount_sdcard()
        sleep(5)
        print "SD Card is %s" % check_sdcard()
        t.join()
        result = que.get()
        print result

    except Exception as e:
        print e.message

    finally:
        print "Deleted the test_file created in host machine"
        os.system("rm -rf %s" % test_file)
        if check_sdcard() == 'unmounted':
            print "Remounting the SD card"
            remount_sdcard()
            print "Closing the android settings"
            dut.run_cmd('pm clear com.android.settings')
        else:
            assert False, "UNEXPECTED: 'Failed to copy error not found' - [FAILED]"

else:
    raise "SD card not found"
    sys.exit(1)
Example #10
0
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


#Take a picture.
cmd_pic = "am start -a android.media.action.IMAGE_CAPTURE"
dut.run_cmd(cmd_pic)
cam_landing_page()
uidevice(resourceId="com.android.camera2:id/shutter_button",
         description="Shutter").click()
sleep(1)
done_btn = uidevice(resourceId="com.android.camera2:id/done_button",
                    description="Done")
if done_btn.exists:
    done_btn.click()

#Take a video.
sleep(1)
cmd_vid = "am start -a android.media.action.VIDEO_CAPTURE"
dut.run_cmd(cmd_vid)
cam_landing_page()
uidevice(packageName="com.android.camera2", description="Shutter").click()