47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
/*
|
|
* SPDX-FileCopyrightText: 2025 The LineageOS Project
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#define LOG_TAG "vendor.lineage.touch-service.xiaomi"
|
|
|
|
#include "HighTouchPollingRate.h"
|
|
|
|
#include <android-base/file.h>
|
|
#include <android-base/logging.h>
|
|
#include <android-base/strings.h>
|
|
|
|
using ::android::base::ReadFileToString;
|
|
using ::android::base::Trim;
|
|
using ::android::base::WriteStringToFile;
|
|
|
|
namespace aidl {
|
|
namespace vendor {
|
|
namespace lineage {
|
|
namespace touch {
|
|
|
|
ndk::ScopedAStatus HighTouchPollingRate::getEnabled(bool* _aidl_return) {
|
|
std::string buf;
|
|
if (!ReadFileToString(HTPR_CONTROL_PATH, &buf)) {
|
|
LOG(ERROR) << "Failed to read current HighTouchPollingRate state";
|
|
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
|
}
|
|
|
|
*_aidl_return = Trim(buf) == "1";
|
|
return ndk::ScopedAStatus::ok();
|
|
}
|
|
|
|
ndk::ScopedAStatus HighTouchPollingRate::setEnabled(bool enabled) {
|
|
if (!WriteStringToFile(enabled ? "1" : "0", HTPR_CONTROL_PATH)) {
|
|
LOG(ERROR) << "Failed to write HighTouchPollingRate state";
|
|
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
|
}
|
|
|
|
return ndk::ScopedAStatus::ok();
|
|
}
|
|
|
|
} // namespace touch
|
|
} // namespace lineage
|
|
} // namespace vendor
|
|
} // namespace aidl
|