diff --git a/configs/hidl/manifest.xml b/configs/hidl/manifest.xml index aff833d..3e1e182 100644 --- a/configs/hidl/manifest.xml +++ b/configs/hidl/manifest.xml @@ -431,15 +431,6 @@ @2.1::IGoodixFingerprintDaemon/default - - vendor.lineage.livedisplay - hwbinder - 2.0 - - IPictureAdjustment - default - - vendor.lineage.power hwbinder diff --git a/device.mk b/device.mk index 700d9da..d9d54e4 100644 --- a/device.mk +++ b/device.mk @@ -197,7 +197,8 @@ PRODUCT_PACKAGES += \ # LiveDisplay PRODUCT_PACKAGES += \ - vendor.lineage.livedisplay@2.0-service-sdm + vendor.lineage.livedisplay@2.0-service-sdm \ + vendor.lineage.livedisplay@2.0-service.davinci # Media PRODUCT_PACKAGES += \ diff --git a/livedisplay/Android.bp b/livedisplay/Android.bp new file mode 100644 index 0000000..5f17b0c --- /dev/null +++ b/livedisplay/Android.bp @@ -0,0 +1,35 @@ +// +// Copyright (C) 2019-2020 The LineageOS 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. + +cc_binary { + name: "vendor.lineage.livedisplay@2.0-service.davinci", + defaults: ["hidl_defaults"], + vintf_fragments: ["vendor.lineage.livedisplay@2.0-service.davinci.xml"], + init_rc: ["vendor.lineage.livedisplay@2.0-service.davinci.rc"], + relative_install_path: "hw", + srcs: [ + "SunlightEnhancement.cpp", + "service.cpp", + ], + vendor: true, + shared_libs: [ + "libbase", + "libbinder", + "libhidlbase", + "libhidltransport", + "libutils", + "vendor.lineage.livedisplay@2.0", + ], +} diff --git a/livedisplay/SunlightEnhancement.cpp b/livedisplay/SunlightEnhancement.cpp new file mode 100644 index 0000000..b5583bb --- /dev/null +++ b/livedisplay/SunlightEnhancement.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2019-2020 The LineageOS 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. + */ + +#define LOG_TAG "SunlightEnhancementService" + +#include +#include +#include + +#include "SunlightEnhancement.h" + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace implementation { + +static constexpr const char* kHbmStatusPath = "/sys/devices/platform/soc/soc:qcom,dsi-display/hbm"; + +Return SunlightEnhancement::isEnabled() { + std::string buf; + if (!android::base::ReadFileToString(kHbmStatusPath, &buf)) { + LOG(ERROR) << "Failed to read " << kHbmStatusPath; + return false; + } + return std::stoi(android::base::Trim(buf)) == 1; +} + +Return SunlightEnhancement::setEnabled(bool enabled) { + if (!android::base::WriteStringToFile((enabled ? "1" : "0"), kHbmStatusPath)) { + LOG(ERROR) << "Failed to write " << kHbmStatusPath; + return false; + } + return true; +} + +} // namespace implementation +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor diff --git a/livedisplay/SunlightEnhancement.h b/livedisplay/SunlightEnhancement.h new file mode 100644 index 0000000..3c3497d --- /dev/null +++ b/livedisplay/SunlightEnhancement.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2019-2020 The LineageOS 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. + */ + +#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H +#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace implementation { + +using ::android::sp; +using ::android::hardware::Return; +using ::android::hardware::Void; + +class SunlightEnhancement : public ISunlightEnhancement { + public: + // Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. + Return isEnabled() override; + Return setEnabled(bool enabled) override; +}; + +} // namespace implementation +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H diff --git a/livedisplay/service.cpp b/livedisplay/service.cpp new file mode 100644 index 0000000..27c6671 --- /dev/null +++ b/livedisplay/service.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2019-2020 The LineageOS 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. + */ + +#define LOG_TAG "vendor.lineage.livedisplay@2.0-service.davinci" + +#include +#include +#include + +#include "SunlightEnhancement.h" + +using ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement; +using ::vendor::lineage::livedisplay::V2_0::implementation::SunlightEnhancement; + +int main() { + android::sp sunlightEnhancement = new SunlightEnhancement(); + + android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/); + + if (sunlightEnhancement->registerAsService() != android::OK) { + LOG(ERROR) << "Cannot register sunlight enhancement HAL service."; + return 1; + } + + LOG(INFO) << "LiveDisplay HAL service is ready."; + + android::hardware::joinRpcThreadpool(); + + LOG(ERROR) << "LiveDisplay HAL service failed to join thread pool."; + return 1; +} diff --git a/livedisplay/vendor.lineage.livedisplay@2.0-service.davinci.rc b/livedisplay/vendor.lineage.livedisplay@2.0-service.davinci.rc new file mode 100644 index 0000000..7d70589 --- /dev/null +++ b/livedisplay/vendor.lineage.livedisplay@2.0-service.davinci.rc @@ -0,0 +1,8 @@ +on boot + chown system system /sys/devices/platform/soc/soc:qcom,dsi-display/hbm + chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display/hbm + +service vendor.livedisplay-hal-2-0 /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service.davinci + class hal + user system + group system diff --git a/livedisplay/vendor.lineage.livedisplay@2.0-service.davinci.xml b/livedisplay/vendor.lineage.livedisplay@2.0-service.davinci.xml new file mode 100644 index 0000000..45cd462 --- /dev/null +++ b/livedisplay/vendor.lineage.livedisplay@2.0-service.davinci.xml @@ -0,0 +1,15 @@ + + + vendor.lineage.livedisplay + hwbinder + 2.0 + + IPictureAdjustment + default + + + ISunlightEnhancement + default + + + diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index e15e42c..00f4db5 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -15,8 +15,12 @@ # HALs /vendor/bin/hw/android\.hardware\.light@2\.0-service\.davinci u:object_r:hal_light_default_exec:s0 /vendor/bin/hw/vendor\.lineage\.biometrics\.fingerprint\.inscreen@1\.0-service\.davinci u:object_r:hal_lineage_fod_default_exec:s0 +/vendor/bin/hw/vendor\.lineage\.livedisplay@2\.0-service\.davinci u:object_r:hal_lineage_livedisplay_qti_exec:s0 /vendor/bin/hw/vendor\.xiaomi\.hardware\.motor@1\.0-service u:object_r:hal_motor_default_exec:s0 +# HBM +/sys/devices/platform/soc/soc:qcom,dsi-display/hbm u:object_r:sysfs_hbm:s0 + # Motor /dev/akm09970 u:object_r:hall_device:s0 /dev/drv8846_dev u:object_r:motor_device:s0 diff --git a/sepolicy/vendor/hal_lineage_livedisplay_qti.te b/sepolicy/vendor/hal_lineage_livedisplay_qti.te new file mode 100644 index 0000000..9d783d9 --- /dev/null +++ b/sepolicy/vendor/hal_lineage_livedisplay_qti.te @@ -0,0 +1,3 @@ +type sysfs_hbm, sysfs_type, fs_type; + +allow hal_lineage_livedisplay_qti sysfs_hbm:file rw_file_perms;