sm7125-common: livedisplay: Use hardware/samsung implementation for Outdoor mode

Change-Id: I55cb42f74a6cf13416f61de5c05183c7d50826db
urubino-microg
Simon1511 2 years ago committed by jenslody
parent ca2b252e3e
commit de6db07632
  1. 25
      livedisplay/SunlightEnhancement.cpp
  2. 11
      livedisplay/SunlightEnhancement.h

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

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019 The LineageOS Project * Copyright (C) 2019-2022 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -14,8 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H #pragma once
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H
#include <hidl/MQDescriptor.h> #include <hidl/MQDescriptor.h>
#include <hidl/Status.h> #include <hidl/Status.h>
@ -42,10 +41,6 @@ class SunlightEnhancement : public ISunlightEnhancement {
// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. // Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow.
Return<bool> isEnabled() override; Return<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override; Return<bool> setEnabled(bool enabled) override;
// Methods from ::android::hidl::base::V1_0::IBase follow.
private:
std::string previous_brightness;
}; };
} // namespace samsung } // namespace samsung
@ -53,5 +48,3 @@ class SunlightEnhancement : public ISunlightEnhancement {
} // namespace livedisplay } // namespace livedisplay
} // namespace lineage } // namespace lineage
} // namespace vendor } // namespace vendor
#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H

Loading…
Cancel
Save