Android には、クラシック Bluetooth と Bluetooth Low Energy の両方をサポートするデフォルトの Bluetooth スタックが用意されています。Bluetooth を使用することで、Android デバイスはパーソナル エリア ネットワークを作成して、付近の Bluetooth デバイスとデータを送受信できます。
Android 4.3 以降では、Android Bluetooth スタックは Bluetooth Low Energy(BLE)を実装するための機能を備えています。BLE API を最大限に活用するには、Android Bluetooth の HCI 要件に従う必要があります。認定チップセットを搭載した Android デバイスでは、クラシック Bluetooth、またはクラシック Bluetooth と BLE の両方を実装できます。BLE には、古い Bluetooth チップセットとの下位互換性がありません。
Android 8.0 では、ネイティブ Bluetooth スタックで Bluetooth 5 に完全に対応しています。Bluetooth 5 で利用できる機能を使用するには、Bluetooth 5 に対応したチップセットをデバイスに搭載する必要があります。
Android のアーキテクチャ
Bluetooth アプリは、Binder を介して Bluetooth プロセスと通信します。Bluetooth プロセスは、JNI を使用して Bluetooth スタックと通信し、デベロッパーが各種の Bluetooth プロファイルにアクセスできるようにします。次の図に、Bluetooth スタックの一般的な構造を示します。
図 1. Android Bluetooth アーキテクチャ
アプリのフレームワーク
アプリのコードはアプリのフレームワークのレベルにあり、android.bluetooth API を使用して Bluetooth ハードウェアを操作します。内部的には、このコードが Binder IPC メカニズムを通じて Bluetooth プロセスを呼び出します。
Bluetooth アプリ
Bluetooth アプリは packages/modules/Bluetooth/android/app に配置されており、Android アプリとしてパッケージ化され、Android フレームワーク レイヤで Bluetooth プロファイルを実装します。このアプリは、JNI 経由でネイティブ Bluetooth スタックを呼び出します。
JNI
android.bluetooth に関連付けられた JNI コードは、packages/modules/Bluetooth/android/app/jni に配置されています。JNI コードは、デバイスが検出されたときなど、特定の Bluetooth オペレーションが発生したときに Bluetooth スタックを呼び出します。
Bluetooth スタック
デフォルトの Bluetooth スタックは AOSP に組み込まれ、packages/modules/Bluetooth/system に配置されています。スタックでは汎用の Bluetooth HAL が実装されており、拡張機能と構成変更によってカスタマイズ可能です。
ベンダー実装
ベンダー デバイスは、ハードウェア インターフェース デザイン言語(HIDL)を使用して Bluetooth スタックを操作します。
Bluetooth システム サービスは JNI 経由で Bluetooth スタックと通信し、Binder IPC を介してアプリと通信します。システム サービスは、デベロッパーが各種の Bluetooth プロファイルにアクセスできるようにします。次の図は、Bluetooth スタックの一般的な構造を示しています。
図 2. Android 7.x 以前の Bluetooth アーキテクチャ
アプリのフレームワーク
アプリのコードはアプリのフレームワークのレベルにあり、android.bluetooth API を使用して Bluetooth ハードウェアを操作します。内部的には、このコードが Binder IPC メカニズムを通じて Bluetooth プロセスを呼び出します。
Bluetooth システム サービス
Bluetooth システム サービスは packages/apps/Bluetooth に配置されており、Android アプリとしてパッケージ化され、Android フレームワーク レイヤで Bluetooth サービスおよびプロファイルを実装します。このアプリは JNI 経由で HAL レイヤを呼び出します。
JNI
android.bluetooth に関連付けられた JNI コードは、packages/apps/Bluetooth/jni に配置されています。JNI コードは、デバイスが検出されるなど特定の Bluetooth オペレーションが発生したときに HAL レイヤを呼び出し、HAL からコールバックを受け取ります。
HAL
Hardware Abstraction Layer では、android.bluetooth API と Bluetooth プロセスが呼び出す標準インターフェースが定義されています。Bluetooth ハードウェアを適切に機能させるには、これを実装する必要があります。Bluetooth HAL のヘッダー ファイルは hardware/libhardware/include/hardware/bluetooth.h です。また、すべての hardware/libhardware/include/hardware/bt_*.h ファイルを確認する必要があります。
Bluetooth スタック
デフォルトの Bluetooth スタックが提供されており、system/bt に配置されています。スタックでは汎用の Bluetooth HAL が実装されており、拡張機能と構成変更によってカスタマイズ可能です。
[[["わかりやすい","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 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."]]