summaryrefslogtreecommitdiff
path: root/libhwc2.1/libdevice/BrightnessController.cpp
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-02-08 03:51:52 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-02-08 03:51:52 +0000
commit541d6913b33ea7f0322b9f9ee781e45f10ea2e2e (patch)
tree6dad5e4db815ca0b9efdd5edfd11f62727fe6e3a /libhwc2.1/libdevice/BrightnessController.cpp
parent0c3ef0f77d755d85db6c7e6fe2436986799d2ad4 (diff)
parent5c20757d6d6934058d8438bc6e1c74162e1b7b14 (diff)
Merge cherrypicks of ['googleplex-android-review.googlesource.com/21266803'] into udc-release.
Change-Id: I82015d665dc1db05a7593d2018a81adedc8031e0
Diffstat (limited to 'libhwc2.1/libdevice/BrightnessController.cpp')
-rw-r--r--libhwc2.1/libdevice/BrightnessController.cpp23
1 files changed, 6 insertions, 17 deletions
diff --git a/libhwc2.1/libdevice/BrightnessController.cpp b/libhwc2.1/libdevice/BrightnessController.cpp
index 5b91786..497889a 100644
--- a/libhwc2.1/libdevice/BrightnessController.cpp
+++ b/libhwc2.1/libdevice/BrightnessController.cpp
@@ -713,23 +713,12 @@ int BrightnessController::checkSysfsStatus(const char* file,
char buf[16];
String8 nodeName;
- if (std::strstr(file, "%d")) {
- nodeName.appendFormat(file, mPanelIndex);
- } else if (std::strstr(file, "%s")) {
- nodeName.appendFormat(file, mPanelIndex == 0 ? "primary"
- : mPanelIndex == 1 ? "secondary" : "unknown");
- } else {
- nodeName = file;
- }
+ nodeName.appendFormat(file, mPanelIndex);
UniqueFd fd = open(nodeName.string(), O_RDONLY);
- if (fd.get() < 0) {
- ALOGE("%s failed to open sysfs %s: %s", __func__, nodeName.c_str(), strerror(errno));
- return false;
- }
int size = read(fd.get(), buf, sizeof(buf));
if (size <= 0) {
- ALOGE("%s failed to read from %s: %s", __func__, nodeName.c_str(), strerror(errno));
+ ALOGE("%s failed to read from %s", __func__, kLocalHbmModeFileNode);
return false;
}
@@ -756,7 +745,7 @@ int BrightnessController::checkSysfsStatus(const char* file,
}
int pollRet = poll(&pfd, 1, ns2ms(remainTimeNs));
if (pollRet == 0) {
- ALOGW("%s poll %s timeout", __func__, nodeName.c_str());
+ ALOGW("%s poll timeout", __func__);
// time out
ret = ETIMEDOUT;
break;
@@ -771,8 +760,7 @@ int BrightnessController::checkSysfsStatus(const char* file,
val = std::string(buf, size - 1);
if (std::find(expectedValue.begin(), expectedValue.end(), val) !=
expectedValue.end()) {
- ret = OK;
- break;
+ ret = 0;
} else {
std::string values;
for (auto& s : expectedValue) {
@@ -783,12 +771,13 @@ int BrightnessController::checkSysfsStatus(const char* file,
}
ALOGE("%s read %s expected %s after notified", __func__, val.c_str(),
values.c_str());
+ ret = EINVAL;
}
} else {
ret = EIO;
ALOGE("%s failed to read after notified %d", __func__, errno);
- break;
}
+ break;
} else {
if (errno == EAGAIN || errno == EINTR) {
continue;