A partire dal 27 marzo 2025, ti consigliamo di utilizzare android-latest-release
anziché aosp-main
per compilare e contribuire ad AOSP. Per ulteriori informazioni, vedi Modifiche ad AOSP.
Bluetooth
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Android fornisce uno stack Bluetooth predefinito che supporta sia Bluetooth Classic che Bluetooth
Low Energy (BLE). Utilizzando il Bluetooth, i dispositivi Android possono creare reti personali per inviare
e ricevere dati con i dispositivi Bluetooth nelle vicinanze.
In Android 4.3 e versioni successive, lo stack Bluetooth Android offre la possibilità di implementare
BLE. Per utilizzare completamente le API BLE, segui i
requisiti HCI Bluetooth di Android. I dispositivi Android con un chipset qualificato possono implementare Bluetooth Classic o sia
Bluetooth Classic che BLE. BLE non è compatibile con le versioni precedenti dei chipset Bluetooth.
In Android 8.0, lo stack Bluetooth è completamente qualificato per Bluetooth 5. Per utilizzare
le funzionalità Bluetooth 5 disponibili, il dispositivo deve disporre di un chipset qualificato Bluetooth 5.
Architettura Android
Un'app Bluetooth comunica con il processo Bluetooth tramite Binder. Il processo
Bluetooth utilizza Java Native Interface (JNI) per comunicare con lo stack Bluetooth e fornisce
agli sviluppatori l'accesso a vari profili Bluetooth. Questo diagramma mostra la struttura generale dello stack Bluetooth:

Figura 1. Architettura Bluetooth di Android.
- framework dell'app
-
A livello di framework dell'app si trova il codice dell'app, che utilizza le
android.bluetooth
API per interagire con l'hardware Bluetooth. Internamente, questo codice chiama il processo
Bluetooth tramite il meccanismo IPC Binder.
- App Bluetooth
-
L'app Bluetooth, che si trova in
packages/modules/Bluetooth/android/app
,
è inclusa come app per Android e implementa i profili Bluetooth a livello di framework Android. Questa app chiama lo stack Bluetooth tramite JNI.
- JNI
-
Il codice JNI associato a
android.bluetooth
si trova in
packages/modules/Bluetooth/android/app/jni
. Il codice JNI chiama lo
stack Bluetooth quando si verificano determinate operazioni Bluetooth, ad esempio quando vengono
rilevati i dispositivi.
- Stack Bluetooth
-
Lo stack Bluetooth predefinito è fornito in AOSP e si trova in
packages/modules/Bluetooth/system
. Lo stack implementa l'HAL Bluetooth generico e lo personalizza con estensioni e modifiche alla configurazione.
- implementazione del fornitore
-
I dispositivi del fornitore interagiscono con lo stack Bluetooth utilizzando il linguaggio di definizione dell'interfaccia HAL (HIDL).
HIDL
HIDL definisce l'interfaccia tra lo
stack Bluetooth e l'implementazione del fornitore. Per generare i file HIDL Bluetooth, passa i file
dell'interfaccia Bluetooth allo strumento di generazione HIDL. I file dell'interfaccia si trovano in
hardware/interfaces/bluetooth
.
Sviluppo dello stack Bluetooth
Lo stack Bluetooth Android è uno stack Bluetooth completamente qualificato. L'elenco delle qualifiche è
disponibile sul sito web di Bluetooth SIG (è necessario accedere) nella sezione
QDID 169365.
Lo stack Bluetooth principale si trova in
packages/modules/Bluetooth
. Lo sviluppo avviene in AOSP e i contributi sono ben accetti.
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-08-22 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-08-22 UTC."],[],[],null,["# Bluetooth\n\nAndroid provides a default Bluetooth stack that supports both Classic Bluetooth and Bluetooth\nLow Energy (BLE). Using Bluetooth, Android devices can create personal area networks to send\nand receive data with nearby Bluetooth devices.\n\n\nIn Android 4.3 and higher, the Android Bluetooth stack provides the ability to implement\nBLE. To fully use the BLE APIs, follow the\n[Android Bluetooth HCI Requirements](/docs/core/connect/bluetooth/hci_requirements). Android devices with a qualified chipset can implement either Classic Bluetooth or both\nClassic Bluetooth and BLE. BLE isn't backward compatible with older Bluetooth chipsets.\n\n\nIn Android 8.0, the Bluetooth stack is fully qualified for Bluetooth 5. To use\navailable Bluetooth 5 features, the device needs to have a Bluetooth 5 qualified chipset.\n\nAndroid architecture\n--------------------\n\n\nA Bluetooth app communicates with the Bluetooth process through Binder. The Bluetooth\nprocess uses Java Native Interface (JNI) to communicate with the Bluetooth stack and provides\ndevelopers with access to various Bluetooth profiles. This diagram shows the general\nstructure of the Bluetooth stack:\n\n**Figure 1.** Android Bluetooth architecture.\n\napp framework\n:\n At the app framework level is app code, which uses the\n [`android.bluetooth`](http://developer.android.com/reference/android/bluetooth/package-summary.html)\n APIs to interact with the Bluetooth hardware. Internally, this code calls the Bluetooth\n process through the Binder IPC mechanism.\n\nBluetooth app\n:\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 Android framework\n layer. This app calls into the Bluetooth stack through JNI.\n\nJNI\n:\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 devices are\n discovered.\n\nBluetooth stack\n:\n The default Bluetooth stack is provided in AOSP and is located in\n `packages/modules/Bluetooth/system`. The stack implements the generic Bluetooth\n HAL and customizes it with extensions and configuration changes.\n\nvendor implementation\n:\n Vendor devices interact with the Bluetooth stack using the HAL interface definition\n language (HIDL).\n\n### HIDL\n\n\n[HIDL](/docs/core/architecture/hidl) defines the interface between the\nBluetooth stack and the vendor implementation. To generate the Bluetooth HIDL files, pass the\nBluetooth interface files into the HIDL generation tool. The interface files are located in\n[`hardware/interfaces/bluetooth`](https://android.googlesource.com/platform/hardware/interfaces/+/android16-release/bluetooth/).\n\n### Bluetooth stack development\n\n\nThe Android Bluetooth stack is a fully qualified Bluetooth stack. The qualification listing is\non the Bluetooth SIG website (requires sign-in) under\n[QDID 169365](https://launchstudio.bluetooth.com/ListingDetails/130825).\n\n\nThe core Bluetooth stack resides in\n[packages/modules/Bluetooth](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/modules/Bluetooth/). Development happens in AOSP, and contributions are welcome."]]