diff options
Diffstat (limited to 'touch/KeyDisabler.cpp')
-rw-r--r-- | touch/KeyDisabler.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/touch/KeyDisabler.cpp b/touch/KeyDisabler.cpp index c5acdef..4f02f9f 100644 --- a/touch/KeyDisabler.cpp +++ b/touch/KeyDisabler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 The LineageOS Project + * Copyright (C) 2019,2021 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,10 @@ #include "KeyDisabler.h" +using ::android::base::ReadFileToString; +using ::android::base::Trim; +using ::android::base::WriteStringToFile; + namespace vendor { namespace lineage { namespace touch { @@ -29,27 +33,27 @@ namespace implementation { constexpr const char kControlPath[] = "/sys/devices/soc/soc:fpc1020/utouch_disable"; KeyDisabler::KeyDisabler() { - mHasKeyDisabler = !access(kControlPath, F_OK); + has_key_disabler_ = !access(kControlPath, F_OK); } // Methods from ::vendor::lineage::touch::V1_0::IKeyDisabler follow. Return<bool> KeyDisabler::isEnabled() { std::string buf; - if (!mHasKeyDisabler) return false; + if (!has_key_disabler_) return false; - if (!android::base::ReadFileToString(kControlPath, &buf, true)) { + if (!ReadFileToString(kControlPath, &buf, true)) { LOG(ERROR) << "Failed to read " << kControlPath; return false; } - return std::stoi(android::base::Trim(buf)) == 1; + return Trim(buf) == "1"; } Return<bool> KeyDisabler::setEnabled(bool enabled) { - if (!mHasKeyDisabler) return false; + if (!has_key_disabler_) return false; - if (!android::base::WriteStringToFile((enabled ? "1" : "0"), kControlPath, true)) { + if (!WriteStringToFile(enabled ? "1" : "0", kControlPath, true)) { LOG(ERROR) << "Failed to write " << kControlPath; return false; } |