blob: 54691a0028c4254df1fc5ce677ca1f0afe88d27f [file] [log] [blame]
Paul Keith5b3bd862019-01-08 23:45:03 +01001/*
2 * Copyright (C) 2019 The LineageOS Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Paul Keith2b27b272019-01-09 00:11:40 +010017#include <fstream>
18
Paul Keith5b3bd862019-01-08 23:45:03 +010019#include "KeyDisabler.h"
20
21namespace vendor {
22namespace lineage {
23namespace touch {
24namespace V1_0 {
Paul Keith2b27b272019-01-09 00:11:40 +010025namespace samsung {
Paul Keith5b3bd862019-01-08 23:45:03 +010026
Paul Keith2b27b272019-01-09 00:11:40 +010027bool KeyDisabler::isSupported() {
28 std::ofstream file("/sys/class/sec/sec_touchkey/input/enabled");
29 return file.good();
Paul Keith5b3bd862019-01-08 23:45:03 +010030}
31
Paul Keith2b27b272019-01-09 00:11:40 +010032// Methods from ::vendor::lineage::touch::V1_0::IKeyDisabler follow.
33Return<bool> KeyDisabler::isEnabled() {
34 std::ifstream file("/sys/class/sec/sec_touchkey/input/enabled");
35 int status = -1;
Paul Keith5b3bd862019-01-08 23:45:03 +010036
Paul Keith2b27b272019-01-09 00:11:40 +010037 if (file.is_open()) {
38 file >> status;
39 }
Paul Keith5b3bd862019-01-08 23:45:03 +010040
Paul Keith2b27b272019-01-09 00:11:40 +010041 return file.good() && status == 0;
42}
43
44Return<bool> KeyDisabler::setEnabled(bool enabled) {
45 std::ofstream file("/sys/class/sec/sec_touchkey/input/enabled");
46 file << (enabled ? "0" : "1");
47 return true;
48}
49
50} // namespace samsung
Paul Keith5b3bd862019-01-08 23:45:03 +010051} // namespace V1_0
52} // namespace touch
53} // namespace lineage
54} // namespace vendor