From 8af90b16090b54cba6da59c94f84f6a36c83d731 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Wed, 6 Jan 2021 17:12:16 +0000 Subject: msm8996-common: touch: Fix code style issues Change-Id: Ide58643d2718f36792a212ea87426e3548a922c0 --- touch/KeyDisabler.cpp | 18 +++++++++++------- touch/KeyDisabler.h | 4 ++-- 2 files changed, 13 insertions(+), 9 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 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 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; } diff --git a/touch/KeyDisabler.h b/touch/KeyDisabler.h index f7a18fa..8aba763 100644 --- a/touch/KeyDisabler.h +++ b/touch/KeyDisabler.h @@ -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. @@ -36,7 +36,7 @@ class KeyDisabler : public IKeyDisabler { Return setEnabled(bool enabled) override; private: - bool mHasKeyDisabler; + bool has_key_disabler_; }; } // namespace implementation -- cgit v1.2.3