1#!/usr/bin/env python3.4 2# 3# Copyright 2018 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17import acts.signals as signals 18 19from acts import asserts 20from acts.base_test import BaseTestClass 21from acts.libs.ota import ota_updater 22from acts.test_decorators import test_tracker_info 23from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_2G 24 25import acts.test_utils.net.net_test_utils as nutils 26import acts.test_utils.wifi.wifi_test_utils as wutils 27 28 29class WifiTethering2GOpenOTATest(BaseTestClass): 30 """Wifi Tethering 2G Open OTA tests""" 31 32 def setup_class(self): 33 34 super(WifiTethering2GOpenOTATest, self).setup_class() 35 ota_updater.initialize(self.user_params, self.android_devices) 36 37 self.hotspot_device = self.android_devices[0] 38 self.tethered_device = self.android_devices[1] 39 req_params = ("wifi_hotspot_open", ) 40 self.unpack_userparams(req_params) 41 42 # verify hotspot device has lte data and supports tethering 43 nutils.verify_lte_data_and_tethering_supported(self.hotspot_device) 44 45 # Save a wifi soft ap configuration and verify that it works 46 wutils.save_wifi_soft_ap_config(self.hotspot_device, 47 self.wifi_hotspot_open, 48 WIFI_CONFIG_APBAND_2G) 49 self._verify_wifi_tethering() 50 51 # Run OTA below, if ota fails then abort all tests. 52 try: 53 ota_updater.update(self.hotspot_device) 54 except Exception as err: 55 raise signals.TestAbortClass( 56 "Failed up apply OTA update. Aborting tests") 57 58 def on_fail(self, test_name, begin_time): 59 for ad in self.android_devices: 60 ad.take_bug_report(test_name, begin_time) 61 62 def teardown_class(self): 63 wutils.wifi_toggle_state(self.hotspot_device, True) 64 65 """Helper Functions""" 66 67 def _verify_wifi_tethering(self): 68 """Verify wifi tethering""" 69 wutils.start_wifi_tethering_saved_config(self.hotspot_device) 70 wutils.wifi_connect(self.tethered_device, self.wifi_hotspot_open) 71 # (TODO: @gmoturu) Change to stop_wifi_tethering. See b/109876061 72 wutils.wifi_toggle_state(self.hotspot_device, True) 73 74 """Tests""" 75 76 @test_tracker_info(uuid="fe502bc3-f9c6-4bed-98ad-acaa7e166521") 77 def test_wifi_tethering_ota_2g_open(self): 78 """ Verify wifi hotspot after ota upgrade 79 80 Steps: 81 1. Save a wifi hotspot config with 2g band and open auth 82 2. Do a OTA update 83 3. Verify that wifi hotspot works with teh saved config 84 """ 85 self._verify_wifi_tethering() 86