bangkk: fingerprint: Update biometrics HAL
Change-Id: I8753fb16104ef141be7fe13014b2140e1f505545
This commit is contained in:
parent
fda6878d84
commit
88b82cf38b
6 changed files with 91 additions and 73 deletions
|
@ -61,7 +61,9 @@ PRODUCT_PACKAGES += \
|
|||
|
||||
# Fingerprint
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.biometrics.fingerprint@2.3-service.bangkk
|
||||
android.hardware.biometrics.fingerprint@2.3-service.bangkk \
|
||||
com.motorola.hardware.biometric.fingerprint@1.0.vendor \
|
||||
vendor.egistec.hardware.fingerprint@4.0.vendor
|
||||
|
||||
# Init
|
||||
$(foreach f,$(wildcard $(LOCAL_PATH)/rootdir/etc/init/hw/*.rc),\
|
||||
|
|
|
@ -17,8 +17,9 @@ cc_binary {
|
|||
"android.hardware.biometrics.fingerprint@2.1",
|
||||
"android.hardware.biometrics.fingerprint@2.2",
|
||||
"android.hardware.biometrics.fingerprint@2.3",
|
||||
"com.motorola.hardware.biometric.fingerprint@1.0",
|
||||
"vendor.egistec.hardware.fingerprint@4.0",
|
||||
],
|
||||
header_libs: ["generated_kernel_headers"]
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
|
|
|
@ -13,23 +13,51 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.3-service.bangkk"
|
||||
#define LOG_TAG "fingerprint@2.3-service.bangkk"
|
||||
|
||||
#include "BiometricsFingerprint.h"
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
#include <thread>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#define NOTIFY_FINGER_UP IMotFodEventType::FINGER_UP
|
||||
#define NOTIFY_FINGER_DOWN IMotFodEventType::FINGER_DOWN
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
|
||||
#define FOD_UI_PATH "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_ui"
|
||||
#include <display/drm/sde_drm.h>
|
||||
|
||||
enum HBM_STATE {
|
||||
OFF = 0,
|
||||
ON = 2
|
||||
};
|
||||
|
||||
void setHbmState(int state) {
|
||||
struct panel_param_info param_info;
|
||||
int32_t node = open("/dev/dri/card0", O_RDWR);
|
||||
int32_t ret = 0;
|
||||
|
||||
if (node < 0) {
|
||||
LOG(ERROR) << "Failed to get card0!";
|
||||
return;
|
||||
}
|
||||
|
||||
param_info.param_idx = PARAM_HBM;
|
||||
param_info.value = state;
|
||||
|
||||
ret = ioctl(node, DRM_IOCTL_SET_PANEL_FEATURE, ¶m_info);
|
||||
if (ret < 0) {
|
||||
LOG(ERROR) << "IOCTL call failed with ret = " << ret;
|
||||
} else {
|
||||
LOG(INFO) << "HBM state set successfully. New state: " << state;
|
||||
}
|
||||
|
||||
close(node);
|
||||
}
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
|
@ -38,55 +66,13 @@ namespace fingerprint {
|
|||
namespace V2_3 {
|
||||
namespace implementation {
|
||||
|
||||
static bool readBool(int fd) {
|
||||
char c;
|
||||
int rc;
|
||||
|
||||
rc = lseek(fd, 0, SEEK_SET);
|
||||
if (rc) {
|
||||
LOG(ERROR) << "failed to seek fd, err: " << rc;
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = read(fd, &c, sizeof(char));
|
||||
if (rc != 1) {
|
||||
LOG(ERROR) << "failed to read bool from fd, err: " << rc;
|
||||
return false;
|
||||
}
|
||||
|
||||
return c != '0';
|
||||
}
|
||||
|
||||
BiometricsFingerprint::BiometricsFingerprint() {
|
||||
biometrics_2_1_service = IBiometricsFingerprint_2_1::getService();
|
||||
mMotoFingerprint = IMotoFingerPrint::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<signed char>&) {});
|
||||
}
|
||||
}).detach();
|
||||
rbs_4_0_service = IBiometricsFingerprintRbs::getService();
|
||||
}
|
||||
|
||||
Return<uint64_t> BiometricsFingerprint::setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
|
||||
Return<uint64_t> BiometricsFingerprint::setNotify(
|
||||
const sp<IBiometricsFingerprintClientCallback> &clientCallback) {
|
||||
return biometrics_2_1_service->setNotify(clientCallback);
|
||||
}
|
||||
|
||||
|
@ -94,7 +80,8 @@ Return<uint64_t> BiometricsFingerprint::preEnroll() {
|
|||
return biometrics_2_1_service->preEnroll();
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) {
|
||||
Return<RequestStatus> BiometricsFingerprint::enroll(const hidl_array<uint8_t, 69> &hat,
|
||||
uint32_t gid, uint32_t timeoutSec) {
|
||||
return biometrics_2_1_service->enroll(hat, gid, timeoutSec);
|
||||
}
|
||||
|
||||
|
@ -107,6 +94,7 @@ Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() {
|
|||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::cancel() {
|
||||
setHbmState(OFF);
|
||||
return biometrics_2_1_service->cancel();
|
||||
}
|
||||
|
||||
|
@ -118,11 +106,13 @@ Return<RequestStatus> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid)
|
|||
return biometrics_2_1_service->remove(gid, fid);
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid, const hidl_string& storePath) {
|
||||
Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid,
|
||||
const hidl_string &storePath) {
|
||||
return biometrics_2_1_service->setActiveGroup(gid, storePath);
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid) {
|
||||
setHbmState(OFF);
|
||||
return biometrics_2_1_service->authenticate(operationId, gid);
|
||||
}
|
||||
|
||||
|
@ -131,10 +121,35 @@ Return<bool> BiometricsFingerprint::isUdfps(uint32_t) {
|
|||
}
|
||||
|
||||
Return<void> BiometricsFingerprint::onFingerDown(uint32_t, uint32_t, float, float) {
|
||||
setHbmState(ON);
|
||||
extraApiWrapper(101);
|
||||
|
||||
std::thread([this]() {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
BiometricsFingerprint::onFingerUp();
|
||||
}).detach();
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> BiometricsFingerprint::onFingerUp() {
|
||||
setHbmState(OFF);
|
||||
extraApiWrapper(102);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> BiometricsFingerprint::extraApiWrapper(int cidValue) {
|
||||
int cid[1] = {cidValue};
|
||||
|
||||
// Create a std::vector<uint8_t> to store the data from 'cid'
|
||||
std::vector<uint8_t> cid_data(reinterpret_cast<uint8_t*>(cid), reinterpret_cast<uint8_t*>(cid) + sizeof(cid));
|
||||
|
||||
// Create the hidl_vec<uint8_t> from the std::vector<uint8_t>
|
||||
::android::hardware::hidl_vec<uint8_t> hidl_cid = cid_data;
|
||||
|
||||
// Call extra_api with the correct input buffer and an empty lambda callback
|
||||
rbs_4_0_service->extra_api(7, hidl_cid, [](const ::android::hardware::hidl_vec<uint8_t>&){});
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H
|
||||
|
||||
#include <android/hardware/biometrics/fingerprint/2.3/IBiometricsFingerprint.h>
|
||||
#include <vendor/egistec/hardware/fingerprint/4.0/IBiometricsFingerprintRbs.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <com/motorola/hardware/biometric/fingerprint/1.0/IMotoFingerPrint.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
|
@ -29,32 +29,33 @@ namespace fingerprint {
|
|||
namespace V2_3 {
|
||||
namespace implementation {
|
||||
|
||||
using IBiometricsFingerprint_2_1 = ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
||||
using IBiometricsFingerprint_2_1 =
|
||||
::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_memory;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::sp;
|
||||
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 ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
||||
using ::vendor::egistec::hardware::fingerprint::V4_0::IBiometricsFingerprintRbs;
|
||||
|
||||
struct BiometricsFingerprint : public IBiometricsFingerprint {
|
||||
BiometricsFingerprint();
|
||||
// Methods from ::V2_1::IBiometricsFingerprint follow.
|
||||
Return<uint64_t> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
|
||||
Return<uint64_t> setNotify(
|
||||
const sp<IBiometricsFingerprintClientCallback> &clientCallback) override;
|
||||
Return<uint64_t> preEnroll() override;
|
||||
Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) override;
|
||||
Return<RequestStatus> enroll(const hidl_array<uint8_t, 69> &hat, uint32_t gid,
|
||||
uint32_t timeoutSec) override;
|
||||
Return<RequestStatus> postEnroll() override;
|
||||
Return<uint64_t> getAuthenticatorId() override;
|
||||
Return<RequestStatus> cancel() override;
|
||||
Return<RequestStatus> enumerate() override;
|
||||
Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
|
||||
Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
|
||||
Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string &storePath) override;
|
||||
Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
|
||||
|
||||
// ::V2_3::IBiometricsFingerprint follow.
|
||||
|
@ -62,9 +63,10 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
|
|||
Return<void> onFingerDown(uint32_t x, uint32_t y, float minor, float major) override;
|
||||
Return<void> onFingerUp() override;
|
||||
|
||||
private:
|
||||
Return<void> extraApiWrapper(int cidValue);
|
||||
private:
|
||||
sp<IBiometricsFingerprint_2_1> biometrics_2_1_service;
|
||||
sp<IMotoFingerPrint> mMotoFingerprint;
|
||||
sp<IBiometricsFingerprintRbs> rbs_4_0_service;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
service fps_hal.bangkk /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.3-service.bangkk
|
||||
service vendor.fps_hal.bangkk /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.3-service.bangkk
|
||||
# "class hal" causes a race condition on some devices due to files created
|
||||
# in /data. As a workaround, postpone startup until later in boot once
|
||||
# /data is mounted.
|
||||
|
|
|
@ -369,10 +369,8 @@ vendor/etc/qdcm_calib_data_mipi_moto_vid_tm_u8_1080p_dsc_655.xml
|
|||
|
||||
# Fingerprint
|
||||
vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service-ets
|
||||
vendor/etc/init/android.hardware.biometrics.fingerprint@2.1-service-ets.rc
|
||||
vendor/lib64/libRbsFlow.so
|
||||
vendor/lib64/libets_teeclient_v3.so
|
||||
vendor/lib64/vendor.egistec.hardware.fingerprint@4.0.so
|
||||
vendor/lib64/vendor.qti.hardware.fingerprint@1.0.so
|
||||
|
||||
# Firmware - From Bangkk
|
||||
|
|
Loading…
Reference in a new issue