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.
Tài liệu tham khảo về cấu trúc light_state_t
#include <
lights.h
>
Các tham số có thể được đặt cho một nguồn sáng nhất định.
Không phải đèn nào cũng phải hỗ trợ tất cả các tham số. Nếu có thể, bạn nên làm những việc có khả năng tương thích ngược.
Định nghĩa tại dòng
145
của tệp
lights.h
.
Chính sách mà khung sử dụng để quản lý độ sáng của đèn. Hiện tại, các giá trị là BRIGHTNESS_MODE_USER và BRIGHTNESS_MODE_SENSOR.
Định nghĩa tại dòng
173
của tệp
lights.h
.
Màu của đèn LED ở định dạng ARGB.
Hãy cố gắng hết sức.
-
Nếu đèn của bạn chỉ có thể chuyển sang màu đỏ hoặc xanh lục, thì nếu người dùng yêu cầu màu xanh dương, bạn nên chuyển sang màu xanh lục.
-
Nếu bạn chỉ có thể làm dải độ sáng, hãy sử dụng công thức này: unsigned char brightness = ((77*((color>>16)&0x00ff))
-
(150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;
-
Nếu bạn chỉ có thể bật hoặc tắt, thì 0 là tắt, mọi giá trị khác là bật.
Bỏ qua byte cao. Phương thức gọi sẽ đặt giá trị này thành 0xff (tương ứng với 255 alpha).
Định nghĩa tại dòng
160
của tệp
lights.h
.
Xem các hằng số LIGHT_FLASH_*
Định nghĩa tại dòng
165
của tệp
lights.h
.
Tài liệu cho cấu trúc này được tạo từ tệp sau:
-
hardware/libhardware/include/hardware/
lights.h
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,["# Android Hardware Abstraction Layer: light_state_t Struct Reference\n\nlight_state_t Struct Reference\n==============================\n\n[Data Fields](#pub-attribs) \nlight_state_t Struct Reference \n\n`\n#include \u003c\n`[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)`\n\u003e\n`\n\n|--------------|------------------------------------------------------------------------------------------|\n| Data Fields ----------- ||\n| unsigned int | [color](/reference/hal/structlight__state__t#aeedc2afa1e522527db2235d0700a3b0d) |\n| ||\n| int | [flashMode](/reference/hal/structlight__state__t#a1376dc4ef9189c6481681f82162911d5) |\n| ||\n| int | [flashOnMS](/reference/hal/structlight__state__t#a11119999eaf9274b752598740c137eee) |\n| ||\n| int | [flashOffMS](/reference/hal/structlight__state__t#a2a43b5608c96a4ce53d78e11cd718cf3) |\n| ||\n| int | [brightnessMode](/reference/hal/structlight__state__t#a29e93d1b3731de25515a118d9818517f) |\n| ||\n\n\nDetailed Description\n--------------------\n\n\nThe parameters that can be set for a given light.\n\n\nNot all lights must support all parameters. If you can do something backward-compatible, you should.\n\n\nDefinition at line\n[145](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\nField Documentation\n-------------------\n\n\n|--------------------|\n| int brightnessMode |\n\n\nPolicy used by the framework to manage the light's brightness. Currently the values are BRIGHTNESS_MODE_USER and BRIGHTNESS_MODE_SENSOR.\n\n\nDefinition at line\n[173](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\n|--------------------|\n| unsigned int color |\n\n\nThe color of the LED in ARGB.\n\n\nDo your best here.\n\n- If your light can only do red or green, if they ask for blue, you should do green.\n- If you can only do a brightness ramp, then use this formula: unsigned char brightness = ((77\\*((color\\\u003e\\\u003e16)\\&0x00ff))\n - (150\\*((color\\\u003e\\\u003e8)\\&0x00ff)) + (29\\*(color\\&0x00ff))) \\\u003e\\\u003e 8;\n- If you can only do on or off, 0 is off, anything else is on.\n\n\nThe high byte should be ignored. Callers will set it to 0xff (which would correspond to 255 alpha).\n\n\nDefinition at line\n[160](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\n|---------------|\n| int flashMode |\n\n\nSee the LIGHT_FLASH_\\* constants\n\n\nDefinition at line\n[165](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\n|----------------|\n| int flashOffMS |\n\n\nDefinition at line\n[167](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\n|---------------|\n| int flashOnMS |\n\n\nDefinition at line\n[166](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\n*** ** * ** ***\n\nThe documentation for this struct was generated from the following file:\n\n- hardware/libhardware/include/hardware/ [lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)"]]