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:停用窺探記錄

傳回
boolean 如果已成功停用,則為「是」

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

受保護的方法

完成

protected void finalize ()

清除所有 SL4A 連線