蓝牙工具

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)

从设备中删除 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)

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

上传 snoop 日志文件以获取测试结果

领域

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)

从设备中删除 snoop 日志文件

参数
device ITestDevice

投掷
DeviceNotAvailableException

禁用

public static boolean disable (ITestDevice device)

在给定设备上禁用蓝牙

退货
boolean如果禁用成功则为真,否则为假

投掷
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如果启用成功则为真,否则为假

投掷
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 static  getBondedDevices (ITestDevice device)

返回给定设备绑定的设备的蓝牙 mac 地址

退货
蓝牙MAC地址

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

getBtSnoopLogFilePath

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 instrumentation 的命令字符串,目前支持: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

取消配对重试

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)

上传 snoop 日志文件以获取测试结果

参数
listener ITestInvocationListener

device ITestDevice

type String

iteration int

投掷
DeviceNotAvailableException