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, profiles)

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

boolean disable(ITestDevice device)

在目标设备上停用蓝牙

boolean disableBluetoothSnoopLog(ITestDevice device)

停用蓝牙信息收集日志

boolean 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)

更改主设备上给定个人资料的优先级设置,使其成为次要设备

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, 
                 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

disableBluetoothSnoopLog

public boolean disableBluetoothSnoopLog (ITestDevice device)

停用蓝牙信息收集日志

参数
device ITestDevice:停用 Snoop 日志

返回
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

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

setBtConnectionTimeout

public void setBtConnectionTimeout (Duration timeout)

参数
timeout Duration

setBtPairTimeout

public void setBtPairTimeout (Duration timeout)

参数
timeout Duration

setProfilePriority

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

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 连接