def phone_setup_data_for_subscription(log, ad, sub_id, network_generation): """Setup Phone <sub_id> Data to <network_generation> Args: log: log object ad: android device object sub_id: subscription id network_generation: network generation, e.g. GEN_2G, GEN_3G, GEN_4G Returns: True if success, False if fail. """ toggle_airplane_mode(log, ad, False, strict_checking=False) set_wifi_to_default(log, ad) if not set_wfc_mode(log, ad, WFC_MODE_DISABLED): ad.log.error("Disable WFC failed.") return False if not ensure_network_generation_for_subscription( log, ad, sub_id, network_generation, voice_or_data=NETWORK_SERVICE_DATA): get_telephony_signal_strength(ad) return False return True
def phone_setup_csfb_for_subscription(log, ad, sub_id): """Setup phone for CSFB call test for subscription id. Setup Phone to be in 4G mode. Disabled VoLTE. Args: log: log object ad: Android device object. sub_id: subscription id. Returns: True if setup successfully. False for errors. """ if not phone_setup_4g_for_subscription(log, ad, sub_id): log.error("{} failed to set to 4G data.".format(ad.serial)) return False if ad.droid.imsIsEnhanced4gLteModeSettingEnabledByPlatform(): toggle_volte(log, ad, False) if not ensure_network_generation_for_subscription( log, ad, sub_id, GEN_4G, voice_or_data=NETWORK_SERVICE_DATA): return False if not wait_for_voice_attach_for_subscription(log, ad, sub_id, MAX_WAIT_TIME_NW_SELECTION): return False return phone_idle_csfb_for_subscription(log, ad, sub_id)
def _data_call_test(self, sub_id, generation): self.dut.log.info(dict(self.result_info)) begin_time = get_device_epoch_time(self.dut) start_qxdm_loggers(self.log, self.android_devices) self.result_info["Network Change Request Total"] += 1 test_name = "%s_network_change_test_iter_%s" % ( self.test_name, self.result_info["Network Change Request Total"]) log_msg = "[Test Case] %s" % test_name self.log.info("%s begin", log_msg) self.dut.droid.logI("%s begin" % log_msg) if not ensure_network_generation_for_subscription( self.log, self.dut, sub_id, generation) or not self._check_data(): self.result_info["Network Change Failure"] += 1 self.dut.droid.logI("%s end" % log_msg) self.dut.log.info("%s end", log_msg) 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.warning(e) return False if not self._mobile_data_toggling(setup=None): return False return True
def phone_setup_iwlan_for_subscription(log, ad, sub_id, is_airplane_mode, wfc_mode, wifi_ssid=None, wifi_pwd=None): """Phone setup function for epdg call test for subscription id. Set WFC mode according to wfc_mode. Set airplane mode according to is_airplane_mode. Make sure phone connect to WiFi. (If wifi_ssid is not None.) Wait for phone to be in iwlan data network type. Wait for phone to report wfc enabled flag to be true. Args: log: Log object. ad: Android device object. sub_id: subscription id. is_airplane_mode: True to turn on airplane mode. False to turn off airplane mode. wfc_mode: WFC mode to set to. wifi_ssid: WiFi network SSID. This is optional. If wifi_ssid is None, then phone_setup_iwlan will not attempt to connect to wifi. wifi_pwd: WiFi network password. This is optional. Returns: True if success. False if fail. """ # VoLTE settings are unavailable in airplane mode toggle_airplane_mode(log, ad, False) # Now that we are out of APM, toggle VoLTE if necessary if ad.droid.imsIsEnhanced4gLteModeSettingEnabledByPlatform(): toggle_volte(log, ad, True) if not is_airplane_mode and not ensure_network_generation_for_subscription( log, ad, sub_id, GEN_4G, voice_or_data=NETWORK_SERVICE_DATA): return False if not set_wfc_mode(log, ad, wfc_mode): log.error("{} set WFC mode failed.".format(ad.serial)) return False if not toggle_airplane_mode(log, ad, is_airplane_mode): log.error("Failed to enable airplane mode on {}".format(ad.serial)) return False if wifi_ssid is not None: if not ensure_wifi_connected(log, ad, wifi_ssid, wifi_pwd): log.error("{} connect to WiFi failed.".format(ad.serial)) return False return phone_idle_iwlan_for_subscription(log, ad, sub_id)
def phone_setup_data_for_subscription(log, ad, sub_id, network_generation): """Setup Phone <sub_id> Data to <network_generation> Args: log: log object ad: android device object sub_id: subscription id network_generation: network generation, e.g. GEN_2G, GEN_3G, GEN_4G Returns: True if success, False if fail. """ toggle_airplane_mode(log, ad, False) if not set_wfc_mode(log, ad, WFC_MODE_DISABLED): log.error("{} Disable WFC failed.".format(ad.serial)) return False if not ensure_network_generation_for_subscription( log, ad, sub_id, network_generation, voice_or_data=NETWORK_SERVICE_DATA): return False return True
def data_connectivity_single_bearer(log, ad, nw_gen): """Test data connection: single-bearer (no voice). Turn off airplane mode, enable Cellular Data. Ensure phone data generation is expected. Verify Internet. Disable Cellular Data, verify Internet is inaccessible. Enable Cellular Data, verify Internet. Args: log: log object. ad: android object. nw_gen: network generation the phone should on. Returns: True if success. False if failed. """ ensure_phones_idle(log, [ad]) if not ensure_network_generation_for_subscription( log, ad, get_default_data_sub_id(ad), nw_gen, MAX_WAIT_TIME_NW_SELECTION, NETWORK_SERVICE_DATA): log.error("Device failed to reselect in {}s.".format( MAX_WAIT_TIME_NW_SELECTION)) return False try: log.info("Step1 Airplane Off, Data On.") toggle_airplane_mode(log, ad, False) ad.droid.telephonyToggleDataConnection(True) if not wait_for_cell_data_connection(log, ad, True): log.error("Failed to enable data connection.") return False log.info("Step2 Verify internet") if not verify_http_connection(log, ad): log.error("Data not available on cell.") return False log.info("Step3 Turn off data and verify not connected.") ad.droid.telephonyToggleDataConnection(False) if not wait_for_cell_data_connection(log, ad, False): log.error("Step3 Failed to disable data connection.") return False if verify_http_connection(log, ad): log.error("Step3 Data still available when disabled.") return False log.info("Step4 Re-enable data.") ad.droid.telephonyToggleDataConnection(True) if not wait_for_cell_data_connection(log, ad, True): log.error("Step4 failed to re-enable data.") return False if not verify_http_connection(log, ad): log.error("Data not available on cell.") return False if not is_droid_in_network_generation_for_subscription( log, ad, get_default_data_sub_id(ad), nw_gen, NETWORK_SERVICE_DATA): log.error("Failed: droid is no longer on correct network") log.info("Expected:{}, Current:{}".format( nw_gen, rat_generation_from_rat( get_network_rat_for_subscription( log, ad, get_default_data_sub_id( ad), NETWORK_SERVICE_DATA)))) return False return True finally: ad.droid.telephonyToggleDataConnection(True)
def wifi_cell_switching(log, ad, wifi_network_ssid, wifi_network_pass, nw_gen): """Test data connection network switching when phone on <nw_gen>. Ensure phone is on <nw_gen> Ensure WiFi can connect to live network, Airplane mode is off, data connection is on, WiFi is on. Turn off WiFi, verify data is on cell and browse to google.com is OK. Turn on WiFi, verify data is on WiFi and browse to google.com is OK. Turn off WiFi, verify data is on cell and browse to google.com is OK. Args: log: log object. ad: android object. wifi_network_ssid: ssid for live wifi network. wifi_network_pass: password for live wifi network. nw_gen: network generation the phone should be camped on. Returns: True if pass. """ try: if not ensure_network_generation_for_subscription( log, ad, get_default_data_sub_id(ad), nw_gen, MAX_WAIT_TIME_NW_SELECTION, NETWORK_SERVICE_DATA): log.error("Device failed to register in {}".format(nw_gen)) return False # Ensure WiFi can connect to live network log.info("Make sure phone can connect to live network by WIFI") if not ensure_wifi_connected(log, ad, wifi_network_ssid, wifi_network_pass): log.error("WiFi connect fail.") return False log.info("Phone connected to WIFI.") log.info("Step1 Airplane Off, WiFi On, Data On.") toggle_airplane_mode(log, ad, False) WifiUtils.wifi_toggle_state(log, ad, True) ad.droid.telephonyToggleDataConnection(True) if (not wait_for_wifi_data_connection(log, ad, True) or not verify_http_connection(log, ad)): log.error("Data is not on WiFi") return False log.info("Step2 WiFi is Off, Data is on Cell.") WifiUtils.wifi_toggle_state(log, ad, False) if (not wait_for_cell_data_connection(log, ad, True) or not verify_http_connection(log, ad)): log.error("Data did not return to cell") return False log.info("Step3 WiFi is On, Data is on WiFi.") WifiUtils.wifi_toggle_state(log, ad, True) if (not wait_for_wifi_data_connection(log, ad, True) or not verify_http_connection(log, ad)): log.error("Data did not return to WiFi") return False log.info("Step4 WiFi is Off, Data is on Cell.") WifiUtils.wifi_toggle_state(log, ad, False) if (not wait_for_cell_data_connection(log, ad, True) or not verify_http_connection(log, ad)): log.error("Data did not return to cell") return False return True finally: WifiUtils.wifi_toggle_state(log, ad, False)