|
|
|
@ -31,43 +31,29 @@ namespace livedisplay { |
|
|
|
|
namespace V2_0 { |
|
|
|
|
namespace samsung { |
|
|
|
|
|
|
|
|
|
static constexpr const char* kHBMPath = "/sys/class/lcd/panel/panel/auto_brightness"; |
|
|
|
|
static constexpr const char* kSREPath = "/sys/class/mdnie/mdnie/outdoor"; |
|
|
|
|
static constexpr const char* kBrightnessPath = "/sys/class/backlight/panel0-backlight/brightness"; |
|
|
|
|
|
|
|
|
|
// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow.
|
|
|
|
|
bool SunlightEnhancement::isSupported() { |
|
|
|
|
std::fstream sre(kSREPath, sre.in | sre.out); |
|
|
|
|
std::fstream hbm(kHBMPath, hbm.in | hbm.out); |
|
|
|
|
|
|
|
|
|
if (hbm.good()) { |
|
|
|
|
mHasHBM = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return sre.good(); |
|
|
|
|
std::fstream brightness(kBrightnessPath, brightness.in | brightness.out); |
|
|
|
|
return brightness.good(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow.
|
|
|
|
|
Return<bool> SunlightEnhancement::isEnabled() { |
|
|
|
|
std::string tmp; |
|
|
|
|
int32_t statusSRE = 0; |
|
|
|
|
int32_t statusHBM = 0; |
|
|
|
|
if (ReadFileToString(kSREPath, &tmp)) { |
|
|
|
|
statusSRE = std::stoi(Trim(tmp)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mHasHBM && ReadFileToString(kHBMPath, &tmp)) { |
|
|
|
|
statusHBM = std::stoi(Trim(tmp)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ((statusSRE == 1 && statusHBM == 6) || statusSRE == 1); |
|
|
|
|
std::string brightness; |
|
|
|
|
ReadFileToString(kBrightnessPath, &brightness); |
|
|
|
|
return brightness == "365"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Return<bool> SunlightEnhancement::setEnabled(bool enabled) { |
|
|
|
|
if (mHasHBM) { |
|
|
|
|
WriteStringToFile(enabled ? "6" : "0", kHBMPath, true); |
|
|
|
|
if (enabled) { |
|
|
|
|
ReadFileToString(kBrightnessPath, &previous_brightness); |
|
|
|
|
return WriteStringToFile("365", kBrightnessPath, true); |
|
|
|
|
} else if (!previous_brightness.empty()) { |
|
|
|
|
return WriteStringToFile(previous_brightness, kBrightnessPath, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return WriteStringToFile(enabled ? "1" : "0", kSREPath, true); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace samsung
|
|
|
|
|