tama-common: Move to touch AIDL

Change-Id: Ic31d3c29a31ece625de67db57de2b8a246b4c7a1
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
This commit is contained in:
Danny Trunk 2025-07-07 07:53:18 +02:00 • committed by aoitsme
commit 63cfbf969e
10 changed files with 67 additions and 80 deletions

View file

@ -431,7 +431,7 @@ PRODUCT_PACKAGES += \
# Touch
PRODUCT_PACKAGES += \
vendor.lineage.touch@1.0-service.tama
vendor.lineage.touch-service.tama
# USB
PRODUCT_PACKAGES += \

View file

@ -88,7 +88,7 @@
# Vendor HALs
/(vendor|system/vendor)/bin/hw/fpc_fingerprint@2\.1_HIDL-service u:object_r:hal_fingerprint_default_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch@1\.0-service\.tama u:object_r:hal_lineage_touch_default_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch-service\.tama u:object_r:hal_lineage_touch_default_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.semc\.hardware\.secd@1\.0-service u:object_r:hal_secd_default_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.semc\.system\.idd@1\.0-service u:object_r:hal_idd_default_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.somc\.hardware\.camera\.provider@1\.0-service u:object_r:hal_camera_default_exec:s0

View file

@ -1,13 +1,13 @@
//
// Copyright (C) 2021 The LineageOS Project
// SPDX-FileCopyrightText: 2025 The LineageOS Project
// SPDX-License-Identifier: Apache-2.0
//
cc_binary {
name: "vendor.lineage.touch@1.0-service.tama",
init_rc: ["vendor.lineage.touch@1.0-service.tama.rc"],
vintf_fragments: ["vendor.lineage.touch@1.0-service.tama.xml"],
defaults: ["hidl_defaults"],
name: "vendor.lineage.touch-service.tama",
init_rc: ["vendor.lineage.touch-service.tama.rc"],
vintf_fragments: ["vendor.lineage.touch-service.tama.xml"],
vendor: true,
relative_install_path: "hw",
srcs: [
"GloveMode.cpp",
@ -15,10 +15,9 @@ cc_binary {
],
shared_libs: [
"libbase",
"libbinder",
"libhidlbase",
"liblog",
"libbinder_ndk",
"libutils",
"vendor.lineage.touch@1.0",
"vendor.lineage.touch-V1-ndk",
],
vendor: true,
}

View file

@ -1,43 +1,51 @@
/*
* Copyright (C) 2021-2022 The LineageOS Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#define LOG_TAG "GloveModeService"
#include "GloveMode.h"
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <fstream>
namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
namespace implementation {
namespace {
const std::string kGloveModePath = "/sys/devices/common_touch/touch/glove_mode";
Return<bool> GloveMode::isEnabled() {
} // anonymous namespace
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
ndk::ScopedAStatus GloveMode::getEnabled(bool* _aidl_return) {
std::ifstream file(kGloveModePath);
if (file.fail()) {
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
bool enabled;
file >> enabled;
return enabled;
*_aidl_return = enabled;
return ndk::ScopedAStatus::ok();
}
Return<bool> GloveMode::setEnabled(bool enabled) {
ndk::ScopedAStatus GloveMode::setEnabled(bool enable) {
std::ofstream file(kGloveModePath);
file << enabled << std::flush;
if (file.fail()) {
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
return !file.fail();
file << enable << std::flush;
return ndk::ScopedAStatus::ok();
}
} // namespace implementation
} // namespace V1_0
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace aidl

View file

@ -1,29 +1,24 @@
/*
* Copyright (C) 2021 The LineageOS Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <vendor/lineage/touch/1.0/IGloveMode.h>
#include <aidl/vendor/lineage/touch/BnGloveMode.h>
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
namespace implementation {
using ::android::hardware::Return;
class GloveMode : public IGloveMode {
class GloveMode : public BnGloveMode {
public:
// Methods from ::vendor::lineage::touch::V1_0::IGloveMode 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 aidl

View file

@ -1,32 +1,27 @@
/*
* Copyright (C) 2021 The LineageOS Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#define LOG_TAG "vendor.lineage.touch@1.0-service.tama"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#define LOG_TAG "vendor.lineage.touch-service.tama"
#include "GloveMode.h"
using ::vendor::lineage::touch::V1_0::IGloveMode;
using ::vendor::lineage::touch::V1_0::implementation::GloveMode;
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
using aidl::vendor::lineage::touch::GloveMode;
int main() {
android::sp<IGloveMode> gloveMode = new GloveMode();
ABinderProcess_setThreadPoolMaxThreadCount(0);
std::shared_ptr<GloveMode> glovemode = ndk::SharedRefBase::make<GloveMode>();
android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/);
const std::string instance = std::string(GloveMode::descriptor) + "/default";
binder_status_t status =
AServiceManager_addService(glovemode->asBinder().get(), instance.c_str());
CHECK_EQ(status, STATUS_OK) << "Failed to add service " << instance << " " << status;
if (gloveMode->registerAsService() != android::OK) {
LOG(ERROR) << "Cannot register touchscreen glove HAL service.";
return 1;
}
LOG(INFO) << "Touchscreen HAL service ready.";
android::hardware::joinRpcThreadpool();
LOG(ERROR) << "Touchscreen HAL service failed to join thread pool.";
return 1;
ABinderProcess_joinThreadPool();
return EXIT_FAILURE; // should not reach
}

View file

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

View file

@ -0,0 +1,7 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>vendor.lineage.touch</name>
<version>1</version>
<fqname>IGloveMode/default</fqname>
</hal>
</manifest>

View file

@ -1,10 +0,0 @@
#
# Copyright (C) 2021-2022 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
#
service vendor.touch-hal-1-0 /vendor/bin/hw/vendor.lineage.touch@1.0-service.tama
class hal
user system
group system

View file

@ -1,11 +0,0 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>vendor.lineage.touch</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IGloveMode</name>
<instance>default</instance>
</interface>
</hal>
</manifest>