blob: c33c964e21e093ec07aa1036469e43b673d47d06 [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
24from acts.controllers import adb
Girish Moturu2c21eb32017-05-25 14:37:55 +053025from acts.test_decorators import test_tracker_info
Girish Moturuf72690e2017-02-14 15:19:53 -080026from acts.test_utils.tel import tel_data_utils
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 toggle_airplane_mode
29from acts.test_utils.tel.tel_data_utils import wait_for_cell_data_connection
30from acts.test_utils.tel.tel_test_utils import get_operator_name
31from acts.test_utils.tel.tel_test_utils import http_file_download_by_chrome
32from acts.test_utils.tel.tel_test_utils import verify_http_connection
33from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_2G
34from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_5G
35from acts.test_utils.wifi import wifi_test_utils as wutils
Girish Moturuf72690e2017-02-14 15:19:53 -080036
37
38class WifiTetheringTest(base_test.BaseTestClass):
39 """ Tests for Wifi Tethering """
40
41 def setup_class(self):
42 """ Setup devices for tethering and unpack params """
Girish Moturu2c21eb32017-05-25 14:37:55 +053043
44 self.convert_byte_to_mb = 1024.0 * 1024.0
45 self.new_ssid = "wifi_tethering_test2"
46 self.data_usage_error = 0.3
47
48 self.hotspot_device = self.android_devices[0]
49 self.tethered_devices = self.android_devices[1:]
50 req_params = ("network", "url", "download_file", "file_size")
Girish Moturuf72690e2017-02-14 15:19:53 -080051 self.unpack_userparams(req_params)
Girish Moturu2c21eb32017-05-25 14:37:55 +053052 self.file_size = int(self.file_size)
53
54 wutils.wifi_toggle_state(self.hotspot_device, False)
Girish Moturuf72690e2017-02-14 15:19:53 -080055 self.hotspot_device.droid.telephonyToggleDataConnection(True)
Girish Moturu2c21eb32017-05-25 14:37:55 +053056 wait_for_cell_data_connection(self.log, self.hotspot_device, True)
Girish Moturuf72690e2017-02-14 15:19:53 -080057 asserts.assert_true(
Girish Moturu2c21eb32017-05-25 14:37:55 +053058 verify_http_connection(self.log, self.hotspot_device),
Girish Moturuf72690e2017-02-14 15:19:53 -080059 "HTTP verification failed on cell data connection")
60 asserts.assert_true(
61 self.hotspot_device.droid.connectivityIsTetheringSupported(),
62 "Tethering is not supported for the provider")
Girish Moturu2c21eb32017-05-25 14:37:55 +053063 for ad in self.tethered_devices:
64 wutils.wifi_test_device_init(ad)
Girish Moturuf72690e2017-02-14 15:19:53 -080065
66 def teardown_class(self):
67 """ Reset devices """
Girish Moturu2c21eb32017-05-25 14:37:55 +053068 wutils.wifi_toggle_state(self.hotspot_device, True)
69
70 def on_fail(self, test_name, begin_time):
71 """ Collect bug report on failure """
72 self.hotspot_device.take_bug_report(test_name, begin_time)
Girish Moturuf72690e2017-02-14 15:19:53 -080073
74 """ Helper functions """
75
Girish Moturu2c21eb32017-05-25 14:37:55 +053076 def _is_ipaddress_ipv6(self, ip_address):
Girish Moturuf72690e2017-02-14 15:19:53 -080077 """ Verify if the given string is a valid IPv6 address
78
79 Args:
80 1. string which contains the IP address
81
82 Returns:
83 True: if valid ipv6 address
84 False: if not
85 """
86 try:
87 socket.inet_pton(socket.AF_INET6, ip_address)
88 return True
89 except socket.error:
90 return False
91
92 def _supports_ipv6_tethering(self, dut):
93 """ Check if provider supports IPv6 tethering.
94 Currently, only Verizon supports IPv6 tethering
95
96 Returns:
97 True: if provider supports IPv6 tethering
98 False: if not
99 """
100 # Currently only Verizon support IPv6 tethering
101 carrier_supports_tethering = ["vzw"]
Girish Moturu2c21eb32017-05-25 14:37:55 +0530102 operator = get_operator_name(self.log, dut)
Girish Moturuf72690e2017-02-14 15:19:53 -0800103 return operator in carrier_supports_tethering
104
Girish Moturu2c21eb32017-05-25 14:37:55 +0530105 def _carrier_supports_ipv6(self,dut):
106 """ Verify if carrier supports ipv6
107 Currently, only verizon and t-mobile supports IPv6
108
109 Returns:
110 True: if carrier supports ipv6
111 False: if not
112 """
113 carrier_supports_ipv6 = ["vzw", "tmo"]
114 operator = get_operator_name(self.log, dut)
115 return operator in carrier_supports_ipv6
116
Girish Moturuf72690e2017-02-14 15:19:53 -0800117 def _find_ipv6_default_route(self, dut):
118 """ Checks if IPv6 default route exists in the link properites
119
120 Returns:
121 True: if default route found
122 False: if not
123 """
124 default_route_substr = "::/0 -> "
125 link_properties = dut.droid.connectivityGetActiveLinkProperties()
126 return link_properties and default_route_substr in link_properties
127
Girish Moturu2c21eb32017-05-25 14:37:55 +0530128 def _verify_ipv6_tethering(self, dut):
Girish Moturuf72690e2017-02-14 15:19:53 -0800129 """ Verify IPv6 tethering """
130 http_response = dut.droid.httpRequestString(self.url)
131 link_properties = dut.droid.connectivityGetActiveLinkProperties()
132 self.log.info("IP address %s " % http_response)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530133 if dut==self.hotspot_device and self._carrier_supports_ipv6(dut)\
134 or self._supports_ipv6_tethering(self.hotspot_device):
Girish Moturuf72690e2017-02-14 15:19:53 -0800135 asserts.assert_true(self._is_ipaddress_ipv6(http_response),
136 "The http response did not return IPv6 address")
137 asserts.assert_true(link_properties and http_response in link_properties,
138 "Could not find IPv6 address in link properties")
139 asserts.assert_true(self._find_ipv6_default_route(dut),
140 "Could not find IPv6 default route in link properties")
141 else:
142 asserts.assert_true(not self._find_ipv6_default_route(dut),
143 "Found IPv6 default route in link properties")
144
Girish Moturu2c21eb32017-05-25 14:37:55 +0530145 def _start_wifi_tethering(self, wifi_band=WIFI_CONFIG_APBAND_2G):
146 """ Start wifi tethering on hotspot device
147
148 Args:
149 1. wifi_band: specifies the wifi band to start the hotspot
150 on. The current options are 2G and 5G
151 """
152 wutils.start_wifi_tethering(self.hotspot_device,
153 self.network[wutils.WifiEnums.SSID_KEY],
154 self.network[wutils.WifiEnums.PWD_KEY],
155 wifi_band)
156
157 def _connect_disconnect_devices(self):
158 """ Randomly connect and disconnect devices from the
159 self.tethered_devices list to hotspot device
160 """
161 device_connected = [ False ] * len(self.tethered_devices)
162 for _ in range(50):
163 dut_id = random.randint(0, len(self.tethered_devices)-1)
164 dut = self.tethered_devices[dut_id]
165 if device_connected[dut_id]:
166 wutils.wifi_forget_network(dut, self.network["SSID"])
167 else:
168 wutils.wifi_connect(dut, self.network)
169 device_connected[dut_id] = not device_connected[dut_id]
170
171 def _verify_ping(self, dut, ip):
172 """ Verify ping works from the dut to IP/hostname
173
174 Args:
175 1. dut - ad object to check ping from
176 2. ip - ip/hostname to ping (IPv4 and IPv6)
177
178 Returns:
179 True - if ping is successful
180 False - if not
181 """
182 self.log.info("Pinging %s from dut %s" % (ip, dut.serial))
183 if self._is_ipaddress_ipv6(ip):
184 return dut.droid.pingHost(ip, 5, "ping6")
185 return dut.droid.pingHost(ip)
186
187 def _return_ip_for_interface(self, dut, iface_name):
188 """ Return list of IP addresses for an interface
189
190 Args:
191 1. dut - ad object
192 2. iface_name - interface name
193
194 Returns:
195 List of IPv4 and IPv6 addresses
196 """
197 return dut.droid.connectivityGetIPv4Addresses(iface_name) + \
198 dut.droid.connectivityGetIPv6Addresses(iface_name)
199
200 def _test_traffic_between_two_tethered_devices(self, dut1, dut2):
201 """ Verify pinging interfaces of one DUT from another
202
203 Args:
204 1. dut1 - tethered device 1
205 2. dut2 - tethered device 2
206 """
207 wutils.wifi_connect(dut1, self.network)
208 wutils.wifi_connect(dut2, self.network)
209
210 dut1_ipaddrs = dut1.droid.connectivityGetIPv4Addresses("wlan0") + \
211 dut1.droid.connectivityGetIPv6Addresses("wlan0")
212 dut2_ipaddrs = dut2.droid.connectivityGetIPv4Addresses("wlan0") + \
213 dut2.droid.connectivityGetIPv6Addresses("wlan0")
214
215 for ip in dut1_ipaddrs:
216 asserts.assert_true(self._verify_ping(dut2, ip), "%s " % ip)
217 for ip in dut2_ipaddrs:
218 asserts.assert_true(self._verify_ping(dut1, ip), "%s " % ip)
219
220 def _ping_hotspot_interfaces_from_tethered_device(self, dut):
221 """ Ping hotspot interfaces from tethered device
222
223 Args:
224 1. dut - tethered device
225
226 Returns:
227 True - if all IP addresses are pingable
228 False - if not
229 """
230 ifaces = self.hotspot_device.droid.connectivityGetNetworkInterfaces()
231 return_result = True
232 for interface in ifaces:
233 iface_name = interface.split()[0].split(':')[1]
234 if iface_name == "lo":
235 continue
236 ip_list = self._return_ip_for_interface(
237 self.hotspot_device, iface_name)
238 for ip in ip_list:
239 ping_result = self._verify_ping(dut, ip)
240 self.log.info("Ping result: %s %s %s" %
241 (iface_name, ip, ping_result))
242 return_result = return_result and ping_result
243
244 return return_result
Girish Moturuf72690e2017-02-14 15:19:53 -0800245
246 """ Test Cases """
247
Girish Moturu2c21eb32017-05-25 14:37:55 +0530248 @test_tracker_info(uuid="36d03295-bea3-446e-8342-b9f8f1962a32")
Girish Moturuf72690e2017-02-14 15:19:53 -0800249 def test_ipv6_tethering(self):
250 """ IPv6 tethering test
251
252 Steps:
Girish Moturu2c21eb32017-05-25 14:37:55 +0530253 1. Start wifi tethering on hotspot device
254 2. Verify IPv6 address on hotspot device
255 3. Connect tethered device to hotspot device
256 4. Verify IPv6 address on the client's link properties
257 5. Verify ping on client using ping6 which should pass
258 6. Disable mobile data on provider and verify that link properties
Girish Moturuf72690e2017-02-14 15:19:53 -0800259 does not have IPv6 address and default route
260 """
261 # Start wifi tethering on the hotspot device
Girish Moturu2c21eb32017-05-25 14:37:55 +0530262 wutils.toggle_wifi_off_and_on(self.hotspot_device)
263 self._start_wifi_tethering()
Girish Moturuf72690e2017-02-14 15:19:53 -0800264
265 # Verify link properties on hotspot device
266 self.log.info("Check IPv6 properties on the hotspot device")
267 self._verify_ipv6_tethering(self.hotspot_device)
268
269 # Connect the client to the SSID
Girish Moturu2c21eb32017-05-25 14:37:55 +0530270 wutils.wifi_connect(self.tethered_devices[0], self.network)
Girish Moturuf72690e2017-02-14 15:19:53 -0800271
272 # Need to wait atleast 2 seconds for IPv6 address to
273 # show up in the link properties
274 time.sleep(2)
275
276 # Verify link properties on tethered device
277 self.log.info("Check IPv6 properties on the tethered device")
Girish Moturu2c21eb32017-05-25 14:37:55 +0530278 self._verify_ipv6_tethering(self.tethered_devices[0])
Girish Moturuf72690e2017-02-14 15:19:53 -0800279
280 # Verify ping6 on tethered device
Girish Moturu2c21eb32017-05-25 14:37:55 +0530281 ping_result = self._verify_ping(self.tethered_devices[0],
282 "www.google.com")
Girish Moturuf72690e2017-02-14 15:19:53 -0800283 if self._supports_ipv6_tethering(self.hotspot_device):
284 asserts.assert_true(ping_result, "Ping6 failed on the client")
285 else:
286 asserts.assert_true(not ping_result, "Ping6 failed as expected")
287
288 # Disable mobile data on hotspot device
289 # and verify the link properties on tethered device
Girish Moturu2c21eb32017-05-25 14:37:55 +0530290 self.log.info("Disabling mobile data to verify ipv6 default route")
Girish Moturuf72690e2017-02-14 15:19:53 -0800291 self.hotspot_device.droid.telephonyToggleDataConnection(False)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530292 asserts.assert_equal(
293 self.hotspot_device.droid.telephonyGetDataConnectionState(),
294 tel_defines.DATA_STATE_CONNECTED,
295 "Could not disable cell data")
296
Girish Moturuf72690e2017-02-14 15:19:53 -0800297 time.sleep(2) # wait until the IPv6 is removed from link properties
Girish Moturu2c21eb32017-05-25 14:37:55 +0530298
299 result = self._find_ipv6_default_route(self.tethered_devices[0])
300 self.hotspot_device.droid.telephonyToggleDataConnection(True)
301 if not result:
302 asserts.fail("Found IPv6 default route in link properties:Data off")
303
304 # Disable wifi tethering
305 wutils.stop_wifi_tethering(self.hotspot_device)
306
307 @test_tracker_info(uuid="110b61d1-8af2-4589-8413-11beac7a3025")
308 def test_wifi_tethering_2ghz_traffic_between_2tethered_devices(self):
309 """ Steps:
310
311 1. Start wifi hotspot with 2G band
312 2. Connect 2 tethered devices to the hotspot device
313 3. Ping interfaces between the tethered devices
314 """
315 wutils.toggle_wifi_off_and_on(self.hotspot_device)
316 self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G)
317 self._test_traffic_between_two_tethered_devices(self.tethered_devices[0],
318 self.tethered_devices[1])
319 wutils.stop_wifi_tethering(self.hotspot_device)
320
321 @test_tracker_info(uuid="953f6e2e-27bd-4b73-85a6-d2eaa4e755d5")
322 def test_wifi_tethering_5ghz_traffic_between_2tethered_devices(self):
323 """ Steps:
324
325 1. Start wifi hotspot with 5ghz band
326 2. Connect 2 tethered devices to the hotspot device
327 3. Send traffic between the tethered devices
328 """
329 wutils.toggle_wifi_off_and_on(self.hotspot_device)
330 self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
331 self._test_traffic_between_two_tethered_devices(self.tethered_devices[0],
332 self.tethered_devices[1])
333 wutils.stop_wifi_tethering(self.hotspot_device)
334
335 @test_tracker_info(uuid="d7d5aa51-682d-4882-a334-61966d93b68c")
336 def test_wifi_tethering_2ghz_connect_disconnect_devices(self):
337 """ Steps:
338
339 1. Start wifi hotspot with 2ghz band
340 2. Connect and disconnect multiple devices randomly
341 3. Verify the correct functionality
342 """
343 wutils.toggle_wifi_off_and_on(self.hotspot_device)
344 self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G)
345 self._connect_disconnect_devices()
346 wutils.stop_wifi_tethering(self.hotspot_device)
347
348 @test_tracker_info(uuid="34abd6c9-c7f1-4d89-aa2b-a66aeabed9aa")
349 def test_wifi_tethering_5ghz_connect_disconnect_devices(self):
350 """ Steps:
351
352 1. Start wifi hotspot with 5ghz band
353 2. Connect and disconnect multiple devices randomly
354 3. Verify the correct functionality
355 """
356 wutils.toggle_wifi_off_and_on(self.hotspot_device)
357 self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
358 self._connect_disconnect_devices()
359 wutils.stop_wifi_tethering(self.hotspot_device)
360
361 @test_tracker_info(uuid="7edfb220-37f8-42ea-8d7c-39712fbe9be5")
362 def test_wifi_tethering_2ghz_ping_hotspot_interfaces(self):
363 """ Steps:
364
365 1. Start wifi hotspot with 2ghz band
366 2. Connect tethered device to hotspot device
367 3. Ping 'wlan0' and 'rmnet_data' interface's IPv4
368 and IPv6 interfaces on hotspot device from tethered device
369 """
370 wutils.toggle_wifi_off_and_on(self.hotspot_device)
371 self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G)
372 wutils.wifi_connect(self.tethered_devices[0], self.network)
373 result = self._ping_hotspot_interfaces_from_tethered_device(
374 self.tethered_devices[0])
375 wutils.stop_wifi_tethering(self.hotspot_device)
376 return result
377
378 @test_tracker_info(uuid="17e450f4-795f-4e67-adab-984940dffedc")
379 def test_wifi_tethering_5ghz_ping_hotspot_interfaces(self):
380 """ Steps:
381
382 1. Start wifi hotspot with 5ghz band
383 2. Connect tethered device to hotspot device
384 3. Ping 'wlan0' and 'rmnet_data' interface's IPv4
385 and IPv6 interfaces on hotspot device from tethered device
386 """
387 wutils.toggle_wifi_off_and_on(self.hotspot_device)
388 self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
389 wutils.wifi_connect(self.tethered_devices[0], self.network)
390 result = self._ping_hotspot_interfaces_from_tethered_device(
391 self.tethered_devices[0])
392 wutils.stop_wifi_tethering(self.hotspot_device)
393 return result
394
395 @test_tracker_info(uuid="d4e18031-0af0-4b29-a574-8707cd4029b7")
396 def test_wifi_tethering_verify_received_bytes(self):
397 """ Steps:
398
399 1. Start wifi hotspot and connect tethered device to it
400 2. Get the data usage on hotspot device
401 3. Download data on tethered device
402 4. Get the new data usage on hotspot device
403 5. Verify that hotspot device's data usage
404 increased by downloaded file size
405 """
406 wutils.toggle_wifi_off_and_on(self.hotspot_device)
407 dut = self.hotspot_device
408 self._start_wifi_tethering()
409 wutils.wifi_connect(self.tethered_devices[0], self.network)
410 subscriber_id = dut.droid.telephonyGetSubscriberId()
411
412 # get data usage limit
413 end_time = int(time.time() * 1000)
414 bytes_before_download = dut.droid.connectivityGetRxBytesForDevice(
415 subscriber_id, 0, end_time)
416 self.log.info("Bytes before download %s" % bytes_before_download)
417
418 # download file
419 http_file_download_by_chrome(self.tethered_devices[0],
420 self.download_file)
421
422 # get data usage limit after download
423 end_time = int(time.time() * 1000)
424 bytes_after_download = dut.droid.connectivityGetRxBytesForDevice(
425 subscriber_id, 0, end_time)
426 self.log.info("Bytes after download %s" % bytes_after_download)
427
428 bytes_diff = bytes_after_download - bytes_before_download
429 wutils.stop_wifi_tethering(self.hotspot_device)
430
431 # verify data usage update is correct
432 bytes_used = bytes_diff/self.convert_byte_to_mb
433 return bytes_used > self.file_size \
434 and bytes_used < self.file_size + self.data_usage_error
435
436 @test_tracker_info(uuid="07a00c96-4770-44a1-a9db-b3d02d6a12b6")
437 def test_wifi_tethering_data_usage_limit(self):
438 """ Steps:
439
440 1. Set the data usage limit to current data usage + 2MB
441 2. Start wifi tethering and connect a dut to the SSID
442 3. Download 5MB data on tethered device
443 a. file download should stop
444 b. tethered device will lose internet connectivity
445 c. data usage limit reached message should be displayed
446 on the hotspot device
447 4. Verify data usage limit
448 """
449 wutils.toggle_wifi_off_and_on(self.hotspot_device)
450 dut = self.hotspot_device
451 data_usage_2mb = 2 * self.convert_byte_to_mb
452 subscriber_id = dut.droid.telephonyGetSubscriberId()
453
454 self._start_wifi_tethering()
455 wutils.wifi_connect(self.tethered_devices[0], self.network)
456
457 # get current data usage
458 end_time = int(time.time() * 1000)
459 old_data_usage = dut.droid.connectivityQuerySummaryForDevice(
460 subscriber_id, 0, end_time)
461
462 # set data usage limit to current usage limit + 2MB
463 dut.droid.connectivitySetDataUsageLimit(
464 subscriber_id, str(int(old_data_usage + data_usage_2mb)))
465
466 # download file - size 5MB
467 http_file_download_by_chrome(self.tethered_devices[0],
468 self.download_file,
469 timeout=120)
470 end_time = int(time.time() * 1000)
471 new_data_usage = dut.droid.connectivityQuerySummaryForDevice(
472 subscriber_id, 0, end_time)
473
474 # test network connectivity on tethered device
475 asserts.assert_true(
476 not wutils.validate_connection(self.tethered_devices[0]),
477 "Tethered device has internet connectivity after data usage"
478 "limit is reached on hotspot device")
479 dut.droid.connectivityFactoryResetNetworkPolicies(subscriber_id)
480 wutils.stop_wifi_tethering(self.hotspot_device)
481
482 old_data_usage = (old_data_usage+data_usage_2mb)/self.convert_byte_to_mb
483 new_data_usage = new_data_usage/self.convert_byte_to_mb
484
485 return (new_data_usage-old_data_usage) < self.data_usage_error
486
487 @test_tracker_info(uuid="2bc344cb-0277-4f06-b6cc-65b3972086ed")
488 def test_change_wifi_hotspot_ssid_when_hotspot_enabled(self):
489 """ Steps:
490
491 1. Start wifi tethering
492 2. Verify wifi Ap configuration
493 3. Change the SSID of the wifi hotspot while hotspot is on
494 4. Verify the new SSID in wifi ap configuration
495 5. Restart tethering and verify that the tethered device is able
496 to connect to the new SSID
497 """
498 wutils.toggle_wifi_off_and_on(self.hotspot_device)
499 dut = self.hotspot_device
500
501 # start tethering and verify the wifi ap configuration settings
502 self._start_wifi_tethering()
503 wifi_ap = dut.droid.wifiGetApConfiguration()
504 asserts.assert_true(
505 wifi_ap[wutils.WifiEnums.SSID_KEY] == \
506 self.network[wutils.WifiEnums.SSID_KEY],
507 "Configured wifi hotspot SSID did not match with the expected SSID")
508 wutils.wifi_connect(self.tethered_devices[0], self.network)
509
510 # update the wifi ap configuration with new ssid
511 config = {wutils.WifiEnums.SSID_KEY: self.new_ssid}
512 config[wutils.WifiEnums.PWD_KEY] = self.network[wutils.WifiEnums.PWD_KEY]
513 config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_2G
514 asserts.assert_true(
515 dut.droid.wifiSetWifiApConfiguration(config),
516 "Failed to update WifiAp Configuration")
517 wifi_ap = dut.droid.wifiGetApConfiguration()
518 asserts.assert_true(
519 wifi_ap[wutils.WifiEnums.SSID_KEY] == self.new_ssid,
520 "Configured wifi hotspot SSID does not match with the expected SSID")
521
522 # start wifi tethering with new wifi ap configuration
523 wutils.stop_wifi_tethering(dut)
524 dut.droid.wifiStartTrackingTetherStateChange()
525 dut.droid.connectivityStartTethering(tel_defines.TETHERING_WIFI, False)
526 try:
527 dut.ed.pop_event("ConnectivityManagerOnTetheringStarted")
528 dut.ed.wait_for_event("TetherStateChanged",
529 lambda x: x["data"]["ACTIVE_TETHER"], 30)
530 except:
531 asserts.fail("Didn't receive wifi tethering starting confirmation")
532 dut.droid.wifiStopTrackingTetherStateChange()
533
534 # verify dut can connect to new wifi ap configuration
535 new_network = {wutils.WifiEnums.SSID_KEY: self.new_ssid,
536 wutils.WifiEnums.PWD_KEY: \
537 self.network[wutils.WifiEnums.PWD_KEY]}
538 wutils.wifi_connect(self.tethered_devices[0], new_network)
539 wutils.stop_wifi_tethering(self.hotspot_device)