1 #/usr/bin/env python3.4 2 # 3 # Copyright (C) 2016 The Android Open Source Project 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 # use this file except in compliance with the License. You may obtain a copy of 7 # 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, WITHOUT 13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See thea 14 # License for the specific language governing permissions and limitations under 15 # the License. 16 """ 17 Bluetooth Pre-Flight Test. 18 """ 19 20 from acts.test_decorators import test_tracker_info 21 from acts.base_test import BaseTestClass 22 import os 23 import pprint 24 25 26 class BtPreFlightTest(BaseTestClass): 27 def __init__(self, controllers): 28 BaseTestClass.__init__(self, controllers) 29 self.tests = ("test_setup_logging", ) 30 31 def setup_class(self): 32 for a in self.android_devices: 33 d = a.droid 34 serial = a.serial 35 self.log.info("****START: {} DEVICE INFO****".format(serial)) 36 self.log.info("BOOTLOADER VERSION {}".format(d.getBuildBootloader( 37 ))) 38 self.log.info("BUILD HARDWARE {}".format(d.getBuildHardware())) 39 self.log.info("BUILD PRODUCT {}".format(d.getBuildProduct())) 40 self.log.info("*ENVIRONMENT DETAILS*") 41 self.log.info(pprint.pformat(d.environment())) 42 self.log.info("****END: {} DEVICE INFO****".format(serial)) 43 return True 44 45 @test_tracker_info(uuid='7b6ac700-9e63-4871-bf7b-527c3da1e462') 46 def test_setup_logging(self): 47 conf_path = "{}/bt_stack.conf".format( 48 os.path.dirname(os.path.realpath(__file__))) 49 log_level_check = "TRC_BTM=5" 50 remount_check = "remount succeeded" 51 for ad in self.android_devices: 52 self.log.info("Remounting device...") 53 remount_result = ad.adb.remount() 54 if remount_check not in str(remount_result): 55 # Test for devices that have disable_verity as not all do 56 try: 57 self.log.info("Disable verity on device...") 58 ad.adb.disable_verity() 59 self.log.info("Rebooting device...") 60 ad.reboot() 61 self.log.info("Remounting device...") 62 remount_result = ad.adb.remount() 63 if remount_check not in str(remount_result): 64 self.abort_all("Unable to remount device") 65 except Exception as e: 66 self.abort_all("Exception in BT pre-flight test: {}" 67 .format(e)) 68 self.log.info("Enabling high level Bluetooth logging to device") 69 ad.adb.push("{} /system/etc/bluetooth/bt_stack.conf".format( 70 conf_path)) 71 result = ad.adb.shell("cat /system/etc/bluetooth/bt_stack.conf") 72 # Verify that the log levels have been raised 73 if log_level_check not in str(result): 74 self.abort_all("BT log levels not set") 75 return True 76