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.base_test import BaseTestClass 21 import os 22 import pprint 23 24 25 class BtPreFlightTest(BaseTestClass): 26 def __init__(self, controllers): 27 BaseTestClass.__init__(self, controllers) 28 self.tests = ("test_setup_logging", ) 29 30 def setup_class(self): 31 for a in self.android_devices: 32 d = a.droid 33 serial = d.getBuildSerial() 34 self.log.info("****START: {} DEVICE INFO****".format(serial)) 35 self.log.info("BOOTLOADER VERSION {}".format(d.getBuildBootloader( 36 ))) 37 self.log.info("BUILD HARDWARE {}".format(d.getBuildHardware())) 38 self.log.info("BUILD PRODUCT {}".format(d.getBuildProduct())) 39 self.log.info("*ENVIRONMENT DETAILS*") 40 self.log.info(pprint.pformat(d.environment())) 41 self.log.info("****END: {} DEVICE INFO****".format(serial)) 42 return True 43 44 def test_setup_logging(self): 45 conf_path = "{}/bt_stack.conf".format(os.path.dirname(os.path.realpath( 46 __file__))) 47 log_level_check = "TRC_BTM=5" 48 remount_check = "remount succeeded" 49 for ad in self.android_devices: 50 self.log.info("Remounting device...") 51 remount_result = ad.adb.remount() 52 if remount_check not in str(remount_result): 53 # Test for devices that have disable_verity as not all do 54 try: 55 self.log.info("Disable verity on device...") 56 ad.adb.disable_verity() 57 self.log.info("Rebooting device...") 58 ad.reboot() 59 self.log.info("Remounting device...") 60 remount_result = ad.adb.remount() 61 if remount_check not in str(remount_result): 62 self.abort_all("Unable to remount device") 63 except Exception as e: 64 self.abort_all("Exception in BT pre-flight test: {}" 65 .format(e)) 66 self.log.info("Enabling high level Bluetooth logging to device") 67 ad.adb.push("{} /system/etc/bluetooth/bt_stack.conf".format( 68 conf_path)) 69 result = ad.adb.shell("cat /system/etc/bluetooth/bt_stack.conf") 70 # Verify that the log levels have been raised 71 if log_level_check not in str(result): 72 self.abort_all("BT log levels not set") 73 return True 74