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
Fields | |
---|---|
public
static
final
String |
BTSNOOP_API
|
public
static
final
String |
BTSNOOP_CMD
|
public
static
final
String |
BTSNOOP_DISABLE_CMD
|
public
static
final
String |
BTSNOOP_ENABLE_CMD
|
public
static
final
String |
GOLD_BTSNOOP_LOG_PATH
|
public
static
final
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
|
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 |
Fields
BTSNOOP_API
public static final String BTSNOOP_API
BTSNOOP_CMD
public static final String BTSNOOP_CMD
BTSNOOP_DISABLE_CMD
public static final String BTSNOOP_DISABLE_CMD
BTSNOOP_ENABLE_CMD
public static final String BTSNOOP_ENABLE_CMD
GOLD_BTSNOOP_LOG_PATH
public static final String GOLD_BTSNOOP_LOG_PATH
O_BUILD
public static final String O_BUILD
Public constructors
BluetoothUtils
public BluetoothUtils ()
Public methods
cleanLogFile
public static void cleanLogFile (ITestDevice device)
Delete snoop log file from device
Parameters | |
---|---|
device |
ITestDevice |
Throws | |
---|---|
DeviceNotAvailableException |
disable
public static boolean disable (ITestDevice device)
Disables bluetooth on the given device
Returns | |
---|---|
boolean |
True if disable is successful, false otherwise |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
disableBtsnoopLogging
public static 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 | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
disableBtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device)
Disable btsnoop logging by sl4a call
Returns | |
---|---|
boolean |
success or not |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
enable
public static boolean enable (ITestDevice device)
Enables bluetooth on the given device
Returns | |
---|---|
boolean |
True if enable is successful, false otherwise |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
enableBtsnoopLogging
public static 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 | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
enableBtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device)
Enable btsnoop logging by sl4a call
Returns | |
---|---|
boolean |
success or not |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBluetoothMac
public static String getBluetoothMac (ITestDevice device)
Retrieves BT mac of the given device
Returns | |
---|---|
String |
BT mac or null if not found |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBondedDevices
public staticgetBondedDevices (ITestDevice device)
Returns bluetooth mac addresses of devices that the given device has bonded with
Returns | |
---|---|
|
bluetooth mac addresses |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
getBtSnoopLogFilePath
public static 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
public static 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 | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
runBluetoothInstrumentationWithRetry
public static boolean runBluetoothInstrumentationWithRetry (ITestDevice device, String command)
Parameters | |
---|---|
device |
ITestDevice |
command |
String |
Returns | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
toggleBtsnoopLogging
public static boolean toggleBtsnoopLogging (Sl4aClient client, boolean onOff)
Parameters | |
---|---|
client |
Sl4aClient |
onOff |
boolean |
Returns | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
unpairWithRetry
public static boolean unpairWithRetry (ITestDevice device)
Retries clearing of BT pairing with linear backoff
Returns | |
---|---|
boolean |
Throws | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
uploadLogFiles
public static 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 |