sdm845-common: Replace lineagehw implementation by HIDL services

Move DisplayModeControl and SunlightEnhancement into a livedisplay
service, and TouchscreenGestures into a touch one.

Change-Id: I5f46671633a13ddc6733a47f4ea5a6515d6d6c98
This commit is contained in:
Danny Baumann
2019-01-22 14:15:40 +01:00
committed by Luca Stefani
parent eaa9bbce92
commit e3ee15e8af
29 changed files with 702 additions and 356 deletions

11
touch/.clang-format Normal file
View File

@@ -0,0 +1,11 @@
BasedOnStyle: Google
AccessModifierOffset: -2
AllowShortFunctionsOnASingleLine: Inline
ColumnLimit: 100
CommentPragmas: NOLINT:.*
DerivePointerAlignment: false
IndentWidth: 4
PointerAlignment: Left
TabWidth: 4
UseTab: Never
PenaltyExcessCharacter: 32

33
touch/Android.bp Normal file
View File

@@ -0,0 +1,33 @@
//
// 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: "lineage.touch@1.0-service.oneplus_sdm845",
init_rc: ["lineage.touch@1.0-service.oneplus_sdm845.rc"],
defaults: ["hidl_defaults"],
relative_install_path: "hw",
srcs: [
"TouchscreenGesture.cpp",
"service.cpp",
],
shared_libs: [
"libbase",
"libbinder",
"libhidlbase",
"libhidltransport",
"libutils",
"vendor.lineage.touch@1.0",
],
}

View File

@@ -0,0 +1,73 @@
/*
* 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 "TouchscreenGestureService"
#include "TouchscreenGesture.h"
#include <android-base/logging.h>
#include <fstream>
namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
namespace implementation {
const std::map<int32_t, TouchscreenGesture::GestureInfo> TouchscreenGesture::kGestureInfoMap = {
{0, {251, "Two fingers down swipe", "/proc/touchpanel/double_swipe_enable"}},
{1, {252, "Up arrow", "/proc/touchpanel/up_arrow_enable"}},
{2, {254, "Right arrow", "/proc/touchpanel/right_arrow_enable"}},
{3, {255, "Down arrow", "/proc/touchpanel/down_arrow_enable"}},
{4, {253, "Left arrow", "/proc/touchpanel/left_arrow_enable"}},
{5, {66, "One finger up swipe", "/proc/touchpanel/up_swipe_enable"}},
{6, {65, "One finger right swipe", "/proc/touchpanel/right_swipe_enable"}},
{7, {64, "One finger down swipe", "/proc/touchpanel/down_swipe_enable"}},
{8, {63, "One finger left swipe", "/proc/touchpanel/left_swipe_enable"}},
{9, {247, "Letter M", "/proc/touchpanel/letter_m_enable"}},
{10, {250, "Letter O", "/proc/touchpanel/letter_o_enable"}},
{11, {248, "Letter S", "/proc/touchpanel/letter_s_enable"}},
{12, {246, "Letter W", "/proc/touchpanel/letter_w_enable"}},
};
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& gesture, bool enabled) {
const auto entry = kGestureInfoMap.find(gesture.id);
if (entry == kGestureInfoMap.end()) {
return false;
}
std::ofstream file(entry->second.path);
file << (enabled ? "1" : "0");
LOG(DEBUG) << "Wrote file " << entry->second.path << " fail " << file.fail();
return !file.fail();
}
} // namespace implementation
} // namespace V1_0
} // namespace touch
} // namespace lineage
} // namespace vendor

View File

@@ -0,0 +1,57 @@
/*
* 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.
*/
#ifndef VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H
#define VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/lineage/touch/1.0/ITouchscreenGesture.h>
#include <map>
namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
namespace implementation {
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
class TouchscreenGesture : public ITouchscreenGesture {
public:
// 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;
const char* path;
} GestureInfo;
static const std::map<int32_t, GestureInfo> kGestureInfoMap; // id -> info
};
} // namespace implementation
} // namespace V1_0
} // namespace touch
} // namespace lineage
} // namespace vendor
#endif // VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H

View File

@@ -0,0 +1,32 @@
on boot
chmod 0660 /proc/touchpanel/double_swipe_enable
chmod 0660 /proc/touchpanel/down_arrow_enable
chmod 0660 /proc/touchpanel/down_swipe_enable
chmod 0660 /proc/touchpanel/left_arrow_enable
chmod 0660 /proc/touchpanel/left_swipe_enable
chmod 0660 /proc/touchpanel/letter_m_enable
chmod 0660 /proc/touchpanel/letter_o_enable
chmod 0660 /proc/touchpanel/letter_s_enable
chmod 0660 /proc/touchpanel/letter_w_enable
chmod 0660 /proc/touchpanel/right_arrow_enable
chmod 0660 /proc/touchpanel/right_swipe_enable
chmod 0660 /proc/touchpanel/up_arrow_enable
chmod 0660 /proc/touchpanel/up_swipe_enable
chown system system /proc/touchpanel/double_swipe_enable
chown system system /proc/touchpanel/down_arrow_enable
chown system system /proc/touchpanel/down_swipe_enable
chown system system /proc/touchpanel/left_arrow_enable
chown system system /proc/touchpanel/left_swipe_enable
chown system system /proc/touchpanel/letter_m_enable
chown system system /proc/touchpanel/letter_o_enable
chown system system /proc/touchpanel/letter_s_enable
chown system system /proc/touchpanel/letter_w_enable
chown system system /proc/touchpanel/right_arrow_enable
chown system system /proc/touchpanel/right_swipe_enable
chown system system /proc/touchpanel/up_arrow_enable
chown system system /proc/touchpanel/up_swipe_enable
service touch-hal-1-0 /system/bin/hw/lineage.touch@1.0-service.oneplus_sdm845
class hal
user system
group system

43
touch/service.cpp Normal file
View File

@@ -0,0 +1,43 @@
/*
* 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 "lineage.touch@1.0-service.oneplus_sdm845"
#include <android-base/logging.h>
#include <binder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>
#include "TouchscreenGesture.h"
using ::vendor::lineage::touch::V1_0::ITouchscreenGesture;
using ::vendor::lineage::touch::V1_0::implementation::TouchscreenGesture;
int main() {
android::sp<ITouchscreenGesture> gestureService = new TouchscreenGesture();
android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/);
if (gestureService->registerAsService() != android::OK) {
LOG(ERROR) << "Cannot register touchscreen gesture 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;
}