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 |
|
配對
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 連線