blob: c968b66ac9af40535ffb261f85d87015eeb8a67f [file] [log] [blame]
Girish Moturuf72690e2017-02-14 15:19:53 -08001#
2# Copyright 2017 - The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import logging
Girish Moturu2c21eb32017-05-25 14:37:55 +053017import random
Girish Moturuf72690e2017-02-14 15:19:53 -080018import socket
Girish Moturu2c21eb32017-05-25 14:37:55 +053019import time
Girish Moturuf72690e2017-02-14 15:19:53 -080020
21from acts import asserts
22from acts import base_test
23from acts import test_runner
Girish Moturu8c771892019-11-07 08:33:57 -080024from acts import utils
Girish Moturuf72690e2017-02-14 15:19:53 -080025from acts.controllers import adb
Girish Moturu2c21eb32017-05-25 14:37:55 +053026from acts.test_decorators import test_tracker_info
Girish Moturuf72690e2017-02-14 15:19:53 -080027from acts.test_utils.tel import tel_defines
Girish Moturu2c21eb32017-05-25 14:37:55 +053028from acts.test_utils.tel.tel_data_utils import wait_for_cell_data_connection
29from acts.test_utils.tel.tel_test_utils import get_operator_name
Girish Moturu2c21eb32017-05-25 14:37:55 +053030from acts.test_utils.tel.tel_test_utils import verify_http_connection
31from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_2G
32from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_5G
Girish Moturuf5d2b2a2018-05-30 10:07:32 -070033from acts.test_utils.net import socket_test_utils as sutils
Girish Moturu47366062018-05-23 12:48:11 -070034from acts.test_utils.net import arduino_test_utils as dutils
Girish Moturu95f2f452018-07-23 15:57:15 -070035from acts.test_utils.net import net_test_utils as nutils
Girish Moturu2c21eb32017-05-25 14:37:55 +053036from acts.test_utils.wifi import wifi_test_utils as wutils
Girish Moturuf72690e2017-02-14 15:19:53 -080037
Girish Moturu8d9741f2019-04-01 08:43:16 -070038WAIT_TIME = 5
Girish Moturuf72690e2017-02-14 15:19:53 -080039
40class WifiTetheringTest(base_test.BaseTestClass):
41 """ Tests for Wifi Tethering """
42
43 def setup_class(self):
44 """ Setup devices for tethering and unpack params """
Girish Moturu2c21eb32017-05-25 14:37:55 +053045
Girish Moturu2c21eb32017-05-25 14:37:55 +053046 self.hotspot_device = self.android_devices[0]
47 self.tethered_devices = self.android_devices[1:]
Girish Moturu8c771892019-11-07 08:33:57 -080048 req_params = ("url", "open_network")
Girish Moturuf72690e2017-02-14 15:19:53 -080049 self.unpack_userparams(req_params)
Girish Moturu8c771892019-11-07 08:33:57 -080050 self.network = {"SSID": "hotspot_%s" % utils.rand_ascii_str(6),
51 "password": "pass_%s" % utils.rand_ascii_str(6)}
Girish Moturu666e0972018-01-02 11:20:31 -080052 self.new_ssid = "wifi_tethering_test2"
Girish Moturu2c21eb32017-05-25 14:37:55 +053053
Girish Moturu95f2f452018-07-23 15:57:15 -070054 nutils.verify_lte_data_and_tethering_supported(self.hotspot_device)
Girish Moturu2c21eb32017-05-25 14:37:55 +053055 for ad in self.tethered_devices:
56 wutils.wifi_test_device_init(ad)
Girish Moturuf72690e2017-02-14 15:19:53 -080057
lutina8e26ac92019-11-25 18:38:11 +080058 def teardown_test(self):
59 if self.hotspot_device.droid.wifiIsApEnabled():
60 wutils.stop_wifi_tethering(self.hotspot_device)
61
Girish Moturuf72690e2017-02-14 15:19:53 -080062 def teardown_class(self):
63 """ Reset devices """
Girish Moturu9bd1e9a2017-12-14 10:10:25 -080064 for ad in self.tethered_devices:
Girish Moturu95f2f452018-07-23 15:57:15 -070065 wutils.reset_wifi(ad)
Girish Moturu2c21eb32017-05-25 14:37:55 +053066
67 def on_fail(self, test_name, begin_time):
68 """ Collect bug report on failure """
Girish Moturu95f2f452018-07-23 15:57:15 -070069 for ad in self.android_devices:
Girish Moturu7df90e32017-10-16 12:49:56 -070070 ad.take_bug_report(test_name, begin_time)
Girish Moturuf72690e2017-02-14 15:19:53 -080071
72 """ Helper functions """
73
Girish Moturu2c21eb32017-05-25 14:37:55 +053074 def _is_ipaddress_ipv6(self, ip_address):
Girish Moturuf72690e2017-02-14 15:19:53 -080075 """ Verify if the given string is a valid IPv6 address
76
77 Args:
78 1. string which contains the IP address
79
80 Returns:
81 True: if valid ipv6 address
82 False: if not
83 """
84 try:
85 socket.inet_pton(socket.AF_INET6, ip_address)
86 return True
87 except socket.error:
88 return False
89
90 def _supports_ipv6_tethering(self, dut):
91 """ Check if provider supports IPv6 tethering.
92 Currently, only Verizon supports IPv6 tethering
93
94 Returns:
95 True: if provider supports IPv6 tethering
96 False: if not
97 """
98 # Currently only Verizon support IPv6 tethering
Girish Moturube552fd2019-08-29 12:58:16 -070099 carrier_supports_tethering = ["vzw", "tmo", "Far EasTone", "Chunghwa Telecom"]
Girish Moturu2c21eb32017-05-25 14:37:55 +0530100 operator = get_operator_name(self.log, dut)
Girish Moturuf72690e2017-02-14 15:19:53 -0800101 return operator in carrier_supports_tethering
102
Girish Moturu2c21eb32017-05-25 14:37:55 +0530103 def _carrier_supports_ipv6(self,dut):
104 """ Verify if carrier supports ipv6
105 Currently, only verizon and t-mobile supports IPv6
106
107 Returns:
108 True: if carrier supports ipv6
109 False: if not
110 """
sasahuangb5f72c52019-08-23 17:33:22 +0800111 carrier_supports_ipv6 = ["vzw", "tmo", "Far EasTone", "Chunghwa Telecom"]
Girish Moturu2c21eb32017-05-25 14:37:55 +0530112 operator = get_operator_name(self.log, dut)
Girish Moturu7f287522017-09-25 13:33:06 -0700113 self.log.info("Carrier is %s" % operator)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530114 return operator in carrier_supports_ipv6
115
Girish Moturu2c21eb32017-05-25 14:37:55 +0530116 def _verify_ipv6_tethering(self, dut):
Girish Moturuf72690e2017-02-14 15:19:53 -0800117 """ Verify IPv6 tethering """
118 http_response = dut.droid.httpRequestString(self.url)
Girish Moturuf72690e2017-02-14 15:19:53 -0800119 self.log.info("IP address %s " % http_response)
Girish Moturu0fd0b942017-12-12 12:04:56 -0800120 active_link_addrs = dut.droid.connectivityGetAllAddressesOfActiveLink()
Girish Moturu2c21eb32017-05-25 14:37:55 +0530121 if dut==self.hotspot_device and self._carrier_supports_ipv6(dut)\
122 or self._supports_ipv6_tethering(self.hotspot_device):
Girish Moturuf72690e2017-02-14 15:19:53 -0800123 asserts.assert_true(self._is_ipaddress_ipv6(http_response),
124 "The http response did not return IPv6 address")
Girish Moturu0fd0b942017-12-12 12:04:56 -0800125 asserts.assert_true(
126 active_link_addrs and http_response in str(active_link_addrs),
127 "Could not find IPv6 address in link properties")
128 asserts.assert_true(
129 dut.droid.connectivityHasIPv6DefaultRoute(),
130 "Could not find IPv6 default route in link properties")
Girish Moturuf72690e2017-02-14 15:19:53 -0800131 else:
Girish Moturu0fd0b942017-12-12 12:04:56 -0800132 asserts.assert_true(
133 not dut.droid.connectivityHasIPv6DefaultRoute(),
134 "Found IPv6 default route in link properties")
Girish Moturuf72690e2017-02-14 15:19:53 -0800135
Girish Moturu2c21eb32017-05-25 14:37:55 +0530136 def _start_wifi_tethering(self, wifi_band=WIFI_CONFIG_APBAND_2G):
137 """ Start wifi tethering on hotspot device
138
139 Args:
140 1. wifi_band: specifies the wifi band to start the hotspot
141 on. The current options are 2G and 5G
142 """
143 wutils.start_wifi_tethering(self.hotspot_device,
144 self.network[wutils.WifiEnums.SSID_KEY],
145 self.network[wutils.WifiEnums.PWD_KEY],
146 wifi_band)
147
148 def _connect_disconnect_devices(self):
149 """ Randomly connect and disconnect devices from the
150 self.tethered_devices list to hotspot device
151 """
152 device_connected = [ False ] * len(self.tethered_devices)
153 for _ in range(50):
154 dut_id = random.randint(0, len(self.tethered_devices)-1)
155 dut = self.tethered_devices[dut_id]
Girish Moturu7df90e32017-10-16 12:49:56 -0700156 # wait for 1 sec between connect & disconnect stress test
157 time.sleep(1)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530158 if device_connected[dut_id]:
159 wutils.wifi_forget_network(dut, self.network["SSID"])
160 else:
161 wutils.wifi_connect(dut, self.network)
162 device_connected[dut_id] = not device_connected[dut_id]
163
Girish Moturu47366062018-05-23 12:48:11 -0700164 def _connect_disconnect_android_device(self, dut_id, wifi_state):
165 """ Connect or disconnect wifi on android device depending on the
166 current wifi state
167
168 Args:
169 1. dut_id: tethered device to change the wifi state
170 2. wifi_state: current wifi state
171 """
172 ad = self.tethered_devices[dut_id]
173 if wifi_state:
174 self.log.info("Disconnecting wifi on android device")
175 wutils.wifi_forget_network(ad, self.network["SSID"])
176 else:
177 self.log.info("Connecting to wifi on android device")
178 wutils.wifi_connect(ad, self.network)
179
180 def _connect_disconnect_wifi_dongle(self, dut_id, wifi_state):
181 """ Connect or disconnect wifi on wifi dongle depending on the
182 current wifi state
183
184 Args:
185 1. dut_id: wifi dongle to change the wifi state
186 2. wifi_state: current wifi state
187 """
188 wd = self.arduino_wifi_dongles[dut_id]
189 if wifi_state:
190 self.log.info("Disconnecting wifi on dongle")
191 dutils.disconnect_wifi(wd)
192 else:
193 self.log.info("Connecting to wifi on dongle")
194 dutils.connect_wifi(wd, self.network)
195
196 def _connect_disconnect_tethered_devices(self):
197 """ Connect disconnect tethered devices to wifi hotspot """
198 num_android_devices = len(self.tethered_devices)
199 num_wifi_dongles = 0
Girish Moturu95f2f452018-07-23 15:57:15 -0700200 if hasattr(self, 'arduino_wifi_dongles'):
Girish Moturu47366062018-05-23 12:48:11 -0700201 num_wifi_dongles = len(self.arduino_wifi_dongles)
202 total_devices = num_android_devices + num_wifi_dongles
203 device_connected = [False] * total_devices
204 for _ in range(50):
205 dut_id = random.randint(0, total_devices-1)
206 wifi_state = device_connected[dut_id]
207 if dut_id < num_android_devices:
208 self._connect_disconnect_android_device(dut_id, wifi_state)
209 else:
210 self._connect_disconnect_wifi_dongle(dut_id-num_android_devices,
211 wifi_state)
212 device_connected[dut_id] = not device_connected[dut_id]
213
Girish Moturu7f287522017-09-25 13:33:06 -0700214 def _verify_ping(self, dut, ip, isIPv6=False):
Girish Moturu2c21eb32017-05-25 14:37:55 +0530215 """ Verify ping works from the dut to IP/hostname
216
217 Args:
218 1. dut - ad object to check ping from
219 2. ip - ip/hostname to ping (IPv4 and IPv6)
220
221 Returns:
222 True - if ping is successful
223 False - if not
224 """
225 self.log.info("Pinging %s from dut %s" % (ip, dut.serial))
Girish Moturu7f287522017-09-25 13:33:06 -0700226 if isIPv6 or self._is_ipaddress_ipv6(ip):
Girish Moturu2c21eb32017-05-25 14:37:55 +0530227 return dut.droid.pingHost(ip, 5, "ping6")
228 return dut.droid.pingHost(ip)
229
230 def _return_ip_for_interface(self, dut, iface_name):
231 """ Return list of IP addresses for an interface
232
233 Args:
234 1. dut - ad object
235 2. iface_name - interface name
236
237 Returns:
238 List of IPv4 and IPv6 addresses
239 """
240 return dut.droid.connectivityGetIPv4Addresses(iface_name) + \
241 dut.droid.connectivityGetIPv6Addresses(iface_name)
242
Girish Moturu47366062018-05-23 12:48:11 -0700243 def _test_traffic_between_two_tethered_devices(self, ad, wd):
Girish Moturu2c21eb32017-05-25 14:37:55 +0530244 """ Verify pinging interfaces of one DUT from another
245
246 Args:
Girish Moturu47366062018-05-23 12:48:11 -0700247 1. ad - android device
248 2. wd - wifi dongle
Girish Moturu2c21eb32017-05-25 14:37:55 +0530249 """
Girish Moturu47366062018-05-23 12:48:11 -0700250 wutils.wifi_connect(ad, self.network)
251 dutils.connect_wifi(wd, self.network)
252 local_ip = ad.droid.connectivityGetIPv4Addresses('wlan0')[0]
253 remote_ip = wd.ip_address()
254 port = 8888
Girish Moturu2c21eb32017-05-25 14:37:55 +0530255
Girish Moturu47366062018-05-23 12:48:11 -0700256 time.sleep(6) # wait until UDP packets method is invoked
Girish Moturuf5d2b2a2018-05-30 10:07:32 -0700257 socket = sutils.open_datagram_socket(ad, local_ip, port)
258 sutils.send_recv_data_datagram_sockets(
Girish Moturu47366062018-05-23 12:48:11 -0700259 ad, ad, socket, socket, remote_ip, port)
Girish Moturuf5d2b2a2018-05-30 10:07:32 -0700260 sutils.close_datagram_socket(ad, socket)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530261
262 def _ping_hotspot_interfaces_from_tethered_device(self, dut):
263 """ Ping hotspot interfaces from tethered device
264
265 Args:
266 1. dut - tethered device
267
268 Returns:
269 True - if all IP addresses are pingable
270 False - if not
271 """
272 ifaces = self.hotspot_device.droid.connectivityGetNetworkInterfaces()
273 return_result = True
274 for interface in ifaces:
275 iface_name = interface.split()[0].split(':')[1]
276 if iface_name == "lo":
277 continue
278 ip_list = self._return_ip_for_interface(
279 self.hotspot_device, iface_name)
280 for ip in ip_list:
281 ping_result = self._verify_ping(dut, ip)
282 self.log.info("Ping result: %s %s %s" %
283 (iface_name, ip, ping_result))
284 return_result = return_result and ping_result
285
286 return return_result
Girish Moturuf72690e2017-02-14 15:19:53 -0800287
Girish Moturub0768fa2018-02-13 15:24:27 -0800288 def _save_wifi_softap_configuration(self, ad, config):
289 """ Save soft AP configuration
290
291 Args:
292 1. dut - device to save configuration on
293 2. config - soft ap configuration
294 """
295 asserts.assert_true(ad.droid.wifiSetWifiApConfiguration(config),
296 "Failed to set WifiAp Configuration")
297 wifi_ap = ad.droid.wifiGetApConfiguration()
298 asserts.assert_true(wifi_ap[wutils.WifiEnums.SSID_KEY] == config[wutils.WifiEnums.SSID_KEY],
299 "Configured wifi hotspot SSID does not match with the expected SSID")
300
301 def _turn_on_wifi_hotspot(self, ad):
302 """ Turn on wifi hotspot with a config that is already saved
303
304 Args:
305 1. dut - device to turn wifi hotspot on
306 """
307 ad.droid.wifiStartTrackingTetherStateChange()
308 ad.droid.connectivityStartTethering(tel_defines.TETHERING_WIFI, False)
309 try:
310 ad.ed.pop_event("ConnectivityManagerOnTetheringStarted")
311 ad.ed.wait_for_event("TetherStateChanged",
312 lambda x: x["data"]["ACTIVE_TETHER"], 30)
313 except:
314 asserts.fail("Didn't receive wifi tethering starting confirmation")
315 ad.droid.wifiStopTrackingTetherStateChange()
316
Girish Moturuf72690e2017-02-14 15:19:53 -0800317 """ Test Cases """
318
Girish Moturu2c21eb32017-05-25 14:37:55 +0530319 @test_tracker_info(uuid="36d03295-bea3-446e-8342-b9f8f1962a32")
Girish Moturuf72690e2017-02-14 15:19:53 -0800320 def test_ipv6_tethering(self):
321 """ IPv6 tethering test
322
323 Steps:
Girish Moturu2c21eb32017-05-25 14:37:55 +0530324 1. Start wifi tethering on hotspot device
Girish Moturu7df90e32017-10-16 12:49:56 -0700325 2. Verify IPv6 address on hotspot device (VZW & TMO only)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530326 3. Connect tethered device to hotspot device
Girish Moturu7df90e32017-10-16 12:49:56 -0700327 4. Verify IPv6 address on the client's link properties (VZW only)
328 5. Verify ping on client using ping6 which should pass (VZW only)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530329 6. Disable mobile data on provider and verify that link properties
Girish Moturu7df90e32017-10-16 12:49:56 -0700330 does not have IPv6 address and default route (VZW only)
Girish Moturuf72690e2017-02-14 15:19:53 -0800331 """
332 # Start wifi tethering on the hotspot device
Girish Moturu2c21eb32017-05-25 14:37:55 +0530333 wutils.toggle_wifi_off_and_on(self.hotspot_device)
334 self._start_wifi_tethering()
Girish Moturuf72690e2017-02-14 15:19:53 -0800335
336 # Verify link properties on hotspot device
Girish Moturu7f287522017-09-25 13:33:06 -0700337 self.log.info("Check IPv6 properties on the hotspot device. "
338 "Verizon & T-mobile should have IPv6 in link properties")
Girish Moturuf72690e2017-02-14 15:19:53 -0800339 self._verify_ipv6_tethering(self.hotspot_device)
340
341 # Connect the client to the SSID
Girish Moturu2c21eb32017-05-25 14:37:55 +0530342 wutils.wifi_connect(self.tethered_devices[0], self.network)
Girish Moturuf72690e2017-02-14 15:19:53 -0800343
344 # Need to wait atleast 2 seconds for IPv6 address to
345 # show up in the link properties
Girish Moturu7f287522017-09-25 13:33:06 -0700346 time.sleep(WAIT_TIME)
Girish Moturuf72690e2017-02-14 15:19:53 -0800347
348 # Verify link properties on tethered device
Girish Moturu7f287522017-09-25 13:33:06 -0700349 self.log.info("Check IPv6 properties on the tethered device. "
350 "Device should have IPv6 if carrier is Verizon")
Girish Moturu2c21eb32017-05-25 14:37:55 +0530351 self._verify_ipv6_tethering(self.tethered_devices[0])
Girish Moturuf72690e2017-02-14 15:19:53 -0800352
353 # Verify ping6 on tethered device
Girish Moturu2c21eb32017-05-25 14:37:55 +0530354 ping_result = self._verify_ping(self.tethered_devices[0],
Girish Moturu7f287522017-09-25 13:33:06 -0700355 wutils.DEFAULT_PING_ADDR, True)
Girish Moturuf72690e2017-02-14 15:19:53 -0800356 if self._supports_ipv6_tethering(self.hotspot_device):
357 asserts.assert_true(ping_result, "Ping6 failed on the client")
358 else:
359 asserts.assert_true(not ping_result, "Ping6 failed as expected")
360
361 # Disable mobile data on hotspot device
362 # and verify the link properties on tethered device
Girish Moturu2c21eb32017-05-25 14:37:55 +0530363 self.log.info("Disabling mobile data to verify ipv6 default route")
Girish Moturuf72690e2017-02-14 15:19:53 -0800364 self.hotspot_device.droid.telephonyToggleDataConnection(False)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530365 asserts.assert_equal(
366 self.hotspot_device.droid.telephonyGetDataConnectionState(),
367 tel_defines.DATA_STATE_CONNECTED,
368 "Could not disable cell data")
369
Girish Moturu7f287522017-09-25 13:33:06 -0700370 time.sleep(WAIT_TIME) # wait until the IPv6 is removed from link properties
Girish Moturu2c21eb32017-05-25 14:37:55 +0530371
Girish Moturu0fd0b942017-12-12 12:04:56 -0800372 result = self.tethered_devices[0].droid.connectivityHasIPv6DefaultRoute()
Girish Moturu2c21eb32017-05-25 14:37:55 +0530373 self.hotspot_device.droid.telephonyToggleDataConnection(True)
Girish Moturu7df90e32017-10-16 12:49:56 -0700374 if result:
Girish Moturu2c21eb32017-05-25 14:37:55 +0530375 asserts.fail("Found IPv6 default route in link properties:Data off")
Girish Moturu7df90e32017-10-16 12:49:56 -0700376 self.log.info("Did not find IPv6 address in link properties")
Girish Moturu2c21eb32017-05-25 14:37:55 +0530377
378 # Disable wifi tethering
379 wutils.stop_wifi_tethering(self.hotspot_device)
380
381 @test_tracker_info(uuid="110b61d1-8af2-4589-8413-11beac7a3025")
Girish Moturu47366062018-05-23 12:48:11 -0700382 def test_wifi_tethering_2ghz_traffic_between_2tethered_devices(self):
Girish Moturu2c21eb32017-05-25 14:37:55 +0530383 """ Steps:
384
385 1. Start wifi hotspot with 2G band
386 2. Connect 2 tethered devices to the hotspot device
387 3. Ping interfaces between the tethered devices
388 """
Girish Moturu95f2f452018-07-23 15:57:15 -0700389 asserts.skip_if(not hasattr(self, 'arduino_wifi_dongles'),
390 "No wifi dongles connected. Skipping test")
Girish Moturu2c21eb32017-05-25 14:37:55 +0530391 wutils.toggle_wifi_off_and_on(self.hotspot_device)
392 self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G)
393 self._test_traffic_between_two_tethered_devices(self.tethered_devices[0],
Girish Moturu47366062018-05-23 12:48:11 -0700394 self.arduino_wifi_dongles[0])
Girish Moturu2c21eb32017-05-25 14:37:55 +0530395 wutils.stop_wifi_tethering(self.hotspot_device)
396
397 @test_tracker_info(uuid="953f6e2e-27bd-4b73-85a6-d2eaa4e755d5")
Girish Moturu7df90e32017-10-16 12:49:56 -0700398 def wifi_tethering_5ghz_traffic_between_2tethered_devices(self):
Girish Moturu2c21eb32017-05-25 14:37:55 +0530399 """ Steps:
400
401 1. Start wifi hotspot with 5ghz band
402 2. Connect 2 tethered devices to the hotspot device
403 3. Send traffic between the tethered devices
404 """
405 wutils.toggle_wifi_off_and_on(self.hotspot_device)
406 self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
407 self._test_traffic_between_two_tethered_devices(self.tethered_devices[0],
Girish Moturu47366062018-05-23 12:48:11 -0700408 self.arduino_wifi_dongles[0])
Girish Moturu2c21eb32017-05-25 14:37:55 +0530409 wutils.stop_wifi_tethering(self.hotspot_device)
410
411 @test_tracker_info(uuid="d7d5aa51-682d-4882-a334-61966d93b68c")
412 def test_wifi_tethering_2ghz_connect_disconnect_devices(self):
413 """ Steps:
414
415 1. Start wifi hotspot with 2ghz band
416 2. Connect and disconnect multiple devices randomly
417 3. Verify the correct functionality
418 """
419 wutils.toggle_wifi_off_and_on(self.hotspot_device)
420 self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G)
Girish Moturu47366062018-05-23 12:48:11 -0700421 self._connect_disconnect_tethered_devices()
Girish Moturu2c21eb32017-05-25 14:37:55 +0530422 wutils.stop_wifi_tethering(self.hotspot_device)
423
424 @test_tracker_info(uuid="34abd6c9-c7f1-4d89-aa2b-a66aeabed9aa")
425 def test_wifi_tethering_5ghz_connect_disconnect_devices(self):
426 """ Steps:
427
428 1. Start wifi hotspot with 5ghz band
429 2. Connect and disconnect multiple devices randomly
430 3. Verify the correct functionality
431 """
432 wutils.toggle_wifi_off_and_on(self.hotspot_device)
433 self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
434 self._connect_disconnect_devices()
435 wutils.stop_wifi_tethering(self.hotspot_device)
436
437 @test_tracker_info(uuid="7edfb220-37f8-42ea-8d7c-39712fbe9be5")
438 def test_wifi_tethering_2ghz_ping_hotspot_interfaces(self):
439 """ Steps:
440
441 1. Start wifi hotspot with 2ghz band
442 2. Connect tethered device to hotspot device
443 3. Ping 'wlan0' and 'rmnet_data' interface's IPv4
444 and IPv6 interfaces on hotspot device from tethered device
445 """
446 wutils.toggle_wifi_off_and_on(self.hotspot_device)
447 self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G)
448 wutils.wifi_connect(self.tethered_devices[0], self.network)
449 result = self._ping_hotspot_interfaces_from_tethered_device(
450 self.tethered_devices[0])
451 wutils.stop_wifi_tethering(self.hotspot_device)
452 return result
453
454 @test_tracker_info(uuid="17e450f4-795f-4e67-adab-984940dffedc")
455 def test_wifi_tethering_5ghz_ping_hotspot_interfaces(self):
456 """ Steps:
457
458 1. Start wifi hotspot with 5ghz band
459 2. Connect tethered device to hotspot device
460 3. Ping 'wlan0' and 'rmnet_data' interface's IPv4
461 and IPv6 interfaces on hotspot device from tethered device
462 """
463 wutils.toggle_wifi_off_and_on(self.hotspot_device)
464 self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
465 wutils.wifi_connect(self.tethered_devices[0], self.network)
466 result = self._ping_hotspot_interfaces_from_tethered_device(
467 self.tethered_devices[0])
468 wutils.stop_wifi_tethering(self.hotspot_device)
469 return result
470
Girish Moturu2c21eb32017-05-25 14:37:55 +0530471 @test_tracker_info(uuid="2bc344cb-0277-4f06-b6cc-65b3972086ed")
472 def test_change_wifi_hotspot_ssid_when_hotspot_enabled(self):
473 """ Steps:
474
475 1. Start wifi tethering
476 2. Verify wifi Ap configuration
477 3. Change the SSID of the wifi hotspot while hotspot is on
478 4. Verify the new SSID in wifi ap configuration
479 5. Restart tethering and verify that the tethered device is able
480 to connect to the new SSID
481 """
482 wutils.toggle_wifi_off_and_on(self.hotspot_device)
483 dut = self.hotspot_device
484
485 # start tethering and verify the wifi ap configuration settings
486 self._start_wifi_tethering()
487 wifi_ap = dut.droid.wifiGetApConfiguration()
488 asserts.assert_true(
489 wifi_ap[wutils.WifiEnums.SSID_KEY] == \
490 self.network[wutils.WifiEnums.SSID_KEY],
491 "Configured wifi hotspot SSID did not match with the expected SSID")
492 wutils.wifi_connect(self.tethered_devices[0], self.network)
493
494 # update the wifi ap configuration with new ssid
495 config = {wutils.WifiEnums.SSID_KEY: self.new_ssid}
496 config[wutils.WifiEnums.PWD_KEY] = self.network[wutils.WifiEnums.PWD_KEY]
497 config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_2G
Girish Moturub0768fa2018-02-13 15:24:27 -0800498 self._save_wifi_softap_configuration(dut, config)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530499
500 # start wifi tethering with new wifi ap configuration
501 wutils.stop_wifi_tethering(dut)
Girish Moturub0768fa2018-02-13 15:24:27 -0800502 self._turn_on_wifi_hotspot(dut)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530503
504 # verify dut can connect to new wifi ap configuration
505 new_network = {wutils.WifiEnums.SSID_KEY: self.new_ssid,
506 wutils.WifiEnums.PWD_KEY: \
507 self.network[wutils.WifiEnums.PWD_KEY]}
508 wutils.wifi_connect(self.tethered_devices[0], new_network)
509 wutils.stop_wifi_tethering(self.hotspot_device)
Girish Moturub0768fa2018-02-13 15:24:27 -0800510
511 @test_tracker_info(uuid="4cf7ab26-ca2d-46f6-9d3f-a935c7e04c97")
512 def test_wifi_tethering_open_network_2g(self):
513 """ Steps:
514
515 1. Start wifi tethering with open network 2G band
516 (Not allowed manually. b/72412729)
517 2. Connect tethered device to the SSID
518 3. Verify internet connectivity
519 """
520 wutils.start_wifi_tethering(
521 self.hotspot_device, self.open_network[wutils.WifiEnums.SSID_KEY],
522 None, WIFI_CONFIG_APBAND_2G)
523 wutils.wifi_connect(self.tethered_devices[0], self.open_network)
524 wutils.stop_wifi_tethering(self.hotspot_device)
525
526 @test_tracker_info(uuid="f407049b-1324-40ea-a8d1-f90587933310")
527 def test_wifi_tethering_open_network_5g(self):
528 """ Steps:
529
530 1. Start wifi tethering with open network 5G band
531 (Not allowed manually. b/72412729)
532 2. Connect tethered device to the SSID
533 3. Verify internet connectivity
534 """
535 wutils.start_wifi_tethering(
536 self.hotspot_device, self.open_network[wutils.WifiEnums.SSID_KEY],
537 None, WIFI_CONFIG_APBAND_5G)
538 wutils.wifi_connect(self.tethered_devices[0], self.open_network)
539 wutils.stop_wifi_tethering(self.hotspot_device)
540
541 @test_tracker_info(uuid="d964f2e6-0acb-417c-ada9-eb9fc5a470e4")
542 def test_wifi_tethering_open_network_2g_stress(self):
543 """ Steps:
544
545 1. Save wifi hotspot configuration with open network 2G band
546 (Not allowed manually. b/72412729)
547 2. Turn on wifi hotspot
548 3. Connect tethered device and verify internet connectivity
549 4. Turn off wifi hotspot
550 5. Repeat steps 2 to 4
551 """
552 # save open network wifi ap configuration with 2G band
553 config = {wutils.WifiEnums.SSID_KEY:
554 self.open_network[wutils.WifiEnums.SSID_KEY]}
555 config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_2G
556 self._save_wifi_softap_configuration(self.hotspot_device, config)
557
558 # turn on/off wifi hotspot, connect device
559 for _ in range(9):
560 self._turn_on_wifi_hotspot(self.hotspot_device)
lutina8e26ac92019-11-25 18:38:11 +0800561 wutils.connect_to_wifi_network(self.tethered_devices[0], self.open_network)
Girish Moturub0768fa2018-02-13 15:24:27 -0800562 wutils.stop_wifi_tethering(self.hotspot_device)
563 time.sleep(1) # wait for some time before turning on hotspot
564
565 @test_tracker_info(uuid="c7ef840c-4003-41fc-80e3-755f9057b542")
566 def test_wifi_tethering_open_network_5g_stress(self):
567 """ Steps:
568
569 1. Save wifi hotspot configuration with open network 5G band
570 (Not allowed manually. b/72412729)
571 2. Turn on wifi hotspot
572 3. Connect tethered device and verify internet connectivity
573 4. Turn off wifi hotspot
574 5. Repeat steps 2 to 4
575 """
576 # save open network wifi ap configuration with 5G band
577 config = {wutils.WifiEnums.SSID_KEY:
578 self.open_network[wutils.WifiEnums.SSID_KEY]}
579 config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_5G
580 self._save_wifi_softap_configuration(self.hotspot_device, config)
581
582 # turn on/off wifi hotspot, connect device
583 for _ in range(9):
584 self._turn_on_wifi_hotspot(self.hotspot_device)
lutina8e26ac92019-11-25 18:38:11 +0800585 wutils.connect_to_wifi_network(self.tethered_devices[0], self.open_network)
Girish Moturub0768fa2018-02-13 15:24:27 -0800586 wutils.stop_wifi_tethering(self.hotspot_device)
587 time.sleep(1) # wait for some time before turning on hotspot