def _send_message(self, ads):
     selection = random.randrange(0, 2)
     message_type_map = {0: "SMS", 1: "MMS"}
     max_length_map = {0: self.max_sms_length, 1: self.max_mms_length}
     min_length_map = {0: self.min_sms_length, 1: self.min_mms_length}
     length = random.randrange(min_length_map[selection],
                               max_length_map[selection] + 1)
     text = rand_ascii_str(length)
     message_content_map = {0: [text], 1: [("Mms Message", text, None)]}
     message_func_map = {
         0: sms_send_receive_verify,
         1: mms_send_receive_verify
     }
     message_type = message_type_map[selection]
     self.result_info["Total %s" % message_type] += 1
     begin_time = get_current_epoch_time()
     start_qxdm_loggers(self.log, self.android_devices)
     if not message_func_map[selection](self.log, ads[0], ads[1],
                                        message_content_map[selection]):
         self.log.error("%s of length %s from %s to %s fails", message_type,
                        length, ads[0].serial, ads[1].serial)
         self.result_info["%s failure" % message_type] += 1
         if message_type == "SMS" or self.result_info["%s failure" %
                                                      message_type] == 1:
             self._take_bug_report("%s_%s_failure" % (self.test_name,
                                                      message_type),
                                   begin_time)
         return False
     else:
         self.log.info("%s of length %s from %s to %s succeed",
                       message_type_map[selection], length, ads[0].serial,
                       ads[1].serial)
         return True
    def test_screenoff_toggle_between_AP(self):

        # Set attenuator to connect phone to both networks
        self.log.info('Set attenuation to connect device to both APs')
        self.set_attenuation(self.atten_level[self.current_test_name])
        # Connect to both APs
        network_main = self.main_network[hc.BAND_2G]
        network_aux = self.aux_network[hc.BAND_2G]
        self.brconfigs_main = self.setup_ap_connection(network_main)
        self.brconfigs_aux = self.setup_ap_connection(network_aux)
        self.mon_info.duration = self.toggle_interval
        self.dut.droid.goToSleepNow()
        time.sleep(5)
        # Toggle between two networks
        begin_time = utils.get_current_epoch_time()
        for i in range(self.toggle_times):
            self.dut.log.info('Connecting to %s' % network_main[wc.SSID])
            self.dut.droid.wifiConnect(network_main)
            file_path, avg_current = wputils.monsoon_data_collect_save(
                self.dut, self.mon_info, self.current_test_name)
            self.dut.log.info('Connecting to %s' % network_aux[wc.SSID])
            self.dut.droid.wifiConnect(network_aux)
            file_path, avg_current = wputils.monsoon_data_collect_save(
                self.dut, self.mon_info, self.current_test_name)
        [plot, dt] = wputils.monsoon_data_plot(self.mon_info, file_path)
        avg_current = dt.source.data['y0'][0]
        # Take Bugreport
        if self.bug_report:
            self.dut.take_bug_report(self.test_name, begin_time)
        # Path fail check
        wputils.pass_fail_check(self, avg_current)
def start_tcpdump(ad, test_name):
    """Start tcpdump on all interfaces

    Args:
        ad: android device object.
        test_name: tcpdump file name will have this
    """
    ad.log.info("Starting tcpdump on all interfaces")
    try:
        ad.adb.shell("killall -9 tcpdump")
    except AdbError:
        ad.log.warn("Killing existing tcpdump processes failed")
    out = ad.adb.shell("ls -l %s" % TCPDUMP_PATH)
    if "No such file" in out or not out:
        ad.adb.shell("mkdir %s" % TCPDUMP_PATH)
    else:
        ad.adb.shell("rm -rf %s/*" % TCPDUMP_PATH, ignore_status=True)

    begin_time = epoch_to_log_line_timestamp(get_current_epoch_time())
    begin_time = normalize_log_line_timestamp(begin_time)

    file_name = "%s/tcpdump_%s_%s.pcap" % (TCPDUMP_PATH, ad.serial, test_name)
    ad.log.info("tcpdump file is %s", file_name)
    cmd = "adb -s {} shell tcpdump -i any -s0 -w {}".format(
        ad.serial, file_name)
    try:
        return start_standing_subprocess(cmd, 5)
    except Exception:
        ad.log.exception('Could not start standing process %s' % repr(cmd))

    return None
Exemplo n.º 4
0
    def setup_class(self):
        super().setup_class()
        self.ad = self.android_devices[0]
        req_params = [
            # A { SSID, password } dictionary. Password is optional.
            'wifi_network',
            # A [latitude, longitude] list to identify test location.
            'test_location',
            # Cold Start Criteria, a int to define the criteria.
            'cs_criteria',
            # Warm Start Criteria, a int to define the criteria.
            'ws_criteria',
            # Hot Start Criteria, a int to define the criteria.
            'hs_criteria',
            # NetworkLocationProvide Criteria, a int to define the criteria.
            'nlp_criteria',
            # A list to identify QXDM log path.
            'qdsp6m_path'
        ]
        self.unpack_userparams(req_param_names=req_params)

        # Init test types Cold Start, Warm Start and Hot Start.
        test_type = namedtuple('Type', ['command', 'criteria'])
        self.test_types = {
            'cs': test_type('Cold Start', self.cs_criteria),
            'ws': test_type('Warm Start', self.ws_criteria),
            'hs': test_type('Hot Start', self.hs_criteria)
        }
        gutils._init_device(self.ad)
        self.begin_time = utils.get_current_epoch_time()
        gutils.clear_logd_gnss_qxdm_log(self.ad)
        tutils.start_qxdm_logger(self.ad, self.begin_time)
        tutils.start_adb_tcpdump(self.ad)
 def check_normal_call(self):
     result = True
     if "wfc" not in self.test_name:
         toggle_airplane_mode_by_adb(self.log, self.dut, False)
     self.dut.ensure_screen_on()
     self.dut.exit_setup_wizard()
     reset_device_password(self.dut, None)
     begin_time = get_current_epoch_time()
     if not call_setup_teardown(
             self.log,
             self.android_devices[1],
             self.dut,
             ad_hangup=self.android_devices[1]):
         self.dut.log.error("Regular MT phone call fails")
         self.dut.log.info("call_info = %s", dumpsys_last_call_info(
             self.dut))
         result = False
     if not call_setup_teardown(
             self.log, self.dut, self.android_devices[1],
             ad_hangup=self.dut):
         self.dut.log.error("Regular MO phone call fails")
         self.dut.log.info("call_info = %s", dumpsys_last_call_info(
             self.dut))
         result = False
     return result
    def wait_for_service_states(self, ssid, states, timeout_seconds):
        """Wait for SSID to reach one state out of a list of states.

        @param ssid string the network to connect to (e.g. 'GoogleGuest').
        @param states tuple the states for which to wait
        @param timeout_seconds int seconds to wait for a state

        @return (result, final_state, wait_time) tuple of the result for the
                wait.
        """
        current_con = self.ad.droid.wifiGetConnectionInfo()
        # Check the current state to see if we're connected/disconnected.
        if set(states).intersection(set(self.SHILL_CONNECTED_STATES)):
            if current_con[wutils.WifiEnums.SSID_KEY] == ssid:
                return True, '', 0
            wait_event = 'WifiNetworkConnected'
        elif set(states).intersection(set(self.SHILL_DISCONNECTED_STATES)):
            if current_con[
                    wutils.WifiEnums.SSID_KEY] == self.DISCONNECTED_SSID:
                return True, '', 0
            wait_event = 'WifiNetworkDisconnected'
        else:
            assert 0, "Unhandled wait states received: %r" % states
        final_state = ""
        wait_time = -1
        result = False
        logging.debug(current_con)
        try:
            self.ad.droid.wifiStartTrackingStateChange()
            start_time = utils.get_current_epoch_time()
            wait_result = self.ad.ed.pop_event(wait_event, timeout_seconds)
            end_time = utils.get_current_epoch_time()
            wait_time = (end_time - start_time) / 1000
            if wait_event == 'WifiNetworkConnected':
                actual_ssid = wait_result['data'][wutils.WifiEnums.SSID_KEY]
                assert actual_ssid == ssid, ("Expected to connect to %s, but "
                                             "connected to %s") % (ssid,
                                                                   actual_ssid)
            result = True
        except Queue.Empty:
            logging.error("No state change available yet!")
        except Exception as e:
            logging.error("State change error: %s", e)
        finally:
            logging.debug((result, final_state, wait_time))
            self.ad.droid.wifiStopTrackingStateChange()
            return result, final_state, wait_time
    def test_begin(self):
        """Call this when the test case it records begins execution.

        Sets the begin_time of this record.
        """
        self.begin_time = utils.get_current_epoch_time()
        self.log_begin_time = logger.epoch_to_log_line_timestamp(
            self.begin_time)
 def _test_stress_cbrsdataswitch_timing(self, ad, method, validation=False):
     setattr(self, "number_of_devices", 1)
     ad.adb.shell("pm disable com.google.android.apps.scone")
     wifi_toggle_state(self.log, ad, True)
     self.cbrs_subid, self.default_subid = get_cbrs_and_default_sub_id(ad)
     toggle_airplane_mode(ad.log,
                          ad,
                          new_state=False,
                          strict_checking=False)
     if self._is_current_data_on_cbrs():
         ad.log.info("Current Data is on CBRS, proceeding with test")
     else:
         ad.log.error("Current Data not on CBRS, forcing it now..")
         ad.droid.telephonySetPreferredOpportunisticDataSubscription(
             self.cbrs_subid, False)
     ad.droid.telephonyUpdateAvailableNetworks(self.cbrs_subid)
     total_iteration = self.stress_test_number
     fail_count = collections.defaultdict(int)
     self.switch_time_dict = {
         'cbrs_default_switch': [],
         'default_cbrs_switch': []
     }
     current_iteration = 1
     for i in range(1, total_iteration + 1):
         msg = "Stress CBRS Test Iteration: <%s> / <%s>" % (i,
                                                            total_iteration)
         begin_time = get_current_epoch_time()
         self.log.info(msg)
         start_qxdm_logger(ad, begin_time)
         iteration_result = self._cbrs_default_data_switch_timing(
             ad, method, validation)
         self.log.info("Result: %s", iteration_result)
         if iteration_result:
             self.log.info(">----Iteration : %d/%d succeed.----<", i,
                           total_iteration)
         else:
             fail_count["cbrsdataswitch_fail"] += 1
             self.log.error(">----Iteration : %d/%d failed.----<", i,
                            total_iteration)
             self._take_bug_report("%s_IterNo_%s" % (self.test_name, i),
                                   begin_time)
         current_iteration += 1
         time.sleep(WAIT_TIME_BETWEEN_ITERATION)
     test_result = True
     for time_task, time_list in self.switch_time_dict.items():
         ad.log.info("%s %s", time_task, time_list)
         avg_time = self._get_list_average(time_list)
         ad.log.info("Average %s for %d iterations = %.2f seconds",
                     time_task, self.stress_test_number, avg_time)
     for failure, count in fail_count.items():
         if count:
             self.log.error("%s: %s %s failures in %s iterations",
                            self.test_name, count, failure, total_iteration)
             test_result = False
     ad.adb.shell("pm enable com.google.android.apps.scone")
     return test_result
    def test_modem_power_anomaly_file_existence(self):
        """Verify if the power anomaly file exists

        1. Collect Bugreport
        2. unzip bugreport
        3. remane the .bin file to .tar
        4. unzip dumpstate.tar
        5. Verify if the file exists

        """
        ad = self.android_devices[0]
        cmd = ("am broadcast -a "
               "com.google.gservices.intent.action.GSERVICES_OVERRIDE "
               "-e \"ce.cm.power_anomaly_data_enable\" \"true\"")
        ad.adb.shell(cmd)
        time.sleep(60)
        begin_time = get_current_epoch_time()
        for i in range(3):
            try:
                ad.take_bug_report(self.test_name, begin_time)
                bugreport_path = ad.device_log_path
                break
            except Exception as e:
                ad.log.error("bugreport attempt %s error: %s", i + 1, e)
        ad.log.info("Bugreport Path is %s" % bugreport_path)
        try:
            list_of_files = os.listdir(bugreport_path)
            ad.log.info(list_of_files)
            for filename in list_of_files:
                if ".zip" in filename:
                    ad.log.info(filename)
                    file_path = os.path.join(bugreport_path, filename)
                    ad.log.info(file_path)
                    unzip_maintain_permissions(file_path, bugreport_path)
            dumpstate_path = os.path.join(bugreport_path,
                                          "dumpstate_board.bin")
            if os.path.isfile(dumpstate_path):
                os.rename(dumpstate_path,
                          bugreport_path + "/dumpstate_board.tar")
                os.chmod(bugreport_path + "/dumpstate_board.tar", 0o777)
                current_dir = os.getcwd()
                os.chdir(bugreport_path)
                exe_cmd("tar -xvf %s" %
                        (bugreport_path + "/dumpstate_board.tar"))
                os.chdir(current_dir)
            else:
                ad.log.info("The dumpstate_path file %s does not exist" %
                            dumpstate_path)
            if os.path.isfile(bugreport_path + "/power_anomaly_data.txt"):
                ad.log.info("Modem Power Anomaly File Exists!!")
                return True
            ad.log.info("Modem Power Anomaly File DO NOT Exist!!")
            return False
        except Exception as e:
            ad.log.error(e)
            return False
Exemplo n.º 10
0
    def _fdr_stress_test(self, *args):
        """Fdr Reliability Test

        Arguments:
            function_name: function to be checked

        Expected Results:
            No crash happens in stress test.

        Returns:
            True is pass, False if fail.
        """
        self.number_of_devices = 2
        fail_count = collections.defaultdict(int)
        test_result = True

        for i in range(1, self.stress_test_number + 1):
            begin_time = get_current_epoch_time()
            test_name = "%s_iteration_%s" % (self.test_name, i)
            log_msg = "[Test Case] %s" % test_name
            self.log.info("%s begin", log_msg)
            self.dut.droid.logI("%s begin" % log_msg)
            test_msg = "FDR Stress Test %s Iteration <%s> / <%s>" % (
                self.test_name, i, self.stress_test_number)
            self.log.info(test_msg)
            fastboot_wipe(self.dut)
            self.log.info("%s wait %s secs for radio up.", self.dut.serial,
                          WAIT_TIME_AFTER_FDR)
            time.sleep(WAIT_TIME_AFTER_FDR)
            failed_tests = self.feature_validator(*args)
            for test in failed_tests:
                fail_count[test] += 1

            crash_report = self.dut.check_crash_report("%s_%s" %
                                                       (self.test_name, i),
                                                       begin_time,
                                                       log_crash_report=True)
            if crash_report:
                fail_count["crashes"] += 1
            if failed_tests or crash_report:
                self.log.error("%s FAIL with %s and crashes %s", test_msg,
                               failed_tests, crash_report)
                self._take_bug_report(test_name, begin_time)
            else:
                self.log.info("%s PASS", test_msg)
            self.log.info("Total failure count: %s", dict(fail_count))
            self.log.info("%s end", log_msg)
            self.dut.droid.logI("%s end" % log_msg)

        for failure, count in fail_count.items():
            if count:
                self.log.error("%s failure count = %s in total %s iterations",
                               failure, count, self.stress_test_number)
                test_result = False
        return test_result
    def _test_stress_cbrs(self, mo_mt):
        """ Test CBRS/SSIM VoLTE Stress

            mo_mt: indicating this call sequence is MO or MT.
                Valid input: DIRECTION_MOBILE_ORIGINATED and
                DIRECTION_MOBILE_TERMINATED.

        Returns:
            True if pass; False if fail.
        """
        if (mo_mt not in [
                DIRECTION_MOBILE_ORIGINATED, DIRECTION_MOBILE_TERMINATED
        ]):
            self.log.error("Invalid parameters.")
            return False
        ads = [self.android_devices[0], self.android_devices[1]]
        total_iteration = self.stress_test_number
        fail_count = collections.defaultdict(int)
        self.cbrs_subid, self.default_subid = get_cbrs_and_default_sub_id(
            ads[0])
        self.log.info("Total iteration = %d.", total_iteration)
        current_iteration = 1
        for i in range(1, total_iteration + 1):
            msg = "Stress Call Test Iteration: <%s> / <%s>" % (i,
                                                               total_iteration)
            begin_time = get_current_epoch_time()
            self.log.info(msg)
            start_qxdm_loggers(self.log, self.android_devices, begin_time)
            iteration_result = self._cbrs_call_sequence(
                ads, mo_mt, self._phone_setup_volte,
                self._is_current_data_on_cbrs,
                self._test_data_browsing_success_using_sl4a,
                self._is_phone_in_call_volte, self._is_current_data_on_default,
                self._test_data_browsing_success_using_sl4a,
                self._test_data_browsing_success_using_sl4a,
                self._is_current_data_on_cbrs, True)
            self.log.info("Result: %s", iteration_result)
            if iteration_result:
                self.log.info(">----Iteration : %d/%d succeed.----<", i,
                              total_iteration)
            else:
                fail_count["cbrs_fail"] += 1
                self.log.error(">----Iteration : %d/%d failed.----<", i,
                               total_iteration)
                self._take_bug_report("%s_IterNo_%s" % (self.test_name, i),
                                      begin_time)
            current_iteration += 1
        test_result = True
        for failure, count in fail_count.items():
            if count:
                self.log.error("%s: %s %s failures in %s iterations",
                               self.test_name, count, failure, total_iteration)
                test_result = False
        return test_result
Exemplo n.º 12
0
    def _data_download(self, file_names=["5MB", "10MB", "20MB", "50MB"]):
        begin_time = get_current_epoch_time()
        start_qxdm_loggers(self.log, self.android_devices)
        self.dut.log.info(dict(self.result_info))
        selection = random.randrange(0, len(file_names))
        file_name = file_names[selection]
        self.result_info["Internet Connection Check Total"] += 1
        if not self.internet_connection_check_method(self.log, self.dut):
            rat = self.dut.adb.getprop("gsm.network.type")
            self.dut.log.info("Network in RAT %s", rat)
            if self.dut_incall and not is_rat_svd_capable(rat.upper()):
                self.result_info[
                    "Expected Incall Internet Connection Check Failure"] += 1
                return True
            else:
                self.result_info["Internet Connection Check Failure"] += 1
                test_name = "%s_internet_connection_No_%s_failure" % (
                    self.test_name,
                    self.result_info["Internet Connection Check Failure"])
                try:
                    self._ad_take_extra_logs(self.dut, test_name, begin_time)
                    self._ad_take_bugreport(self.dut, test_name, begin_time)
                except Exception as e:
                    self.log.exception(e)
                return False
        else:
            self.result_info["Internet Connection Check Success"] += 1

        self.result_info["File Download Total"] += 1
        if not active_file_download_test(
                self.log, self.dut, file_name,
                method=self.file_download_method):
            self.result_info["File Download Failure"] += 1
            if self.result_info["File Download Failure"] == 1:
                try:
                    self._ad_take_extra_logs(
                        self.dut, "%s_file_download_failure" % self.test_name,
                        begin_time)
                    self._ad_take_bugreport(
                        self.dut, "%s_file_download_failure" % self.test_name,
                        begin_time)
                except Exception as e:
                    self.log.exception(e)
            return False
        else:
            self.result_info["File Download Success"] += 1
            return True
    def test_screenoff_toggle_between_AP(self):

        # Set attenuator to connect phone to both networks
        network_main = copy.deepcopy(self.main_network)[hc.BAND_2G]
        network_aux = copy.deepcopy(self.aux_network)[hc.BAND_2G]
        # Connect to both APs
        network_main = self.main_network[hc.BAND_2G]
        network_aux = self.aux_network[hc.BAND_2G]
        self.log.info('Set attenuation to connect device to the main AP')
        self.set_attenuation(self.atten_level[wc.AP_MAIN])
        self.brconfigs_main = self.setup_ap_connection(
            network_main, ap=self.access_point_main)
        self.log.info('Set attenuation to connect device to the aux AP')
        self.set_attenuation(self.atten_level[wc.AP_AUX])
        self.brconfigs_aux = self.setup_ap_connection(network_aux,
                                                      ap=self.access_point_aux)
        self.mon_info.duration = self.toggle_interval
        self.dut.droid.goToSleepNow()
        time.sleep(5)
        # Toggle between two networks
        begin_time = utils.get_current_epoch_time()
        results = []
        for i in range(self.toggle_times):
            self.dut.log.info('Connecting to %s' % network_main[wc.SSID])
            self.dut.droid.wifiConnect(network_main)
            results.append(self.monsoon_data_collect_save())
            self.dut.log.info('Connecting to %s' % network_aux[wc.SSID])
            self.dut.droid.wifiConnect(network_aux)
            results.append(self.monsoon_data_collect_save())
        plot_utils.monsoon_data_plot(self.mon_info, results)

        total_current = 0
        total_samples = 0
        for result in results:
            total_current += result.average_current * result.num_samples
            total_samples += result.num_samples
        average_current = total_current / total_samples

        self.power_result.metric_value = [
            result.total_power for result in results
        ]
        # Take Bugreport
        if self.bug_report:
            self.dut.take_bug_report(self.test_name, begin_time)
        # Path fail check
        self.pass_fail_check(average_current)
    def _test_end(self, result, e):
        """Class internal function to signal the end of a test case execution.

        Args:
            result: One of the TEST_RESULT enums in TestResultEnums.
            e: A test termination signal (usually an exception object). It can
                be any exception instance or of any subclass of
                acts.signals.TestSignal.
        """
        self.end_time = utils.get_current_epoch_time()
        self.log_end_time = logger.epoch_to_log_line_timestamp(self.end_time)
        self.result = result
        if self.extra_errors:
            self.result = TestResultEnums.TEST_RESULT_UNKNOWN
        if isinstance(e, signals.TestSignal):
            self.details = e.details
            self.extras = e.extras
        elif e:
            self.details = str(e)
Exemplo n.º 15
0
 def flp_ttff_hs_and_cs(self, criteria, location):
     flp_results = []
     ttff = {"hs": "Hot Start", "cs": "Cold Start"}
     for mode in ttff.keys():
         begin_time = get_current_epoch_time()
         process_gnss_by_gtw_gpstool(self.ad,
                                     self.standalone_cs_criteria,
                                     type="flp")
         start_ttff_by_gtw_gpstool(self.ad,
                                   ttff_mode=mode,
                                   iteration=self.ttff_test_cycle)
         ttff_data = process_ttff_by_gtw_gpstool(self.ad,
                                                 begin_time,
                                                 location,
                                                 type="flp")
         result = check_ttff_data(self.ad, ttff_data, ttff[mode], criteria)
         flp_results.append(result)
     asserts.assert_true(all(flp_results),
                         "FLP TTFF fails to reach designated criteria")
 def _make_phone_call(self, ads):
     self.result_info["Total Calls"] += 1
     begin_time = get_current_epoch_time()
     start_qxdm_loggers(self.log, self.android_devices)
     if not call_setup_teardown(
             self.log,
             ads[0],
             ads[1],
             ad_hangup=ads[random.randrange(0, 2)],
             wait_time_in_call=random.randrange(
                 self.min_phone_call_duration,
                 self.max_phone_call_duration)):
         self.log.error("Call setup and teardown failed.")
         self.result_info["Call Failure"] += 1
         self._take_bug_report("%s_call_failure" % self.test_name,
                               begin_time)
         return False
     self.log.info("Call setup and teardown succeed.")
     return True
 def data_test(self):
     failure = 0
     total_count = 0
     #file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB", "1GB"]
     #wifi download is very slow in lab, limit the file size upto 200MB
     file_names = ["5MB", "10MB", "20MB", "50MB", "200MB"]
     while time.time() < self.finishing_time:
         total_count += 1
         begin_time = get_current_epoch_time()
         start_qxdm_loggers(self.log, self.android_devices)
         try:
             self.dut.log.info(dict(self.result_info))
             self.result_info["Total file download"] += 1
             selection = random.randrange(0, len(file_names))
             file_name = file_names[selection]
             if not active_file_download_test(self.log, self.dut,
                                              file_name):
                 self.result_info["File download failure"] += 1
                 failure += 1
                 if self.result_info["File download failure"] == 1:
                     self._take_bug_report(
                         "%s_file_download_failure" % self.test_name,
                         begin_time)
             self.dut.droid.goToSleepNow()
             time.sleep(random.randrange(0, self.max_sleep_time))
         except IGNORE_EXCEPTIONS as e:
             self.log.error("Exception error %s", str(e))
             self.result_info["Exception Errors"] += 1
             if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE:
                 self.log.error("Too many exception error %s",
                                IGNORE_EXCEPTIONS)
                 return False
         except Exception as e:
             self.log.error(e)
             return False
         self.dut.log.info("File download test failure: %s/%s", failure,
                           total_count)
     if failure / total_count > 0.1:
         return False
     else:
         return True
Exemplo n.º 18
0
 def _cycle_aboslute_volume_control_helper(self, volume_step,
                                           android_volume_steps, pri_dut):
     begin_time = get_current_epoch_time()
     pri_dut.droid.setMediaVolume(volume_step)
     percentage_to_set = int((volume_step / android_volume_steps) * 100)
     self.log.info("Setting phone volume to {}%".format(percentage_to_set))
     volume_info_logcat = pri_dut.search_logcat(
         logcat_strings['media_playback_vol_changed'], begin_time)
     if len(volume_info_logcat) > 1:
         self.log.info("Instant response detected.")
         carkit_response = volume_info_logcat[-1]['log_message'].split(',')
         for item in carkit_response:
             if " volume=" in item:
                 carkit_vol_response = int(
                     (int(item.split("=")[-1]) / android_volume_steps) *
                     100)
                 self.log.info(
                     "Carkit set volume to {}%".format(carkit_vol_response))
     result = input(
         "Did volume change reflect properly on carkit and phone? (Y/n) "
     ).lower()