From 690071580e85ee2cbe78f29fb895560273d9b5b9 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Sat, 13 Sep 2025 16:54:17 +0200 Subject: [PATCH] Introduce vendor.oplus.hardware.urcc-service Change-Id: I7fe1a4e9b590d077f43bbaac03e483724d3198e0 --- aidl/urcc/Android.bp | 21 ++++ aidl/urcc/Urcc.cpp | 115 ++++++++++++++++++ aidl/urcc/Urcc.h | 49 ++++++++ aidl/urcc/service.cpp | 24 ++++ .../vendor.oplus.hardware.urcc-service.rc | 4 + .../vendor.oplus.hardware.urcc-service.xml | 7 ++ sepolicy/qti/vendor/file_contexts | 1 + 7 files changed, 221 insertions(+) create mode 100644 aidl/urcc/Android.bp create mode 100644 aidl/urcc/Urcc.cpp create mode 100644 aidl/urcc/Urcc.h create mode 100644 aidl/urcc/service.cpp create mode 100644 aidl/urcc/vendor.oplus.hardware.urcc-service.rc create mode 100644 aidl/urcc/vendor.oplus.hardware.urcc-service.xml diff --git a/aidl/urcc/Android.bp b/aidl/urcc/Android.bp new file mode 100644 index 0000000..a34fb19 --- /dev/null +++ b/aidl/urcc/Android.bp @@ -0,0 +1,21 @@ +// +// SPDX-FileCopyrightText: 2025 The LineageOS Project +// SPDX-License-Identifier: Apache-2.0 +// + +cc_binary { + name: "vendor.oplus.hardware.urcc-service", + vendor: true, + relative_install_path: "hw", + init_rc: ["vendor.oplus.hardware.urcc-service.rc"], + vintf_fragments: ["vendor.oplus.hardware.urcc-service.xml"], + srcs: [ + "Urcc.cpp", + "service.cpp", + ], + shared_libs: [ + "libbase", + "libbinder_ndk", + "vendor.oplus.hardware.urcc-V1-ndk", + ], +} diff --git a/aidl/urcc/Urcc.cpp b/aidl/urcc/Urcc.cpp new file mode 100644 index 0000000..b743197 --- /dev/null +++ b/aidl/urcc/Urcc.cpp @@ -0,0 +1,115 @@ +/* + * SPDX-FileCopyrightText: 2025 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "Urcc.h" + +#include + +#define LOG_TAG "vendor.oplus.hardware.urcc-service" + +namespace aidl { +namespace vendor { +namespace oplus { +namespace hardware { +namespace urcc { + +ndk::ScopedAStatus Urcc::urccInit() { + LOG(INFO) << __func__; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::urccResCtlRequest(const UrccRequestParcel& mUrccRequestParcel, + int32_t* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::urccResCtlRelease(int32_t mhandle, int32_t* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::urccResStateRequest(const UrccRequestParcel& mUrccRequestParcel, + std::vector* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = {}; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::urccResListeningRegister( + const UrccRequestParcel& mUrccRequestParcel, + const std::shared_ptr& urccCallback, int32_t* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::urccResListeningUnRegister(int32_t mhandle, int32_t* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::urccPropertyGet(const std::string& name, std::string* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = ""; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::urccPropertySet(const std::string& name, const std::string& value, + int32_t* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::urccThermalListeningRegister( + const std::vector& types, const std::shared_ptr& urccCallback, + int32_t* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::urccThermalListeningUnRegister(int32_t mhandle, int32_t* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::uahNotifyExt(int32_t src, int32_t type, const std::vector& args, + int32_t* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::setRelatedSysInfo(int32_t cmd, const std::vector& info, + int32_t* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::urccRuleCtl(int32_t ruleId, int32_t status, + const std::vector& ruleData, + int32_t* _aidl_return) { + LOG(INFO) << __func__; + *_aidl_return = 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Urcc::uahResCtlRequestBypass(const UrccRequestParcel& mRequestParcel) { + LOG(INFO) << __func__; + return ndk::ScopedAStatus::ok(); +} + +} // namespace urcc +} // namespace hardware +} // namespace oplus +} // namespace vendor +} // namespace aidl diff --git a/aidl/urcc/Urcc.h b/aidl/urcc/Urcc.h new file mode 100644 index 0000000..03d591a --- /dev/null +++ b/aidl/urcc/Urcc.h @@ -0,0 +1,49 @@ +/* + * SPDX-FileCopyrightText: 2025 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include + +namespace aidl { +namespace vendor { +namespace oplus { +namespace hardware { +namespace urcc { + +class Urcc : public BnUrcc { + ndk::ScopedAStatus urccInit() override; + ndk::ScopedAStatus urccResCtlRequest(const UrccRequestParcel& mUrccRequestParcel, + int32_t* _aidl_return) override; + ndk::ScopedAStatus urccResCtlRelease(int32_t mhandle, int32_t* _aidl_return) override; + ndk::ScopedAStatus urccResStateRequest(const UrccRequestParcel& mUrccRequestParcel, + std::vector* _aidl_return) override; + ndk::ScopedAStatus urccResListeningRegister(const UrccRequestParcel& mUrccRequestParcel, + const std::shared_ptr& urccCallback, + int32_t* _aidl_return) override; + ndk::ScopedAStatus urccResListeningUnRegister(int32_t mhandle, int32_t* _aidl_return) override; + ndk::ScopedAStatus urccPropertyGet(const std::string& name, std::string* _aidl_return) override; + ndk::ScopedAStatus urccPropertySet(const std::string& name, const std::string& value, + int32_t* _aidl_return) override; + ndk::ScopedAStatus urccThermalListeningRegister( + const std::vector& types, const std::shared_ptr& urccCallback, + int32_t* _aidl_return) override; + ndk::ScopedAStatus urccThermalListeningUnRegister(int32_t mhandle, + int32_t* _aidl_return) override; + ndk::ScopedAStatus uahNotifyExt(int32_t src, int32_t type, const std::vector& args, + int32_t* _aidl_return) override; + ndk::ScopedAStatus setRelatedSysInfo(int32_t cmd, const std::vector& info, + int32_t* _aidl_return) override; + ndk::ScopedAStatus urccRuleCtl(int32_t ruleId, int32_t status, + const std::vector& ruleData, + int32_t* _aidl_return) override; + ndk::ScopedAStatus uahResCtlRequestBypass(const UrccRequestParcel& mRequestParcel) override; +}; + +} // namespace urcc +} // namespace hardware +} // namespace oplus +} // namespace vendor +} // namespace aidl diff --git a/aidl/urcc/service.cpp b/aidl/urcc/service.cpp new file mode 100644 index 0000000..375c744 --- /dev/null +++ b/aidl/urcc/service.cpp @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: 2025 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "Urcc.h" + +#include +#include +#include + +using ::aidl::vendor::oplus::hardware::urcc::Urcc; + +int main() { + ABinderProcess_setThreadPoolMaxThreadCount(0); + std::shared_ptr urcc = ndk::SharedRefBase::make(); + + const std::string instance = std::string() + Urcc::descriptor + "/default"; + binder_status_t status = AServiceManager_addService(urcc->asBinder().get(), instance.c_str()); + CHECK_EQ(status, STATUS_OK); + + ABinderProcess_joinThreadPool(); + return EXIT_FAILURE; // should not reach +} diff --git a/aidl/urcc/vendor.oplus.hardware.urcc-service.rc b/aidl/urcc/vendor.oplus.hardware.urcc-service.rc new file mode 100644 index 0000000..eea9be2 --- /dev/null +++ b/aidl/urcc/vendor.oplus.hardware.urcc-service.rc @@ -0,0 +1,4 @@ +service oplus.urcc.hal.service /vendor/bin/hw/vendor.oplus.hardware.urcc-service + class hal + user system + group system diff --git a/aidl/urcc/vendor.oplus.hardware.urcc-service.xml b/aidl/urcc/vendor.oplus.hardware.urcc-service.xml new file mode 100644 index 0000000..3ba0bf4 --- /dev/null +++ b/aidl/urcc/vendor.oplus.hardware.urcc-service.xml @@ -0,0 +1,7 @@ + + + vendor.oplus.hardware.urcc + 1 + IUrcc/default + + diff --git a/sepolicy/qti/vendor/file_contexts b/sepolicy/qti/vendor/file_contexts index 2d40251..46f5c51 100644 --- a/sepolicy/qti/vendor/file_contexts +++ b/sepolicy/qti/vendor/file_contexts @@ -188,6 +188,7 @@ # URCC /(odm|vendor/odm)/bin/hw/vendor\.oplus\.hardware\.urcc-service u:object_r:hal_oplus_urcc_aidl_exec:s0 +/vendor/bin/hw/vendor\.oplus\.hardware\.urcc-service u:object_r:hal_oplus_urcc_aidl_exec:s0 # Vibrator /dev/awinic_haptic u:object_r:aac_richtap_device:s0