ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
บลูทูธ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Android มีสแต็กบลูทูธเริ่มต้นที่รองรับทั้งบลูทูธคลาสสิกและบลูทูธพลังงานต่ำ (BLE) อุปกรณ์ Android ใช้บลูทูธเพื่อสร้างเครือข่ายส่วนบุคคลเพื่อส่ง
และรับข้อมูลกับอุปกรณ์บลูทูธที่อยู่ใกล้เคียง
ใน Android 4.3 ขึ้นไป สแต็กบลูทูธของ Android จะช่วยให้สามารถใช้ BLE ได้
หากต้องการใช้ BLE API อย่างเต็มรูปแบบ ให้ทำตาม
ข้อกำหนด HCI ของบลูทูธใน Android อุปกรณ์ Android ที่มีชิปเซ็ตที่ผ่านการรับรองสามารถใช้บลูทูธแบบคลาสสิกหรือทั้งบลูทูธแบบคลาสสิกและ BLE
ได้ BLE ไม่สามารถใช้งานร่วมกับชิปเซ็ตบลูทูธรุ่นเก่าได้
ใน Android 8.0 สแต็กบลูทูธมีคุณสมบัติครบถ้วนสำหรับบลูทูธ 5 หากต้องการใช้ฟีเจอร์บลูทูธ 5 ที่มี
อุปกรณ์ต้องมีชิปเซ็ตที่ผ่านการรับรองบลูทูธ 5
สถาปัตยกรรม Android
แอปบลูทูธจะสื่อสารกับกระบวนการบลูทูธผ่าน Binder กระบวนการบลูทูธ
ใช้ Java Native Interface (JNI) เพื่อสื่อสารกับสแต็กบลูทูธและให้
นักพัฒนาแอปเข้าถึงโปรไฟล์บลูทูธต่างๆ แผนภาพนี้แสดงโครงสร้างทั่วไปของสแต็กบลูทูธ

รูปที่ 1 สถาปัตยกรรมบลูทูธของ Android
- เฟรมเวิร์กแอป
-
ที่ระดับเฟรมเวิร์กของแอปคือโค้ดของแอป ซึ่งใช้
android.bluetooth
API เพื่อโต้ตอบกับฮาร์ดแวร์บลูทูธ ภายใน โค้ดนี้จะเรียกใช้กระบวนการ Bluetooth
ผ่านกลไก Binder IPC
- แอปบลูทูธ
-
แอปบลูทูธซึ่งอยู่ใน
packages/modules/Bluetooth/android/app
จะได้รับการแพ็กเกจเป็นแอป Android และใช้โปรไฟล์บลูทูธที่เลเยอร์เฟรมเวิร์ก Android
แอปนี้จะเรียกใช้สแต็กบลูทูธผ่าน JNI
- JNI
-
โค้ด JNI ที่เชื่อมโยงกับ
android.bluetooth
อยู่ใน
packages/modules/Bluetooth/android/app/jni
โค้ด JNI จะเรียกใช้สแต็กบลูทูธเมื่อมีการดำเนินการบลูทูธบางอย่าง เช่น เมื่อมีการค้นพบอุปกรณ์
- สแต็กบลูทูธ
-
สแต็ก Bluetooth เริ่มต้นมีอยู่ใน AOSP และอยู่ใน
packages/modules/Bluetooth/system
สแต็กจะใช้ HAL บลูทูธทั่วไป
และปรับแต่งด้วยส่วนขยายและการเปลี่ยนแปลงการกำหนดค่า
- การติดตั้งใช้งานของผู้ให้บริการ
-
อุปกรณ์ของผู้ให้บริการจะโต้ตอบกับสแต็กบลูทูธโดยใช้คำจำกัดความของอินเทอร์เฟซ HAL (HIDL)
HIDL
HIDL กำหนดอินเทอร์เฟซระหว่าง
สแต็ก Bluetooth กับการติดตั้งของผู้ให้บริการ หากต้องการสร้างไฟล์ HIDL ของบลูทูธ ให้ส่ง
ไฟล์อินเทอร์เฟซบลูทูธไปยังเครื่องมือสร้าง HIDL ไฟล์อินเทอร์เฟซจะอยู่ใน
hardware/interfaces/bluetooth
การพัฒนาสแต็กบลูทูธ
สแต็กบลูทูธของ Android เป็นสแต็กบลูทูธที่สมบูรณ์ในตัวเอง รายการการรับรองจะอยู่ใน
เว็บไซต์ของ Bluetooth SIG (ต้องลงชื่อเข้าใช้) ในส่วน
QDID 169365
สแต็กบลูทูธหลักอยู่ใน
packages/modules/Bluetooth
การพัฒนาเกิดขึ้นใน AOSP และเรายินดีรับการมีส่วนร่วม
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-22 UTC
[null,null,["อัปเดตล่าสุด 2025-08-22 UTC"],[],[],null,["Android provides a default Bluetooth stack that supports both Classic\nBluetooth and Bluetooth Low Energy (BLE). Using Bluetooth, Android devices\ncan create personal area networks to send and receive data with nearby\nBluetooth devices.\n\nIn Android 4.3 and higher, the Android Bluetooth stack provides the ability\nto implement BLE. To fully use the BLE APIs, follow the\n[Android Bluetooth HCI Requirements](/docs/core/connect/bluetooth/hci_requirements).\nAndroid devices with a qualified chipset can implement either Classic\nBluetooth or both Classic Bluetooth and BLE. BLE isn't backward compatible\nwith older Bluetooth chipsets.\n\nIn Android 8.0, the Bluetooth stack is fully qualified for Bluetooth 5. To\nuse available Bluetooth 5 features, the device needs to have a Bluetooth 5\nqualified chipset.\n\nAndroid architecture\n\nA Bluetooth app communicates with the Bluetooth process through Binder. The\nBluetooth process uses Java Native Interface (JNI) to communicate with the\nBluetooth stack and provides developers with access to various Bluetooth\nprofiles. This diagram shows the general structure of the Bluetooth stack:\n\n**Figure 1.** Android Bluetooth architecture.\n\napp framework\n: At the app framework level is app code, which uses the\n [`android.bluetooth`](http://developer.android.com/reference/android/bluetooth/package-summary)\n APIs to interact with the Bluetooth hardware. Internally, this code calls\n the Bluetooth process through the Binder IPC mechanism.\n\nBluetooth app\n: The Bluetooth app, located in `packages/modules/Bluetooth/android/app`,\n is packaged as an Android app and implements the Bluetooth profiles at the\n Android framework layer. This app calls into the Bluetooth stack through\n JNI.\n\nJNI\n: The JNI code associated with `android.bluetooth` is located in\n `packages/modules/Bluetooth/android/app/jni`. The JNI code calls into the\n Bluetooth stack when certain Bluetooth operations occur, such as when\n devices are discovered.\n\nBluetooth stack\n: The default Bluetooth stack is provided in AOSP and is located in\n `packages/modules/Bluetooth/system`. The stack implements the generic\n Bluetooth HAL and customizes it with extensions and configuration changes.\n\nvendor implementation\n: Vendor devices interact with the Bluetooth stack using the HAL interface\n definition language (HIDL).\n\nHIDL\n\n[HIDL](/docs/core/architecture/hidl) defines the interface between the\nBluetooth stack and the vendor implementation. To generate the Bluetooth\nHIDL files, pass the Bluetooth interface files into the HIDL generation\ntool. The interface files are located in\n[`hardware/interfaces/bluetooth`](https://android.googlesource.com/platform/hardware/interfaces/+/android16-release/bluetooth/).\n\nBluetooth stack development\n\nThe Android Bluetooth stack is a fully qualified Bluetooth stack. The\nqualification listing is on the Bluetooth SIG website (requires sign-in)\nunder [QDID 169365](https://launchstudio.bluetooth.com/ListingDetails/130825).\n\nThe core Bluetooth stack resides in\n[`packages/modules/Bluetooth`](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/modules/Bluetooth/).\nDevelopment happens in AOSP, and contributions are welcome."]]