藍牙實用程式
public class BluetoothUtils
extends Object
java.lang.Object |
↳ | com.android.tradefed.util.BluetoothUtils |
用於在裝置上呼叫BluetoothInstrumentation的實用函數
設備端BluetoothInstrumentation程式碼可以在AOSP中找到: frameworks/base/core/tests/bluetoothtests
概括
領域
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
公共構造函數
藍牙實用程式
public BluetoothUtils ()
公共方法
清理日誌文件
public static void cleanLogFile (ITestDevice device)
從設備中刪除監聽日誌文件
投擲 |
---|
DeviceNotAvailableException | |
停用
public static boolean disable (ITestDevice device)
停用給定裝置上的藍牙
退貨 |
---|
boolean | 如果停用成功則為 true,否則為 false |
投擲 |
---|
DeviceNotAvailableException | |
禁用BtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device,
File sl4aApkFile)
透過 sl4a 呼叫禁用 btsnoop 日誌記錄
參數 |
---|
sl4aApkFile | File :sl4a.apk檔案位置,如果已安裝則為空 |
投擲 |
---|
DeviceNotAvailableException | |
禁用BtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device)
透過 sl4a 呼叫禁用 btsnoop 日誌記錄
投擲 |
---|
DeviceNotAvailableException | |
使能夠
public static boolean enable (ITestDevice device)
在給定裝置上啟用藍牙
退貨 |
---|
boolean | 若啟用成功則為 true,否則為 false |
投擲 |
---|
DeviceNotAvailableException | |
啟用BtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device,
File sl4aApkFile)
透過 sl4a 呼叫啟用 btsnoop 日誌記錄
參數 |
---|
sl4aApkFile | File :sl4a.apk檔案位置,如果已安裝則為空 |
投擲 |
---|
DeviceNotAvailableException | |
啟用BtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device)
透過 sl4a 呼叫啟用 btsnoop 日誌記錄
投擲 |
---|
DeviceNotAvailableException | |
取得藍牙Mac
public static String getBluetoothMac (ITestDevice device)
檢索給定設備的 BT mac
退貨 |
---|
String | BT mac 或 null(如果找不到) |
投擲 |
---|
DeviceNotAvailableException | |
取得綁定設備
public static getBondedDevices (ITestDevice device)
傳回給定裝置已綁定的裝置的藍牙 MAC 位址
投擲 |
---|
DeviceNotAvailableException | |
取得BtSnoopLogFilePath
public static String getBtSnoopLogFilePath (ITestDevice device)
從 bt_stack.config 檔案取得 bt snoop 記錄檔路徑
退貨 |
---|
String | bt_snoop_log 的檔名,如果找不到則為 null |
投擲 |
---|
DeviceNotAvailableException | |
運行藍牙儀器
public static String runBluetoothInstrumentation (ITestDevice device,
String command)
執行 BT 偵測指令並傳回輸出的便捷方法
參數 |
---|
command | String :傳送到 BT 偵測的命令字串,目前支援:enable、disable、unpairAll、getName、getAddress、getBondedDevices;請參閱 AOSP 來源以了解更多詳細信息 |
投擲 |
---|
DeviceNotAvailableException | |
執行藍牙檢測並重試
public static boolean runBluetoothInstrumentationWithRetry (ITestDevice device,
String command)
參數 |
---|
device | ITestDevice |
command | String |
投擲 |
---|
DeviceNotAvailableException | |
切換Btsnoop日誌記錄
public static boolean toggleBtsnoopLogging (Sl4aClient client,
boolean onOff)
參數 |
---|
client | Sl4aClient |
onOff | boolean |
投擲 |
---|
DeviceNotAvailableException | |
取消配對並重試
public static boolean unpairWithRetry (ITestDevice device)
使用線性退避重試清除 BT 配對
投擲 |
---|
DeviceNotAvailableException | |
上傳日誌文件
public static void uploadLogFiles (ITestInvocationListener listener,
ITestDevice device,
String type,
int iteration)
上傳監聽日誌檔案以取得測試結果
參數 |
---|
listener | ITestInvocationListener |
device | ITestDevice |
type | String |
iteration | int |
投擲 |
---|
DeviceNotAvailableException | |