Files
android_hardware_oplus/aidl/livedisplay/service.cpp
LuK1337 622f8070f3 livedisplay: Migrate to AIDL
Change-Id: I8dbe9ed99549aff3e7fcff553482a4c45aae67ef
2025-08-17 23:40:08 +02:00

67 lines
2.6 KiB
C++

/*
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#define LOG_TAG "vendor.lineage.livedisplay-service-oplus"
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <binder/ProcessState.h>
#include <livedisplay/oplus/AntiFlicker.h>
#include <livedisplay/oplus/DisplayModes.h>
#include <livedisplay/oplus/SunlightEnhancement.h>
#include <livedisplay/sdm/PictureAdjustment.h>
using ::aidl::vendor::lineage::livedisplay::AntiFlicker;
using ::aidl::vendor::lineage::livedisplay::DisplayModes;
using ::aidl::vendor::lineage::livedisplay::SunlightEnhancement;
using ::aidl::vendor::lineage::livedisplay::sdm::PictureAdjustment;
using ::aidl::vendor::lineage::livedisplay::sdm::SDMController;
int main() {
android::ProcessState::self()->setThreadPoolMaxThreadCount(1);
android::ProcessState::self()->startThreadPool();
LOG(INFO) << "LiveDisplay HAL service is starting.";
std::shared_ptr<SDMController> controller =
ENABLE_DM || ENABLE_PA ? std::make_shared<SDMController>() : nullptr;
std::shared_ptr<AntiFlicker> af = ENABLE_AF ? ndk::SharedRefBase::make<AntiFlicker>() : nullptr;
std::shared_ptr<DisplayModes> dm =
ENABLE_DM ? ndk::SharedRefBase::make<DisplayModes>(controller) : nullptr;
std::shared_ptr<PictureAdjustment> pa =
ENABLE_PA ? ndk::SharedRefBase::make<PictureAdjustment>(controller) : nullptr;
std::shared_ptr<SunlightEnhancement> se =
ENABLE_SE ? ndk::SharedRefBase::make<SunlightEnhancement>() : nullptr;
if (af) {
std::string instance = std::string() + AntiFlicker::descriptor + "/default";
binder_status_t status = AServiceManager_addService(af->asBinder().get(), instance.c_str());
CHECK_EQ(status, STATUS_OK);
}
if (dm) {
std::string instance = std::string() + DisplayModes::descriptor + "/default";
binder_status_t status = AServiceManager_addService(dm->asBinder().get(), instance.c_str());
CHECK_EQ(status, STATUS_OK);
}
if (pa) {
std::string instance = std::string() + PictureAdjustment::descriptor + "/default";
binder_status_t status = AServiceManager_addService(pa->asBinder().get(), instance.c_str());
CHECK_EQ(status, STATUS_OK);
}
if (se) {
std::string instance = std::string() + SunlightEnhancement::descriptor + "/default";
binder_status_t status = AServiceManager_addService(se->asBinder().get(), instance.c_str());
CHECK_EQ(status, STATUS_OK);
}
ABinderProcess_joinThreadPool();
return EXIT_FAILURE; // should not reach
}