BluetoothUtils
public
class
BluetoothUtils
extends Object
| java.lang.Object | |
| ↳ | com.android.tradefed.util.BluetoothUtils |
Utility functions for calling BluetoothInstrumentation on device
裝置端的 BluetoothInstrumentation 程式碼位於 Android 開放原始碼計畫 (AOSP) 的:
frameworks/base/core/tests/bluetoothtests
摘要
常數 | |
|---|---|
String |
BTSNOOP_API
|
String |
BTSNOOP_CMD
|
String |
BTSNOOP_DISABLE_CMD
|
String |
BTSNOOP_ENABLE_CMD
|
String |
GOLD_BTSNOOP_LOG_PATH
|
String |
O_BUILD
|
公用建構函式 | |
|---|---|
BluetoothUtils()
|
|
公用方法 | |
|---|---|
static
void
|
cleanLogFile(ITestDevice device)
從裝置刪除監聽記錄檔 |
static
boolean
|
disable(ITestDevice device)
在指定裝置上停用藍牙 |
static
boolean
|
disableBtsnoopLogging(ITestDevice device, File sl4aApkFile)
透過 sl4a 呼叫停用 btsnoop 記錄 |
static
boolean
|
disableBtsnoopLogging(ITestDevice device)
透過 sl4a 呼叫停用 btsnoop 記錄 |
static
boolean
|
enable(ITestDevice device)
在指定裝置上啟用藍牙 |
static
boolean
|
enableBtsnoopLogging(ITestDevice device, File sl4aApkFile)
透過 sl4a 呼叫啟用 btsnoop 記錄功能 |
static
boolean
|
enableBtsnoopLogging(ITestDevice device)
透過 sl4a 呼叫啟用 btsnoop 記錄功能 |
static
String
|
getBluetoothMac(ITestDevice device)
擷取指定裝置的 BT MAC |
static
|
getBondedDevices(ITestDevice device)
傳回指定裝置已繫結的裝置藍牙 MAC 位址 |
static
String
|
getBtSnoopLogFilePath(ITestDevice device)
從 bt_stack.config 檔案取得 bt 窺探記錄檔路徑 |
static
String
|
runBluetoothInstrumentation(ITestDevice device, String command)
執行 BT 檢測指令並傳回輸出的便利方法 |
static
boolean
|
runBluetoothInstrumentationWithRetry(ITestDevice device, String command)
|
static
boolean
|
toggleBtsnoopLogging(Sl4aClient client, boolean onOff)
|
static
boolean
|
unpairWithRetry(ITestDevice device)
Retries clearing of BT pairing with linear backoff |
static
void
|
uploadLogFiles(ITestInvocationListener listener, ITestDevice device, String type, int iteration)
上傳監聽記錄檔,查看測試結果 |
常數
BTSNOOP_API
public static final String BTSNOOP_API
常數值: "bluetoothConfigHciSnoopLog"
BTSNOOP_CMD
public static final String BTSNOOP_CMD
常數值: "setprop persist.bluetooth.btsnoopenable "
BTSNOOP_DISABLE_CMD
public static final String BTSNOOP_DISABLE_CMD
常數值: "setprop persist.bluetooth.btsnoopenable false"
BTSNOOP_ENABLE_CMD
public static final String BTSNOOP_ENABLE_CMD
常數值: "setprop persist.bluetooth.btsnoopenable true"
GOLD_BTSNOOP_LOG_PATH
public static final String GOLD_BTSNOOP_LOG_PATH
常數值: "/data/misc/bluetooth/logs/btsnoop_hci.log"
O_BUILD
public static final String O_BUILD
常數值: "O"
公用建構函式
BluetoothUtils
public BluetoothUtils ()
公用方法
cleanLogFile
public static void cleanLogFile (ITestDevice device)
從裝置刪除監聽記錄檔
| 參數 | |
|---|---|
device |
ITestDevice |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
停用
public static boolean disable (ITestDevice device)
停用指定裝置的藍牙
| 傳回 | |
|---|---|
boolean |
如果停用成功,則為 True,否則為 False |
| 擲回 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
disableBtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device, File sl4aApkFile)
透過 sl4a 呼叫停用 btsnoop 記錄
| 參數 | |
|---|---|
sl4aApkFile |
File:sl4a.apk 檔案位置,如果已安裝則為空值 |
| 傳回 | |
|---|---|
boolean |
是否成功 |
| 擲回 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
disableBtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device)
透過 sl4a 呼叫停用 btsnoop 記錄
| 傳回 | |
|---|---|
boolean |
是否成功 |
| 擲回 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
啟用
public static boolean enable (ITestDevice device)
在指定裝置上啟用藍牙
| 傳回 | |
|---|---|
boolean |
如果啟用成功,則為 True,否則為 False |
| 擲回 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
enableBtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device, File sl4aApkFile)
透過 sl4a 呼叫啟用 btsnoop 記錄功能
| 參數 | |
|---|---|
sl4aApkFile |
File:sl4a.apk 檔案位置,如果已安裝則為空值 |
| 傳回 | |
|---|---|
boolean |
是否成功 |
| 擲回 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
enableBtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device)
透過 sl4a 呼叫啟用 btsnoop 記錄功能
| 傳回 | |
|---|---|
boolean |
是否成功 |
| 擲回 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
getBluetoothMac
public static String getBluetoothMac (ITestDevice device)
擷取指定裝置的藍牙 MAC 位址
| 傳回 | |
|---|---|
String |
如果找不到,則為 BT mac 或空值 |
| 擲回 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
getBondedDevices
public staticgetBondedDevices (ITestDevice device)
傳回指定裝置已配對的裝置藍牙 MAC 位址
| 傳回 | |
|---|---|
|
藍牙 MAC 位址 |
| 擲回 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
getBtSnoopLogFilePath
public static String getBtSnoopLogFilePath (ITestDevice device)
從 bt_stack.config 檔案取得藍牙監聽記錄檔路徑
| 傳回 | |
|---|---|
String |
bt_snoop_log 的檔案名稱,如果找不到則為空值 |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
runBluetoothInstrumentation
public static String runBluetoothInstrumentation (ITestDevice device, String command)
執行 BT 檢測指令並傳回輸出內容的便利方法
| 參數 | |
|---|---|
command |
String:傳送至藍牙儀器的指令字串,目前支援:enable、disable、unpairAll、getName、getAddress、getBondedDevices;詳情請參閱 Android 開放原始碼計畫來源 |
| 傳回 | |
|---|---|
String |
BluetoothInstrumentation 的輸出內容 |
| 擲回 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
runBluetoothInstrumentationWithRetry
public static boolean runBluetoothInstrumentationWithRetry (ITestDevice device, String command)
| 參數 | |
|---|---|
device |
ITestDevice |
command |
String |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
toggleBtsnoopLogging
public static boolean toggleBtsnoopLogging (Sl4aClient client, boolean onOff)
| 參數 | |
|---|---|
client |
Sl4aClient |
onOff |
boolean |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
unpairWithRetry
public static boolean unpairWithRetry (ITestDevice device)
以線性輪詢方式重試清除藍牙配對
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
uploadLogFiles
public static void uploadLogFiles (ITestInvocationListener listener, ITestDevice device, String type, int iteration)
上傳窺探記錄檔,查看測試結果
| 參數 | |
|---|---|
listener |
ITestInvocationListener |
device |
ITestDevice |
type |
String |
iteration |
int |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|