Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Nhận dạng hệ điều hành Android
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
từ khoá: AiAssisted,release16,androidconnectivity,bluetooth,category:AndroidConnectivity,docType:Guide
Kể từ Android 14, khung Android có một dịch vụ Thuộc tính chung (GATT) có tên là dịch vụ thông tin Android (AIS), cho phép các thiết bị Bluetooth đọc cấp độ API Android dưới dạng một đặc điểm GATT của dịch vụ.
Dịch vụ này cho phép nhà sản xuất thiết bị Bluetooth biết liệu một thiết bị ngoại vi Bluetooth có đang ghép nối với một thiết bị trung tâm chạy hệ điều hành Android hay không, đồng thời quản lý logic chuyên biệt dựa trên cấp độ API.
AIS là một dịch vụ GATT tiêu chuẩn và chỉ có thể có một phiên bản AIS trên thiết bị. UUID dịch vụ chính là e73e0001-ef1b-4e74-8291-2e4f3164f3b5
.
Đặc điểm cấp độ API Android (UUID: e73e0002-ef1b-4e74-8291-2e4f3164f3b5
) chứa cấp độ API của thiết bị dưới dạng số nguyên 32 bit không dấu ở dạng nhị phân (little-endian). Giá trị của đặc điểm cấp độ API Android có độ dài là 4 octet (ví dụ: API cấp 36 là 0x24_00_00_00
). Khi thiết bị có thể phát hiện, giá trị đặc điểm cấp độ API Android có thể đọc được mà không cần xác thực hoặc uỷ quyền.
Khi thiết bị không thể phát hiện, đặc điểm cấp độ API Android chỉ có thể đọc được khi có xác thực và uỷ quyền.
Khám phá dịch vụ
Thiết bị Bluetooth ở vai trò máy khách GATT và thiết bị chạy Android ở vai trò máy chủ. Để khám phá AIS và đọc cấp độ API Android, các thiết bị Bluetooth sử dụng các quy trình hồ sơ GATT, chẳng hạn như quy trình khám phá dịch vụ chính, khám phá đặc điểm và đọc giá trị đặc điểm. Để biết thông tin chi tiết về các quy trình này, hãy xem quy cách hồ sơ GATT.
Cấp độ API được xác định bằng thuộc tính hệ thống ro.build.version.sdk
. Nếu không phát hiện được dịch vụ chính, tức là thuộc tính hệ thống chưa được xác định hoặc giá trị được đặt thành trống, hoặc hệ điều hành máy chủ không phải là Android.
Xác nhận kết quả
Để xác minh rằng AIS có thể được phát hiện, hãy chạy một quy trình kiểm thử thủ công bằng cách ghép nối một thiết bị ngoại vi Bluetooth với một thiết bị chạy Android, sau đó tra cứu UUID dịch vụ AIS trong các dịch vụ chính đã phát hiện.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-08-22 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-22 UTC."],[],[],null,["# Android OS identification\n\nkeywords: AiAssisted,release16,androidconnectivity,bluetooth,category:AndroidConnectivity,docType:Guide\n\nStarting in Android 14, the Android framework includes a Generic Attribute\n(GATT) service called Android information service (AIS), which lets Bluetooth\ndevices read the Android API level as a GATT characteristic of the service.\nThis service lets Bluetooth device manufacturers know whether a Bluetooth\nperipheral is pairing with a central device that is running the Android OS,\nand manage specialized logic based on the API level.\n\nAndroid information service (AIS)\n---------------------------------\n\nAIS is a standard GATT service and there can be only one instance of AIS on\na device. The primary service UUID is `e73e0001-ef1b-4e74-8291-2e4f3164f3b5`.\nThe Android API level characteristic (UUID:\n`e73e0002-ef1b-4e74-8291-2e4f3164f3b5`) contains the API level of the device as\nan unsigned 32-bit integer in binary form (little-endian). The value of the\nAndroid API level characteristic is 4 octets in length (for example, API\nlevel 36 is `0x24_00_00_00`). When the device is discoverable, the Android API\nlevel characteristic value is readable without authentication or authorization.\nWhen the device isn't discoverable, the Android API level characteristic is\nreadable only with authentication and authorization.\n\nDiscover the service\n--------------------\n\nThe Bluetooth device is on the GATT client role and the Android-powered device\nis on the server role. To discover AIS and read the Android API level, Bluetooth\ndevices use GATT profile procedures such as the *primary service discovery* ,\n*characteristic discovery* , and *characteristic value read* procedures. For\ndetails on these procedures, see the [GATT profile specification](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host/generic-attribute-profile--gatt-.html).\n\nThe API level is defined by the `ro.build.version.sdk` system property. If the\nprimary service can't be discovered, it means that the system property isn't\ndefined or the value is set to empty, or the host operation system isn't\nAndroid.\n\nValidation\n----------\n\nTo verify that AIS can be discovered, run a manual test by pairing a Bluetooth\nperipheral with an Android-powered device, and then looking up the AIS service\nUUID in the discovered primary services."]]