Android는 기본 블루투스와 저전력 블루투스를 모두 지원하는 기본 블루투스 스택을 제공합니다. Android 기기는 블루투스를 사용하여 주변 블루투스 기기와 데이터를 주고받기 위한 개인 영역 네트워크를 만들 수 있습니다.
Android 4.3 이상에서 Android 블루투스 스택은 저전력 블루투스(BLE)를 구현할 수 있는 기능을 제공합니다. BLE API를 충분히 활용하려면 Android 블루투스 HCI 요구사항을 따르세요. 적합한 칩셋이 있는 Android 기기는 기본 블루투스 또는 기본 블루투스와 BLE를 모두 구현할 수 있습니다. BLE는 이전 블루투스 칩셋과 호환되지 않습니다.
Android 8.0에서 네이티브 블루투스 스택은 블루투스 5의 요건을 모두 충족합니다. 제공되는 블루투스 5 기능을 사용하려면 기기에 블루투스 5용 칩셋이 있어야 합니다.
Android 아키텍처
블루투스 애플리케이션은 바인더를 통해 블루투스 프로세스와 통신합니다. 블루투스 프로세스는 JNI를 사용하여 블루투스 스택과 통신하며 개발자는 블루투스 프로세스를 통해 다양한 블루투스 프로필에 액세스할 수 있습니다. 다음 다이어그램은 블루투스 스택의 일반적인 구조를 보여줍니다.
그림 1. Android 블루투스 아키텍처
애플리케이션 프레임워크
애플리케이션 프레임워크 수준에는 android.bluetooth API를 사용하여 블루투스 하드웨어와 상호작용하는 애플리케이션 코드가 있습니다. 내부적으로 이 코드는 바인더 IPC 메커니즘을 통해 블루투스 프로세스를 호출합니다.
블루투스 애플리케이션
packages/modules/Bluetooth/android/app에 있는 블루투스 애플리케이션은 Android 앱으로 패키징되며 Android 프레임워크 레이어에서 블루투스 프로필을 구현합니다. 이 앱은 JNI를 통해 네이티브 블루투스 스택을 호출합니다.
JNI
android.bluetooth와 연결된 JNI 코드는 packages/modules/Bluetooth/android/app/jni에 있습니다. JNI 코드는 기기가 검색될 때와 같이 특정 블루투스 작업이 발생할 때 블루투스 스택을 호출합니다.
블루투스 스택
기본 블루투스 스택은 AOSP에 제공되며 packages/modules/Bluetooth/system에 있습니다. 스택은 일반 블루투스 HAL을 구현하고 확장 프로그램 및 구성 변경사항을 사용하여 맞춤설정합니다.
공급업체 구현
공급업체 기기는 하드웨어 인터페이스 디자인 언어(HIDL)를 사용하여 블루투스 스택과 상호작용합니다.
HIDL
HIDL은 블루투스 스택과 공급업체 구현 사이의 인터페이스를 정의합니다. 블루투스 HIDL 파일을 생성하려면 블루투스 인터페이스 파일을 HIDL 생성 도구에 전달하세요. 인터페이스 파일은 hardware/interfaces/bluetooth에 있습니다.
블루투스 스택 개발
Android 블루투스 스택은 블루투스 자격 요건을 충족하는 스택입니다. 인증 목록은 블루투스 SIG 웹사이트의 QDID 169365에 있습니다.
블루투스 시스템 서비스는 JNI를 통해 블루투스 스택과 통신하고 바인더 IPC를 통해 애플리케이션과 통신합니다. 시스템 서비스를 통해 개발자는 다양한 블루투스 프로필에 액세스할 수 있습니다. 다음 다이어그램은 블루투스 스택의 일반적인 구조를 보여줍니다.
그림 2. Android 7.x 이하 블루투스 아키텍처
애플리케이션 프레임워크
애플리케이션 프레임워크 수준에는 android.bluetooth API를 활용하여 블루투스 하드웨어와 상호작용하는 애플리케이션 코드가 있습니다. 내부적으로 이 코드는 바인더 IPC 메커니즘을 통해 블루투스 프로세스를 호출합니다.
블루투스 시스템 서비스
packages/apps/Bluetooth에 있는 블루투스 시스템 서비스는 Android 앱으로 패키징되며 Android 프레임워크 레이어에서 블루투스 서비스와 프로필을 구현합니다. 이 앱은 JNI를 통해 HAL 레이어를 호출합니다.
JNI
android.bluetooth와 연결된 JNI 코드는 packages/apps/Bluetooth/jni에 있습니다. JNI 코드는 HAL 레이어를 호출하고 기기가 검색될 때와 같이 특정 블루투스 작업이 발생할 때 HAL에서 콜백을 수신합니다.
HAL
하드웨어 추상화 계층은 android.bluetooth API와 블루투스 프로세스에서 호출하고 블루투스 하드웨어를 올바로 작동하기 위해 구현해야 하는 표준 인터페이스를 정의합니다. 블루투스 HAL의 헤더 파일은 hardware/libhardware/include/hardware/bluetooth.h입니다. 모든 hardware/libhardware/include/hardware/bt_*.h 파일을 검토하세요.
블루투스 스택
기본 블루투스 스택이 제공되며 system/bt에 있습니다.
스택은 일반 블루투스 HAL을 구현하고 확장 프로그램 및 구성 변경사항을 사용하여 맞춤설정합니다.
공급업체 확장 프로그램
추적을 위해 맞춤 확장 프로그램과 HCI 레이어를 추가하려면 libbt-vendor 모듈을 만들고 이러한 구성요소를 지정하세요.
HAL 구현
블루투스 HAL은 /hardware/libhardware/include/hardware/bluetooth.h에 있습니다. bluetooth.h 파일은 블루투스 스택의 기본 인터페이스를 포함하며 블루투스 스택의 기능을 구현해야 합니다.
프로필별 파일은 동일한 디렉터리에 있습니다. 자세한 내용은 HAL 파일 참조를 참고하세요.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2024-04-26(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"]],["최종 업데이트: 2024-04-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."]]