蓝牙实用程序
public class BluetoothUtils
extends Object
java.lang.Object | |
↳ | com.android.tradefed.util.BluetoothUtils |
用于在设备上调用BluetoothInstrumentation的实用函数
设备端BluetoothInstrumentation代码可以在AOSP中找到: frameworks/base/core/tests/bluetoothtests
概括
领域 | |
---|---|
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
|
公共构造函数 | |
---|---|
BluetoothUtils () |
公共方法 | |
---|---|
static void | cleanLogFile ( ITestDevice device) 从设备中删除监听日志文件 |
static boolean | disable ( ITestDevice device) 禁用给定设备上的蓝牙 |
static boolean | disableBtsnoopLogging ( ITestDevice device, File sl4aApkFile) 通过 sl4a 调用禁用 btsnoop 日志记录 |
static boolean | disableBtsnoopLogging ( ITestDevice device) 通过 sl4a 调用禁用 btsnoop 日志记录 |
static boolean | enable ( ITestDevice device) 在给定设备上启用蓝牙 |
static boolean | enableBtsnoopLogging ( ITestDevice device, File sl4aApkFile) 通过 sl4a 调用启用 btsnoop 日志记录 |
static boolean | enableBtsnoopLogging ( ITestDevice device) 通过 sl4a 调用启用 btsnoop 日志记录 |
static String | getBluetoothMac ( ITestDevice device) 检索给定设备的 BT mac |
static | getBondedDevices ( ITestDevice device) 返回给定设备已绑定的设备的蓝牙 MAC 地址 |
static String | getBtSnoopLogFilePath ( ITestDevice device) 从 bt_stack.config 文件获取 bt snoop 日志文件路径 |
static String | runBluetoothInstrumentation ( ITestDevice device, String command) 执行 BT 检测命令并返回输出的便捷方法 |
static boolean | runBluetoothInstrumentationWithRetry ( ITestDevice device, String command) |
static boolean | toggleBtsnoopLogging ( Sl4aClient client, boolean onOff) |
static boolean | unpairWithRetry ( ITestDevice device) 使用线性退避重试清除 BT 配对 |
static void | uploadLogFiles ( ITestInvocationListener listener, ITestDevice device, String type, int iteration) 上传监听日志文件以获取测试结果 |
领域
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 BluetoothUtils ()
公共方法
清理日志文件
public static void cleanLogFile (ITestDevice device)
从设备中删除监听日志文件
参数 | |
---|---|
device | ITestDevice |
投掷 | |
---|---|
DeviceNotAvailableException |
禁用
public static boolean disable (ITestDevice device)
禁用给定设备上的蓝牙
退货 | |
---|---|
boolean | 如果禁用成功则为 true,否则为 false |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
禁用BtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device, File sl4aApkFile)
通过 sl4a 调用禁用 btsnoop 日志记录
参数 | |
---|---|
sl4aApkFile | File :sl4a.apk文件位置,如果已安装则为null |
退货 | |
---|---|
boolean | 成功与否 |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
禁用BtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device)
通过 sl4a 调用禁用 btsnoop 日志记录
退货 | |
---|---|
boolean | 成功与否 |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
使能够
public static boolean enable (ITestDevice device)
在给定设备上启用蓝牙
退货 | |
---|---|
boolean | 如果启用成功则为 true,否则为 false |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
启用BtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device, File sl4aApkFile)
通过 sl4a 调用启用 btsnoop 日志记录
参数 | |
---|---|
sl4aApkFile | File :sl4a.apk文件位置,如果已安装则为null |
退货 | |
---|---|
boolean | 成功与否 |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
启用BtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device)
通过 sl4a 调用启用 btsnoop 日志记录
退货 | |
---|---|
boolean | 成功与否 |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
获取蓝牙Mac
public static String getBluetoothMac (ITestDevice device)
检索给定设备的 BT mac
退货 | |
---|---|
String | BT mac 或 null(如果未找到) |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
获取绑定设备
public staticgetBondedDevices (ITestDevice device)
返回给定设备已绑定的设备的蓝牙 MAC 地址
退货 | |
---|---|
蓝牙mac地址 |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
获取BtSnoopLogFilePath
public static String getBtSnoopLogFilePath (ITestDevice device)
从 bt_stack.config 文件获取 bt snoop 日志文件路径
退货 | |
---|---|
String | bt_snoop_log 的文件名,如果未找到则为 null |
投掷 | |
---|---|
DeviceNotAvailableException |
运行蓝牙仪器
public static String runBluetoothInstrumentation (ITestDevice device, String command)
执行 BT 检测命令并返回输出的便捷方法
参数 | |
---|---|
command | String :发送到 BT 检测的命令字符串,当前支持:enable、disable、unpairAll、getName、getAddress、getBondedDevices;请参阅 AOSP 源了解更多详细信息 |
退货 | |
---|---|
String | 蓝牙仪器的输出 |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
运行蓝牙检测并重试
public static boolean runBluetoothInstrumentationWithRetry (ITestDevice device, String command)
参数 | |
---|---|
device | ITestDevice |
command | String |
退货 | |
---|---|
boolean |
投掷 | |
---|---|
DeviceNotAvailableException |
切换Btsnoop日志记录
public static boolean toggleBtsnoopLogging (Sl4aClient client, boolean onOff)
参数 | |
---|---|
client | Sl4aClient |
onOff | boolean |
退货 | |
---|---|
boolean |
投掷 | |
---|---|
DeviceNotAvailableException |
取消配对并重试
public static boolean unpairWithRetry (ITestDevice device)
使用线性退避重试清除 BT 配对
退货 | |
---|---|
boolean |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
上传日志文件
public static void uploadLogFiles (ITestInvocationListener listener, ITestDevice device, String type, int iteration)
上传监听日志文件以获取测试结果
参数 | |
---|---|
listener | ITestInvocationListener |
device | ITestDevice |
type | String |
iteration | int |
投掷 | |
---|---|
DeviceNotAvailableException |