summaryrefslogtreecommitdiffstats
path: root/sysfs/ReadingEnhancement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sysfs/ReadingEnhancement.cpp')
-rw-r--r--sysfs/ReadingEnhancement.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/sysfs/ReadingEnhancement.cpp b/sysfs/ReadingEnhancement.cpp
index af366da..0e4b92d 100644
--- a/sysfs/ReadingEnhancement.cpp
+++ b/sysfs/ReadingEnhancement.cpp
@@ -14,32 +14,45 @@
* limitations under the License.
*/
+#include <android-base/file.h>
+#include <android-base/strings.h>
+
+#include <fstream>
+
#include "ReadingEnhancement.h"
+using android::base::ReadFileToString;
+using android::base::Trim;
+using android::base::WriteStringToFile;
+
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_0 {
namespace sysfs {
+bool ReadingEnhancement::isSupported() {
+ std::fstream re(FILE_RE, re.in | re.out);
+
+ return re.good();
+}
+
// Methods from ::vendor::lineage::livedisplay::V2_0::IReadingEnhancement follow.
Return<bool> ReadingEnhancement::isEnabled() {
- // TODO implement
- return bool {};
+ std::string tmp;
+ int32_t contents = 0;
+
+ if (ReadFileToString(FILE_RE, &tmp)) {
+ contents = std::stoi(Trim(tmp));
+ }
+
+ return contents > 0;
}
Return<bool> ReadingEnhancement::setEnabled(bool enabled) {
- // TODO implement
- return bool {};
+ return WriteStringToFile(enabled ? "1" : "0", FILE_RE, true);
}
-
-// Methods from ::android::hidl::base::V1_0::IBase follow.
-
-//IReadingEnhancement* HIDL_FETCH_IReadingEnhancement(const char* /* name */) {
- //return new ReadingEnhancement();
-//}
-//
} // namespace sysfs
} // namespace V2_0
} // namespace livedisplay