diff --git a/common.mk b/common.mk
index d782bb7..111fa95 100644
--- a/common.mk
+++ b/common.mk
@@ -387,7 +387,7 @@ PRODUCT_PACKAGES += \
# Touch features
PRODUCT_PACKAGES += \
- vendor.lineage.touch@1.0-service.samsung
+ vendor.lineage.touch@1.0-service.sm7125
# Trust HAL
PRODUCT_PACKAGES += \
diff --git a/configs/manifest.xml b/configs/manifest.xml
index 1a73008..eb2bc59 100644
--- a/configs/manifest.xml
+++ b/configs/manifest.xml
@@ -311,6 +311,10 @@
IGloveMode
default
+
+ ITouchscreenGesture
+ default
+
vendor.qti.hardware.radio.am
diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts
index 39f377f..56d79df 100644
--- a/sepolicy/vendor/file_contexts
+++ b/sepolicy/vendor/file_contexts
@@ -57,7 +57,7 @@
/(vendor|system/vendor)/bin/hw/android\.hardware\.power(@[0-9]\.[0-9])?-service\.samsung-libperfmgr u:object_r:hal_power_default_exec:s0
/(vendor|system/vendor)/bin/hw/android\.hardware\.nfc@[0-9]\.[0-9]-service\.samsung u:object_r:hal_nfc_default_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.fastcharge@[0-9]\.[0-9]-service\.samsung u:object_r:hal_lineage_fastcharge_default_exec:s0
-/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch\@[0-9]\.[0-9]-service.samsung u:object_r:hal_lineage_touch_default_exec:s0
+/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch\@[0-9]\.[0-9]-service.sm7125 u:object_r:hal_lineage_touch_default_exec:s0
/(vendor|system/vendor)/bin/secril_config_svc u:object_r:secril_config_svc_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.0-service.samsung-qcom\.sm7125 u:object_r:hal_lineage_livedisplay_sysfs_exec:s0
/(vendor|system/vendor)/bin/hw/android.hardware.biometrics.fingerprint@2.3-service-samsung.sm7125 u:object_r:hal_fingerprint_default_exec:s0
diff --git a/touch/Android.bp b/touch/Android.bp
new file mode 100644
index 0000000..c9b541e
--- /dev/null
+++ b/touch/Android.bp
@@ -0,0 +1,36 @@
+// Copyright (C) 2019 The LineageOS Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_binary {
+ name: "vendor.lineage.touch@1.0-service.sm7125",
+ init_rc: ["vendor.lineage.touch@1.0-service.sm7125.rc"],
+ defaults: ["hidl_defaults"],
+ relative_install_path: "hw",
+ // FIXME: this should be 'vendor: true' for modules that will eventually be
+ // on AOSP.
+ proprietary: true,
+ local_include_dirs: ["include"],
+ srcs: [
+ "GloveMode.cpp",
+ "TouchscreenGesture.cpp",
+ "service.cpp"
+ ],
+ shared_libs: [
+ "libbase",
+ "libbinder",
+ "libhidlbase",
+ "libutils",
+ "vendor.lineage.touch@1.0",
+ ],
+}
diff --git a/touch/GloveMode.cpp b/touch/GloveMode.cpp
new file mode 100644
index 0000000..124bca9
--- /dev/null
+++ b/touch/GloveMode.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+
+#include "GloveMode.h"
+
+namespace vendor {
+namespace lineage {
+namespace touch {
+namespace V1_0 {
+namespace samsung {
+
+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;
+}
+
+// Methods from ::vendor::lineage::touch::V1_0::IGloveMode follow.
+Return GloveMode::isEnabled() {
+ std::ifstream file(TSP_CMD_RESULT_NODE);
+ if (file.is_open()) {
+ std::string line;
+ getline(file, line);
+ if (!line.compare("glove_mode,1:OK")) return true;
+ file.close();
+ }
+ return false;
+}
+
+Return GloveMode::setEnabled(bool enabled) {
+ std::ofstream file(TSP_CMD_NODE);
+ file << "glove_mode," << (enabled ? "1" : "0");
+ return true;
+}
+
+} // namespace samsung
+} // namespace V1_0
+} // namespace touch
+} // namespace lineage
+} // namespace vendor
diff --git a/touch/GloveMode.h b/touch/GloveMode.h
new file mode 100644
index 0000000..08fe4a7
--- /dev/null
+++ b/touch/GloveMode.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2019-2022 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include
+#include
+#include
+#include "samsung_touch.h"
+
+namespace vendor {
+namespace lineage {
+namespace touch {
+namespace V1_0 {
+namespace samsung {
+
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+class GloveMode : public IGloveMode {
+ public:
+ GloveMode() = default;
+
+ bool isSupported();
+
+ // Methods from ::vendor::lineage::touch::V1_0::IGloveMode follow.
+ Return isEnabled() override;
+ Return setEnabled(bool enabled) override;
+
+ // Methods from ::android::hidl::base::V1_0::IBase follow.
+};
+
+} // namespace samsung
+} // namespace V1_0
+} // namespace touch
+} // namespace lineage
+} // namespace vendor
diff --git a/touch/TouchscreenGesture.cpp b/touch/TouchscreenGesture.cpp
new file mode 100644
index 0000000..ef1f1d3
--- /dev/null
+++ b/touch/TouchscreenGesture.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+
+#include "TouchscreenGesture.h"
+
+namespace vendor {
+namespace lineage {
+namespace touch {
+namespace V1_0 {
+namespace samsung {
+
+static constexpr const char* kTspPath = TSP_CMD_NODE;
+
+const std::map TouchscreenGesture::kGestureInfoMap = {
+ // clang-format off
+ {0, {0x1c7, "Single Tap"}},
+ // clang-format on
+};
+
+bool TouchscreenGesture::isSupported() {
+ std::ifstream file(kTspPath);
+ return file.good();
+}
+
+// Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow.
+Return TouchscreenGesture::getSupportedGestures(getSupportedGestures_cb resultCb) {
+ std::vector gestures;
+
+ for (const auto& entry : kGestureInfoMap) {
+ gestures.push_back({entry.first, entry.second.name, entry.second.keycode});
+ }
+ resultCb(gestures);
+
+ return Void();
+}
+
+Return TouchscreenGesture::setGestureEnabled(
+ const ::vendor::lineage::touch::V1_0::Gesture&, bool enabled) {
+ std::fstream file(kTspPath);
+
+ file << "singletap_enable," << (enabled ? "1" : "0");
+
+ return !file.fail();
+}
+
+// Methods from ::android::hidl::base::V1_0::IBase follow.
+
+} // namespace samsung
+} // namespace V1_0
+} // namespace touch
+} // namespace lineage
+} // namespace vendor
diff --git a/touch/TouchscreenGesture.h b/touch/TouchscreenGesture.h
new file mode 100644
index 0000000..28bf9c8
--- /dev/null
+++ b/touch/TouchscreenGesture.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019-2022 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include
+#include
+#include
+#include "samsung_touch.h"
+
+namespace vendor {
+namespace lineage {
+namespace touch {
+namespace V1_0 {
+namespace samsung {
+
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+class TouchscreenGesture : public ITouchscreenGesture {
+ public:
+ bool isSupported();
+
+ // Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow.
+ Return getSupportedGestures(getSupportedGestures_cb resultCb) override;
+ Return setGestureEnabled(const ::vendor::lineage::touch::V1_0::Gesture& gesture,
+ bool enabled) override;
+
+ private:
+ typedef struct {
+ int32_t keycode;
+ const char* name;
+ } GestureInfo;
+ static const std::map kGestureInfoMap; // id -> info
+};
+
+// FIXME: most likely delete, this is only for passthrough implementations
+// extern "C" ITouchscreenGesture* HIDL_FETCH_ITouchscreenGesture(const char* name);
+
+} // namespace samsung
+} // namespace V1_0
+} // namespace touch
+} // namespace lineage
+} // namespace vendor
diff --git a/touch/include/samsung_touch.h b/touch/include/samsung_touch.h
new file mode 100644
index 0000000..2070743
--- /dev/null
+++ b/touch/include/samsung_touch.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SAMSUNG_TOUCH_H
+#define SAMSUNG_TOUCH_H
+
+/*
+ * 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"
+
+#endif // SAMSUNG_TOUCH_H
diff --git a/touch/service.cpp b/touch/service.cpp
new file mode 100644
index 0000000..3b9a5e7
--- /dev/null
+++ b/touch/service.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "vendor.lineage.touch@1.0-service.samsung"
+
+#include
+#include
+#include
+
+#include "GloveMode.h"
+#include "TouchscreenGesture.h"
+
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+using android::sp;
+using android::status_t;
+using android::OK;
+
+using ::vendor::lineage::touch::V1_0::samsung::GloveMode;
+using ::vendor::lineage::touch::V1_0::samsung::TouchscreenGesture;
+
+int main() {
+ sp gloveMode;
+ sp touchscreenGesture;
+ status_t status;
+
+ LOG(INFO) << "Touch HAL service is starting.";
+
+ gloveMode = new GloveMode();
+ if (gloveMode == nullptr) {
+ LOG(ERROR) << "Can not create an instance of Touch HAL GloveMode Iface, exiting.";
+ goto shutdown;
+ }
+
+ touchscreenGesture = new TouchscreenGesture();
+ if (touchscreenGesture == nullptr) {
+ LOG(ERROR) << "Can not create an instance of Touch HAL TouchscreenGesture Iface, exiting.";
+ goto shutdown;
+ }
+
+ configureRpcThreadpool(1, true /*callerWillJoin*/);
+
+ if (gloveMode->isSupported()) {
+ status = gloveMode->registerAsService();
+ if (status != OK) {
+ LOG(ERROR) << "Could not register service for Touch HAL GloveMode Iface (" << status
+ << ")";
+ goto shutdown;
+ }
+ }
+
+ if (touchscreenGesture->isSupported()) {
+ status = touchscreenGesture->registerAsService();
+ if (status != OK) {
+ LOG(ERROR) << "Could not register service for Touch HAL TouchscreenGesture Iface ("
+ << status << ")";
+ goto shutdown;
+ }
+ }
+
+ LOG(INFO) << "Touch HAL service is ready.";
+ joinRpcThreadpool();
+// Should not pass this line
+
+shutdown:
+ // In normal operation, we don't expect the thread pool to shutdown
+ LOG(ERROR) << "Touch HAL service is shutting down.";
+ return 1;
+}
diff --git a/touch/vendor.lineage.touch@1.0-service.sm7125.rc b/touch/vendor.lineage.touch@1.0-service.sm7125.rc
new file mode 100644
index 0000000..50fe9d8
--- /dev/null
+++ b/touch/vendor.lineage.touch@1.0-service.sm7125.rc
@@ -0,0 +1,4 @@
+service vendor.touch-hal-1-0 /vendor/bin/hw/vendor.lineage.touch@1.0-service.sm7125
+ class hal
+ user system
+ group system