aboutsummaryrefslogtreecommitdiff
path: root/touch/KeyDisabler.cpp
diff options
context:
space:
mode:
authorBruno Martins <bgcngm@gmail.com>2021-01-06 17:12:16 +0000
committerDavide Garberi <dade.garberi@gmail.com>2021-10-28 22:38:40 +0200
commit8af90b16090b54cba6da59c94f84f6a36c83d731 (patch)
treeff7c127e066c1f0a279923e4b9c651806d7ee75a /touch/KeyDisabler.cpp
parent9327d74d955a2329e4475bf003d4cab2b00be88b (diff)
msm8996-common: touch: Fix code style issues
Change-Id: Ide58643d2718f36792a212ea87426e3548a922c0
Diffstat (limited to 'touch/KeyDisabler.cpp')
-rw-r--r--touch/KeyDisabler.cpp18
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;
}