Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
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
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 |
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 |
DeviceNotAvailableException |
|
disableBtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device)
Disable btsnoop logging by sl4a call
Returns |
boolean |
success or not |
Throws |
DeviceNotAvailableException |
|
enable
public static boolean enable (ITestDevice device)
Enables bluetooth on the given device
Returns |
boolean |
True if enable is successful, false otherwise |
Throws |
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 |
DeviceNotAvailableException |
|
enableBtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device)
Enable btsnoop logging by sl4a call
Returns |
boolean |
success or not |
Throws |
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 |
DeviceNotAvailableException |
|
getBondedDevices
public static getBondedDevices (ITestDevice device)
Returns bluetooth mac addresses of devices that the given device has bonded with
Returns |
|
bluetooth mac addresses |
Throws |
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 |
DeviceNotAvailableException |
|
runBluetoothInstrumentationWithRetry
public static boolean runBluetoothInstrumentationWithRetry (ITestDevice device,
String command)
Parameters |
device |
ITestDevice |
command |
String |
Throws |
DeviceNotAvailableException |
|
toggleBtsnoopLogging
public static boolean toggleBtsnoopLogging (Sl4aClient client,
boolean onOff)
Parameters |
client |
Sl4aClient |
onOff |
boolean |
Throws |
DeviceNotAvailableException |
|
unpairWithRetry
public static boolean unpairWithRetry (ITestDevice device)
Retries clearing of BT pairing with linear backoff
Throws |
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 |
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-08-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-08-03 UTC."],[],[]]