From e288798b65f42b97b248dbc04780cfb4878e9f27 Mon Sep 17 00:00:00 2001 From: Konsta Date: Sat, 15 Mar 2025 00:01:58 +0200 Subject: [PATCH] light: convert to apex --- device.mk | 2 +- light/Android.bp | 34 +++++++++++++++++++-- light/android.hardware.light-service.rpi.rc | 2 +- light/apex_file_contexts | 3 ++ light/apex_manifest.json | 4 +++ light/main.cpp | 5 +-- sepolicy/file_contexts | 1 - 7 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 light/apex_file_contexts create mode 100644 light/apex_manifest.json diff --git a/device.mk b/device.mk index 425198e..d00fe98 100644 --- a/device.mk +++ b/device.mk @@ -217,7 +217,7 @@ PRODUCT_COPY_FILES += \ # Lights PRODUCT_PACKAGES += \ - android.hardware.light-service.rpi + com.android.hardware.light.rpi4 # Media PRODUCT_COPY_FILES += \ diff --git a/light/Android.bp b/light/Android.bp index ef7087c..d79ae27 100644 --- a/light/Android.bp +++ b/light/Android.bp @@ -7,15 +7,43 @@ cc_binary { name: "android.hardware.light-service.rpi", relative_install_path: "hw", vendor: true, - init_rc: ["android.hardware.light-service.rpi.rc"], - vintf_fragments: ["android.hardware.light-service.rpi.xml"], srcs: [ "Lights.cpp", "main.cpp", ], shared_libs: [ + "android.hardware.light-V2-ndk", "libbase", "libbinder_ndk", - "android.hardware.light-V2-ndk", + ], + installable: false, +} + +prebuilt_etc { + name: "android.hardware.light-service.rpi.rc", + src: "android.hardware.light-service.rpi.rc", + installable: false, +} + +prebuilt_etc { + name: "android.hardware.light-service.rpi.xml", + src: "android.hardware.light-service.rpi.xml", + sub_dir: "vintf", + installable: false, +} + +apex { + name: "com.android.hardware.light.rpi4", + manifest: "apex_manifest.json", + file_contexts: "apex_file_contexts", + key: "com.android.hardware.key", + certificate: ":com.android.hardware.certificate", + updatable: false, + vendor: true, + + binaries: ["android.hardware.light-service.rpi"], + prebuilts: [ + "android.hardware.light-service.rpi.rc", + "android.hardware.light-service.rpi.xml", ], } diff --git a/light/android.hardware.light-service.rpi.rc b/light/android.hardware.light-service.rpi.rc index 427d0ea..372d7d7 100644 --- a/light/android.hardware.light-service.rpi.rc +++ b/light/android.hardware.light-service.rpi.rc @@ -4,7 +4,7 @@ on early-boot chmod 660 /sys/class/backlight/11-0045/brightness chmod 440 /sys/class/backlight/11-0045/max_brightness -service vendor.light-default /vendor/bin/hw/android.hardware.light-service.rpi +service vendor.light-rpi /apex/com.android.hardware.light.rpi4/bin/hw/android.hardware.light-service.rpi class hal user system group system diff --git a/light/apex_file_contexts b/light/apex_file_contexts new file mode 100644 index 0000000..d343946 --- /dev/null +++ b/light/apex_file_contexts @@ -0,0 +1,3 @@ +(/.*)? u:object_r:vendor_file:s0 +/etc(/.*)? u:object_r:vendor_configs_file:s0 +/bin/hw/android\.hardware\.light-service\.rpi u:object_r:hal_light_default_exec:s0 diff --git a/light/apex_manifest.json b/light/apex_manifest.json new file mode 100644 index 0000000..8293c44 --- /dev/null +++ b/light/apex_manifest.json @@ -0,0 +1,4 @@ +{ + "name": "com.android.hardware.light.rpi4", + "version": 1 +} diff --git a/light/main.cpp b/light/main.cpp index a860bf4..d4ed632 100644 --- a/light/main.cpp +++ b/light/main.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2020 The Android Open Source Project + * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2025 KonstaKANG * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,5 +32,5 @@ int main() { CHECK(status == STATUS_OK); ABinderProcess_joinThreadPool(); - return EXIT_FAILURE; // should not reached + return EXIT_FAILURE; // should not reach } diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts index b308b89..be7b007 100644 --- a/sepolicy/file_contexts +++ b/sepolicy/file_contexts @@ -31,7 +31,6 @@ # Lights /sys/class/backlight/11-0045/brightness u:object_r:sysfs_leds:s0 /sys/class/backlight/11-0045/max_brightness u:object_r:sysfs_leds:s0 -/vendor/bin/hw/android\.hardware\.light-service\.rpi u:object_r:hal_light_default_exec:s0 # Partitions /dev/block/mmcblk0p1 u:object_r:boot_block_device:s0