Sl4aBluetoothUtil

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, Set<Sl4aBluetoothUtil.BluetoothProfile> profiles)

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

boolean disable(ITestDevice device)

停用目标设备上的蓝牙

boolean disableBluetoothSnoopLog(ITestDevice device)

停用蓝牙信息收集日志

boolean disconnect(ITestDevice primary, ITestDevice secondary, Set<Sl4aBluetoothUtil.BluetoothProfile> profiles)

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

boolean enable(ITestDevice device)

在目标设备上启用蓝牙

boolean enableBluetoothSnoopLog(ITestDevice device)

启用蓝牙信息收集日志

String getAddress(ITestDevice device)

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

Set<String> getBondedDevices(ITestDevice device)

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

boolean pair(ITestDevice primary, ITestDevice secondary)

将主设备与辅助设备配对

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

更改主设备上指定配置文件相对于次设备的优先级设置

void startSl4a(ITestDevice device, File sl4aApkFile)

使用给定的设备和 SL4A APK 文件明确启动 SL4A 客户端。

void stopSl4a()

停止已打开的 SL4A 客户端。

boolean unpairAll(ITestDevice device)

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

受保护的方法

void finalize()

清理所有 SL4A 连接

公共构造函数

Sl4aBluetoothUtil

public Sl4aBluetoothUtil ()

公共方法

changeProfileAccessPermission

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, 
                Set<Sl4aBluetoothUtil.BluetoothProfile> profiles)

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

参数
primary ITestDevice:要连接的设备

secondary ITestDevice:要连接的设备

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

返回
boolean 如果连接成功,则为 true

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

停用

public boolean disable (ITestDevice device)

在目标设备上停用蓝牙

参数
device ITestDevice:目标设备

返回
boolean 如果蓝牙已成功停用,则为 true

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

disableBluetoothSnoopLog

public boolean disableBluetoothSnoopLog (ITestDevice device)

停用蓝牙信息收集日志

参数
device ITestDevice:停用监听日志

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

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

断开连接

public boolean disconnect (ITestDevice primary, 
                ITestDevice secondary, 
                Set<Sl4aBluetoothUtil.BluetoothProfile> profiles)

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

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

secondary ITestDevice:要断开连接的设备

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

返回
boolean 如果成功断开连接,则为 true

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

启用

public boolean enable (ITestDevice device)

在目标设备上启用蓝牙

参数
device ITestDevice:目标设备

返回
boolean 如果蓝牙成功启用,则为 true

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

enableBluetoothSnoopLog

public boolean enableBluetoothSnoopLog (ITestDevice device)

启用蓝牙信息收集日志

参数
device ITestDevice:启用信息收集日志

返回
boolean 如果成功启用,则为 true

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

getAddress

public String getAddress (ITestDevice device)

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

参数
device ITestDevice:目标设备

返回
String MAC 地址字符串

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

getBondedDevices

public Set<String> getBondedDevices (ITestDevice device)

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

参数
device ITestDevice:目标设备

返回
Set<String> 一组蓝牙 MAC 地址

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

pair

public boolean pair (ITestDevice primary, 
                ITestDevice secondary)

将主设备与辅助设备配对

参数
primary ITestDevice:要配对的设备

secondary ITestDevice:要配对的设备

返回
boolean 如果配对成功,则为 true

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

setBtConnectionTimeout

public void setBtConnectionTimeout (Duration timeout)

参数
timeout Duration

setBtPairTimeout

public void setBtPairTimeout (Duration timeout)

参数
timeout Duration

setProfilePriority

public boolean setProfilePriority (ITestDevice primary, 
                ITestDevice secondary, 
                Set<Sl4aBluetoothUtil.BluetoothProfile> profiles, 
                Sl4aBluetoothUtil.BluetoothPriorityLevel priority)

更改主设备上指定个人资料相对于次要设备的优先级设置

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

secondary ITestDevice:要设置优先级的设备

profiles Set:要更改优先级设置的蓝牙配置文件

priority Sl4aBluetoothUtil.BluetoothPriorityLevel:优先级

返回
boolean 如果成功设置优先级,则为 true

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

startSl4a

public void startSl4a (ITestDevice device, 
                File sl4aApkFile)

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

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

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

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

stopSl4a

public void stopSl4a ()

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

unpairAll

public boolean unpairAll (ITestDevice device)

取消与当前设备的所有配对设备之间的配对

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

返回
boolean 如果取消配对成功,则为 true

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

受保护的方法

finalize

protected void finalize ()

清理所有 SL4A 连接