/* * 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 #define FINGERPRINT_ACQUIRED_VENDOR 6 #define COMMAND_NIT 10 #define PARAM_NIT_FOD 1 #define PARAM_NIT_NONE 0 #define FOD_STATUS_PATH "/sys/devices/virtual/touch/tp_dev/fod_status" #define FOD_STATUS_ON 1 #define FOD_STATUS_OFF 0 #define FOD_SENSOR_X 445 #define FOD_SENSOR_Y 1931 #define FOD_SENSOR_SIZE 190 namespace { template static void set(const std::string& path, const T& value) { std::ofstream file(path); file << value; } } // anonymous namespace namespace vendor { namespace lineage { namespace biometrics { namespace fingerprint { namespace inscreen { namespace V1_0 { namespace implementation { FingerprintInscreen::FingerprintInscreen() { xiaomiFingerprintService = IXiaomiFingerprint::getService(); } Return FingerprintInscreen::getPositionX() { return FOD_SENSOR_X; } Return FingerprintInscreen::getPositionY() { return FOD_SENSOR_Y; } Return FingerprintInscreen::getSize() { return FOD_SENSOR_SIZE; } Return FingerprintInscreen::onStartEnroll() { return Void(); } Return FingerprintInscreen::onFinishEnroll() { return Void(); } Return FingerprintInscreen::onPress() { xiaomiFingerprintService->extCmd(COMMAND_NIT, PARAM_NIT_FOD); return Void(); } Return FingerprintInscreen::onRelease() { xiaomiFingerprintService->extCmd(COMMAND_NIT, PARAM_NIT_NONE); return Void(); } Return FingerprintInscreen::onShowFODView() { set(FOD_STATUS_PATH, FOD_STATUS_ON); return Void(); } Return FingerprintInscreen::onHideFODView() { set(FOD_STATUS_PATH, FOD_STATUS_OFF); return Void(); } Return FingerprintInscreen::handleAcquired(int32_t acquiredInfo, int32_t vendorCode) { std::lock_guard _lock(mCallbackLock); if (mCallback == nullptr) { return false; } if (acquiredInfo == FINGERPRINT_ACQUIRED_VENDOR) { if (vendorCode == 0) { Return ret = mCallback->onFingerDown(); if (!ret.isOk()) { LOG(ERROR) << "FingerDown() error: " << ret.description(); } return true; } if (vendorCode == 1) { Return ret = mCallback->onFingerUp(); if (!ret.isOk()) { LOG(ERROR) << "FingerUp() error: " << ret.description(); } return true; } } return false; } Return FingerprintInscreen::handleError(int32_t error, int32_t vendorCode) { LOG(ERROR) << "error: " << error << ", vendorCode: " << vendorCode; return false; } Return FingerprintInscreen::setLongPressEnabled(bool) { return Void(); } Return FingerprintInscreen::getDimAmount(int32_t /* brightness */) { return 0; } Return FingerprintInscreen::shouldBoostBrightness() { return false; } Return FingerprintInscreen::setCallback(const sp& 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