Files
android_hardware_oplus/power/power-mode.cpp
DtHnAme 00f0edf25e power: Implement DT2W through OplusTouch
Co-authored-by: Maitreya25 <maitreyapatni25@gmail.com>
Co-authored-by: Mashopy <eliasgheeraert@gmail.com>
Co-authored-by: Bruno Martins <bgcngm@gmail.com>
Change-Id: I5ad57428aeefe68c8a188aa1e445f4091cbc0d8a
2025-07-06 14:51:26 +01:00

67 lines
2.3 KiB
C++

/*
* SPDX-FileCopyrightText: 2024-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#include <aidl/android/hardware/power/BnPower.h>
#include <aidl/vendor/oplus/hardware/touch/IOplusTouch.h>
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <OplusTouchConstants.h>
using aidl::android::hardware::power::Mode;
using aidl::vendor::oplus::hardware::touch::IOplusTouch;
#ifdef LIBPERFMGR_EXT
namespace aidl::google::hardware::power::impl::pixel {
#else
namespace aidl::android::hardware::power::impl {
#endif
bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return) {
switch (type) {
case Mode::DOUBLE_TAP_TO_WAKE:
*_aidl_return = true;
return true;
default:
return false;
}
}
bool setDeviceSpecificMode(Mode type, bool enabled) {
switch (type) {
case Mode::DOUBLE_TAP_TO_WAKE: {
std::string tmp;
int contents = 0;
const std::string instance = std::string() + IOplusTouch::descriptor + "/default";
std::shared_ptr<IOplusTouch> oplusTouch = IOplusTouch::fromBinder(
ndk::SpAIBinder(AServiceManager_waitForService(instance.c_str())));
LOG(INFO) << "Power mode: " << toString(type) << " isDoubleTapEnabled: " << enabled;
oplusTouch->touchReadNodeFile(OplusTouchConstants::DEFAULT_TP_IC_ID,
OplusTouchConstants::DOUBLE_TAP_INDEP_NODE, &tmp);
contents = std::stoi(tmp, nullptr, 16);
if (enabled) {
contents |= OplusTouchConstants::DOUBLE_TAP_GESTURE;
} else {
contents &= ~OplusTouchConstants::DOUBLE_TAP_GESTURE;
}
oplusTouch->touchWriteNodeFileOneWay(OplusTouchConstants::DEFAULT_TP_IC_ID,
OplusTouchConstants::DOUBLE_TAP_ENABLE_NODE, "1");
oplusTouch->touchWriteNodeFileOneWay(OplusTouchConstants::DEFAULT_TP_IC_ID,
OplusTouchConstants::DOUBLE_TAP_INDEP_NODE,
std::to_string(contents));
return true;
}
default:
return false;
}
}
} // namespace