החל מ-27 במרץ 2025, מומלץ להשתמש ב-android-latest-release
במקום ב-aosp-main
כדי ליצור תרומות ל-AOSP. מידע נוסף זמין במאמר שינויים ב-AOSP.
Bluetooth
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Android מספקת מחסנית Bluetooth שמוגדרת כברירת מחדל ותומכת גם ב-Bluetooth קלאסי וגם ב-Bluetooth עם צריכת אנרגיה נמוכה (BLE). באמצעות Bluetooth, מכשירי Android יכולים ליצור רשתות אזור אישיות כדי לשלוח ולקבל נתונים עם מכשירי Bluetooth בקרבת מקום.
ב-Android מגרסה 4.3 ואילך, מחסנית ה-Bluetooth של Android מספקת את היכולת להטמיע BLE. כדי להשתמש במלוא היכולות של ממשקי ה-API של BLE, צריך לפעול לפי הדרישות של Android Bluetooth HCI. מכשירי Android עם ערכת שבבים מתאימה יכולים להטמיע Bluetooth קלאסי או גם Bluetooth קלאסי וגם BLE. BLE לא תואם לאחור לערכות שבבים ישנות יותר של Bluetooth.
ב-Android 8.0, מחסנית ה-Bluetooth עומדת בדרישות של Bluetooth 5. כדי להשתמש בתכונות הזמינות של Bluetooth 5, במכשיר צריך להיות ערכת שבבים שעומדת בדרישות של Bluetooth 5.
ארכיטקטורה ל-Android
אפליקציית Bluetooth מתקשרת עם תהליך ה-Bluetooth באמצעות Binder. תהליך ה-Bluetooth
משתמש ב-Java Native Interface (JNI) כדי לתקשר עם מחסנית ה-Bluetooth, ומספק
למפתחים גישה לפרופילים שונים של Bluetooth. הדיאגרמה הזו מציגה את המבנה הכללי של מחסנית Bluetooth:

איור 1. ארכיטקטורת Bluetooth ב-Android.
- app framework
-
ברמת מסגרת האפליקציה נמצא קוד האפליקציה, שמשתמש בממשקי ה-API
android.bluetooth
כדי ליצור אינטראקציה עם חומרת ה-Bluetooth. באופן פנימי, הקוד הזה מפעיל את תהליך ה-Bluetooth באמצעות מנגנון ה-IPC של Binder.
- אפליקציית Bluetooth
-
אפליקציית ה-Bluetooth, שנמצאת ב-
packages/modules/Bluetooth/android/app
,
מגיעה כחבילה של אפליקציית Android ומיישמת את פרופילי ה-Bluetooth בשכבת מסגרת Android. האפליקציה הזו קוראת למערך Bluetooth דרך JNI.
- JNI
-
קוד ה-JNI שמשויך ל-
android.bluetooth
נמצא ב-packages/modules/Bluetooth/android/app/jni
. קוד ה-JNI קורא למערך Bluetooth כשמתרחשות פעולות מסוימות של Bluetooth, למשל כשמגלים מכשירים.
- Bluetooth stack
-
מקבץ ברירת המחדל של Bluetooth מסופק ב-AOSP וממוקם ב-
packages/modules/Bluetooth/system
. המקבץ מיישם את ה-HAL הגנרי של Bluetooth
ומתאים אותו אישית באמצעות תוספים ושינויים בהגדרות.
- הטמעה של ספק
-
מכשירי ספקים מקיימים אינטראקציה עם מחסנית Bluetooth באמצעות שפת הגדרת ממשק HAL (HIDL).
HIDL
HIDL מגדיר את הממשק בין מחסנית Bluetooth לבין ההטמעה של הספק. כדי ליצור את קובצי ה-Bluetooth HIDL, מעבירים את קובצי ממשק ה-Bluetooth לכלי ליצירת HIDL. קבצי הממשק נמצאים בתיקייה
hardware/interfaces/bluetooth
.
פיתוח של Bluetooth stack
מקבץ הפיצ'רים של Bluetooth ב-Android הוא מקבץ פיצ'רים מלא של Bluetooth. רשימת ההסמכות מופיעה באתר של Bluetooth SIG (נדרשת כניסה) בקטע QDID 169365.
מקבץ הפיצ'רים של Bluetooth נמצא ב-
packages/modules/Bluetooth
. הפיתוח מתבצע ב-AOSP, ואנחנו מקבלים בברכה הצעות לשיפורים.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-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"]],["עדכון אחרון: 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."]]