livedisplay: Check current state before toggling AF/SE

This prevents us from sending unexpected panel commands.

Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/4790
Change-Id: I97c5a008f242c861cafdec392b19ab9435a5239b
This commit is contained in:
Albert Tang
2022-12-05 09:52:50 -06:00
committed by LuK1337
parent 99cfe97b5c
commit bd2d84c295
2 changed files with 3 additions and 2 deletions

View File

@@ -33,7 +33,8 @@ Return<bool> AntiFlicker::isEnabled() {
Return<bool> AntiFlicker::setEnabled(bool enabled) {
unsigned int value = enabled;
return ioctl(mOplusDisplayFd, PANEL_IOCTL_SET_DIMLAYER_BL_EN, &value) == 0;
return isEnabled() == enabled ||
ioctl(mOplusDisplayFd, PANEL_IOCTL_SET_DIMLAYER_BL_EN, &value) == 0;
}
} // namespace implementation

View File

@@ -33,7 +33,7 @@ Return<bool> SunlightEnhancement::isEnabled() {
Return<bool> SunlightEnhancement::setEnabled(bool enabled) {
unsigned int value = enabled;
return ioctl(mOplusDisplayFd, PANEL_IOCTL_SET_HBM, &value) == 0;
return isEnabled() == enabled || ioctl(mOplusDisplayFd, PANEL_IOCTL_SET_HBM, &value) == 0;
}
} // namespace implementation