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