Change-Id: I667f7a260e2ef1db24cbaa804897cf28a0cec9datirimbino
parent
7738899323
commit
ea008a5a7e
@ -0,0 +1,5 @@ |
|||||||
|
# hal_lineage_touch_default.te |
||||||
|
|
||||||
|
allow hal_lineage_touch_default sysfs_sec_touchscreen:dir search; |
||||||
|
allow hal_lineage_touch_default sysfs_sec_touchscreen:file r_file_perms; |
||||||
|
allow hal_lineage_touch_default sysfs_touchscreen_writable:file rw_file_perms; |
@ -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", |
||||||
|
], |
||||||
|
} |
@ -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 <fstream> |
||||||
|
|
||||||
|
#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<bool> 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<bool> 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
|
@ -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 <hidl/MQDescriptor.h> |
||||||
|
#include <hidl/Status.h> |
||||||
|
#include <vendor/lineage/touch/1.0/IGloveMode.h> |
||||||
|
#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<bool> isEnabled() override; |
||||||
|
Return<bool> setEnabled(bool enabled) override; |
||||||
|
|
||||||
|
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace samsung
|
||||||
|
} // namespace V1_0
|
||||||
|
} // namespace touch
|
||||||
|
} // namespace lineage
|
||||||
|
} // namespace vendor
|
@ -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 <fstream> |
||||||
|
|
||||||
|
#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<int32_t, TouchscreenGesture::GestureInfo> 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<void> TouchscreenGesture::getSupportedGestures(getSupportedGestures_cb resultCb) { |
||||||
|
std::vector<Gesture> gestures; |
||||||
|
|
||||||
|
for (const auto& entry : kGestureInfoMap) { |
||||||
|
gestures.push_back({entry.first, entry.second.name, entry.second.keycode}); |
||||||
|
} |
||||||
|
resultCb(gestures); |
||||||
|
|
||||||
|
return Void(); |
||||||
|
} |
||||||
|
|
||||||
|
Return<bool> 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
|
@ -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 <hidl/MQDescriptor.h> |
||||||
|
#include <hidl/Status.h> |
||||||
|
#include <vendor/lineage/touch/1.0/ITouchscreenGesture.h> |
||||||
|
#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<void> getSupportedGestures(getSupportedGestures_cb resultCb) override; |
||||||
|
Return<bool> 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<int32_t, GestureInfo> 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
|
@ -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
|
@ -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 <android-base/logging.h> |
||||||
|
#include <binder/ProcessState.h> |
||||||
|
#include <hidl/HidlTransportSupport.h> |
||||||
|
|
||||||
|
#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> gloveMode; |
||||||
|
sp<TouchscreenGesture> 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; |
||||||
|
} |
@ -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 |
Loading…
Reference in new issue