自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
BluetoothUtils
public
class
BluetoothUtils
extends Object
java.lang.Object
|
↳ |
com.android.tradefed.util.BluetoothUtils
|
用於在裝置上呼叫 BluetoothInstrumentation 的工具函式
裝置端的藍牙測試程式碼可在 Android 開放原始碼計畫中找到:
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
公用建構函式
BluetoothUtils
public BluetoothUtils ()
公用方法
cleanLogFile
public static void cleanLogFile (ITestDevice device)
從裝置中刪除窺探日誌檔案
擲回 |
DeviceNotAvailableException |
|
停用
public static boolean disable (ITestDevice device)
停用指定裝置的藍牙
傳回 |
boolean |
如果停用成功,則傳回 True,否則傳回 false |
擲回 |
DeviceNotAvailableException |
|
disableBtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device,
File sl4aApkFile)
透過 sl4a 呼叫停用 btsnoop 記錄
參數 |
sl4aApkFile |
File :sl4a.apk 檔案位置,如果已安裝則為空值 |
擲回 |
DeviceNotAvailableException |
|
disableBtsnoopLogging
public static boolean disableBtsnoopLogging (ITestDevice device)
透過 sl4a 呼叫停用 btsnoop 記錄
擲回 |
DeviceNotAvailableException |
|
啟用
public static boolean enable (ITestDevice device)
在指定裝置上啟用藍牙
傳回 |
boolean |
如果啟用成功,則傳回 True,否則傳回 false |
擲回 |
DeviceNotAvailableException |
|
enableBtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device,
File sl4aApkFile)
透過 sl4a 呼叫啟用 btsnoop 記錄功能
參數 |
sl4aApkFile |
File :sl4a.apk 檔案位置,如果已安裝則為空值 |
擲回 |
DeviceNotAvailableException |
|
enableBtsnoopLogging
public static boolean enableBtsnoopLogging (ITestDevice device)
透過 sl4a 呼叫啟用 btsnoop 記錄功能
擲回 |
DeviceNotAvailableException |
|
getBluetoothMac
public static String getBluetoothMac (ITestDevice device)
擷取指定裝置的 BT MAC
傳回 |
String |
BT MAC 或空值 (如果找不到) |
擲回 |
DeviceNotAvailableException |
|
getBondedDevices
public static getBondedDevices (ITestDevice device)
傳回指定裝置已綁定的裝置的藍牙 MAC 位址
擲回 |
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 的輸出內容 |
擲回 |
DeviceNotAvailableException |
|
runBluetoothInstrumentationWithRetry
public static boolean runBluetoothInstrumentationWithRetry (ITestDevice device,
String command)
參數 |
device |
ITestDevice |
command |
String |
擲回 |
DeviceNotAvailableException |
|
toggleBtsnoopLogging
public static boolean toggleBtsnoopLogging (Sl4aClient client,
boolean onOff)
參數 |
client |
Sl4aClient |
onOff |
boolean |
擲回 |
DeviceNotAvailableException |
|
unpairWithRetry
public static boolean unpairWithRetry (ITestDevice device)
以線性輪詢方式重試清除藍牙配對
擲回 |
DeviceNotAvailableException |
|
uploadLogFiles
public static void uploadLogFiles (ITestInvocationListener listener,
ITestDevice device,
String type,
int iteration)
上傳 snoop 記錄檔以取得測試結果
參數 |
listener |
ITestInvocationListener |
device |
ITestDevice |
type |
String |
iteration |
int |
擲回 |
DeviceNotAvailableException |
|
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-03-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-03-26 (世界標準時間)。"],[],[]]