BluetoothUtils

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 嗅探日志文件路径

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

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 日志文件

参数
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)

检索给定设备的 BT 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 文件获取 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 的输出

抛出
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