mondrian: Switch lineage touch HAL to AIDL

This commit is contained in:
flakeforever
2025-07-13 11:28:46 -07:00
parent 686c10d85e
commit 720790ba68
10 changed files with 70 additions and 81 deletions

View File

@@ -409,7 +409,7 @@ PRODUCT_PACKAGES += \
# Touch
PRODUCT_PACKAGES += \
vendor.lineage.touch@1.0-service.xiaomi_sm8475
vendor.lineage.touch-service.xiaomi_sm8475
# Touchscreen
PRODUCT_COPY_FILES += \

View File

@@ -58,7 +58,7 @@
/sys/class/thermal/thermal_zone87/temp u:object_r:sysfs_thermal:s0
# Touch
/vendor/bin/hw/vendor\.lineage\.touch@1\.0-service\.xiaomi_sm8475 u:object_r:hal_lineage_touch_default_exec:s0
/vendor/bin/hw/vendor\.lineage\.touch-service\.xiaomi_sm8475 u:object_r:hal_lineage_touch_default_exec:s0
# Touchscreen
/sys/devices/virtual/touch/tp_dev/fod_status u:object_r:sysfs_tp_fodstatus:s0

View File

@@ -1,14 +1,12 @@
//
// Copyright (C) 2024 The LineageOS Project
//
// SPDX-FileCopyrightText: 2025 The LineageOS Project
// SPDX-License-Identifier: Apache-2.0
//
cc_binary {
name: "vendor.lineage.touch@1.0-service.xiaomi_sm8475",
vintf_fragments: ["vendor.lineage.touch@1.0-service.xiaomi_sm8475.xml"],
init_rc: ["vendor.lineage.touch@1.0-service.xiaomi_sm8475.rc"],
defaults: ["hidl_defaults"],
name: "vendor.lineage.touch-service.xiaomi_sm8475",
init_rc: ["vendor.lineage.touch-service.xiaomi_sm8475.rc"],
vintf_fragments: ["vendor.lineage.touch-service.xiaomi-htpr.xml"],
relative_install_path: "hw",
proprietary: true,
srcs: [
@@ -17,9 +15,9 @@ cc_binary {
],
shared_libs: [
"libbase",
"libbinder",
"libhidlbase",
"libbinder_ndk",
"liblog",
"libutils",
"vendor.lineage.touch@1.0",
"vendor.lineage.touch-V1-ndk",
],
}
}

View File

@@ -1,23 +1,27 @@
/*
* Copyright (C) 2024 The LineageOS Project
* Copyright (C) 2024 Flakeforever
*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* 2023-2025 flakeforever
* SPDX-License-Identifier: Apache-2.0
*/
#define LOG_TAG "vendor.lineage.touch@1.0-service.xiaomi_sm8475"
#define LOG_TAG "vendor.lineage.touch-service.xiaomi"
#include "HighTouchPollingRate.h"
#include <android-base/file.h>
#include <android-base/logging.h>
#include <sys/ioctl.h>
#include "xiaomi_touch.h"
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/strings.h>
#include <sys/ioctl.h>
using ::android::base::ReadFileToString;
using ::android::base::Trim;
using ::android::base::WriteStringToFile;
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
namespace implementation {
#define TOUCH_DEV_PATH "/dev/xiaomi-touch"
#define TOUCH_ID 0
@@ -57,13 +61,15 @@ bool getTouchModeValue(int mode, int* value) {
return true;
}
Return<bool> HighTouchPollingRate::isEnabled() {
ndk::ScopedAStatus HighTouchPollingRate::getEnabled(bool* _aidl_return) {
int gameMode = 0;
getTouchModeValue(Touch_Game_Mode, &gameMode);
return gameMode == 1;
*_aidl_return = gameMode == 1;
return ndk::ScopedAStatus::ok();
}
Return<bool> HighTouchPollingRate::setEnabled(bool enabled) {
ndk::ScopedAStatus HighTouchPollingRate::setEnabled(bool enabled) {
if (enabled) {
getTouchModeValue(Touch_UP_THRESHOLD, &upThreshold);
getTouchModeValue(Touch_Tolerance, &tolerance);
@@ -82,11 +88,11 @@ Return<bool> HighTouchPollingRate::setEnabled(bool enabled) {
setTouchModeValue(Touch_Tolerance, tolerance);
setTouchModeValue(Touch_Edge_Filter, edgeFilter);
}
return true;
return ndk::ScopedAStatus::ok();
}
} // namespace implementation
} // namespace V1_0
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace vendor
} // namespace aidl

View File

@@ -1,30 +1,24 @@
/*
* Copyright (C) 2024 The LineageOS Project
*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <vendor/lineage/touch/1.0/IHighTouchPollingRate.h>
#include <aidl/vendor/lineage/touch/BnHighTouchPollingRate.h>
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
namespace implementation {
using ::android::hardware::Return;
class HighTouchPollingRate : public IHighTouchPollingRate {
class HighTouchPollingRate : public BnHighTouchPollingRate {
public:
// Methods from ::vendor::lineage::touch::V1_0::IHighTouchPollingRate follow.
Return<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override;
ndk::ScopedAStatus getEnabled(bool* _aidl_return) override;
ndk::ScopedAStatus setEnabled(bool enabled) override;
};
} // namespace implementation
} // namespace V1_0
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace vendor
} // namespace aidl

View File

@@ -1,33 +1,28 @@
/*
* Copyright (C) 2024 The LineageOS Project
*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#define LOG_TAG "vendor.lineage.touch@1.0-service.xiaomi_sm8475"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#define LOG_TAG "vendor.lineage.touch-service.xiaomi"
#include "HighTouchPollingRate.h"
using ::vendor::lineage::touch::V1_0::IHighTouchPollingRate;
using ::vendor::lineage::touch::V1_0::implementation::HighTouchPollingRate;
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
using aidl::vendor::lineage::touch::HighTouchPollingRate;
int main() {
android::sp<IHighTouchPollingRate> highTouchPollingRate = new HighTouchPollingRate();
binder_status_t status = STATUS_OK;
android::hardware::configureRpcThreadpool(1, true);
ABinderProcess_setThreadPoolMaxThreadCount(0);
if (highTouchPollingRate->registerAsService() != android::OK) {
LOG(ERROR) << "Cannot register touch high polling rate HAL service.";
return 1;
}
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;
LOG(INFO) << "Touch HAL service ready.";
android::hardware::joinRpcThreadpool();
LOG(ERROR) << "Touch HAL service failed to join thread pool.";
return 1;
}
ABinderProcess_joinThreadPool();
return EXIT_FAILURE; // should not reach
}

View File

@@ -0,0 +1,10 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>vendor.lineage.touch</name>
<version>1</version>
<interface>
<name>IHighTouchPollingRate</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

View File

@@ -0,0 +1,4 @@
service vendor.touch-hal /vendor/bin/hw/vendor.lineage.touch-service.xiaomi_sm8475
class hal
user system
group system

View File

@@ -1,11 +0,0 @@
#
# Copyright (C) 2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
#
service vendor.touch-hal-1-0 /vendor/bin/hw/vendor.lineage.touch@1.0-service.xiaomi_sm8475
interface vendor.lineage.touch@1.0::IHighTouchPollingRate default
class hal
user system
group system

View File

@@ -1,7 +0,0 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>vendor.lineage.touch</name>
<transport>hwbinder</transport>
<fqname>@1.0::IHighTouchPollingRate/default</fqname>
</hal>
</manifest>