From 651dde32ef84273c0e320ae8735f2ca94ecd4864 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Sun, 31 Aug 2025 00:28:47 +0100 Subject: [PATCH] a71-common: Move to Samsung common Touch HAL Change-Id: I5c4de6e4956e316600e327b725b863ddf9e63fc1 --- Android.bp | 3 +- common.mk | 2 +- include/samsung_touch.h | 19 ------- manifest.xml | 16 ++++++ sepolicy/vendor/file_contexts | 2 +- touch/Android.bp | 27 ---------- touch/GloveMode.cpp | 49 ----------------- touch/GloveMode.h | 27 ---------- touch/HighTouchPollingRate.cpp | 49 ----------------- touch/HighTouchPollingRate.h | 27 ---------- touch/TouchscreenGesture.cpp | 54 ------------------- touch/TouchscreenGesture.h | 35 ------------ touch/service.cpp | 48 ----------------- ...or.lineage.touch-service.samsung_sm6150.rc | 8 --- ...r.lineage.touch-service.samsung_sm6150.xml | 18 ------- 15 files changed, 19 insertions(+), 365 deletions(-) delete mode 100644 include/samsung_touch.h delete mode 100644 touch/Android.bp delete mode 100644 touch/GloveMode.cpp delete mode 100644 touch/GloveMode.h delete mode 100644 touch/HighTouchPollingRate.cpp delete mode 100644 touch/HighTouchPollingRate.h delete mode 100644 touch/TouchscreenGesture.cpp delete mode 100644 touch/TouchscreenGesture.h delete mode 100644 touch/service.cpp delete mode 100644 touch/vendor.lineage.touch-service.samsung_sm6150.rc delete mode 100644 touch/vendor.lineage.touch-service.samsung_sm6150.xml diff --git a/Android.bp b/Android.bp index 3fb95f8..e18254c 100644 --- a/Android.bp +++ b/Android.bp @@ -1,5 +1,5 @@ // -// Copyright (C) 2024 The LineageOS Project +// Copyright (C) 2024-2025 The LineageOS Project // // SPDX-License-Identifier: Apache-2.0 // @@ -7,7 +7,6 @@ soong_namespace { imports: [ "hardware/qcom-caf/common/libqti-perfd-client", - "hardware/samsung", ], } diff --git a/common.mk b/common.mk index fe30c4a..6cd88a2 100644 --- a/common.mk +++ b/common.mk @@ -393,7 +393,7 @@ PRODUCT_BOOT_JARS += \ # Touch PRODUCT_PACKAGES += \ - vendor.lineage.touch-service.samsung_sm6150 \ + vendor.lineage.touch-service.samsung \ # USB PRODUCT_PACKAGES += \ diff --git a/include/samsung_touch.h b/include/samsung_touch.h deleted file mode 100644 index 18de7d2..0000000 --- a/include/samsung_touch.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024-2025 The LineageOS Project - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -/* - * Board specific nodes - * - * If your kernel exposes these controls in another place, you can either - * symlink to the locations given here, or override this header in your - * device tree. - */ - -// For GloveMode -#define TSP_CMD_LIST_NODE "/sys/class/sec/tsp/cmd_list" -#define TSP_CMD_RESULT_NODE "/sys/class/sec/tsp/cmd_result" -#define TSP_CMD_NODE "/sys/class/sec/tsp/cmd" diff --git a/manifest.xml b/manifest.xml index 2c60a69..e72ebcf 100755 --- a/manifest.xml +++ b/manifest.xml @@ -158,6 +158,22 @@ com.qualcomm.qti.uceservice hwbinder + + vendor.lineage.touch + 1 + + IGloveMode + default + + + IHighTouchPollingRate + default + + + ITouchscreenGesture + default + + vendor.display.color hwbinder diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 472a894..1b0d7ed 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -188,7 +188,7 @@ /(vendor|system/vendor)/bin/hw/macloader u:object_r:macloader_exec:s0 /(vendor|system/vendor)/bin/hw/sehradiomanager u:object_r:sehradiomanager_exec:s0 /(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.0-service.samsung-qcom\.sm6150 u:object_r:hal_lineage_livedisplay_sysfs_exec:s0 -/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch-service\.samsung_sm6150 u:object_r:hal_lineage_touch_default_exec:s0 +/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch-service\.samsung u:object_r:hal_lineage_touch_default_exec:s0 /(vendor|system/vendor)/bin/factory\.ssc u:object_r:factory_ssc_exec:s0 /(vendor|system/vendor)/bin/secril_config_svc u:object_r:secril_config_svc_exec:s0 /vendor/lib(/.*)? u:object_r:same_process_hal_file:s0 diff --git a/touch/Android.bp b/touch/Android.bp deleted file mode 100644 index 5fd2aec..0000000 --- a/touch/Android.bp +++ /dev/null @@ -1,27 +0,0 @@ -// -// Copyright (C) 2024-2025 The LineageOS Project -// -// SPDX-License-Identifier: Apache-2.0 -// - -cc_binary { - name: "vendor.lineage.touch-service.samsung_sm6150", - init_rc: ["vendor.lineage.touch-service.samsung_sm6150.rc"], - vintf_fragments: ["vendor.lineage.touch-service.samsung_sm6150.xml"], - defaults: ["samsung_header_path_defaults"], - relative_install_path: "hw", - proprietary: true, - srcs: [ - "GloveMode.cpp", - "HighTouchPollingRate.cpp", - "TouchscreenGesture.cpp", - "service.cpp" - ], - shared_libs: [ - "libbase", - "liblog", - "libbinder_ndk", - "libutils", - "vendor.lineage.touch-V1-ndk", - ], -} diff --git a/touch/GloveMode.cpp b/touch/GloveMode.cpp deleted file mode 100644 index 369cfe0..0000000 --- a/touch/GloveMode.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2025 The LineageOS Project - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -#include "GloveMode.h" - -namespace aidl { -namespace vendor { -namespace lineage { -namespace touch { - -bool GloveMode::isSupported() { - std::ifstream file(TSP_CMD_LIST_NODE); - if (file.is_open()) { - std::string line; - while (getline(file, line)) { - if (!line.compare("glove_mode")) return true; - } - file.close(); - } - return false; -} - -ndk::ScopedAStatus GloveMode::getEnabled(bool* _aidl_return) { - std::ifstream file(TSP_CMD_RESULT_NODE); - if (file.is_open()) { - std::string line; - getline(file, line); - *_aidl_return = !line.compare("glove_mode,1:OK"); - file.close(); - } - - return ndk::ScopedAStatus::ok(); -} - -ndk::ScopedAStatus GloveMode::setEnabled(bool enabled) { - std::ofstream file(TSP_CMD_NODE); - file << "glove_mode," << (enabled ? "1" : "0"); - - return ndk::ScopedAStatus::ok(); -} - -} // namespace touch -} // namespace lineage -} // namespace vendor -} // namespace aidl diff --git a/touch/GloveMode.h b/touch/GloveMode.h deleted file mode 100644 index 5799b19..0000000 --- a/touch/GloveMode.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2025 The LineageOS Project - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -#include - -namespace aidl { -namespace vendor { -namespace lineage { -namespace touch { - -class GloveMode : public BnGloveMode { - public: - bool isSupported(); - - ndk::ScopedAStatus getEnabled(bool* _aidl_return) override; - ndk::ScopedAStatus setEnabled(bool enabled) override; -}; - -} // namespace touch -} // namespace lineage -} // namespace vendor -} // namespace aidl diff --git a/touch/HighTouchPollingRate.cpp b/touch/HighTouchPollingRate.cpp deleted file mode 100644 index 23831e6..0000000 --- a/touch/HighTouchPollingRate.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2025 The LineageOS Project - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -#include "HighTouchPollingRate.h" - -namespace aidl { -namespace vendor { -namespace lineage { -namespace touch { - -bool HighTouchPollingRate::isSupported() { - std::ifstream file(TSP_CMD_LIST_NODE); - if (file.is_open()) { - std::string line; - while (getline(file, line)) { - if (!line.compare("set_game_mode")) return true; - } - file.close(); - } - return false; -} - -ndk::ScopedAStatus HighTouchPollingRate::getEnabled(bool* _aidl_return) { - std::ifstream file(TSP_CMD_RESULT_NODE); - if (file.is_open()) { - std::string line; - getline(file, line); - *_aidl_return = !line.compare("set_game_mode,1:OK"); - file.close(); - } - - return ndk::ScopedAStatus::ok(); -} - -ndk::ScopedAStatus HighTouchPollingRate::setEnabled(bool enabled) { - std::ofstream file(TSP_CMD_NODE); - file << "set_game_mode," << (enabled ? "1" : "0"); - - return ndk::ScopedAStatus::ok(); -} - -} // namespace touch -} // namespace lineage -} // namespace vendor -} // namespace aidl diff --git a/touch/HighTouchPollingRate.h b/touch/HighTouchPollingRate.h deleted file mode 100644 index 7d9e869..0000000 --- a/touch/HighTouchPollingRate.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2025 The LineageOS Project - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -#include - -namespace aidl { -namespace vendor { -namespace lineage { -namespace touch { - -class HighTouchPollingRate : public BnHighTouchPollingRate { - public: - bool isSupported(); - - ndk::ScopedAStatus getEnabled(bool* _aidl_return) override; - ndk::ScopedAStatus setEnabled(bool enabled) override; -}; - -} // namespace touch -} // namespace lineage -} // namespace vendor -} // namespace aidl diff --git a/touch/TouchscreenGesture.cpp b/touch/TouchscreenGesture.cpp deleted file mode 100644 index 796f28f..0000000 --- a/touch/TouchscreenGesture.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2025 The LineageOS Project - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -#include "TouchscreenGesture.h" - -namespace aidl { -namespace vendor { -namespace lineage { -namespace touch { - -const std::map TouchscreenGesture::kGestureInfoMap = { - // clang-format off - {0, {0x1c7, "Single Tap"}}, - // clang-format on -}; - -bool TouchscreenGesture::isSupported() { - std::ifstream file(TSP_CMD_LIST_NODE); - if (file.is_open()) { - std::string line; - while (getline(file, line)) { - if (!line.compare("singletap_enable")) return true; - } - file.close(); - } - return false; -} - -ndk::ScopedAStatus TouchscreenGesture::getSupportedGestures(std::vector* _aidl_return) { - std::vector gestures; - - for (const auto& entry : kGestureInfoMap) { - gestures.push_back({entry.first, entry.second.name, entry.second.keycode}); - } - - *_aidl_return = gestures; - return ndk::ScopedAStatus::ok(); -} - -ndk::ScopedAStatus TouchscreenGesture::setGestureEnabled(const Gesture& gesture, bool enabled) { - std::ofstream file(TSP_CMD_NODE); - file << "singletap_enable," << (enabled ? "1" : "0"); - - return ndk::ScopedAStatus::ok(); -} - -} // namespace touch -} // namespace lineage -} // namespace vendor -} // namespace aidl diff --git a/touch/TouchscreenGesture.h b/touch/TouchscreenGesture.h deleted file mode 100644 index 31c2f3d..0000000 --- a/touch/TouchscreenGesture.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2025 The LineageOS Project - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -#include -#include - -namespace aidl { -namespace vendor { -namespace lineage { -namespace touch { - -class TouchscreenGesture : public BnTouchscreenGesture { - public: - bool isSupported(); - - ndk::ScopedAStatus getSupportedGestures(std::vector* _aidl_return) override; - ndk::ScopedAStatus setGestureEnabled(const Gesture& gesture, bool enabled) override; - - private: - typedef struct { - int32_t keycode; - const char* name; - } GestureInfo; - static const std::map kGestureInfoMap; // id -> info -}; - -} // namespace touch -} // namespace lineage -} // namespace vendor -} // namespace aidl diff --git a/touch/service.cpp b/touch/service.cpp deleted file mode 100644 index 16ff902..0000000 --- a/touch/service.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2025 The LineageOS Project - * SPDX-License-Identifier: Apache-2.0 - */ - -#define LOG_TAG "vendor.lineage.touch-service.samsung_sm6150" - -#include "GloveMode.h" -#include "HighTouchPollingRate.h" -#include "TouchscreenGesture.h" - -#include -#include -#include - -using aidl::vendor::lineage::touch::GloveMode; -using aidl::vendor::lineage::touch::HighTouchPollingRate; -using aidl::vendor::lineage::touch::TouchscreenGesture; - -int main() { - binder_status_t status = STATUS_OK; - - ABinderProcess_setThreadPoolMaxThreadCount(0); - - std::shared_ptr gm = ndk::SharedRefBase::make(); - if (gm->isSupported()) { - const std::string gm_instance = std::string(GloveMode::descriptor) + "/default"; - status = AServiceManager_addService(gm->asBinder().get(), gm_instance.c_str()); - CHECK_EQ(status, STATUS_OK) << "Failed to add service " << gm_instance << " " << status; - } - - std::shared_ptr htpr = ndk::SharedRefBase::make(); - if (htpr->isSupported()) { - 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; - } - - std::shared_ptr tg = ndk::SharedRefBase::make(); - if (tg->isSupported()) { - const std::string tg_instance = std::string(TouchscreenGesture::descriptor) + "/default"; - status = AServiceManager_addService(tg->asBinder().get(), tg_instance.c_str()); - CHECK_EQ(status, STATUS_OK) << "Failed to add service " << tg_instance << " " << status; - } - - ABinderProcess_joinThreadPool(); - return EXIT_FAILURE; // should not reach -} diff --git a/touch/vendor.lineage.touch-service.samsung_sm6150.rc b/touch/vendor.lineage.touch-service.samsung_sm6150.rc deleted file mode 100644 index f62009d..0000000 --- a/touch/vendor.lineage.touch-service.samsung_sm6150.rc +++ /dev/null @@ -1,8 +0,0 @@ -on early-init - chown system radio /sys/class/sec/tsp/cmd - chmod 0664 /sys/class/sec/tsp/cmd - -service vendor.touch-hal /vendor/bin/hw/vendor.lineage.touch-service.samsung_sm6150 - class hal - user system - group system diff --git a/touch/vendor.lineage.touch-service.samsung_sm6150.xml b/touch/vendor.lineage.touch-service.samsung_sm6150.xml deleted file mode 100644 index c84cd86..0000000 --- a/touch/vendor.lineage.touch-service.samsung_sm6150.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - vendor.lineage.touch - 1 - - IGloveMode - default - - - IHighTouchPollingRate - default - - - ITouchscreenGesture - default - - -