android_device_sony_tama-co.../touch/GloveMode.cpp
Danny Trunk 63cfbf969e tama-common: Move to touch AIDL
Change-Id: Ic31d3c29a31ece625de67db57de2b8a246b4c7a1
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
2026-05-25 14:18:17 +00:00

51 lines
1 KiB
C++

/*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#include "GloveMode.h"
#include <fstream>
namespace {
const std::string kGloveModePath = "/sys/devices/common_touch/touch/glove_mode";
} // anonymous namespace
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
ndk::ScopedAStatus GloveMode::getEnabled(bool* _aidl_return) {
std::ifstream file(kGloveModePath);
if (file.fail()) {
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
bool enabled;
file >> enabled;
*_aidl_return = enabled;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus GloveMode::setEnabled(bool enable) {
std::ofstream file(kGloveModePath);
if (file.fail()) {
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
file << enable << std::flush;
return ndk::ScopedAStatus::ok();
}
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace aidl