/* * 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 "FingerprintInscreenService" #include "FingerprintInscreen.h" #include #include #include #include #define FP_PRESS_PATH "/sys/kernel/oppo_display/notify_fppress" #define HBM_PATH "/sys/kernel/oppo_display/hbm" #define DIM_AMOUNT_PATH "/sys/kernel/oppo_display/dim_alpha" namespace { template static void set(const std::string& path, const T& value) { std::ofstream file(path); file << value; LOG(INFO) << "wrote path: " << path << ", value: " << value << "\n"; } template static T get(const std::string& path, const T& def) { std::ifstream file(path); T result; file >> result; return file.fail() ? def : result; } } // anonymous namespace namespace vendor { namespace lineage { namespace biometrics { namespace fingerprint { namespace inscreen { namespace V1_0 { namespace implementation { FingerprintInscreen::FingerprintInscreen() { } Return FingerprintInscreen::getPositionX() { return 442; } Return FingerprintInscreen::getPositionY() { return 1986; } Return FingerprintInscreen::getSize() { return 196; } Return FingerprintInscreen::onStartEnroll() { return Void(); } Return FingerprintInscreen::onFinishEnroll() { return Void(); } Return FingerprintInscreen::onPress() { set(HBM_PATH, 1); set(FP_PRESS_PATH, 1); return Void(); } Return FingerprintInscreen::onRelease() { set(HBM_PATH, 0); set(FP_PRESS_PATH, 0); return Void(); } Return FingerprintInscreen::onShowFODView() { return Void(); } Return FingerprintInscreen::onHideFODView() { set(HBM_PATH, 0); set(FP_PRESS_PATH, 0); return Void(); } Return FingerprintInscreen::handleAcquired(int32_t acquiredInfo, int32_t vendorCode) { LOG(ERROR) << "acquiredInfo: " << acquiredInfo << ", vendorCode: " << vendorCode << "\n"; return false; } Return FingerprintInscreen::handleError(int32_t error, int32_t vendorCode) { LOG(ERROR) << "error: " << error << ", vendorCode: " << vendorCode << "\n"; return false; } Return FingerprintInscreen::setLongPressEnabled(bool) { return Void(); } Return FingerprintInscreen::getDimAmount(int32_t) { int dimAmount = get(DIM_AMOUNT_PATH, 0); LOG(INFO) << "dimAmount = " << dimAmount; return dimAmount; } Return FingerprintInscreen::shouldBoostBrightness() { return false; } Return FingerprintInscreen::setCallback(const sp<::vendor::lineage::biometrics::fingerprint::inscreen::V1_0::IFingerprintInscreenCallback>& callback) { { std::lock_guard _lock(mCallbackLock); mCallback = callback; } return Void(); } } // namespace implementation } // namespace V1_0 } // namespace inscreen } // namespace fingerprint } // namespace biometrics } // namespace lineage } // namespace vendor