BluetoothUtils
public
class
BluetoothUtils
extends Object
java.lang.Object | |
↳ | com.android.tradefed.util.BluetoothUtils |
用於在裝置上呼叫 BluetoothInstrumentation 的工具函式
裝置端藍牙測試程式碼可在 AOSP 中找到:
frameworks/base/core/tests/bluetoothtests
摘要
欄位 | |
---|---|
public
static
final
String |
BTSNOOP_API
|
public
static
final
String |
BTSNOOP_CMD
|
public
static
final
String |
BTSNOOP_DISABLE_CMD
|
public
static
final
String |
BTSNOOP_ENABLE_CMD
|
public
static
final
String |
GOLD_BTSNOOP_LOG_PATH
|
public
static
final
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)
以線性輪詢方式重試清除藍牙配對 |
static
void
|
uploadLogFiles(ITestInvocationListener listener, ITestDevice device, String type, int iteration)
上傳 snoop 記錄檔以取得測試結果 |
欄位
BTSNOOP_API
public static final String BTSNOOP_API
BTSNOOP_CMD
public static final String BTSNOOP_CMD
BTSNOOP_DISABLE_CMD
public static final String BTSNOOP_DISABLE_CMD
BTSNOOP_ENABLE_CMD
public static final String BTSNOOP_ENABLE_CMD
GOLD_BTSNOOP_LOG_PATH
public static final String GOLD_BTSNOOP_LOG_PATH
O_BUILD
public static final String O_BUILD
公用建構函式
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)
擷取指定裝置的 BT 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 檔案取得 bt 窺探記錄檔案路徑
傳回 | |
---|---|
String |
bt_snoop_log 的檔案名稱,如果找不到則為空值 |
擲回 | |
---|---|
DeviceNotAvailableException |
runBluetoothInstrumentation
public static String runBluetoothInstrumentation (ITestDevice device, String command)
執行 BT 檢測指令並傳回輸出的便利方法
參數 | |
---|---|
command |
String :傳送至 BT 檢測工具的指令字串,目前支援以下指令: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)
上傳 snoop 記錄檔以取得測試結果
參數 | |
---|---|
listener |
ITestInvocationListener |
device |
ITestDevice |
type |
String |
iteration |
int |
擲回 | |
---|---|
DeviceNotAvailableException |