BluetoothUtils

public class BluetoothUtils
extends Object

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


用于在设备上调用 BluetoothInstrumentation 的实用程序函数

设备端 BluetoothInstrumentation 代码可在 AOSP 中找到,路径为:frameworks/base/core/tests/bluetoothtests

摘要

常量

String BTSNOOP_API

String BTSNOOP_CMD

String BTSNOOP_DISABLE_CMD

String BTSNOOP_ENABLE_CMD

String GOLD_BTSNOOP_LOG_PATH

String O_BUILD

公共构造函数

BluetoothUtils()

公共方法

static void cleanLogFile(ITestDevice device)

从设备中删除 snoop 日志文件

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)

检索给定设备的蓝牙 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)

使用线性退避算法重试清除蓝牙配对

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

上传用于测试结果的 snoop 日志文件

常量

BTSNOOP_API

public static final String BTSNOOP_API

常量值: "bluetoothConfigHciSnoopLog"

BTSNOOP_CMD

public static final String BTSNOOP_CMD

常量值: “setprop persist.bluetooth.btsnoopenable ”

BTSNOOP_DISABLE_CMD

public static final String BTSNOOP_DISABLE_CMD

常量值: “setprop persist.bluetooth.btsnoopenable false”

BTSNOOP_ENABLE_CMD

public static final String BTSNOOP_ENABLE_CMD

常量值: “setprop persist.bluetooth.btsnoopenable true”

GOLD_BTSNOOP_LOG_PATH

public static final String GOLD_BTSNOOP_LOG_PATH

常量值: "/data/misc/bluetooth/logs/btsnoop_hci.log"

O_BUILD

public static final String O_BUILD

常量值: "O"

公共构造函数

BluetoothUtils

public BluetoothUtils ()

公共方法

cleanLogFile

public static void cleanLogFile (ITestDevice device)

从设备中删除 snoop 日志文件

参数
device ITestDevice

抛出
DeviceNotAvailableException

停用

public static boolean disable (ITestDevice device)

停用指定设备上的蓝牙

返回
boolean 如果停用成功,则为 true,否则为 false

抛出
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

disableBtsnoopLogging

public static boolean disableBtsnoopLogging (ITestDevice device, 
                File sl4aApkFile)

通过 sl4a 调用停用 btsnoop 日志记录

参数
sl4aApkFile File:sl4a.apk 文件位置,如果已安装,则为 null

返回
boolean 成功与否

抛出
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

disableBtsnoopLogging

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

enableBtsnoopLogging

public static boolean enableBtsnoopLogging (ITestDevice device, 
                File sl4aApkFile)

通过 sl4a 调用启用 btsnoop 日志记录

参数
sl4aApkFile File:sl4a.apk 文件位置,如果已安装,则为 null

返回
boolean 成功与否

抛出
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

enableBtsnoopLogging

public static boolean enableBtsnoopLogging (ITestDevice device)

通过 sl4a 调用启用 btsnoop 日志记录

返回
boolean 成功与否

抛出
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

getBluetoothMac

public static String getBluetoothMac (ITestDevice device)

检索给定设备的蓝牙 MAC 地址

返回
String BT mac,如果未找到,则为 null

抛出
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

getBondedDevices

public static  getBondedDevices (ITestDevice device)

返回指定设备已配对的设备的蓝牙 MAC 地址

返回
蓝牙 MAC 地址

抛出
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

getBtSnoopLogFilePath

public static String getBtSnoopLogFilePath (ITestDevice device)

从 bt_stack.config 文件中获取蓝牙监听日志文件路径

返回
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 的输出

抛出
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

runBluetoothInstrumentationWithRetry

public static boolean runBluetoothInstrumentationWithRetry (ITestDevice device, 
                String command)

参数
device ITestDevice

command String

返回
boolean

抛出
DeviceNotAvailableException

toggleBtsnoopLogging

public static boolean toggleBtsnoopLogging (Sl4aClient client, 
                boolean onOff)

参数
client Sl4aClient

onOff boolean

返回
boolean

抛出
DeviceNotAvailableException

unpairWithRetry

public static boolean unpairWithRetry (ITestDevice device)

使用线性退避算法重试清除蓝牙配对

返回
boolean

抛出
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

uploadLogFiles

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

上传用于测试结果的 snoop 日志文件

参数
listener ITestInvocationListener

device ITestDevice

type String

iteration int

抛出
DeviceNotAvailableException