def on_fail(self, test_name, begin_time):
     result = True
     if not super(BluetoothCarHfpBaseTest, self).on_fail(
             test_name, begin_time):
         result = False
     ensure_phones_default_state(self.log, self.android_devices[1:])
     return result
コード例 #2
0
    def teardown_class(self):
        try:
            ensure_phones_default_state(self.log, self.android_devices)

            for ad in self.android_devices:
                ad.droid.telephonyAdjustPreciseCallStateListenLevel(
                    PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND, False)
                ad.droid.telephonyAdjustPreciseCallStateListenLevel(
                    PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING, False)
                ad.droid.telephonyAdjustPreciseCallStateListenLevel(
                    PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND, False)
                if "enable_wifi_verbose_logging" in self.user_params:
                    ad.droid.wifiEnableVerboseLogging(
                        WIFI_VERBOSE_LOGGING_DISABLED)
        finally:
            for ad in self.android_devices:
                try:
                    toggle_airplane_mode(self.log,
                                         ad,
                                         True,
                                         strict_checking=False)
                except BrokenPipeError:
                    # Broken Pipe, can not call SL4A API to turn on Airplane Mode.
                    # Use adb command to turn on Airplane Mode.
                    if not force_airplane_mode(ad, True):
                        self.log.error(
                            "Can not turn on airplane mode on:{}".format(
                                ad.serial))
        return True
コード例 #3
0
    def test_smoke_wfc_call_sms(self):
        ads = self.android_devices
        sms_idle_result = False
        sms_incall_result = False
        call_result = False

        self.log.info("--------start test_smoke_wfc_call_sms--------")
        for ad in [ads[0], ads[1]]:
            if not ad.droid.imsIsWfcEnabledByPlatform():
                self.log.info("WFC not supported by platform.")
                return True
        try:
            ensure_phones_default_state(self.log, ads)
            tasks = [(phone_setup_iwlan,
                      (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
                       self.wifi_network_ssid, self.wifi_network_pass)),
                     (phone_setup_iwlan,
                      (self.log, ads[1], True, WFC_MODE_WIFI_PREFERRED,
                       self.wifi_network_ssid, self.wifi_network_pass))]
            if not multithread_func(self.log, tasks):
                self.log.error("Phone Failed to Set Up WiFI Calling.")
                return False

            self.log.info("1. Verify SMS in idle.")
            if sms_send_receive_verify(self.log, ads[0], ads[1],
                                       [rand_ascii_str(50)]):
                sms_idle_result = True

            self.log.info("2. Setup WiFi Call.")
            if not call_setup_teardown(
                    self.log,
                    ads[0],
                    ads[1],
                    ad_hangup=None,
                    verify_caller_func=is_phone_in_call_iwlan,
                    verify_callee_func=is_phone_in_call_iwlan):
                self.log.error("Setup WiFi Call Failed.")
                self.log.info("sms_idle_result:{}".format(sms_idle_result))
                return False

            self.log.info("3. Verify SMS in call.")
            if sms_send_receive_verify(self.log, ads[0], ads[1],
                                       [rand_ascii_str(51)]):
                sms_incall_result = True

            self.log.info("4. Verify Call not drop and hangup.")
            if (is_phone_in_call_iwlan(self.log, ads[0])
                    and is_phone_in_call_iwlan(self.log, ads[1])
                    and hangup_call(self.log, ads[0])):
                call_result = True

            return (call_result and sms_idle_result and sms_incall_result)
        finally:
            self.log.info(
                "Summary for test run. Testbed:<{}>. <WFC> SMS idle: {}, "
                "SMS in call: {}, Voice Call: {}".format(
                    getattr(self, Config.ikey_testbed_name.value),
                    sms_idle_result, sms_incall_result, call_result))
    def setup_test(self):
        if getattr(self, "diag_logger", None):
            for logger in self.diag_logger:
                self.log.info("Starting a diagnostic session %s", logger)
                self.logger_sessions.append((logger, logger.start()))

        if self.skip_reset_between_cases:
            ensure_phones_idle(self.log, self.android_devices)
        ensure_phones_default_state(self.log, self.android_devices)
コード例 #5
0
    def test_smoke_data_airplane_mode_network_switch_tethering(self):
        try:
            ads = self.android_devices
            apm_result = False
            nw_switch_result = False
            tethering_result = False

            self.log.info("--------start test_smoke_data_airplane_mode_network"
                          "_switch_tethering--------")
            ensure_phones_default_state(self.log, ads)
            self.log.info("1. Verify toggle airplane mode.")
            apm_result = airplane_mode_test(self.log, ads[0])
            self.log.info("2. Verify LTE-WiFi network switch.")
            nw_switch_result = wifi_cell_switching(self.log, ads[0],
                                                   self.wifi_network_ssid,
                                                   self.wifi_network_pass,
                                                   GEN_4G)
            if ads[0].droid.carrierConfigIsTetheringModeAllowed(
                    TETHERING_MODE_WIFI,
                    MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK):
                self.log.info("3. Verify WiFi Tethering.")
                if ads[0].droid.wifiIsApEnabled():
                    WifiUtils.stop_wifi_tethering(self.log, ads[0])
                tethering_result = wifi_tethering_setup_teardown(
                    self.log,
                    ads[0], [ads[1]],
                    ap_band=WifiUtils.WIFI_CONFIG_APBAND_2G,
                    check_interval=10,
                    check_iteration=4)
                # check_interval=10, check_iteration=4: in this Smoke test,
                # check tethering connection for 4 times, each time delay 10s,
                # to provide a reasonable check_time (10*4=40s) and also reduce test
                # execution time. In regular test, check_iteration is set to 10.
            else:
                self.log.info("3. Skip WiFi Tethering."
                              "Tethering not allowed on SIM.")
                tethering_result = SKIP

            return (apm_result and nw_switch_result and
                    ((tethering_result is True) or (tethering_result == SKIP)))
        finally:
            self.log.info(
                "Summary for test run. Testbed:<{}>. <Data> Airplane Mode: {}, "
                "WiFi-Cell Network Switch: {}, Tethering: {}".format(
                    getattr(self, Config.ikey_testbed_name.value), apm_result,
                    nw_switch_result, tethering_result))
コード例 #6
0
    def setup_test(self):
        for ad in self.android_devices:
            refresh_droid_config(self.log, ad)

        if getattr(self, "diag_logger", None):
            for logger in self.diag_logger:
                self.log.info(
                    "Starting a diagnostic session {}".format(logger))
                self.logger_sessions.append((logger, logger.start()))

        return ensure_phones_default_state(self.log, self.android_devices)
 def _test_setup(self,
                 apm=False,
                 rat=None,
                 volte=False,
                 wifi=None,
                 wfc=False,
                 mobile_data_always_on=False,
                 periodic_ping=False,
                 active_call=False):
     if not ensure_phones_default_state(self.log, self.android_devices):
         self.log.error("Fail to set phones in default state")
         return False
     else:
         self.log.info("Set phones in default state successfully")
     if apm and not self._setup_apm(): return False
     if rat and not self._setup_rat(rat, volte): return False
     if wifi and not self._setup_wifi(wifi): return False
     if wfc and not self._setup_wfc(): return False
     if mobile_data_always_on: set_mobile_data_always_on(self.ad, True)
     if periodic_ping and not self._start_alarm(): return False
     if active_call and not self._setup_phone_active_call(): return False
     self.ad.droid.goToSleepNow()
     return True
コード例 #8
0
    def test_smoke_volte_call_data_sms(self):
        try:
            ads = self.android_devices
            sms_idle_result = False
            sms_incall_result = False
            data_idle_result = False
            data_incall_result = False
            call_result = False

            self.log.info(
                "--------start test_smoke_volte_call_data_sms--------")
            ensure_phones_default_state(self.log, ads)
            tasks = [(phone_setup_volte, (self.log, ads[0])),
                     (phone_setup_volte, (self.log, ads[1]))]
            if not multithread_func(self.log, tasks):
                self.log.error("Phone Failed to Set Up VoLTE.")
                return False

            # This is to reduce call fail in VoLTE mode.
            # TODO: b/26338170 remove sleep, use proper API to check DUT status.
            time.sleep(10)

            self.log.info("1. SMS in LTE idle.")
            sms_idle_result = sms_send_receive_verify(self.log, ads[0], ads[1],
                                                      [rand_ascii_str(50)])

            self.log.info("2. Data in LTE idle.")
            if (wait_for_cell_data_connection(self.log, ads[0], True)
                    and verify_http_connection(self.log, ads[0])):
                data_idle_result = True

            self.log.info("3. Setup VoLTE Call.")
            if not call_setup_teardown(
                    self.log,
                    ads[0],
                    ads[1],
                    ad_hangup=None,
                    verify_caller_func=is_phone_in_call_volte,
                    verify_callee_func=is_phone_in_call_volte,
                    wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS):
                self.log.error("Setup VoLTE Call Failed.")
                return False

            self.log.info("4. Verify SMS in call.")
            sms_incall_result = sms_send_receive_verify(
                self.log, ads[0], ads[1], [rand_ascii_str(51)])

            self.log.info("5. Verify Data in call.")
            if (wait_for_cell_data_connection(self.log, ads[0], True)
                    and verify_http_connection(self.log, ads[0])):
                data_incall_result = True

            self.log.info("6. Verify Call not drop and hangup.")
            if (is_phone_in_call_volte(self.log, ads[0])
                    and is_phone_in_call_volte(self.log, ads[1])
                    and hangup_call(self.log, ads[0])):
                call_result = True

            return (sms_idle_result and data_idle_result and call_result
                    and sms_incall_result and data_incall_result)
        finally:
            self.log.info(
                "Summary for test run. Testbed:<{}>. <VoLTE> SMS idle: {}, "
                "Data idle: {}, SMS in call: {}, Data in call: {}, "
                "Voice Call: {}".format(
                    getattr(self, Config.ikey_testbed_name.value),
                    sms_idle_result, data_idle_result, sms_incall_result,
                    data_incall_result, call_result))
コード例 #9
0
    def test_smoke_3g_call_data_sms(self):
        try:
            ads = self.android_devices
            sms_idle_result = False
            sms_incall_result = False
            data_idle_result = False
            data_incall_result = False
            call_result = False

            self.log.info("--------start test_smoke_3g_call_data_sms--------")
            ensure_phones_default_state(self.log, ads)
            tasks = [(phone_setup_voice_3g, (self.log, ads[0])),
                     (phone_setup_voice_3g, (self.log, ads[1]))]
            if not multithread_func(self.log, tasks):
                self.log.error("Phone Failed to Set Up 3G.")
                return False
            self.log.info("1. SMS in 3G idle.")
            sms_idle_result = sms_send_receive_verify(self.log, ads[0], ads[1],
                                                      [rand_ascii_str(50)])

            self.log.info("2. Data in 3G idle.")
            if (wait_for_cell_data_connection(self.log, ads[0], True)
                    and verify_http_connection(self.log, ads[0])):
                data_idle_result = True

            self.log.info("3. Setup 3G Call.")
            if not call_setup_teardown(self.log,
                                       ads[0],
                                       ads[1],
                                       ad_hangup=None,
                                       verify_caller_func=is_phone_in_call_3g,
                                       verify_callee_func=is_phone_in_call_3g):
                self.log.error("Setup 3G Call Failed.")
                return False

            self.log.info("4. Verify SMS in call.")
            sms_incall_result = sms_send_receive_verify(
                self.log, ads[0], ads[1], [rand_ascii_str(51)])

            self.log.info("5. Verify Data in call.")
            if is_rat_svd_capable(
                    get_network_rat(self.log, ads[0], NETWORK_SERVICE_VOICE)):
                if (wait_for_cell_data_connection(self.log, ads[0], True)
                        and verify_http_connection(self.log, ads[0])):
                    data_incall_result = True
            else:
                self.log.info("Data in call not supported on current RAT."
                              "Skip Data verification.")
                data_incall_result = SKIP

            self.log.info("6. Verify Call not drop and hangup.")
            if (is_phone_in_call_3g(self.log, ads[0])
                    and is_phone_in_call_3g(self.log, ads[1])
                    and hangup_call(self.log, ads[0])):
                call_result = True

            return (sms_idle_result and data_idle_result and call_result
                    and sms_incall_result and ((data_incall_result is True) or
                                               (data_incall_result == SKIP)))
        finally:
            self.log.info(
                "Summary for test run. Testbed:<{}>. <3G> SMS idle: {}, "
                "Data idle: {}, SMS in call: {}, Data in call: {}, "
                "Voice Call: {}".format(
                    getattr(self, Config.ikey_testbed_name.value),
                    sms_idle_result, data_idle_result, sms_incall_result,
                    data_incall_result, call_result))
 def teardown_test(self):
     if not super(BluetoothCarHfpBaseTest, self).teardown_test():
         return False
     return ensure_phones_default_state(self.log, self.android_devices[1:])
コード例 #11
0
 def test_pre_flight_check(self):
     return ensure_phones_default_state(self.log, self.android_devices)
    def setup_class(self):
        sim_conf_file = self.user_params.get("sim_conf_file")
        if not sim_conf_file:
            self.log.info("\"sim_conf_file\" is not provided test bed config!")
        else:
            # If the sim_conf_file is not a full path, attempt to find it
            # relative to the config file.
            if not os.path.isfile(sim_conf_file):
                sim_conf_file = os.path.join(
                    self.user_params[Config.key_config_path], sim_conf_file)
                if not os.path.isfile(sim_conf_file):
                    self.log.error("Unable to load user config %s ",
                                   sim_conf_file)
                    return False

        setattr(
            self, "diag_logger",
            self.register_controller(acts.controllers.diag_logger,
                                     required=False))

        if not self.user_params.get("Attenuator"):
            ensure_phones_default_state(self.log, self.android_devices)
        else:
            ensure_phones_idle(self.log, self.android_devices)
        for ad in self.android_devices:
            setup_droid_properties(self.log, ad, sim_conf_file)

            # Setup VoWiFi MDN for Verizon. b/33187374
            build_id = ad.build_info["build_id"]
            if "vzw" in [
                    sub["operator"] for sub in ad.cfg["subscription"].values()
            ] and ad.is_apk_installed("com.google.android.wfcactivation"):
                ad.log.info("setup VoWiFi MDN per b/33187374")
                ad.adb.shell("setprop dbg.vzw.force_wfc_nv_enabled true")
                ad.adb.shell("am start --ei EXTRA_LAUNCH_CARRIER_APP 0 -n "
                             "\"com.google.android.wfcactivation/"
                             ".VzwEmergencyAddressActivity\"")
            # Start telephony monitor
            if not ad.is_apk_running("com.google.telephonymonitor"):
                ad.log.info("TelephonyMonitor is not running, start it now")
                ad.adb.shell(
                    'am broadcast -a '
                    'com.google.gservices.intent.action.GSERVICES_OVERRIDE -e '
                    '"ce.telephony_monitor_enable" "true"')
            # Sub ID setup
            initial_set_up_for_subid_infomation(self.log, ad)
            if "enable_wifi_verbose_logging" in self.user_params:
                ad.droid.wifiEnableVerboseLogging(WIFI_VERBOSE_LOGGING_ENABLED)
            # If device is setup already, skip the following setup procedures
            if getattr(ad, "telephony_test_setup", None):
                continue
            # Disable Emergency alerts
            # Set chrome browser start with no-first-run verification and
            # disable-fre. Give permission to read from and write to storage.
            for cmd in (
                    "am start -n com.google.android.setupwizard/."
                    "SetupWizardExitActivity",
                    "pm disable com.android.cellbroadcastreceiver",
                    "pm grant com.android.chrome "
                    "android.permission.READ_EXTERNAL_STORAGE",
                    "pm grant com.android.chrome "
                    "android.permission.WRITE_EXTERNAL_STORAGE",
                    "rm /data/local/chrome-command-line",
                    "am set-debug-app --persistent com.android.chrome",
                    'echo "chrome --no-default-browser-check --no-first-run '
                    '--disable-fre" > /data/local/tmp/chrome-command-line'):
                ad.adb.shell(cmd)

            # Ensure that a test class starts from a consistent state that
            # improves chances of valid network selection and facilitates
            # logging.
            try:
                if not set_phone_screen_on(self.log, ad):
                    self.log.error("Failed to set phone screen-on time.")
                    return False
                if not set_phone_silent_mode(self.log, ad):
                    self.log.error("Failed to set phone silent mode.")
                    return False
                ad.droid.telephonyAdjustPreciseCallStateListenLevel(
                    PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND, True)
                ad.droid.telephonyAdjustPreciseCallStateListenLevel(
                    PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING, True)
                ad.droid.telephonyAdjustPreciseCallStateListenLevel(
                    PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND, True)
            except Exception as e:
                self.log.error("Failure with %s", e)
            setattr(ad, "telephony_test_setup", True)

        return True