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.
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.
Lớp trừu tượng phần cứng (HAL) là loại lớp trừu tượng có giao diện tiêu chuẩn để nhà cung cấp phần cứng triển khai. HAL cho phép nhà cung cấp phần cứng triển khai các tính năng cấp thấp, dành riêng cho thiết bị mà không ảnh hưởng hoặc sửa đổi mã trong các lớp cấp cao hơn.
Các điều khoản bắt buộc
Sau đây là danh sách định nghĩa cho các thuật ngữ được sử dụng trong phần tài liệu này:
Ngôn ngữ định nghĩa giao diện Android (AIDL)
Một ngôn ngữ giống Java dùng để xác định giao diện theo cách độc lập với ngôn ngữ lập trình đang được sử dụng. AIDL cho phép giao tiếp giữa ứng dụng HAL và dịch vụ HAL.
HAL liên kết
HAL giao tiếp với các quy trình khác bằng các lệnh gọi giao tiếp liên quy trình (IPC) của liên kết. HAL được liên kết chạy trong một quy trình riêng biệt với ứng dụng sử dụng các HAL đó.
Các HAL được liên kết được đăng ký với trình quản lý dịch vụ để ứng dụng có thể truy cập vào các chức năng của HAL. Các HAL được viết cho Android 8 trở lên được liên kết.
Ứng dụng HAL
Quy trình truy cập vào dịch vụ HAL.
Giao diện HAL
Giao diện chung mà cả ứng dụng và dịch vụ HAL đều dùng để giao tiếp.
Dịch vụ HAL
Mã dành riêng cho phần cứng, chẳng hạn như mã giao tiếp với máy ảnh của thiết bị cụ thể. Bạn phải triển khai tất cả HAL bắt buộc được liệt kê trong ma trận tương thích cho bản phát hành mà bạn nhắm đến trong phân vùng nhà cung cấp.
Để biết thêm thông tin về ma trận tương thích, hãy xem bài viết Ma trận tương thích.
Bạn cũng có thể tạo giao diện HAL mới hoặc mở rộng giao diện của HAL để hỗ trợ các chức năng riêng biệt của phần cứng.
Ngôn ngữ định nghĩa giao diện phần cứng (HIDL)
Ngôn ngữ dùng để xác định giao diện theo cách độc lập với ngôn ngữ lập trình đang được sử dụng. HIDL cho phép giao tiếp giữa ứng dụng HAL và dịch vụ HAL.
HAL quy trình giống nhau (SP)
Một tập hợp HAL được gói bị hạn chế. Quyền thành viên trong nhóm này do Google kiểm soát. Các HAL SP bao gồm:
HAL trình ánh xạ C 5 ổn định
OpenGL
Vulkan
android.hidl.memory@1.0 (do hệ thống Android cung cấp, luôn được gói)
android.hardware.renderscript@1.0
HAL được gói
Dịch vụ HAL được tạo trước Android 8, nhưng đã được gói trong trình bao bọc AIDL hoặc HIDL để hoạt động với Android 8 trở lên.
Tiếp theo là gì?
Để tìm hiểu cách triển khai dịch vụ HAL, hãy tham khảo phần AIDL cho HAL.
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-07-27 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-07-27 UTC."],[],[],null,["# Hardware abstraction layer (HAL) overview\n\nA *hardware abstraction layer (HAL)* is type of abstraction layer with a\nstandard interface for hardware vendors to implement. A HAL allows hardware\nvendors to implement lower-level, device-specific features without affecting or\nmodifying code in higher-level layers.\n| **Note:** HALs existed before Android 8. However, Android 8 ensured each HAL had a standard interface. For an explanation of HAL architecture before Android 8, refer to [Legacy HALs](/docs/core/architecture/hal/archive).\n\nRequired terms\n--------------\n\nFollowing is a list of definitions for terms used in this section of\ndocumentation:\n\n*Android Interface Definition Language (AIDL)*\n: A Java-like language used to define interfaces in a way that is independent of\n the programming language being used. AIDL allows communication between\n HAL clients and HAL services.\n\n*Binderized HAL*\n: A HAL that communicates with other processes\n using\n [binder inter-process communication (IPC)](/docs/core/architecture/hidl/binder-ipc)\n calls. Binderized HALs run in a separate process from the client that uses them.\n Binderized HALs are registered with a service manager so that clients can\n access their capabilities. HALs written for Android 8 and higher are\n binderized.\n\n*HAL client*\n: The process that accesses the HAL service.\n\n*HAL interface*\n: The common interface used by both the HAL client and service to communicate.\n\n*HAL service*\n\n: The hardware-specific code, such as the code that talks to your specific\n device's camera. You must implement all required HALs listed in the\n compatibility matrix for the release you target in your vendor partition.\n For further information on compatibility matrixes, see\n [Compatibility matrixes](/docs/core/architecture/vintf/comp-matrices).\n\n You can also create a new HAL interface, or extend the interface of a HAL, to\n support your hardware's unique capabilities.\n\n*Hardware Interface Definition Language (HIDL)*\n\n: A language used to define interfaces in a way that is independent of the\n programming language being used. HIDL enables communication between\n HAL clients and HAL services.\n\n | **Note:** As of Android 13, HIDL has been deprecated. Instead of HIDL, you should use Android Interface Definition Language (AIDL) for HALs. HALs previously written using [HIDL](/docs/core/architecture/hidl) are supported.\n\n*Same Process (SP) HAL*\n\n: A restricted set of wrapped HALs. Membership in the set is controlled by\n Google. SP HALs include:\n\n - Stable C mapper 5 HAL\n - OpenGL\n - Vulkan\n - android.hidl.memory@1.0 (provided by the Android system, always wrapped)\n - android.hardware.renderscript@1.0\n\n | **Note:** Some HAL implementations wrap legacy interfaces, such as those in `libhardware`, in an AIDL or HIDL wrapper.\n\n*Wrapped HAL*\n\n: A HAL service that was created before Android 8, but has been wrapped in an\n AIDL or HIDL wrapper to work with Android 8 and higher.\n\nWhat's next?\n------------\n\n- To learn how to implement a HAL service, refer to [AIDL for HALs](/docs/core/architecture/aidl/aidl-hals).\n- To learn how to create or extend an existing HAL, refer to [Attached extended interfaces](/docs/core/architecture/aidl/aidl-hals#attached-extensions)."]]