自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
BluetoothUtils
public
class
BluetoothUtils
extends Object
java.lang.Object
|
↳ |
com.android.tradefed.util.BluetoothUtils
|
用于在设备上调用 BluetoothInstrumentation 的实用函数
设备端 BluetoothInstrumentation 代码位于 AOSP 中的以下位置:
frameworks/base/core/tests/bluetoothtests
摘要
字段
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
公共构造函数
BluetoothUtils
public BluetoothUtils ()
公共方法
cleanLogFile
public static void cleanLogFile (ITestDevice device)
从设备中删除 Snoop 日志文件
抛出 |
DeviceNotAvailableException |
|
停用
public static boolean disable (ITestDevice device)
在给定设备上停用蓝牙
返回 |
boolean |
如果停用成功,则为 true;否则为 false |
抛出 |
DeviceNotAvailableException |
|
disableBtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device,
File sl4aApkFile)
通过 sl4a 调用停用 btsnoop 日志记录
参数 |
sl4aApkFile |
File :sl4a.apk 文件位置,如果已安装,则为 null |
抛出 |
DeviceNotAvailableException |
|
disableBtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device)
通过 sl4a 调用停用 btsnoop 日志记录
抛出 |
DeviceNotAvailableException |
|
启用
public static boolean enable (ITestDevice device)
在指定设备上启用蓝牙
返回 |
boolean |
如果启用成功,则为 true,否则为 false |
抛出 |
DeviceNotAvailableException |
|
enableBtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device,
File sl4aApkFile)
通过 sl4a 调用启用 btsnoop 日志记录
参数 |
sl4aApkFile |
File :sl4a.apk 文件位置,如果已安装,则为 null |
抛出 |
DeviceNotAvailableException |
|
enableBtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device)
通过 sl4a 调用启用 btsnoop 日志记录
抛出 |
DeviceNotAvailableException |
|
getBluetoothMac
public static String getBluetoothMac (ITestDevice device)
检索给定设备的 BT MAC
返回 |
String |
BT MAC 或 null(如果未找到) |
抛出 |
DeviceNotAvailableException |
|
getBondedDevices
public static getBondedDevices (ITestDevice device)
返回给定设备已配对的设备的蓝牙 MAC 地址
抛出 |
DeviceNotAvailableException |
|
getBtSnoopLogFilePath
public static String getBtSnoopLogFilePath (ITestDevice device)
从 bt_stack.config 文件获取 bt snoop 日志文件路径
返回 |
String |
bt_snoop_log 的文件名,如果未找到,则为 null
|
抛出 |
DeviceNotAvailableException |
|
runBluetoothInstrumentation
public static String runBluetoothInstrumentation (ITestDevice device,
String command)
用于执行 BT 插桩命令并返回输出的便捷方法
参数 |
command |
String :发送到 BT 插桩的命令字符串,目前支持:enable、disable、unpairAll、getName、getAddress、getBondedDevices;如需了解详情,请参阅 AOSP 源代码 |
返回 |
String |
BluetoothInstrumentation 的输出 |
抛出 |
DeviceNotAvailableException |
|
runBluetoothInstrumentationWithRetry
public static boolean runBluetoothInstrumentationWithRetry (ITestDevice device,
String command)
参数 |
device |
ITestDevice |
command |
String |
抛出 |
DeviceNotAvailableException |
|
toggleBtsnoopLogging
public static boolean toggleBtsnoopLogging (Sl4aClient client,
boolean onOff)
参数 |
client |
Sl4aClient |
onOff |
boolean |
抛出 |
DeviceNotAvailableException |
|
unpairWithRetry
public static boolean unpairWithRetry (ITestDevice device)
使用线性退避算法重试清除蓝牙配对
抛出 |
DeviceNotAvailableException |
|
uploadLogFiles
public static void uploadLogFiles (ITestInvocationListener listener,
ITestDevice device,
String type,
int iteration)
上传 Snoop 日志文件以获取测试结果
参数 |
listener |
ITestInvocationListener |
device |
ITestDevice |
type |
String |
iteration |
int |
抛出 |
DeviceNotAvailableException |
|
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-26。"],[],[]]