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 true 如果权限更改成功

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

连接

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

在给定的蓝牙配置文件上将主设备连接到辅助设备

参数
primary ITestDevice :要连接的设备

secondary ITestDevice :要连接的设备

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

退货
boolean true 如果连接成功

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

禁用

public boolean disable (ITestDevice device)

禁用目标设备上的蓝牙

参数
device ITestDevice :目标设备

退货
boolean true 如果蓝牙成功禁用

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

禁用蓝牙监听日志

public boolean disableBluetoothSnoopLog (ITestDevice device)

禁用蓝牙监听日志

参数
device ITestDevice :禁用监听日志

退货
boolean true 如果成功禁用

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

断开

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

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

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

secondary ITestDevice :要断开连接的设备

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

退货
boolean true 如果断开连接成功

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

使能够

public boolean enable (ITestDevice device)

在目标设备上启用蓝牙

参数
device ITestDevice :目标设备

退货
boolean true 如果蓝牙成功启用

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

启用蓝牙监听日志

public boolean enableBluetoothSnoopLog (ITestDevice device)

启用蓝牙监听日志

参数
device ITestDevice :启用监听日志

退货
boolean true 如果成功启用

投掷
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 true 如果配对成功

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

设置Bt连接超时

public void setBtConnectionTimeout (Duration timeout)

参数
timeout Duration

设置BtPair超时

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 true 如果设置优先级成功

投掷
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 true 如果取消配对成功

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

受保护的方法

敲定

protected void finalize ()

清理所有 SL4A 连接