mirror of
https://github.com/Evolution-X-Devices/device_motorola_rtwo
synced 2026-01-27 18:07:35 +00:00
eqs: FOD implementation using moto panel hal
uses a timeout to disable fod hbm after 200ms, which should be enough for the FPS to recognize/register/fail.
This commit is contained in:
@@ -18,16 +18,7 @@ cc_binary {
|
|||||||
"android.hardware.biometrics.fingerprint@2.2",
|
"android.hardware.biometrics.fingerprint@2.2",
|
||||||
"android.hardware.biometrics.fingerprint@2.3",
|
"android.hardware.biometrics.fingerprint@2.3",
|
||||||
"com.motorola.hardware.biometric.fingerprint@1.0",
|
"com.motorola.hardware.biometric.fingerprint@1.0",
|
||||||
],
|
"com.motorola.hardware.display.panel@1.0",
|
||||||
}
|
"com.motorola.hardware.display.panel@1.1",
|
||||||
|
|
||||||
cc_library_static {
|
|
||||||
name: "libudfps_extension.eqs",
|
|
||||||
srcs: ["UdfpsExtension.cpp"],
|
|
||||||
include_dirs: [
|
|
||||||
"frameworks/native/services/surfaceflinger/CompositionEngine/include"
|
|
||||||
],
|
|
||||||
header_libs: [
|
|
||||||
"generated_kernel_headers",
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* 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 "BiometricsFingerprint.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@@ -29,8 +30,6 @@
|
|||||||
#define NOTIFY_FINGER_UP IMotFodEventType::FINGER_UP
|
#define NOTIFY_FINGER_UP IMotFodEventType::FINGER_UP
|
||||||
#define NOTIFY_FINGER_DOWN IMotFodEventType::FINGER_DOWN
|
#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 android {
|
||||||
namespace hardware {
|
namespace hardware {
|
||||||
namespace biometrics {
|
namespace biometrics {
|
||||||
@@ -38,52 +37,36 @@ namespace fingerprint {
|
|||||||
namespace V2_3 {
|
namespace V2_3 {
|
||||||
namespace implementation {
|
namespace implementation {
|
||||||
|
|
||||||
static bool readBool(int fd) {
|
void BiometricsFingerprint::disableHighBrightFod() {
|
||||||
char c;
|
std::lock_guard<std::mutex> lock(mSetHbmFodMutex);
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = lseek(fd, 0, SEEK_SET);
|
if(!hbmFodEnabled) return;
|
||||||
if (rc) {
|
// this is no mistake, setColor sets the PanelMode, while setMode sets the panel color
|
||||||
LOG(ERROR) << "failed to seek fd, err: " << rc;
|
displayPanelService->setColor((PanelColor) PanelMode::PANEL_MODE_NORMAL);
|
||||||
return false;
|
mMotoFingerprint->sendFodEvent(NOTIFY_FINGER_UP, {},
|
||||||
}
|
[](IMotFodEventResult, const hidl_vec<signed char>&) {});
|
||||||
|
|
||||||
rc = read(fd, &c, sizeof(char));
|
hbmFodEnabled = false;
|
||||||
if (rc != 1) {
|
}
|
||||||
LOG(ERROR) << "failed to read bool from fd, err: " << rc;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return c != '0';
|
void BiometricsFingerprint::enableHighBrightFod() {
|
||||||
|
std::lock_guard<std::mutex> 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<signed char>&) {});
|
||||||
|
|
||||||
|
hbmFodEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BiometricsFingerprint::BiometricsFingerprint() {
|
BiometricsFingerprint::BiometricsFingerprint() {
|
||||||
biometrics_2_1_service = IBiometricsFingerprint_2_1::getService();
|
biometrics_2_1_service = IBiometricsFingerprint_2_1::getService();
|
||||||
mMotoFingerprint = IMotoFingerPrint::getService();
|
mMotoFingerprint = IMotoFingerPrint::getService();
|
||||||
|
displayPanelService = IDisplayPanel::getService();
|
||||||
|
|
||||||
std::thread([this]() {
|
hbmFodEnabled = false;
|
||||||
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<signed char>&) {});
|
|
||||||
}
|
|
||||||
}).detach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<uint64_t> BiometricsFingerprint::setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
|
Return<uint64_t> BiometricsFingerprint::setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
|
||||||
@@ -107,7 +90,9 @@ Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Return<RequestStatus> BiometricsFingerprint::cancel() {
|
Return<RequestStatus> BiometricsFingerprint::cancel() {
|
||||||
return biometrics_2_1_service->cancel();
|
auto ret = biometrics_2_1_service->cancel();
|
||||||
|
BiometricsFingerprint::onFingerUp();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<RequestStatus> BiometricsFingerprint::enumerate() {
|
Return<RequestStatus> BiometricsFingerprint::enumerate() {
|
||||||
@@ -123,7 +108,9 @@ Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid) {
|
Return<RequestStatus> 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<bool> BiometricsFingerprint::isUdfps(uint32_t) {
|
Return<bool> BiometricsFingerprint::isUdfps(uint32_t) {
|
||||||
@@ -131,10 +118,19 @@ Return<bool> BiometricsFingerprint::isUdfps(uint32_t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Return<void> BiometricsFingerprint::onFingerDown(uint32_t, uint32_t, float, float) {
|
Return<void> 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 Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<void> BiometricsFingerprint::onFingerUp() {
|
Return<void> BiometricsFingerprint::onFingerUp() {
|
||||||
|
BiometricsFingerprint::disableHighBrightFod();
|
||||||
|
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <hidl/MQDescriptor.h>
|
#include <hidl/MQDescriptor.h>
|
||||||
#include <hidl/Status.h>
|
#include <hidl/Status.h>
|
||||||
#include <com/motorola/hardware/biometric/fingerprint/1.0/IMotoFingerPrint.h>
|
#include <com/motorola/hardware/biometric/fingerprint/1.0/IMotoFingerPrint.h>
|
||||||
|
#include <com/motorola/hardware/display/panel/1.1/IDisplayPanel.h>
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace hardware {
|
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::IMotFodEventType;
|
||||||
using ::com::motorola::hardware::biometric::fingerprint::V1_0::IMotFodEventResult;
|
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 {
|
struct BiometricsFingerprint : public IBiometricsFingerprint {
|
||||||
BiometricsFingerprint();
|
BiometricsFingerprint();
|
||||||
// Methods from ::V2_1::IBiometricsFingerprint follow.
|
// Methods from ::V2_1::IBiometricsFingerprint follow.
|
||||||
@@ -63,8 +68,15 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
|
|||||||
Return<void> onFingerUp() override;
|
Return<void> onFingerUp() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void disableHighBrightFod();
|
||||||
|
void enableHighBrightFod();
|
||||||
|
|
||||||
|
bool hbmFodEnabled;
|
||||||
|
std::mutex mSetHbmFodMutex;
|
||||||
|
|
||||||
sp<IBiometricsFingerprint_2_1> biometrics_2_1_service;
|
sp<IBiometricsFingerprint_2_1> biometrics_2_1_service;
|
||||||
sp<IMotoFingerPrint> mMotoFingerprint;
|
sp<IMotoFingerPrint> mMotoFingerprint;
|
||||||
|
sp<IDisplayPanel> displayPanelService;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2022 The LineageOS Project
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <compositionengine/UdfpsExtension.h>
|
|
||||||
#include <display/drm/sde_drm.h>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user