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