touch: Implement opt-in IHighTouchPollingRate interface
Change-Id: Ia0b45caa224cc9fea38f9b4efacce3287f888baa
This commit is contained in:
@@ -26,6 +26,7 @@ cc_binary {
|
|||||||
vendor: true,
|
vendor: true,
|
||||||
relative_install_path: "hw",
|
relative_install_path: "hw",
|
||||||
srcs: [
|
srcs: [
|
||||||
|
"HighTouchPollingRate.cpp",
|
||||||
"TouchscreenGesture.cpp",
|
"TouchscreenGesture.cpp",
|
||||||
"service.cpp",
|
"service.cpp",
|
||||||
],
|
],
|
||||||
|
|||||||
51
hidl/touch/HighTouchPollingRate.cpp
Normal file
51
hidl/touch/HighTouchPollingRate.cpp
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LOG_TAG "vendor.lineage.touch@1.0-service.oplus"
|
||||||
|
|
||||||
|
#include "HighTouchPollingRate.h"
|
||||||
|
|
||||||
|
#include <android-base/file.h>
|
||||||
|
|
||||||
|
using ::android::base::ReadFileToString;
|
||||||
|
using ::android::base::WriteStringToFile;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr const char* kGameSwitchEnablePath = "/proc/touchpanel/game_switch_enable";
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
namespace vendor {
|
||||||
|
namespace lineage {
|
||||||
|
namespace touch {
|
||||||
|
namespace V1_0 {
|
||||||
|
namespace implementation {
|
||||||
|
|
||||||
|
Return<bool> HighTouchPollingRate::isEnabled() {
|
||||||
|
std::string value;
|
||||||
|
return ReadFileToString(kGameSwitchEnablePath, &value) && value[0] != '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<bool> HighTouchPollingRate::setEnabled(bool enabled) {
|
||||||
|
return WriteStringToFile(enabled ? "1" : "0", kGameSwitchEnablePath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace implementation
|
||||||
|
} // namespace V1_0
|
||||||
|
} // namespace touch
|
||||||
|
} // namespace lineage
|
||||||
|
} // namespace vendor
|
||||||
43
hidl/touch/HighTouchPollingRate.h
Normal file
43
hidl/touch/HighTouchPollingRate.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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/IHighTouchPollingRate.h>
|
||||||
|
|
||||||
|
namespace vendor {
|
||||||
|
namespace lineage {
|
||||||
|
namespace touch {
|
||||||
|
namespace V1_0 {
|
||||||
|
namespace implementation {
|
||||||
|
|
||||||
|
using ::android::hardware::Return;
|
||||||
|
using ::android::hardware::Void;
|
||||||
|
|
||||||
|
class HighTouchPollingRate : public IHighTouchPollingRate {
|
||||||
|
public:
|
||||||
|
// Methods from ::vendor::lineage::touch::V1_0::IHighTouchPollingRate follow.
|
||||||
|
Return<bool> isEnabled() override;
|
||||||
|
Return<bool> setEnabled(bool enabled) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace implementation
|
||||||
|
} // namespace V1_0
|
||||||
|
} // namespace touch
|
||||||
|
} // namespace lineage
|
||||||
|
} // namespace vendor
|
||||||
@@ -18,20 +18,28 @@
|
|||||||
|
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <hidl/HidlTransportSupport.h>
|
#include <hidl/HidlTransportSupport.h>
|
||||||
|
#include "HighTouchPollingRate.h"
|
||||||
#include "TouchscreenGesture.h"
|
#include "TouchscreenGesture.h"
|
||||||
|
|
||||||
using android::sp;
|
using android::sp;
|
||||||
using android::hardware::configureRpcThreadpool;
|
using android::hardware::configureRpcThreadpool;
|
||||||
using android::hardware::joinRpcThreadpool;
|
using android::hardware::joinRpcThreadpool;
|
||||||
|
|
||||||
|
using vendor::lineage::touch::V1_0::IHighTouchPollingRate;
|
||||||
using vendor::lineage::touch::V1_0::ITouchscreenGesture;
|
using vendor::lineage::touch::V1_0::ITouchscreenGesture;
|
||||||
|
using vendor::lineage::touch::V1_0::implementation::HighTouchPollingRate;
|
||||||
using vendor::lineage::touch::V1_0::implementation::TouchscreenGesture;
|
using vendor::lineage::touch::V1_0::implementation::TouchscreenGesture;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
sp<IHighTouchPollingRate> highToushPollingRateService = new HighTouchPollingRate();
|
||||||
sp<ITouchscreenGesture> gestureService = new TouchscreenGesture();
|
sp<ITouchscreenGesture> gestureService = new TouchscreenGesture();
|
||||||
|
|
||||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||||
|
|
||||||
|
if (highToushPollingRateService->registerAsService() != android::OK) {
|
||||||
|
LOG(WARNING) << "Can't register HighTouchPollingRate HAL service";
|
||||||
|
}
|
||||||
|
|
||||||
if (gestureService->registerAsService() != android::OK) {
|
if (gestureService->registerAsService() != android::OK) {
|
||||||
LOG(ERROR) << "Can't register TouchscreenGesture HAL service";
|
LOG(ERROR) << "Can't register TouchscreenGesture HAL service";
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user