diff --git a/hidl/touch/Android.bp b/hidl/touch/Android.bp index 8137c84..a64ad51 100644 --- a/hidl/touch/Android.bp +++ b/hidl/touch/Android.bp @@ -26,6 +26,7 @@ cc_binary { vendor: true, relative_install_path: "hw", srcs: [ + "HighTouchPollingRate.cpp", "TouchscreenGesture.cpp", "service.cpp", ], diff --git a/hidl/touch/HighTouchPollingRate.cpp b/hidl/touch/HighTouchPollingRate.cpp new file mode 100644 index 0000000..0cee793 --- /dev/null +++ b/hidl/touch/HighTouchPollingRate.cpp @@ -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 + +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 HighTouchPollingRate::isEnabled() { + std::string value; + return ReadFileToString(kGameSwitchEnablePath, &value) && value[0] != '0'; +} + +Return HighTouchPollingRate::setEnabled(bool enabled) { + return WriteStringToFile(enabled ? "1" : "0", kGameSwitchEnablePath, true); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace touch +} // namespace lineage +} // namespace vendor diff --git a/hidl/touch/HighTouchPollingRate.h b/hidl/touch/HighTouchPollingRate.h new file mode 100644 index 0000000..52fc0b2 --- /dev/null +++ b/hidl/touch/HighTouchPollingRate.h @@ -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 +#include +#include + +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 isEnabled() override; + Return setEnabled(bool enabled) override; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace touch +} // namespace lineage +} // namespace vendor diff --git a/hidl/touch/service.cpp b/hidl/touch/service.cpp index c89a069..24f7e2d 100644 --- a/hidl/touch/service.cpp +++ b/hidl/touch/service.cpp @@ -18,20 +18,28 @@ #include #include +#include "HighTouchPollingRate.h" #include "TouchscreenGesture.h" using android::sp; using android::hardware::configureRpcThreadpool; using android::hardware::joinRpcThreadpool; +using vendor::lineage::touch::V1_0::IHighTouchPollingRate; using vendor::lineage::touch::V1_0::ITouchscreenGesture; +using vendor::lineage::touch::V1_0::implementation::HighTouchPollingRate; using vendor::lineage::touch::V1_0::implementation::TouchscreenGesture; int main() { + sp highToushPollingRateService = new HighTouchPollingRate(); sp gestureService = new TouchscreenGesture(); configureRpcThreadpool(1, true /*callerWillJoin*/); + if (highToushPollingRateService->registerAsService() != android::OK) { + LOG(WARNING) << "Can't register HighTouchPollingRate HAL service"; + } + if (gestureService->registerAsService() != android::OK) { LOG(ERROR) << "Can't register TouchscreenGesture HAL service"; return 1;