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-03 19:52:09 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-02-03 19:52:09 +0000
commit4b4a1c9381476883fe8000d5f70cac1a94e52ad5 (patch)
treee1d31eba8f6b846732c1b8fae5561d033e49e277 /libhwc2.1/libdevice/BrightnessController.cpp
parent6169f5e4cf2be159576fc19184dc047c22b0e2ae (diff)
parent2f037bf60d3db37cd29a3cc25777a3ef7ad3ce64 (diff)
Merge cherrypicks of ['googleplex-android-review.googlesource.com/21266804', 'googleplex-android-review.googlesource.com/21266803'] into sparse-9558421-L47400000958444034.
SPARSE_CHANGE: I42fb9d1c1f3c814e5416209378ea38b61e901e62 SPARSE_CHANGE: Ifaaee60913ffc32e8ae9ab7acec327a968468ac7 Change-Id: Ief57303a5b89e22764af22b8eca27e26d8409f96
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;