diff --git a/fingerprint/Android.bp b/fingerprint/Android.bp index b3415e2..ef686ae 100644 --- a/fingerprint/Android.bp +++ b/fingerprint/Android.bp @@ -18,16 +18,7 @@ cc_binary { "android.hardware.biometrics.fingerprint@2.2", "android.hardware.biometrics.fingerprint@2.3", "com.motorola.hardware.biometric.fingerprint@1.0", - ], -} - -cc_library_static { - name: "libudfps_extension.eqs", - srcs: ["UdfpsExtension.cpp"], - include_dirs: [ - "frameworks/native/services/surfaceflinger/CompositionEngine/include" - ], - header_libs: [ - "generated_kernel_headers", + "com.motorola.hardware.display.panel@1.0", + "com.motorola.hardware.display.panel@1.1", ], } diff --git a/fingerprint/BiometricsFingerprint.cpp b/fingerprint/BiometricsFingerprint.cpp index 7cb49e8..947d9c0 100644 --- a/fingerprint/BiometricsFingerprint.cpp +++ b/fingerprint/BiometricsFingerprint.cpp @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#define LOG_TAG "android.hardware.biometrics.fingerprint@2.3-service.eqs" +#define LOG_TAG "fingerprint@2.3-service.eqs" #include "BiometricsFingerprint.h" +#include #include #include #include @@ -29,8 +30,6 @@ #define NOTIFY_FINGER_UP IMotFodEventType::FINGER_UP #define NOTIFY_FINGER_DOWN IMotFodEventType::FINGER_DOWN -#define FOD_UI_PATH "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_ui" - namespace android { namespace hardware { namespace biometrics { @@ -38,52 +37,36 @@ namespace fingerprint { namespace V2_3 { namespace implementation { -static bool readBool(int fd) { - char c; - int rc; +void BiometricsFingerprint::disableHighBrightFod() { + std::lock_guard lock(mSetHbmFodMutex); - rc = lseek(fd, 0, SEEK_SET); - if (rc) { - LOG(ERROR) << "failed to seek fd, err: " << rc; - return false; - } + if(!hbmFodEnabled) return; + // this is no mistake, setColor sets the PanelMode, while setMode sets the panel color + displayPanelService->setColor((PanelColor) PanelMode::PANEL_MODE_NORMAL); + mMotoFingerprint->sendFodEvent(NOTIFY_FINGER_UP, {}, + [](IMotFodEventResult, const hidl_vec&) {}); - rc = read(fd, &c, sizeof(char)); - if (rc != 1) { - LOG(ERROR) << "failed to read bool from fd, err: " << rc; - return false; - } + hbmFodEnabled = false; +} - return c != '0'; +void BiometricsFingerprint::enableHighBrightFod() { + std::lock_guard lock(mSetHbmFodMutex); + + if(hbmFodEnabled) return; + // this is no mistake, setColor sets the PanelMode, while setMode sets the panel color + displayPanelService->setColor((PanelColor) PanelMode::PANEL_MODE_HIGH_BRIGHT_FOD); + mMotoFingerprint->sendFodEvent(NOTIFY_FINGER_DOWN, {}, + [](IMotFodEventResult, const hidl_vec&) {}); + + hbmFodEnabled = true; } BiometricsFingerprint::BiometricsFingerprint() { biometrics_2_1_service = IBiometricsFingerprint_2_1::getService(); mMotoFingerprint = IMotoFingerPrint::getService(); + displayPanelService = IDisplayPanel::getService(); - std::thread([this]() { - int fd = open(FOD_UI_PATH, O_RDONLY); - if (fd < 0) { - LOG(ERROR) << "failed to open fd, err: " << fd; - return; - } - - struct pollfd fodUiPoll = { - .fd = fd, - .events = POLLERR | POLLPRI, - .revents = 0, - }; - - while (true) { - int rc = poll(&fodUiPoll, 1, -1); - if (rc < 0) { - LOG(ERROR) << "failed to poll fd, err: " << rc; - continue; - } - mMotoFingerprint->sendFodEvent(readBool(fd) ? NOTIFY_FINGER_DOWN : NOTIFY_FINGER_UP , {}, - [](IMotFodEventResult, const hidl_vec&) {}); - } - }).detach(); + hbmFodEnabled = false; } Return BiometricsFingerprint::setNotify(const sp& clientCallback) { @@ -107,7 +90,9 @@ Return BiometricsFingerprint::getAuthenticatorId() { } Return BiometricsFingerprint::cancel() { - return biometrics_2_1_service->cancel(); + auto ret = biometrics_2_1_service->cancel(); + BiometricsFingerprint::onFingerUp(); + return ret; } Return BiometricsFingerprint::enumerate() { @@ -123,7 +108,9 @@ Return BiometricsFingerprint::setActiveGroup(uint32_t gid, const } Return BiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid) { - return biometrics_2_1_service->authenticate(operationId, gid); + auto ret = biometrics_2_1_service->authenticate(operationId, gid); + BiometricsFingerprint::onFingerUp(); + return ret; } Return BiometricsFingerprint::isUdfps(uint32_t) { @@ -131,10 +118,19 @@ Return BiometricsFingerprint::isUdfps(uint32_t) { } Return BiometricsFingerprint::onFingerDown(uint32_t, uint32_t, float, float) { + BiometricsFingerprint::enableHighBrightFod(); + + std::thread([this]() { + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + BiometricsFingerprint::onFingerUp(); + }).detach(); + return Void(); } Return BiometricsFingerprint::onFingerUp() { + BiometricsFingerprint::disableHighBrightFod(); + return Void(); } diff --git a/fingerprint/BiometricsFingerprint.h b/fingerprint/BiometricsFingerprint.h index aed29e0..55ade69 100644 --- a/fingerprint/BiometricsFingerprint.h +++ b/fingerprint/BiometricsFingerprint.h @@ -21,6 +21,7 @@ #include #include #include +#include namespace android { namespace hardware { @@ -43,6 +44,10 @@ using ::com::motorola::hardware::biometric::fingerprint::V1_0::IMotoFingerPrint; using ::com::motorola::hardware::biometric::fingerprint::V1_0::IMotFodEventType; using ::com::motorola::hardware::biometric::fingerprint::V1_0::IMotFodEventResult; +using ::com::motorola::hardware::display::panel::V1_1::IDisplayPanel; +using ::com::motorola::hardware::display::panel::V1_0::PanelColor; +using ::com::motorola::hardware::display::panel::V1_0::PanelMode; + struct BiometricsFingerprint : public IBiometricsFingerprint { BiometricsFingerprint(); // Methods from ::V2_1::IBiometricsFingerprint follow. @@ -63,8 +68,15 @@ struct BiometricsFingerprint : public IBiometricsFingerprint { Return onFingerUp() override; private: + void disableHighBrightFod(); + void enableHighBrightFod(); + + bool hbmFodEnabled; + std::mutex mSetHbmFodMutex; + sp biometrics_2_1_service; sp mMotoFingerprint; + sp displayPanelService; }; } // namespace implementation diff --git a/fingerprint/UdfpsExtension.cpp b/fingerprint/UdfpsExtension.cpp deleted file mode 100644 index f51a9e3..0000000 --- a/fingerprint/UdfpsExtension.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2022 The LineageOS Project - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include - -uint32_t getUdfpsZOrder(uint32_t z, bool touched) { - if (touched) { - z |= FOD_PRESSED_LAYER_ZORDER; - } - return z; -} - -uint64_t getUdfpsUsageBits(uint64_t usageBits, bool) { - return usageBits; -}