livedisplay: Remove SDM-backended AdaptiveBacklight implementation
OnePlus 3 is the only device using this interface, remove it from the
common HAL to avoid dealing with various corner cases when interacting
with the sysfs HAL.
Change-Id: I5082e9da9bfde1515a5a57959cef78061afd3d61
diff --git a/sdm/AdaptiveBacklight.cpp b/sdm/AdaptiveBacklight.cpp
deleted file mode 100644
index 68fc470..0000000
--- a/sdm/AdaptiveBacklight.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.
- */
-
-#include "livedisplay/sdm/AdaptiveBacklight.h"
-
-#include <android-base/properties.h>
-#include <android-base/unique_fd.h>
-#include <cutils/sockets.h>
-#include <poll.h>
-
-namespace {
-constexpr size_t kDppsBufSize = 10;
-
-constexpr const char* kDaemonSocket = "pps";
-constexpr const char* kFossOff = "foss:off";
-constexpr const char* kFossOn = "foss:on";
-constexpr const char* kFossProperty = "ro.vendor.display.foss.backlight";
-constexpr const char* kSuccess = "Success";
-
-android::status_t SendDppsCommand(const char* cmd) {
- android::base::unique_fd sock(
- socket_local_client(kDaemonSocket, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM));
- if (sock < 0) {
- return android::NO_INIT;
- }
-
- if (TEMP_FAILURE_RETRY(write(sock, cmd, strlen(cmd))) <= 0) {
- return android::FAILED_TRANSACTION;
- }
-
- std::string result(kDppsBufSize, 0);
- size_t len = result.length();
- char* buf = &result[0];
- ssize_t ret;
- while ((ret = TEMP_FAILURE_RETRY(read(sock, buf, len))) > 0) {
- if (ret == len) {
- break;
- }
- len -= ret;
- buf += ret;
-
- struct pollfd p = {.fd = sock, .events = POLLIN, .revents = 0};
-
- ret = poll(&p, 1, 20);
- if ((ret <= 0) || !(p.revents & POLLIN)) {
- break;
- }
- }
-
- if (result.compare(0, strlen(kSuccess), kSuccess) == 0) {
- return android::OK;
- }
-
- return android::BAD_VALUE;
-}
-} // anonymous namespace
-
-namespace vendor {
-namespace lineage {
-namespace livedisplay {
-namespace V2_0 {
-namespace sdm {
-
-using ::android::base::GetBoolProperty;
-
-bool AdaptiveBacklight::isSupported() {
- return GetBoolProperty(kFossProperty, false);
-}
-
-// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow.
-Return<bool> AdaptiveBacklight::isEnabled() {
- return enabled_;
-}
-
-Return<bool> AdaptiveBacklight::setEnabled(bool enabled) {
- if (enabled_ == enabled) {
- return true;
- }
-
- if (SendDppsCommand(enabled ? kFossOn : kFossOff) == android::OK) {
- enabled_ = enabled;
- return true;
- }
-
- return false;
-}
-
-} // namespace sdm
-} // namespace V2_0
-} // namespace livedisplay
-} // namespace lineage
-} // namespace vendor
diff --git a/sdm/Android.bp b/sdm/Android.bp
index fdf4dd1..041b41a 100644
--- a/sdm/Android.bp
+++ b/sdm/Android.bp
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2020 The LineageOS Project
+// Copyright (C) 2019-2021 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.
@@ -13,13 +13,6 @@
// limitations under the License.
filegroup {
- name: "vendor.lineage.livedisplay@2.0-sdm-ab",
- srcs: [
- "AdaptiveBacklight.cpp",
- ],
-}
-
-filegroup {
name: "vendor.lineage.livedisplay@2.0-sdm-dm",
srcs: [
"DisplayModes.cpp",
@@ -52,7 +45,6 @@
defaults: ["hidl_defaults"],
relative_install_path: "hw",
srcs: [
- ":vendor.lineage.livedisplay@2.0-sdm-ab",
":vendor.lineage.livedisplay@2.0-sdm-dm",
":vendor.lineage.livedisplay@2.0-sdm-pa",
":vendor.lineage.livedisplay@2.0-sdm-utils",
@@ -61,7 +53,6 @@
shared_libs: [
"libbase",
"libbinder",
- "libcutils",
"libdl",
"libhidlbase",
"libutils",
diff --git a/sdm/include/livedisplay/sdm/AdaptiveBacklight.h b/sdm/include/livedisplay/sdm/AdaptiveBacklight.h
deleted file mode 100644
index 1fa2be1..0000000
--- a/sdm/include/livedisplay/sdm/AdaptiveBacklight.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.
- */
-
-#pragma once
-
-#include <vendor/lineage/livedisplay/2.0/IAdaptiveBacklight.h>
-
-namespace vendor {
-namespace lineage {
-namespace livedisplay {
-namespace V2_0 {
-namespace sdm {
-
-using ::android::hardware::Return;
-
-class AdaptiveBacklight : public IAdaptiveBacklight {
- public:
- static bool isSupported();
-
- // Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow.
- Return<bool> isEnabled() override;
- Return<bool> setEnabled(bool enabled) override;
-
- private:
- bool enabled_ = false;
-};
-
-} // namespace sdm
-} // namespace V2_0
-} // namespace livedisplay
-} // namespace lineage
-} // namespace vendor
diff --git a/sdm/service.cpp b/sdm/service.cpp
index f6f80a1..78a63b6 100644
--- a/sdm/service.cpp
+++ b/sdm/service.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2020 The LineageOS Project
+ * Copyright (C) 2019-2021 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.
@@ -23,7 +23,6 @@
#include <android-base/logging.h>
#include <binder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>
-#include <livedisplay/sdm/AdaptiveBacklight.h>
#include <livedisplay/sdm/DisplayModes.h>
#include <livedisplay/sdm/PictureAdjustment.h>
#include <livedisplay/sdm/SDMController.h>
@@ -34,24 +33,12 @@
using ::android::hardware::configureRpcThreadpool;
using ::android::hardware::joinRpcThreadpool;
-using ::vendor::lineage::livedisplay::V2_0::sdm::AdaptiveBacklight;
using ::vendor::lineage::livedisplay::V2_0::sdm::DisplayModes;
using ::vendor::lineage::livedisplay::V2_0::sdm::PictureAdjustment;
using ::vendor::lineage::livedisplay::V2_0::sdm::SDMController;
status_t RegisterAsServices() {
status_t status = OK;
-
- if (AdaptiveBacklight::isSupported()) {
- sp<AdaptiveBacklight> ab = new AdaptiveBacklight();
- status = ab->registerAsService();
- if (status != OK) {
- LOG(ERROR) << "Could not register service for LiveDisplay HAL AdaptiveBacklight Iface ("
- << status << ")";
- return status;
- }
- }
-
std::shared_ptr<SDMController> controller = std::make_shared<SDMController>();
sp<PictureAdjustment> pa = new PictureAdjustment(controller);
diff --git a/sysfs/AdaptiveBacklight.cpp b/sysfs/AdaptiveBacklight.cpp
index 9a9ac0f..f47a48f 100644
--- a/sysfs/AdaptiveBacklight.cpp
+++ b/sysfs/AdaptiveBacklight.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2020 The LineageOS Project
+ * Copyright (C) 2019-2021 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.
@@ -17,10 +17,8 @@
#include "livedisplay/sysfs/AdaptiveBacklight.h"
#include <android-base/file.h>
-#include <android-base/properties.h>
#include <android-base/strings.h>
-using ::android::base::GetBoolProperty;
using ::android::base::ReadFileToString;
using ::android::base::Trim;
using ::android::base::WriteStringToFile;
@@ -28,7 +26,6 @@
namespace {
constexpr const char* kFileAcl = "/sys/class/graphics/fb0/acl";
constexpr const char* kFileCabc = "/sys/class/graphics/fb0/cabc";
-constexpr const char* kFossProperty = "ro.vendor.display.foss.backlight";
} // anonymous namespace
namespace vendor {
@@ -48,10 +45,7 @@
}
bool AdaptiveBacklight::isSupported() {
- if (GetBoolProperty(kFossProperty, false) || file_ == nullptr) {
- return false;
- }
- return true;
+ return file_ != nullptr;
}
// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow.
diff --git a/sysfs/Android.bp b/sysfs/Android.bp
index 218e4bc..6f7a8df 100644
--- a/sysfs/Android.bp
+++ b/sysfs/Android.bp
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2020 The LineageOS Project
+// Copyright (C) 2019-2021 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.
@@ -52,7 +52,6 @@
shared_libs: [
"libbase",
"libbinder",
- "libcutils",
"libhidlbase",
"libutils",
"vendor.lineage.livedisplay@2.0",