touch: Include KeyDisabler and KeySwapper generic support
This adds conditional support for KeyDisabler and KeySwapper along with HighTouchPollingRate feature. Change-Id: Ie6c0e7c1032e9d44bf03e6f6738581a4418fb645
This commit is contained in:
@@ -6,3 +6,5 @@
|
||||
| --------- | -------- | ----------- | ------- |
|
||||
| XIAOMI_BIOMETRICS_FINGERPRINT | RUN_32BIT | Opt to run service in 32-bit mode only | false |
|
||||
| XIAOMI_TOUCH | HIGH_TOUCH_POLLING_PATH | HighTouchPollingRate feature control path | |
|
||||
| XIAOMI_TOUCH | KEY_DISABLER_CONTROL_PATH | KeyDisabler feature control path | |
|
||||
| XIAOMI_TOUCH | KEY_SWAPPER_CONTROL_PATH | KeySwapper feature control path | |
|
||||
|
||||
@@ -5,18 +5,39 @@
|
||||
|
||||
cc_binary {
|
||||
name: "vendor.lineage.touch-service.xiaomi",
|
||||
vintf_fragments: ["vendor.lineage.touch-service.xiaomi.xml"],
|
||||
init_rc: ["vendor.lineage.touch-service.xiaomi.rc"],
|
||||
vintf_fragments: select(soong_config_variable("XIAOMI_TOUCH", "HIGH_TOUCH_POLLING_PATH"), {
|
||||
any: ["vendor.lineage.touch-service.xiaomi-htpr.xml"],
|
||||
default: [],
|
||||
}) + select(soong_config_variable("XIAOMI_TOUCH", "KEY_DISABLER_CONTROL_PATH"), {
|
||||
any: ["vendor.lineage.touch-service.xiaomi-kd.xml"],
|
||||
default: [],
|
||||
}) + select(soong_config_variable("XIAOMI_TOUCH", "KEY_SWAPPER_CONTROL_PATH"), {
|
||||
any: ["vendor.lineage.touch-service.xiaomi-ks.xml"],
|
||||
default: [],
|
||||
}),
|
||||
relative_install_path: "hw",
|
||||
proprietary: true,
|
||||
cppflags: select(soong_config_variable("XIAOMI_TOUCH", "HIGH_TOUCH_POLLING_PATH"), {
|
||||
any @ flag_val: ["-DHTPR_CONTROL_PATH=\"" + flag_val + "\""],
|
||||
default: [],
|
||||
}) + select(soong_config_variable("XIAOMI_TOUCH", "KEY_DISABLER_CONTROL_PATH"), {
|
||||
any @ flag_val: ["-DKD_CONTROL_PATH=\"" + flag_val + "\""],
|
||||
default: [],
|
||||
}) + select(soong_config_variable("XIAOMI_TOUCH", "KEY_SWAPPER_CONTROL_PATH"), {
|
||||
any @ flag_val: ["-DKS_CONTROL_PATH=\"" + flag_val + "\""],
|
||||
default: [],
|
||||
}),
|
||||
srcs: [
|
||||
"HighTouchPollingRate.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
srcs: select(soong_config_variable("XIAOMI_TOUCH", "HIGH_TOUCH_POLLING_PATH"), {
|
||||
any: ["HighTouchPollingRate.cpp"],
|
||||
default: [],
|
||||
}) + select(soong_config_variable("XIAOMI_TOUCH", "KEY_DISABLER_CONTROL_PATH"), {
|
||||
any: ["KeyDisabler.cpp"],
|
||||
default: [],
|
||||
}) + select(soong_config_variable("XIAOMI_TOUCH", "KEY_SWAPPER_CONTROL_PATH"), {
|
||||
any: ["KeySwapper.cpp"],
|
||||
default: [],
|
||||
}) + ["service.cpp"],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
|
||||
46
aidl/touch/KeyDisabler.cpp
Normal file
46
aidl/touch/KeyDisabler.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define LOG_TAG "vendor.lineage.touch-service.xiaomi"
|
||||
|
||||
#include "KeyDisabler.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 KeyDisabler::getEnabled(bool* _aidl_return) {
|
||||
std::string buf;
|
||||
if (!ReadFileToString(KD_CONTROL_PATH, &buf)) {
|
||||
LOG(ERROR) << "Failed to read current KeyDisabler state";
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
*_aidl_return = Trim(buf) == "0";
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus KeyDisabler::setEnabled(bool enabled) {
|
||||
if (!WriteStringToFile(enabled ? "0" : "1", KD_CONTROL_PATH, true)) {
|
||||
LOG(ERROR) << "Failed to write KeyDisabler state";
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace touch
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
24
aidl/touch/KeyDisabler.h
Normal file
24
aidl/touch/KeyDisabler.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/lineage/touch/BnKeyDisabler.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace touch {
|
||||
|
||||
class KeyDisabler : public BnKeyDisabler {
|
||||
public:
|
||||
ndk::ScopedAStatus getEnabled(bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus setEnabled(bool enabled) override;
|
||||
};
|
||||
|
||||
} // namespace touch
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
46
aidl/touch/KeySwapper.cpp
Normal file
46
aidl/touch/KeySwapper.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define LOG_TAG "vendor.lineage.touch-service.xiaomi"
|
||||
|
||||
#include "KeySwapper.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 KeySwapper::getEnabled(bool* _aidl_return) {
|
||||
std::string buf;
|
||||
if (!ReadFileToString(KS_CONTROL_PATH, &buf)) {
|
||||
LOG(ERROR) << "Failed to read current KeySwapper state";
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
*_aidl_return = Trim(buf) == "1";
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus KeySwapper::setEnabled(bool enabled) {
|
||||
if (!WriteStringToFile(enabled ? "1" : "0", KS_CONTROL_PATH, true)) {
|
||||
LOG(ERROR) << "Failed to write KeySwapper state";
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace touch
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
24
aidl/touch/KeySwapper.h
Normal file
24
aidl/touch/KeySwapper.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/lineage/touch/BnKeySwapper.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace touch {
|
||||
|
||||
class KeySwapper : public BnKeySwapper {
|
||||
public:
|
||||
ndk::ScopedAStatus getEnabled(bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus setEnabled(bool enabled) override;
|
||||
};
|
||||
|
||||
} // namespace touch
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
||||
@@ -3,21 +3,45 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define LOG_TAG "vendor.lineage.touch-service.xiaomi"
|
||||
|
||||
#include "HighTouchPollingRate.h"
|
||||
#include "KeyDisabler.h"
|
||||
#include "KeySwapper.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
using aidl::vendor::lineage::touch::HighTouchPollingRate;
|
||||
using aidl::vendor::lineage::touch::KeyDisabler;
|
||||
using aidl::vendor::lineage::touch::KeySwapper;
|
||||
|
||||
int main() {
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
std::shared_ptr<HighTouchPollingRate> htpr = ndk::SharedRefBase::make<HighTouchPollingRate>();
|
||||
binder_status_t status = STATUS_OK;
|
||||
|
||||
const std::string instance = std::string(HighTouchPollingRate::descriptor) + "/default";
|
||||
binder_status_t status = AServiceManager_addService(htpr->asBinder().get(), instance.c_str());
|
||||
CHECK_EQ(status, STATUS_OK);
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
|
||||
#ifdef HTPR_CONTROL_PATH
|
||||
std::shared_ptr<HighTouchPollingRate> htpr = ndk::SharedRefBase::make<HighTouchPollingRate>();
|
||||
const std::string htpr_instance = std::string(HighTouchPollingRate::descriptor) + "/default";
|
||||
status = AServiceManager_addService(htpr->asBinder().get(), htpr_instance.c_str());
|
||||
CHECK_EQ(status, STATUS_OK) << "Failed to add service " << htpr_instance << " " << status;
|
||||
#endif
|
||||
|
||||
#ifdef KD_CONTROL_PATH
|
||||
std::shared_ptr<KeyDisabler> kd = ndk::SharedRefBase::make<KeyDisabler>();
|
||||
const std::string kd_instance = std::string(KeyDisabler::descriptor) + "/default";
|
||||
status = AServiceManager_addService(kd->asBinder().get(), kd_instance.c_str());
|
||||
CHECK_EQ(status, STATUS_OK) << "Failed to add service " << kd_instance << " " << status;
|
||||
#endif
|
||||
|
||||
#ifdef KS_CONTROL_PATH
|
||||
std::shared_ptr<KeySwapper> ks = ndk::SharedRefBase::make<KeySwapper>();
|
||||
const std::string ks_instance = std::string(KeySwapper::descriptor) + "/default";
|
||||
status = AServiceManager_addService(ks->asBinder().get(), ks_instance.c_str());
|
||||
CHECK_EQ(status, STATUS_OK) << "Failed to add service " << ks_instance << " " << status;
|
||||
#endif
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
|
||||
10
aidl/touch/vendor.lineage.touch-service.xiaomi-kd.xml
Normal file
10
aidl/touch/vendor.lineage.touch-service.xiaomi-kd.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>vendor.lineage.touch</name>
|
||||
<version>1</version>
|
||||
<interface>
|
||||
<name>IKeyDisabler</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
10
aidl/touch/vendor.lineage.touch-service.xiaomi-ks.xml
Normal file
10
aidl/touch/vendor.lineage.touch-service.xiaomi-ks.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>vendor.lineage.touch</name>
|
||||
<version>1</version>
|
||||
<interface>
|
||||
<name>IKeySwapper</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
Reference in New Issue
Block a user