BluetoothUtils

public class BluetoothUtils
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.BluetoothUtils


Utility functions for calling BluetoothInstrumentation on device

Device side BluetoothInstrumentation code can be found in AOSP at: frameworks/base/core/tests/bluetoothtests

Summary

Constants

String BTSNOOP_API

String BTSNOOP_CMD

String BTSNOOP_DISABLE_CMD

String BTSNOOP_ENABLE_CMD

String GOLD_BTSNOOP_LOG_PATH

String O_BUILD

Public constructors

BluetoothUtils()

Public methods

static void cleanLogFile(ITestDevice device)

Delete snoop log file from device

static boolean disable(ITestDevice device)

Disables bluetooth on the given device

static boolean disableBtsnoopLogging(ITestDevice device, File sl4aApkFile)

Disable btsnoop logging by sl4a call

static boolean disableBtsnoopLogging(ITestDevice device)

Disable btsnoop logging by sl4a call

static boolean enable(ITestDevice device)

Enables bluetooth on the given device

static boolean enableBtsnoopLogging(ITestDevice device, File sl4aApkFile)

Enable btsnoop logging by sl4a call

static boolean enableBtsnoopLogging(ITestDevice device)

Enable btsnoop logging by sl4a call

static String getBluetoothMac(ITestDevice device)

Retrieves BT mac of the given device

static Set<String> getBondedDevices(ITestDevice device)

Returns bluetooth mac addresses of devices that the given device has bonded with

static String getBtSnoopLogFilePath(ITestDevice device)

Get bt snoop log file path from bt_stack.config file

static String runBluetoothInstrumentation(ITestDevice device, String command)

Convenience method to execute BT instrumentation command and return output

static boolean runBluetoothInstrumentationWithRetry(ITestDevice device, String command)
static boolean toggleBtsnoopLogging(Sl4aClient client, boolean onOff)
static boolean unpairWithRetry(ITestDevice device)

Retries clearing of BT pairing with linear backoff

static void uploadLogFiles(ITestInvocationListener listener, ITestDevice device, String type, int iteration)

Upload snoop log file for test results

Constants

BTSNOOP_API

String BTSNOOP_API

Constant Value: "bluetoothConfigHciSnoopLog"

BTSNOOP_CMD

String BTSNOOP_CMD

Constant Value: "setprop persist.bluetooth.btsnoopenable "

BTSNOOP_DISABLE_CMD

String BTSNOOP_DISABLE_CMD

Constant Value: "setprop persist.bluetooth.btsnoopenable false"

BTSNOOP_ENABLE_CMD

String BTSNOOP_ENABLE_CMD

Constant Value: "setprop persist.bluetooth.btsnoopenable true"

GOLD_BTSNOOP_LOG_PATH

String GOLD_BTSNOOP_LOG_PATH

Constant Value: "/data/misc/bluetooth/logs/btsnoop_hci.log"

O_BUILD

String O_BUILD

Constant Value: "O"

Public constructors

BluetoothUtils

BluetoothUtils ()

Public methods

cleanLogFile

void cleanLogFile (ITestDevice device)

Delete snoop log file from device

Parameters
device ITestDevice

Throws
DeviceNotAvailableException

disable

boolean disable (ITestDevice device)

Disables bluetooth on the given device

Returns
boolean True if disable is successful, false otherwise

Throws
DeviceNotAvailableException

disableBtsnoopLogging

boolean disableBtsnoopLogging (ITestDevice device, 
                File sl4aApkFile)

Disable btsnoop logging by sl4a call

Parameters
sl4aApkFile File: sl4a.apk file location, null if it has been installed

Returns
boolean success or not

Throws
DeviceNotAvailableException

disableBtsnoopLogging

boolean disableBtsnoopLogging (ITestDevice device)

Disable btsnoop logging by sl4a call

Returns
boolean success or not

Throws
DeviceNotAvailableException

enable

boolean enable (ITestDevice device)

Enables bluetooth on the given device

Returns
boolean True if enable is successful, false otherwise

Throws
DeviceNotAvailableException

enableBtsnoopLogging

boolean enableBtsnoopLogging (ITestDevice device, 
                File sl4aApkFile)

Enable btsnoop logging by sl4a call

Parameters
sl4aApkFile File: sl4a.apk file location, null if it has been installed

Returns
boolean success or not

Throws
DeviceNotAvailableException

enableBtsnoopLogging

boolean enableBtsnoopLogging (ITestDevice device)

Enable btsnoop logging by sl4a call

Returns
boolean success or not

Throws
DeviceNotAvailableException

getBluetoothMac

String getBluetoothMac (ITestDevice device)

Retrieves BT mac of the given device

Returns
String BT mac or null if not found

Throws
DeviceNotAvailableException

getBondedDevices

Set<String> getBondedDevices (ITestDevice device)

Returns bluetooth mac addresses of devices that the given device has bonded with

Returns
Set<String> bluetooth mac addresses

Throws
DeviceNotAvailableException

getBtSnoopLogFilePath

String getBtSnoopLogFilePath (ITestDevice device)

Get bt snoop log file path from bt_stack.config file

Returns
String THe file name for bt_snoop_log or null if it is not found

Throws
DeviceNotAvailableException

runBluetoothInstrumentation

String runBluetoothInstrumentation (ITestDevice device, 
                String command)

Convenience method to execute BT instrumentation command and return output

Parameters
command String: a command string sent over to BT instrumentation, currently supported: enable, disable, unpairAll, getName, getAddress, getBondedDevices; refer to AOSP source for more details

Returns
String output of BluetoothInstrumentation

Throws
DeviceNotAvailableException

runBluetoothInstrumentationWithRetry

boolean runBluetoothInstrumentationWithRetry (ITestDevice device, 
                String command)

Parameters
device ITestDevice

command String

Returns
boolean

Throws
DeviceNotAvailableException

toggleBtsnoopLogging

boolean toggleBtsnoopLogging (Sl4aClient client, 
                boolean onOff)

Parameters
client Sl4aClient

onOff boolean

Returns
boolean

Throws
DeviceNotAvailableException

unpairWithRetry

boolean unpairWithRetry (ITestDevice device)

Retries clearing of BT pairing with linear backoff

Returns
boolean

Throws
DeviceNotAvailableException

uploadLogFiles

void uploadLogFiles (ITestInvocationListener listener, 
                ITestDevice device, 
                String type, 
                int iteration)

Upload snoop log file for test results

Parameters
listener ITestInvocationListener

device ITestDevice

type String

iteration int

Throws
DeviceNotAvailableException