/* * 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 #include #include #include "TouchscreenGesture.h" namespace vendor { namespace lineage { namespace touch { namespace V1_0 { namespace implementation { Return TouchscreenGesture::getSupportedGestures(getSupportedGestures_cb resultCb) { std::vector gestures; for (int32_t i = 0; i < std::size(kGestureNodes); ++i) { gestures.push_back({i, kGestureNodes[i].name, kGestureNodes[i].keycode}); } resultCb(gestures); return Void(); } Return TouchscreenGesture::setGestureEnabled( const ::vendor::lineage::touch::V1_0::Gesture& gesture, bool enable) { if (gesture.id >= std::size(kGestureNodes)) { return false; } if (!android::base::WriteStringToFile(enable ? kGestureNodes[gesture.id].enable : kGestureNodes[gesture.id].disable, kGestureNodes[gesture.id].path)) { LOG(ERROR) << "Writing to file " << kGestureNodes[gesture.id].path << " failed"; return false; } return true; } } // namespace implementation } // namespace V1_0 } // namespace touch } // namespace lineage } // namespace vendor