ตั้งแต่ปี 2026 เป็นต้นไป เราจะเผยแพร่ซอร์สโค้ดไปยัง AOSP ในไตรมาสที่ 2 และ 4 เพื่อให้สอดคล้องกับโมเดลการพัฒนาแบบ Trunk Stable และรับประกันความเสถียรของแพลตฟอร์มสำหรับระบบนิเวศ หากต้องการสร้างและมีส่วนร่วมใน AOSP ให้ใช้ android-latest-release android-latest-release สาขา Manifest จะอ้างอิงถึงรุ่นล่าสุดที่พุชไปยัง AOSP เสมอ ดูข้อมูลเพิ่มเติมได้ที่การเปลี่ยนแปลงใน AOSP
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Sl4aBluetoothUtil
public
class
Sl4aBluetoothUtil
extends Object
| java.lang.Object
|
| ↳ |
com.android.tradefed.util.Sl4aBluetoothUtil
|
คลาสยูทิลิตีจะให้การดำเนินการบลูทูธในอุปกรณ์ 1 หรือ 2 เครื่องโดยใช้ SL4A
สรุป
เมธอดสาธารณะ |
boolean
|
changeProfileAccessPermission(ITestDevice primary, ITestDevice secondary, Sl4aBluetoothUtil.BluetoothProfile profile, Sl4aBluetoothUtil.BluetoothAccessLevel access)
เปลี่ยนสิทธิ์เข้าถึงโปรไฟล์บลูทูธของอุปกรณ์รองในอุปกรณ์หลักเพื่อให้
อุปกรณ์รองเข้าถึงอุปกรณ์หลักในโปรไฟล์ที่กำหนดได้
|
boolean
|
connect(ITestDevice primary, ITestDevice secondary, Set<Sl4aBluetoothUtil.BluetoothProfile> profiles)
เชื่อมต่ออุปกรณ์หลักกับอุปกรณ์รองในโปรไฟล์บลูทูธที่กำหนด
|
boolean
|
disable(ITestDevice device)
ปิดใช้บลูทูธในอุปกรณ์เป้าหมาย
|
boolean
|
disableBluetoothSnoopLog(ITestDevice device)
ปิดใช้บันทึกการสอดแนมบลูทูธ
|
boolean
|
disconnect(ITestDevice primary, ITestDevice secondary, Set<Sl4aBluetoothUtil.BluetoothProfile> profiles)
ยกเลิกการเชื่อมต่ออุปกรณ์หลักจากอุปกรณ์รอง
|
boolean
|
enable(ITestDevice device)
เปิดใช้บลูทูธในอุปกรณ์เป้าหมาย
|
boolean
|
enableBluetoothSnoopLog(ITestDevice device)
เปิดใช้บันทึกการสอดแนมบลูทูธ
|
String
|
getAddress(ITestDevice device)
รับที่อยู่ MAC ของบลูทูธของอุปกรณ์เป้าหมาย
|
Set<String>
|
getBondedDevices(ITestDevice device)
รับชุดที่อยู่ MAC ของบลูทูธของอุปกรณ์ที่ผูก (จับคู่) ในอุปกรณ์เป้าหมาย
|
boolean
|
pair(ITestDevice primary, ITestDevice secondary)
จับคู่อุปกรณ์หลักกับอุปกรณ์รอง
|
void
|
setBtConnectionTimeout(Duration timeout)
|
void
|
setBtPairTimeout(Duration timeout)
|
boolean
|
setProfilePriority(ITestDevice primary, ITestDevice secondary, Set<Sl4aBluetoothUtil.BluetoothProfile> 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 |
จริง หากเปลี่ยนสิทธิ์สำเร็จ |
เชื่อมต่อ
public boolean connect (ITestDevice primary,
ITestDevice secondary,
Set<Sl4aBluetoothUtil.BluetoothProfile> profiles)
เชื่อมต่ออุปกรณ์หลักกับอุปกรณ์รองในโปรไฟล์บลูทูธที่กำหนด
| พารามิเตอร์ |
primary |
ITestDevice: อุปกรณ์ที่จะใช้เชื่อมต่อ |
secondary |
ITestDevice: อุปกรณ์ที่จะเชื่อมต่อ |
profiles |
Set: ต้องเชื่อมต่อชุดโปรไฟล์บลูทูธ |
| การคืนสินค้า |
boolean |
True หากเชื่อมต่อสำเร็จ |
ปิดใช้
public boolean disable (ITestDevice device)
ปิดใช้บลูทูธในอุปกรณ์เป้าหมาย
| พารามิเตอร์ |
device |
ITestDevice: อุปกรณ์เป้าหมาย |
| การคืนสินค้า |
boolean |
จริง หากปิดใช้บลูทูธสำเร็จ |
disableBluetoothSnoopLog
public boolean disableBluetoothSnoopLog (ITestDevice device)
ปิดใช้บันทึกการสอดแนมบลูทูธ
| พารามิเตอร์ |
device |
ITestDevice: ปิดใช้บันทึกการสอดแนม |
| การคืนสินค้า |
boolean |
true หากปิดใช้สำเร็จ |
ยกเลิกการเชื่อมต่อ
public boolean disconnect (ITestDevice primary,
ITestDevice secondary,
Set<Sl4aBluetoothUtil.BluetoothProfile> profiles)
ยกเลิกการเชื่อมต่ออุปกรณ์หลักจากอุปกรณ์รอง
| พารามิเตอร์ |
primary |
ITestDevice: อุปกรณ์ที่จะดำเนินการยกเลิกการเชื่อมต่อ |
secondary |
ITestDevice: อุปกรณ์ที่จะยกเลิกการเชื่อมต่อ |
profiles |
Set: ชุดโปรไฟล์บลูทูธที่กำหนดซึ่งต้องยกเลิกการเชื่อมต่อ |
| การคืนสินค้า |
boolean |
จริง หากยกเลิกการเชื่อมต่อสำเร็จ |
เปิดใช้
public boolean enable (ITestDevice device)
เปิดใช้บลูทูธในอุปกรณ์เป้าหมาย
| พารามิเตอร์ |
device |
ITestDevice: อุปกรณ์เป้าหมาย |
| การคืนสินค้า |
boolean |
true หากเปิดใช้บลูทูธสำเร็จ |
enableBluetoothSnoopLog
public boolean enableBluetoothSnoopLog (ITestDevice device)
เปิดใช้บันทึกการสอดแนมบลูทูธ
| พารามิเตอร์ |
device |
ITestDevice: เพื่อเปิดใช้บันทึกการดักฟัง |
| การคืนสินค้า |
boolean |
จริง หากเปิดใช้สำเร็จ |
getAddress
public String getAddress (ITestDevice device)
รับที่อยู่ MAC ของบลูทูธของอุปกรณ์เป้าหมาย
| พารามิเตอร์ |
device |
ITestDevice: อุปกรณ์เป้าหมาย |
| การคืนสินค้า |
String |
สตริงที่อยู่ MAC |
getBondedDevices
public Set<String> getBondedDevices (ITestDevice device)
รับชุดที่อยู่ MAC ของบลูทูธของอุปกรณ์ที่ผูก (จับคู่) ในอุปกรณ์เป้าหมาย
| พารามิเตอร์ |
device |
ITestDevice: อุปกรณ์เป้าหมาย |
| การคืนสินค้า |
Set<String> |
ชุดที่อยู่ MAC ของบลูทูธ |
จับคู่
public boolean pair (ITestDevice primary,
ITestDevice secondary)
จับคู่อุปกรณ์หลักกับอุปกรณ์รอง
| พารามิเตอร์ |
primary |
ITestDevice: อุปกรณ์ที่จะจับคู่ |
secondary |
ITestDevice: อุปกรณ์ที่จะจับคู่ |
| การคืนสินค้า |
boolean |
จริง หากจับคู่สำเร็จ |
setBtConnectionTimeout
public void setBtConnectionTimeout (Duration timeout)
| พารามิเตอร์ |
timeout |
Duration |
setBtPairTimeout
public void setBtPairTimeout (Duration timeout)
| พารามิเตอร์ |
timeout |
Duration |
setProfilePriority
public boolean setProfilePriority (ITestDevice primary,
ITestDevice secondary,
Set<Sl4aBluetoothUtil.BluetoothProfile> profiles,
Sl4aBluetoothUtil.BluetoothPriorityLevel priority)
เปลี่ยนการตั้งค่าลำดับความสำคัญของโปรไฟล์ที่ระบุในอุปกรณ์หลักไปยังอุปกรณ์รอง
| พารามิเตอร์ |
primary |
ITestDevice: อุปกรณ์ที่จะกำหนดลำดับความสำคัญ |
secondary |
ITestDevice: อุปกรณ์ที่จะกำหนดลำดับความสำคัญ |
profiles |
Set: โปรไฟล์บลูทูธเพื่อเปลี่ยนการตั้งค่าลำดับความสำคัญ |
priority |
Sl4aBluetoothUtil.BluetoothPriorityLevel: ระดับความสำคัญ |
| การคืนสินค้า |
boolean |
จริง หากตั้งค่าลำดับความสำคัญสำเร็จ |
startSl4a
public void startSl4a (ITestDevice device,
File sl4aApkFile)
เริ่มไคลเอ็นต์ SL4A อย่างชัดเจนด้วยอุปกรณ์และไฟล์ APK ของ SL4A ที่ระบุ โดยปกติแล้วไม่จำเป็นต้องใช้วิธีนี้ เนื่องจากระบบจะสร้างการเชื่อมต่อ SL4A เสมอก่อนที่จะดำเนินการจริง
| พารามิเตอร์ |
device |
ITestDevice: อุปกรณ์ที่จะเชื่อมต่อโดยใช้ SL4A |
sl4aApkFile |
File: APK ของ SL4A ที่ไม่บังคับเพื่อติดตั้งและใช้งาน |
stopSl4a
public void stopSl4a ()
หยุดไคลเอ็นต์ SL4A ที่เปิดอยู่แล้ว โดยพื้นฐานแล้วจะช่วยให้คุณล้างข้อมูลไคลเอ็นต์ได้ทันทีหลังจากที่ไม่ได้ใช้งานแล้ว
unpairAll
public boolean unpairAll (ITestDevice device)
เลิกจับคู่อุปกรณ์ที่จับคู่ทั้งหมดสำหรับอุปกรณ์ปัจจุบัน
| พารามิเตอร์ |
device |
ITestDevice: อุปกรณ์ปัจจุบันที่จะดำเนินการ |
| การคืนสินค้า |
boolean |
true หากยกเลิกการจับคู่สำเร็จ |
วิธีการที่ได้รับการป้องกัน
สรุป
protected void finalize ()
ล้างการเชื่อมต่อ SL4A ทั้งหมด
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2026-06-22 UTC
[[["เข้าใจง่าย","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"]],["อัปเดตล่าสุด 2026-06-22 UTC"],[],[]]