Files
hardware_samsung/aidl/touch/KeyDisabler.cpp
Bruno Martins 60c28a403e touch: Migrate to AIDL
Change-Id: Ie0c2dd615652e80032393b04112fc39803205814
2025-07-22 10:12:37 +00:00

43 lines
854 B
C++

/*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#include <fstream>
#include "KeyDisabler.h"
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
bool KeyDisabler::isSupported() {
std::ofstream file(KEY_DISABLER_NODE);
return file.good();
}
ndk::ScopedAStatus KeyDisabler::getEnabled(bool* _aidl_return) {
std::ifstream file(KEY_DISABLER_NODE);
int status = -1;
if (file.is_open()) {
file >> status;
}
*_aidl_return = status == 0;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus KeyDisabler::setEnabled(bool enabled) {
std::ofstream file(KEY_DISABLER_NODE);
file << (enabled ? "0" : "1");
return ndk::ScopedAStatus::ok();
}
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace aidl