SL4a蓝牙工具

public class Sl4aBluetoothUtil
extends Object

java.lang.Object
com.android.tradefed.util.Sl4aBluetoothUtil


实用程序类使用 SL4A 在一个或两个设备上提供蓝牙操作

概括

公共构造函数

Sl4aBluetoothUtil ()

公共方法

boolean changeProfileAccessPermission ( ITestDevice primary, ITestDevice secondary, Sl4aBluetoothUtil.BluetoothProfile profile, Sl4aBluetoothUtil.BluetoothAccessLevel access)

更改主设备上辅助设备的蓝牙配置文件访问权限,以便辅助设备访问给定配置文件上的主设备

boolean connect ( ITestDevice primary, ITestDevice secondary, profiles) connect ( ITestDevice primary, ITestDevice secondary, profiles)

根据给定的蓝牙配置文件将主要设备连接到辅助设备

boolean disable ( ITestDevice device)

在目标设备上禁用蓝牙

boolean disableBluetoothSnoopLog ( ITestDevice device)

禁用蓝牙监听日志

boolean disconnect ( ITestDevice primary, ITestDevice secondary, profiles) disconnect ( ITestDevice primary, ITestDevice secondary, profiles)

断开主设备与辅助设备的连接

boolean enable ( ITestDevice device)

在目标设备上启用蓝牙

boolean enableBluetoothSnoopLog ( ITestDevice device)

启用蓝牙监听日志

String getAddress ( ITestDevice device)

获取目标设备的蓝牙 MAC 地址

getBondedDevices ( ITestDevice device)

获取目标设备上绑定(配对)设备的蓝牙 MAC 地址集

boolean pair ( ITestDevice primary, ITestDevice secondary)

将主要设备与次要设备配对

void setBtConnectionTimeout (Duration timeout)
void setBtPairTimeout (Duration timeout)
boolean setProfilePriority ( ITestDevice primary, ITestDevice secondary, profiles, Sl4aBluetoothUtil.BluetoothPriorityLevel priority) setProfilePriority ( ITestDevice primary, ITestDevice secondary, profiles, Sl4aBluetoothUtil.BluetoothPriorityLevel priority)

将主设备上给定配置文件的优先级设置更改为辅助设备

void startSl4a ( ITestDevice device, File sl4aApkFile)

使用给定的设备和 SL4A apk 文件显式启动 SL4A 客户端。

void stopSl4a ()

停止已经打开的 SL4A 客户端。

boolean unpairAll ( ITestDevice device)

取消配对当前设备的所有配对设备

受保护的方法

void finalize ()

清理所有 SL4A 连接

公共构造函数

SL4a蓝牙工具

public Sl4aBluetoothUtil ()

公共方法

更改个人资料访问权限

public boolean changeProfileAccessPermission (ITestDevice primary, 
                ITestDevice secondary, 
                Sl4aBluetoothUtil.BluetoothProfile profile, 
                Sl4aBluetoothUtil.BluetoothAccessLevel access)

更改主设备上辅助设备的蓝牙配置文件访问权限,以便辅助设备访问给定配置文件上的主设备

参数
primary ITestDevice :更改权限的设备

secondary ITestDevice :访问给定配置文件上的主设备的设备

profile Sl4aBluetoothUtil.BluetoothProfile :要访问的蓝牙配置文件

access Sl4aBluetoothUtil.BluetoothAccessLevel :访问级别,参见BluetoothAccessLevel

退货
boolean如果权限更改成功则为真

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

连接

public boolean connect (ITestDevice primary, 
                ITestDevice secondary, 
                 profiles)

根据给定的蓝牙配置文件将主要设备连接到辅助设备

参数
primary ITestDevice :要连接的设备

secondary ITestDevice :要连接的设备

profiles :需要一组蓝牙配置文件才能连接

退货
boolean如果连接成功则为真

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

禁用

public boolean disable (ITestDevice device)

在目标设备上禁用蓝牙

参数
device ITestDevice :目标设备

退货
boolean如果蓝牙成功禁用则为真

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

禁用蓝牙探听日志

public boolean disableBluetoothSnoopLog (ITestDevice device)

禁用蓝牙监听日志

参数
device ITestDevice :禁用探听日志

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

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

断开

public boolean disconnect (ITestDevice primary, 
                ITestDevice secondary, 
                 profiles)

断开主设备与辅助设备的连接

参数
primary ITestDevice :执行断开连接操作的设备

secondary ITestDevice :要断开连接的设备

profiles :给定的一组蓝牙配置文件需要断开连接

退货
boolean如果成功断开连接则为真

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

使能够

public boolean enable (ITestDevice device)

在目标设备上启用蓝牙

参数
device ITestDevice :目标设备

退货
boolean如果蓝牙成功启用则为真

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

启用蓝牙探听日志

public boolean enableBluetoothSnoopLog (ITestDevice device)

启用蓝牙监听日志

参数
device ITestDevice : 启用监听日志

退货
boolean如果成功启用则为真

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

获取地址

public String getAddress (ITestDevice device)

获取目标设备的蓝牙 MAC 地址

参数
device ITestDevice :目标设备

退货
String MAC 地址字符串

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

获取保税设备

public  getBondedDevices (ITestDevice device)

获取目标设备上绑定(配对)设备的蓝牙 MAC 地址集

参数
device ITestDevice :目标设备

退货
一组蓝牙 MAC 地址

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

一对

public boolean pair (ITestDevice primary, 
                ITestDevice secondary)

将主要设备与次要设备配对

参数
primary ITestDevice :要配对的设备

secondary ITestDevice :要配对的设备

退货
boolean如果配对成功则为真

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

设置 BtConnectionTimeout

public void setBtConnectionTimeout (Duration timeout)

参数
timeout Duration

设置 BtPairTimeout

public void setBtPairTimeout (Duration timeout)

参数
timeout Duration

设置配置文件优先级

public boolean setProfilePriority (ITestDevice primary, 
                ITestDevice secondary, 
                 profiles, 
                Sl4aBluetoothUtil.BluetoothPriorityLevel priority)

将主设备上给定配置文件的优先级设置更改为辅助设备

参数
primary ITestDevice :设置优先级的设备

secondary ITestDevice :设置优先级的设备

profiles :用于更改优先级设置的蓝牙配置文件

priority Sl4aBluetoothUtil.BluetoothPriorityLevel :优先级

退货
boolean如果成功设置优先级则为真

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

启动Sl4a

public void startSl4a (ITestDevice device, 
                File sl4aApkFile)

使用给定的设备和 SL4A apk 文件显式启动 SL4A 客户端。通常不需要此方法,因为 SL4A 连接总是会在实际操作之前建立。

参数
device ITestDevice :要使用 SL4A 连接的设备

sl4aApkFile File :要安装和使用的可选 SL4A apk。

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

停止Sl4a

public void stopSl4a ()

停止已经打开的 SL4A 客户端。它基本上提供了一种在不再使用客户端后立即清理客户端的方法

取消配对

public boolean unpairAll (ITestDevice device)

取消配对当前设备的所有配对设备

参数
device ITestDevice :执行操作的当前设备

退货
boolean如果取消配对成功则为真

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

受保护的方法

敲定

protected void finalize ()

清理所有 SL4A 连接