You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
4.9 KiB
148 lines
4.9 KiB
6 years ago
|
/*
|
||
|
* Copyright (C) 2019 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.
|
||
|
*/
|
||
|
|
||
|
#ifdef LIVES_IN_SYSTEM
|
||
|
#define LOG_TAG "lineage.livedisplay@2.0-service.samsung-qcom"
|
||
|
#else
|
||
|
#define LOG_TAG "vendor.lineage.livedisplay@2.0-service.samsung-qcom"
|
||
|
#endif
|
||
|
|
||
|
#include <android-base/logging.h>
|
||
|
#include <binder/ProcessState.h>
|
||
|
#include <hidl/HidlTransportSupport.h>
|
||
|
|
||
|
#include "AdaptiveBacklight.h"
|
||
|
#include "DisplayColorCalibration.h"
|
||
|
#include "DisplayModes.h"
|
||
|
#include "ReadingEnhancement.h"
|
||
|
#include "SunlightEnhancement.h"
|
||
|
|
||
|
using android::hardware::configureRpcThreadpool;
|
||
|
using android::hardware::joinRpcThreadpool;
|
||
|
using android::sp;
|
||
|
using android::status_t;
|
||
|
using android::OK;
|
||
|
|
||
|
using vendor::lineage::livedisplay::V2_0::samsung::AdaptiveBacklight;
|
||
|
using vendor::lineage::livedisplay::V2_0::samsung::DisplayColorCalibration;
|
||
|
using vendor::lineage::livedisplay::V2_0::samsung::DisplayModes;
|
||
|
using vendor::lineage::livedisplay::V2_0::samsung::ReadingEnhancement;
|
||
|
using vendor::lineage::livedisplay::V2_0::samsung::SunlightEnhancement;
|
||
|
|
||
|
int main() {
|
||
|
sp<AdaptiveBacklight> adaptiveBacklight;
|
||
|
sp<DisplayColorCalibration> displayColorCalibration;
|
||
|
sp<DisplayModes> displayModes;
|
||
|
sp<ReadingEnhancement> readingEnhancement;
|
||
|
sp<SunlightEnhancement> sunlightEnhancement;
|
||
|
status_t status;
|
||
|
|
||
|
LOG(INFO) << "LiveDisplay HAL service is starting.";
|
||
|
|
||
|
adaptiveBacklight = new AdaptiveBacklight();
|
||
|
if (adaptiveBacklight == nullptr) {
|
||
6 years ago
|
LOG(ERROR)
|
||
|
<< "Can not create an instance of LiveDisplay HAL AdaptiveBacklight Iface, exiting.";
|
||
6 years ago
|
goto shutdown;
|
||
|
}
|
||
|
|
||
|
displayColorCalibration = new DisplayColorCalibration();
|
||
|
if (displayColorCalibration == nullptr) {
|
||
6 years ago
|
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayColorCalibration "
|
||
|
"Iface, exiting.";
|
||
6 years ago
|
goto shutdown;
|
||
|
}
|
||
|
|
||
|
displayModes = new DisplayModes();
|
||
|
if (displayModes == nullptr) {
|
||
|
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayModes Iface, exiting.";
|
||
|
goto shutdown;
|
||
|
}
|
||
|
|
||
|
readingEnhancement = new ReadingEnhancement();
|
||
|
if (readingEnhancement == nullptr) {
|
||
6 years ago
|
LOG(ERROR)
|
||
|
<< "Can not create an instance of LiveDisplay HAL ReadingEnhancement Iface, exiting.";
|
||
6 years ago
|
goto shutdown;
|
||
|
}
|
||
|
|
||
|
sunlightEnhancement = new SunlightEnhancement();
|
||
|
if (sunlightEnhancement == nullptr) {
|
||
6 years ago
|
LOG(ERROR)
|
||
|
<< "Can not create an instance of LiveDisplay HAL SunlightEnhancement Iface, exiting.";
|
||
6 years ago
|
goto shutdown;
|
||
|
}
|
||
|
|
||
|
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||
|
|
||
|
if (adaptiveBacklight->isSupported()) {
|
||
|
status = adaptiveBacklight->registerAsService();
|
||
|
if (status != OK) {
|
||
6 years ago
|
LOG(ERROR) << "Could not register service for LiveDisplay HAL AdaptiveBacklight Iface ("
|
||
|
<< status << ")";
|
||
6 years ago
|
goto shutdown;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (displayColorCalibration->isSupported()) {
|
||
|
status = displayColorCalibration->registerAsService();
|
||
|
if (status != OK) {
|
||
|
LOG(ERROR)
|
||
|
<< "Could not register service for LiveDisplay HAL DisplayColorCalibration Iface ("
|
||
|
<< status << ")";
|
||
|
goto shutdown;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (displayModes->isSupported()) {
|
||
|
status = displayModes->registerAsService();
|
||
|
if (status != OK) {
|
||
6 years ago
|
LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface ("
|
||
|
<< status << ")";
|
||
6 years ago
|
goto shutdown;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (readingEnhancement->isSupported()) {
|
||
|
status = readingEnhancement->registerAsService();
|
||
|
if (status != OK) {
|
||
|
LOG(ERROR)
|
||
|
<< "Could not register service for LiveDisplay HAL ReadingEnhancement Iface ("
|
||
|
<< status << ")";
|
||
|
goto shutdown;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (sunlightEnhancement->isSupported()) {
|
||
|
status = sunlightEnhancement->registerAsService();
|
||
|
if (status != OK) {
|
||
|
LOG(ERROR)
|
||
|
<< "Could not register service for LiveDisplay HAL SunlightEnhancement Iface ("
|
||
|
<< status << ")";
|
||
|
goto shutdown;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
LOG(INFO) << "LiveDisplay HAL service is ready.";
|
||
|
joinRpcThreadpool();
|
||
6 years ago
|
// Should not pass this line
|
||
6 years ago
|
|
||
|
shutdown:
|
||
|
// In normal operation, we don't expect the thread pool to shutdown
|
||
|
LOG(ERROR) << "LiveDisplay HAL service is shutting down.";
|
||
|
return 1;
|
||
|
}
|