hidl: fingerprint: Uprev to 2.3

* Move fingerprint HIDL to 2.3
 * Remove Lineage FOD HIDL

[Linux4: Autodetect if fingerprint is udfps]

Change-Id: I8c628d2ee9158b45eeb04dd324b56ef3697296b7
tirimbino
TheScarastic 3 years ago committed by Tim Zimmermann
parent 5a7577b20c
commit 99af8deb5f
No known key found for this signature in database
GPG Key ID: 6DC21A63F819C5EF
  1. 9
      hidl/fingerprint/Android.mk
  2. 26
      hidl/fingerprint/BiometricsFingerprint.cpp
  3. 23
      hidl/fingerprint/BiometricsFingerprint.h
  4. 2
      hidl/fingerprint/android.hardware.biometrics.fingerprint@2.3-service.samsung.rc
  5. 8
      hidl/fingerprint/android.hardware.biometrics.fingerprint@2.3-service.samsung.xml
  6. 44
      hidl/fingerprint/inscreen/Android.mk
  7. 148
      hidl/fingerprint/inscreen/FingerprintInscreen.cpp
  8. 68
      hidl/fingerprint/inscreen/FingerprintInscreen.h
  9. 35
      hidl/fingerprint/inscreen/include/samsung_fingerprint_inscreen.h
  10. 50
      hidl/fingerprint/inscreen/service.cpp
  11. 6
      hidl/fingerprint/inscreen/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.rc
  12. 6
      hidl/fingerprint/service.cpp

@ -28,7 +28,9 @@ LOCAL_SHARED_LIBRARIES := \
libhidlbase \
liblog \
libutils \
android.hardware.biometrics.fingerprint@2.1
android.hardware.biometrics.fingerprint@2.1 \
android.hardware.biometrics.fingerprint@2.2 \
android.hardware.biometrics.fingerprint@2.3
ifeq ($(TARGET_SEC_FP_CALL_NOTIFY_ON_CANCEL),true)
LOCAL_CFLAGS += -DCALL_NOTIFY_ON_CANCEL
@ -42,8 +44,9 @@ ifeq ($(TARGET_SEC_FP_CALL_CANCEL_ON_ENROLL_COMPLETION),true)
LOCAL_CFLAGS += -DCALL_CANCEL_ON_ENROLL_COMPLETION
endif
LOCAL_MODULE := android.hardware.biometrics.fingerprint@2.1-service.samsung
LOCAL_INIT_RC := android.hardware.biometrics.fingerprint@2.1-service.samsung.rc
LOCAL_MODULE := android.hardware.biometrics.fingerprint@2.3-service.samsung
LOCAL_INIT_RC := android.hardware.biometrics.fingerprint@2.3-service.samsung.rc
LOCAL_VINTF_FRAGMENTS := android.hardware.biometrics.fingerprint@2.3-service.samsung.xml
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_OWNER := samsung

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.samsung"
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.3-service.samsung"
#include <android-base/logging.h>
@ -24,6 +24,7 @@
#include "BiometricsFingerprint.h"
#include <dlfcn.h>
#include <fstream>
#include <inttypes.h>
#include <unistd.h>
@ -31,7 +32,7 @@ namespace android {
namespace hardware {
namespace biometrics {
namespace fingerprint {
namespace V2_1 {
namespace V2_3 {
namespace implementation {
using RequestStatus = android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
@ -43,6 +44,11 @@ BiometricsFingerprint::BiometricsFingerprint() : mClientCallback(nullptr) {
if (!openHal()) {
LOG(ERROR) << "Can't open HAL module";
}
std::ifstream in("/sys/devices/virtual/fingerprint/fingerprint/position");
mIsUdfps = !!in;
if (in)
in.close();
}
BiometricsFingerprint::~BiometricsFingerprint() {
@ -51,6 +57,18 @@ BiometricsFingerprint::~BiometricsFingerprint() {
}
}
Return<bool> BiometricsFingerprint::isUdfps(uint32_t) {
return mIsUdfps;
}
Return<void> BiometricsFingerprint::onFingerDown(uint32_t, uint32_t, float, float) {
return Void();
}
Return<void> BiometricsFingerprint::onFingerUp() {
return Void();
}
Return<RequestStatus> BiometricsFingerprint::ErrorFilter(int32_t error) {
switch (error) {
case 0:
@ -146,7 +164,7 @@ Return<uint64_t> BiometricsFingerprint::setNotify(
const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
std::lock_guard<std::mutex> lock(mClientCallbackMutex);
mClientCallback = clientCallback;
// This is here because HAL 2.1 doesn't have a way to propagate a
// This is here because HAL 2.3 doesn't have a way to propagate a
// unique token for its driver. Subsequent versions should send a unique
// token for each call to setNotify(). This is fine as long as there's only
// one fingerprint device on the platform.
@ -368,7 +386,7 @@ void BiometricsFingerprint::notify(const fingerprint_msg_t* msg) {
}
} // namespace implementation
} // namespace V2_1
} // namespace V2_3
} // namespace fingerprint
} // namespace biometrics
} // namespace hardware

@ -14,20 +14,21 @@
* limitations under the License.
*/
#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H
#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
#include <hardware/fingerprint.h>
#include <hardware/hardware.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <android/hardware/biometrics/fingerprint/2.3/IBiometricsFingerprint.h>
#include <android/hardware/biometrics/fingerprint/2.1/types.h>
namespace android {
namespace hardware {
namespace biometrics {
namespace fingerprint {
namespace V2_1 {
namespace V2_3 {
namespace implementation {
using ::android::sp;
@ -35,8 +36,10 @@ using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
using ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint;
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
using ::android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo;
using ::android::hardware::biometrics::fingerprint::V2_1::FingerprintError;
using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
struct BiometricsFingerprint : public IBiometricsFingerprint {
@ -46,7 +49,7 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
// Method to wrap legacy HAL with BiometricsFingerprint class
static IBiometricsFingerprint* getInstance();
// Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow.
// Methods from ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint follow.
Return<uint64_t> setNotify(
const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
Return<uint64_t> preEnroll() override;
@ -59,6 +62,9 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
Return<bool> isUdfps(uint32_t sensorID) override;
Return<void> onFingerDown(uint32_t x, uint32_t y, float minor, float major) override;
Return<void> onFingerUp() override;
private:
bool openHal();
@ -71,6 +77,7 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
std::mutex mClientCallbackMutex;
sp<IBiometricsFingerprintClientCallback> mClientCallback;
bool mIsUdfps;
int (*ss_fingerprint_close)();
int (*ss_fingerprint_open)(const char* id);
@ -88,10 +95,10 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
};
} // namespace implementation
} // namespace V2_1
} // namespace V2_3
} // namespace fingerprint
} // namespace biometrics
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H

@ -1,4 +1,4 @@
service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.samsung
service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.3-service.samsung
# "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.

@ -1,10 +1,10 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>vendor.lineage.biometrics.fingerprint.inscreen</name>
<hal format="hidl" override="true">
<name>android.hardware.biometrics.fingerprint</name>
<transport>hwbinder</transport>
<version>1.0</version>
<version>2.3</version>
<interface>
<name>IFingerprintInscreen</name>
<name>IBiometricsFingerprint</name>
<instance>default</instance>
</interface>
</hal>

@ -1,44 +0,0 @@
#
# Copyright (C) 2020 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.
#
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
FingerprintInscreen.cpp \
service.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SHARED_LIBRARIES := \
libbase \
libhardware \
libhidlbase \
liblog \
libhwbinder \
libutils \
vendor.lineage.biometrics.fingerprint.inscreen@1.0
LOCAL_MODULE := vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung
LOCAL_INIT_RC := vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.rc
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_OWNER := samsung
LOCAL_VINTF_FRAGMENTS := vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.xml
LOCAL_VENDOR_MODULE := true
include $(BUILD_EXECUTABLE)

@ -1,148 +0,0 @@
/*
* Copyright (C) 2020 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 <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include <fstream>
namespace vendor {
namespace lineage {
namespace biometrics {
namespace fingerprint {
namespace inscreen {
namespace V1_0 {
namespace implementation {
/*
* Write value to path and close file.
*/
template <typename T>
static void set(const std::string& path, const T& value) {
std::ofstream file(path);
if (!file) {
PLOG(ERROR) << "Failed to open: " << path;
return;
}
LOG(DEBUG) << "write: " << path << " value: " << value;
file << value << std::endl;
if (!file) {
PLOG(ERROR) << "Failed to write: " << path << " value: " << value;
}
}
template <typename T>
static T get(const std::string& path, const T& def) {
std::ifstream file(path);
if (!file) {
PLOG(ERROR) << "Failed to open: " << path;
return def;
}
T result;
file >> result;
if (file.fail()) {
PLOG(ERROR) << "Failed to read: " << path;
return def;
} else {
LOG(DEBUG) << "read: " << path << " value: " << result;
return result;
}
}
FingerprintInscreen::FingerprintInscreen() {
#ifdef FOD_SET_RECT
set(TSP_CMD_PATH, FOD_SET_RECT);
#endif
set(TSP_CMD_PATH, FOD_ENABLE);
}
Return<void> FingerprintInscreen::onStartEnroll() { return Void(); }
Return<void> FingerprintInscreen::onFinishEnroll() { return Void(); }
Return<void> FingerprintInscreen::onPress() { return Void(); }
Return<void> FingerprintInscreen::onRelease() { return Void(); }
Return<void> FingerprintInscreen::onShowFODView() { return Void(); }
Return<void> FingerprintInscreen::onHideFODView() { return Void(); }
Return<bool> FingerprintInscreen::handleAcquired(int32_t acquiredInfo, int32_t vendorCode) {
std::lock_guard<std::mutex> _lock(mCallbackLock);
if (mCallback == nullptr) {
return false;
}
if (acquiredInfo == FINGERPRINT_ACQUIRED_VENDOR) {
if (vendorCode == VENDORCODE_FINGER_DOWN) {
Return<void> ret = mCallback->onFingerDown();
if (!ret.isOk()) {
LOG(ERROR) << "FingerDown() error: " << ret.description();
}
return true;
} else if (vendorCode == VENDORCODE_FINGER_UP) {
Return<void> ret = mCallback->onFingerUp();
if (!ret.isOk()) {
LOG(ERROR) << "FingerUp() error: " << ret.description();
}
return true;
}
}
return false;
}
Return<bool> FingerprintInscreen::handleError(int32_t, int32_t) { return false; }
Return<void> FingerprintInscreen::setLongPressEnabled(bool) { return Void(); }
Return<int32_t> FingerprintInscreen::getDimAmount(int32_t) { return 0; }
Return<bool> FingerprintInscreen::shouldBoostBrightness() { return false; }
Return<void> FingerprintInscreen::setCallback(const sp<IFingerprintInscreenCallback>& callback) {
mCallback = callback;
return Void();
}
Return<int32_t> FingerprintInscreen::getPositionX() { return FOD_SENSOR_X; }
Return<int32_t> FingerprintInscreen::getPositionY() { return FOD_SENSOR_Y; }
Return<int32_t> FingerprintInscreen::getSize() { return FOD_SENSOR_SIZE; }
} // namespace implementation
} // namespace V1_0
} // namespace inscreen
} // namespace fingerprint
} // namespace biometrics
} // namespace lineage
} // namespace vendor

@ -1,68 +0,0 @@
/*
* Copyright (C) 2020 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.
*/
#ifndef VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H
#define VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H
#include <vendor/lineage/biometrics/fingerprint/inscreen/1.0/IFingerprintInscreen.h>
#include "samsung_fingerprint_inscreen.h"
namespace vendor {
namespace lineage {
namespace biometrics {
namespace fingerprint {
namespace inscreen {
namespace V1_0 {
namespace implementation {
using ::android::sp;
using ::android::hardware::Return;
using ::android::hardware::Void;
class FingerprintInscreen : public IFingerprintInscreen {
public:
FingerprintInscreen();
Return<void> onStartEnroll() override;
Return<void> onFinishEnroll() override;
Return<void> onPress() override;
Return<void> onRelease() override;
Return<void> onShowFODView() override;
Return<void> onHideFODView() override;
Return<bool> handleAcquired(int32_t acquiredInfo, int32_t vendorCode) override;
Return<bool> handleError(int32_t error, int32_t vendorCode) override;
Return<void> setLongPressEnabled(bool enabled) override;
Return<int32_t> getDimAmount(int32_t cur_brightness) override;
Return<bool> shouldBoostBrightness() override;
Return<void> setCallback(const sp<IFingerprintInscreenCallback>& callback) override;
Return<int32_t> getPositionX() override;
Return<int32_t> getPositionY() override;
Return<int32_t> getSize() override;
private:
std::mutex mCallbackLock;
sp<IFingerprintInscreenCallback> mCallback;
};
} // namespace implementation
} // namespace V1_0
} // namespace inscreen
} // namespace fingerprint
} // namespace biometrics
} // namespace lineage
} // namespace vendor
#endif // VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H

@ -1,35 +0,0 @@
/*
* Copyright (C) 2020 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.
*/
#ifndef SAMSUNG_FINGERPRINT_INSCREEN_H
#define SAMSUNG_FINGERPRINT_INSCREEN_H
#define FOD_SENSOR_X 435
#define FOD_SENSOR_Y 2025
#define FOD_SENSOR_SIZE 210
#define FOD_ENABLE "fod_enable,1,1"
#define FOD_DISABLE "fod_enable,0"
// #define FOD_SET_RECT "set_fod_rect,554,2263,886,2595"
#define FINGERPRINT_ACQUIRED_VENDOR 6
#define VENDORCODE_FINGER_DOWN 9002
#define VENDORCODE_FINGER_UP 9001
#define TSP_CMD_PATH "/sys/class/sec/tsp/cmd"
#endif // SAMSUNG_FINGERPRINT_INSCREEN_H

@ -1,50 +0,0 @@
/*
* Copyright (C) 2020 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 "lineage.biometrics.fingerprint.inscreen@1.0-service.samsung"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include "FingerprintInscreen.h"
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using vendor::lineage::biometrics::fingerprint::inscreen::V1_0::IFingerprintInscreen;
using vendor::lineage::biometrics::fingerprint::inscreen::V1_0::implementation::FingerprintInscreen;
using android::OK;
using android::status_t;
int main() {
android::sp<IFingerprintInscreen> service = new FingerprintInscreen();
configureRpcThreadpool(1, true);
status_t status = service->registerAsService();
if (status != OK) {
LOG(ERROR) << "Cannot register FOD HAL service.";
return 1;
}
LOG(INFO) << "FOD HAL service ready.";
joinRpcThreadpool();
LOG(ERROR) << "FOD HAL service failed to join thread pool.";
return 1;
}

@ -1,6 +0,0 @@
service vendor.fingerprint-inscreen-1-0 /vendor/bin/hw/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung
interface vendor.lineage.biometrics.fingerprint.inscreen@1.0::IFingerprintInscreen default
class hal
user system
group system
shutdown critical

@ -14,7 +14,7 @@
* limitations under the License.
*/
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.samsung"
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.3-service.samsung"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
@ -25,8 +25,8 @@
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
using android::hardware::biometrics::fingerprint::V2_1::implementation::BiometricsFingerprint;
using android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint;
using android::hardware::biometrics::fingerprint::V2_3::implementation::BiometricsFingerprint;
using android::OK;
using android::sp;

Loading…
Cancel
Save