diff --git a/led/Android.bp b/led/Android.bp new file mode 100644 index 0000000..6e15ac5 --- /dev/null +++ b/led/Android.bp @@ -0,0 +1,18 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_binary { + name: "dump_led", + srcs: ["dump_led.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libdump", + ], + vendor: true, + relative_install_path: "dump", +} diff --git a/led/dump_led.cpp b/led/dump_led.cpp new file mode 100644 index 0000000..7ce4846 --- /dev/null +++ b/led/dump_led.cpp @@ -0,0 +1,24 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +int main() { + dumpFileContent("Green LED Brightness", "/sys/class/leds/green/brightness"); + dumpFileContent("Green LED Max Brightness", "/sys/class/leds/green/max_brightness"); + dumpFileContent("LED Calibration Data", "/mnt/vendor/persist/led/led_calibration_LUT.txt"); + return 0; +} diff --git a/led/led.mk b/led/led.mk new file mode 100644 index 0000000..81d0f33 --- /dev/null +++ b/led/led.mk @@ -0,0 +1,3 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/led/sepolicy + +PRODUCT_PACKAGES_DEBUG += dump_led diff --git a/led/sepolicy/dump_led.te b/led/sepolicy/dump_led.te new file mode 100644 index 0000000..b1ba1ef --- /dev/null +++ b/led/sepolicy/dump_led.te @@ -0,0 +1,9 @@ +pixel_bugreport(dump_led) + +allow dump_led mnt_vendor_file:dir search; +allow dump_led persist_file:dir search; +allow dump_led persist_leds_file:dir search; +allow dump_led persist_leds_file:file r_file_perms; +allow dump_led sysfs_leds:dir search; +allow dump_led sysfs_leds:file r_file_perms; + diff --git a/led/sepolicy/file.te b/led/sepolicy/file.te new file mode 100644 index 0000000..7fda883 --- /dev/null +++ b/led/sepolicy/file.te @@ -0,0 +1,2 @@ +type persist_leds_file, file_type, vendor_persist_type; + diff --git a/led/sepolicy/file_contexts b/led/sepolicy/file_contexts new file mode 100644 index 0000000..1b006cf --- /dev/null +++ b/led/sepolicy/file_contexts @@ -0,0 +1,4 @@ +/vendor/bin/dump/dump_led u:object_r:dump_led_exec:s0 + +/mnt/vendor/persist/led(/.*)? u:object_r:persist_leds_file:s0 +