upload android base code part4
This commit is contained in:
parent
b9e30e05b1
commit
78ea2404cd
23455 changed files with 5250148 additions and 0 deletions
5
android/hardware/interfaces/biometrics/Android.bp
Normal file
5
android/hardware/interfaces/biometrics/Android.bp
Normal file
|
@ -0,0 +1,5 @@
|
|||
// This is an autogenerated file, do not edit.
|
||||
subdirs = [
|
||||
"fingerprint/2.1",
|
||||
"fingerprint/2.1/vts/functional",
|
||||
]
|
|
@ -0,0 +1,73 @@
|
|||
// This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
filegroup {
|
||||
name: "android.hardware.biometrics.fingerprint@2.1_hal",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IBiometricsFingerprint.hal",
|
||||
"IBiometricsFingerprintClientCallback.hal",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.biometrics.fingerprint@2.1_genc++",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.biometrics.fingerprint@2.1",
|
||||
srcs: [
|
||||
":android.hardware.biometrics.fingerprint@2.1_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/biometrics/fingerprint/2.1/types.cpp",
|
||||
"android/hardware/biometrics/fingerprint/2.1/BiometricsFingerprintAll.cpp",
|
||||
"android/hardware/biometrics/fingerprint/2.1/BiometricsFingerprintClientCallbackAll.cpp",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.biometrics.fingerprint@2.1_genc++_headers",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.biometrics.fingerprint@2.1",
|
||||
srcs: [
|
||||
":android.hardware.biometrics.fingerprint@2.1_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/biometrics/fingerprint/2.1/types.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/hwtypes.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/IHwBiometricsFingerprint.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/BnHwBiometricsFingerprint.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/BpHwBiometricsFingerprint.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/BsBiometricsFingerprint.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/IHwBiometricsFingerprintClientCallback.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/BnHwBiometricsFingerprintClientCallback.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/BpHwBiometricsFingerprintClientCallback.h",
|
||||
"android/hardware/biometrics/fingerprint/2.1/BsBiometricsFingerprintClientCallback.h",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "android.hardware.biometrics.fingerprint@2.1",
|
||||
defaults: ["hidl-module-defaults"],
|
||||
generated_sources: ["android.hardware.biometrics.fingerprint@2.1_genc++"],
|
||||
generated_headers: ["android.hardware.biometrics.fingerprint@2.1_genc++_headers"],
|
||||
export_generated_headers: ["android.hardware.biometrics.fingerprint@2.1_genc++_headers"],
|
||||
vendor_available: true,
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
],
|
||||
export_shared_lib_headers: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"libutils",
|
||||
],
|
||||
}
|
|
@ -0,0 +1,468 @@
|
|||
# This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
################################################################################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.biometrics.fingerprint-V2.1-java
|
||||
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
||||
|
||||
intermediates := $(call local-generated-sources-dir, COMMON)
|
||||
|
||||
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := \
|
||||
android.hidl.base-V1.0-java \
|
||||
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintAcquired)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintAcquired.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintAcquired
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintAcquiredInfo)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintAcquiredInfo.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintAcquiredInfo
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintAuthenticated)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintAuthenticated.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintAuthenticated
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintEnroll)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintEnroll.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintEnroll
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintError)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintError.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintError
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintFingerId)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintFingerId.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintFingerId
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintIterator)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintIterator.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintIterator
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintMsgType)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintMsgType.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintMsgType
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (RequestStatus)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/RequestStatus.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.RequestStatus
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build IBiometricsFingerprint.hal
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/IBiometricsFingerprint.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBiometricsFingerprint.hal
|
||||
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IBiometricsFingerprintClientCallback.hal
|
||||
$(GEN): $(LOCAL_PATH)/IBiometricsFingerprintClientCallback.hal
|
||||
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::IBiometricsFingerprint
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/IBiometricsFingerprint.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build IBiometricsFingerprintClientCallback.hal
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/IBiometricsFingerprintClientCallback.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBiometricsFingerprintClientCallback.hal
|
||||
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::IBiometricsFingerprintClientCallback
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/IBiometricsFingerprintClientCallback.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
include $(BUILD_JAVA_LIBRARY)
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.biometrics.fingerprint-V2.1-java-static
|
||||
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
||||
|
||||
intermediates := $(call local-generated-sources-dir, COMMON)
|
||||
|
||||
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
android.hidl.base-V1.0-java-static \
|
||||
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintAcquired)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintAcquired.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintAcquired
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintAcquiredInfo)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintAcquiredInfo.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintAcquiredInfo
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintAuthenticated)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintAuthenticated.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintAuthenticated
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintEnroll)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintEnroll.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintEnroll
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintError)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintError.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintError
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintFingerId)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintFingerId.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintFingerId
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintIterator)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintIterator.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintIterator
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (FingerprintMsgType)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/FingerprintMsgType.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.FingerprintMsgType
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (RequestStatus)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/RequestStatus.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::types.RequestStatus
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build IBiometricsFingerprint.hal
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/IBiometricsFingerprint.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBiometricsFingerprint.hal
|
||||
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IBiometricsFingerprintClientCallback.hal
|
||||
$(GEN): $(LOCAL_PATH)/IBiometricsFingerprintClientCallback.hal
|
||||
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::IBiometricsFingerprint
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/IBiometricsFingerprint.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build IBiometricsFingerprintClientCallback.hal
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/biometrics/fingerprint/V2_1/IBiometricsFingerprintClientCallback.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBiometricsFingerprintClientCallback.hal
|
||||
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.biometrics.fingerprint@2.1::IBiometricsFingerprintClientCallback
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/IBiometricsFingerprintClientCallback.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
|
||||
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* Copyright (C) 2017 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
package android.hardware.biometrics.fingerprint@2.1;
|
||||
|
||||
import IBiometricsFingerprintClientCallback;
|
||||
|
||||
interface IBiometricsFingerprint {
|
||||
/**
|
||||
* Set notification callback:
|
||||
* Registers a user function that must receive notifications from the HAL
|
||||
* This call must block if the HAL state machine is in busy state until HAL
|
||||
* leaves the busy state.
|
||||
*
|
||||
* @return deviceId is a unique handle for this fingerprint device
|
||||
*/
|
||||
@callflow(next={"setActiveGroup"})
|
||||
@entry
|
||||
setNotify(IBiometricsFingerprintClientCallback clientCallback)
|
||||
generates (uint64_t deviceId);
|
||||
|
||||
/**
|
||||
* Fingerprint pre-enroll enroll request:
|
||||
* Generates a unique token to upper layers to indicate the start of
|
||||
* an enrollment transaction. pre-enroll and post-enroll specify
|
||||
* a pin/password cleared time window where enrollment is allowed.
|
||||
* Pre-enroll only generates a challenge, a full hardwareAuthToken is
|
||||
* generated by trustzone after verifying a pin/password/swipe. This is to
|
||||
* ensure adding a new fingerprint template was preceded by some kind of
|
||||
* credential confirmation (e.g. device password).
|
||||
*
|
||||
* @return 0 if function failed, a uint64_t of challenge otherwise.
|
||||
*/
|
||||
@callflow(next={"enroll", "postEnroll"})
|
||||
preEnroll() generates (uint64_t authChallenge);
|
||||
|
||||
/**
|
||||
* Fingerprint enroll request:
|
||||
* Switches the HAL state machine to collect and store a new fingerprint
|
||||
* template. Switches back as soon as enroll is complete, signalled by
|
||||
* (fingerprintMsg.type == FINGERPRINT_TEMPLATE_ENROLLING &&
|
||||
* fingerprintMsg.data.enroll.samplesRemaining == 0)
|
||||
* or after timeoutSec seconds.
|
||||
* The fingerprint template must be assigned to the group gid.
|
||||
*
|
||||
* @param hat a valid Hardware Authentication Token (HAT), generated
|
||||
* as a result of a preEnroll() call.
|
||||
* @param gid a framework defined fingerprint set (group) id.
|
||||
* @param timeoutSec a timeout in seconds.
|
||||
*
|
||||
* @return debugErrno is a value the framework logs in case it is not 0.
|
||||
*
|
||||
* A notify() function may be called with a more detailed error structure.
|
||||
*/
|
||||
@callflow(next={"cancel", "enroll", "postEnroll", "remove"})
|
||||
enroll(uint8_t[69] hat, uint32_t gid, uint32_t timeoutSec)
|
||||
generates (RequestStatus debugErrno);
|
||||
|
||||
/**
|
||||
* Finishes the enroll operation and invalidates the preEnroll() generated
|
||||
* challenge. This must be called at the end of a multi-finger enrollment
|
||||
* session to indicate that no more fingers may be added.
|
||||
*
|
||||
* @return debugErrno is a value the framework logs in case it is not 0.
|
||||
*/
|
||||
@callflow(next={"authenticate", "setActiveGroup", "enumerate", "remove"})
|
||||
postEnroll() generates (RequestStatus debugErrno);
|
||||
|
||||
/**
|
||||
* getAuthenticatorId:
|
||||
* Returns a token associated with the current fingerprint set. This value
|
||||
* must change whenever a new fingerprint is enrolled, thus creating a new
|
||||
* fingerprint set.
|
||||
*
|
||||
* @return getAuthenticatorIdRet current authenticator id, 0 if function
|
||||
* failed.
|
||||
*/
|
||||
@callflow(next={"authenticate"})
|
||||
getAuthenticatorId() generates (uint64_t AuthenticatorId);
|
||||
|
||||
/**
|
||||
* Cancel pending enroll or authenticate, sending FINGERPRINT_ERROR_CANCELED
|
||||
* to all running clients. Switches the HAL state machine back to the idle
|
||||
* state. Unlike enrollDone() doesn't invalidate the preEnroll() challenge.
|
||||
*
|
||||
* @return debugErrno is a value the framework logs in case it is not 0.
|
||||
*/
|
||||
@callflow(next={"authenticate", "enroll", "enumerate", "remove",
|
||||
"setActiveGroup"})
|
||||
cancel() generates (RequestStatus debugErrno);
|
||||
|
||||
/**
|
||||
* Enumerate all the fingerprint templates found in the directory set by
|
||||
* setActiveGroup():
|
||||
* For each template found a notify() must be called with:
|
||||
* fingerprintMsg.type == FINGERPRINT_TEMPLATE_ENUMERATED
|
||||
* fingerprintMsg.data.enumerated.finger indicating a template id
|
||||
* fingerprintMsg.data.enumerated.remainingTemplates indicating how many more
|
||||
* enumeration messages to expect.
|
||||
*
|
||||
* @return debugErrno is a value the framework logs in case it is not 0.
|
||||
*/
|
||||
@callflow(next={"remove", "enroll", "authenticate", "setActiveGroup"})
|
||||
enumerate() generates (RequestStatus debugErrno);
|
||||
|
||||
/**
|
||||
* Fingerprint remove request:
|
||||
* Deletes fingerprint template(s).
|
||||
* Works only within the path set by setActiveGroup().
|
||||
* For each template found a notify() must be called with:
|
||||
* fingerprintMsg.type == FINGERPRINT_TEMPLATE_REMOVED
|
||||
* fingerprintMsg.data.removed.finger indicating the template id deleted
|
||||
* fingerprintMsg.data.removed.remainingTemplates indicating how many more
|
||||
* templates must be deleted by this operation.
|
||||
*
|
||||
* @param gid group id must match the last group set by setActiveGroup().
|
||||
* @param fid template id to delete or 0 to delete all templates within the
|
||||
* current group.
|
||||
*
|
||||
* @return debugErrno is a value the framework logs in case it is not 0.
|
||||
*/
|
||||
@callflow(next={"enumerate", "authenticate", "cancel", "getAuthenticatorId",
|
||||
"setActiveGroup"})
|
||||
remove(uint32_t gid, uint32_t fid) generates (RequestStatus debugErrno);
|
||||
|
||||
/**
|
||||
* Restricts the HAL operation to a set of fingerprints belonging to a group
|
||||
* provided. The caller must provide a path to a storage location within the
|
||||
* user's data directory.
|
||||
*
|
||||
* @param gid the fingerprint group (set) id.
|
||||
* @param storePath filesystem path to the template storage directory.
|
||||
*
|
||||
* @return debugErrno is a value the framework logs in case it is not 0.
|
||||
*/
|
||||
@callflow(next={"authenticate", "preEnroll", "enumerate", "remove"})
|
||||
setActiveGroup(uint32_t gid, string storePath)
|
||||
generates (RequestStatus debugErrno);
|
||||
|
||||
/**
|
||||
* Authenticates an operation identified by operationId
|
||||
*
|
||||
* @param operationId operation id.
|
||||
* @param gid fingerprint group id.
|
||||
*
|
||||
* @return debugErrno is a value the framework logs in case it is not 0.
|
||||
*/
|
||||
@callflow(next={"cancel", "preEnroll", "remove"})
|
||||
authenticate(uint64_t operationId, uint32_t gid)
|
||||
generates (RequestStatus debugErrno);
|
||||
};
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (C) 2017 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
package android.hardware.biometrics.fingerprint@2.1;
|
||||
|
||||
/* This HAL interface communicates asynchronous results from the
|
||||
fingerprint driver in response to user actions on the fingerprint sensor
|
||||
*/
|
||||
interface IBiometricsFingerprintClientCallback {
|
||||
/**
|
||||
* Sent when one enrollment step is complete.
|
||||
* @param deviceId the instance of this fingerprint device
|
||||
* @param fingerId the fingerprint templetate being enrolled
|
||||
* @param groupId the groupid for the template being enrolled
|
||||
* @param remaining the number of remaining steps before enrolllment is complete
|
||||
*/
|
||||
oneway onEnrollResult(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, uint32_t remaining);
|
||||
|
||||
/**
|
||||
* Sent when a fingerprint image is acquired by the sensor
|
||||
* @param deviceId the instance of this fingerprint device
|
||||
* @param acquiredInfo a message about the quality of the acquired image
|
||||
* @param vendorCode a vendor-specific message about the quality of the image. Only
|
||||
* valid when acquiredInfo == ACQUIRED_VENDOR
|
||||
*/
|
||||
oneway onAcquired(uint64_t deviceId, FingerprintAcquiredInfo acquiredInfo, int32_t vendorCode);
|
||||
|
||||
/**
|
||||
* Sent when a fingerprint is authenticated
|
||||
* @param deviceId the instance of this fingerprint device
|
||||
* @param fingerId the fingerprint templetate that was authenticated
|
||||
* @param groupId the groupid for the template that was authenticated
|
||||
* @param token the hardware authentication token to pass to Keystore.addAuthToken()
|
||||
*/
|
||||
oneway onAuthenticated(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, vec<uint8_t> token);
|
||||
|
||||
/**
|
||||
* Sent when a fingerprint error occurs
|
||||
* @param deviceId the instance of this fingerprint device
|
||||
* @param error a message about the error that occurred
|
||||
* @param vendorCode a vendor-speicifc error message. Only valid
|
||||
* when error == ERROR_VENDOR
|
||||
*/
|
||||
oneway onError(uint64_t deviceId, FingerprintError error, int32_t vendorCode);
|
||||
|
||||
/**
|
||||
* Sent when one template is removed
|
||||
* @param deviceId the instance of this fingerprint device
|
||||
* @param fingerId the fingerprint templetate being removed
|
||||
* @param groupId the groupid for the template being removed
|
||||
* @param remaining the number of remaining templates that will be removed.
|
||||
*/
|
||||
oneway onRemoved(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, uint32_t remaining);
|
||||
|
||||
/**
|
||||
* Sent when one fingerprint template is enumerated
|
||||
* @param deviceId the instance of this fingerprint device
|
||||
* @param fingerId the fingerprint for this templetate
|
||||
* @param groupId the groupid for this template
|
||||
* @param remaining the number of remaining steps before enumeration is complete
|
||||
*/
|
||||
oneway onEnumerate(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, uint32_t remaining);
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.biometrics.fingerprint@2.1-service
|
||||
LOCAL_INIT_RC := android.hardware.biometrics.fingerprint@2.1-service.rc
|
||||
LOCAL_PROPRIETARY_MODULE := true
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_SRC_FILES := \
|
||||
BiometricsFingerprint.cpp \
|
||||
service.cpp \
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libcutils \
|
||||
liblog \
|
||||
libhidlbase \
|
||||
libhidltransport \
|
||||
libhardware \
|
||||
libutils \
|
||||
android.hardware.biometrics.fingerprint@2.1 \
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
|
@ -0,0 +1,358 @@
|
|||
/*
|
||||
* Copyright (C) 2017 The Android Open Source 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 "android.hardware.biometrics.fingerprint@2.1-service"
|
||||
#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.1-service"
|
||||
|
||||
#include <hardware/hw_auth_token.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/fingerprint.h>
|
||||
#include "BiometricsFingerprint.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace biometrics {
|
||||
namespace fingerprint {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
|
||||
// Supported fingerprint HAL version
|
||||
static const uint16_t kVersion = HARDWARE_MODULE_API_VERSION(2, 1);
|
||||
|
||||
using RequestStatus =
|
||||
android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
||||
|
||||
BiometricsFingerprint *BiometricsFingerprint::sInstance = nullptr;
|
||||
|
||||
BiometricsFingerprint::BiometricsFingerprint() : mClientCallback(nullptr), mDevice(nullptr) {
|
||||
sInstance = this; // keep track of the most recent instance
|
||||
mDevice = openHal();
|
||||
if (!mDevice) {
|
||||
ALOGE("Can't open HAL module");
|
||||
}
|
||||
}
|
||||
|
||||
BiometricsFingerprint::~BiometricsFingerprint() {
|
||||
ALOGV("~BiometricsFingerprint()");
|
||||
if (mDevice == nullptr) {
|
||||
ALOGE("No valid device");
|
||||
return;
|
||||
}
|
||||
int err;
|
||||
if (0 != (err = mDevice->common.close(
|
||||
reinterpret_cast<hw_device_t*>(mDevice)))) {
|
||||
ALOGE("Can't close fingerprint module, error: %d", err);
|
||||
return;
|
||||
}
|
||||
mDevice = nullptr;
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::ErrorFilter(int32_t error) {
|
||||
switch(error) {
|
||||
case 0: return RequestStatus::SYS_OK;
|
||||
case -2: return RequestStatus::SYS_ENOENT;
|
||||
case -4: return RequestStatus::SYS_EINTR;
|
||||
case -5: return RequestStatus::SYS_EIO;
|
||||
case -11: return RequestStatus::SYS_EAGAIN;
|
||||
case -12: return RequestStatus::SYS_ENOMEM;
|
||||
case -13: return RequestStatus::SYS_EACCES;
|
||||
case -14: return RequestStatus::SYS_EFAULT;
|
||||
case -16: return RequestStatus::SYS_EBUSY;
|
||||
case -22: return RequestStatus::SYS_EINVAL;
|
||||
case -28: return RequestStatus::SYS_ENOSPC;
|
||||
case -110: return RequestStatus::SYS_ETIMEDOUT;
|
||||
default:
|
||||
ALOGE("An unknown error returned from fingerprint vendor library: %d", error);
|
||||
return RequestStatus::SYS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// Translate from errors returned by traditional HAL (see fingerprint.h) to
|
||||
// HIDL-compliant FingerprintError.
|
||||
FingerprintError BiometricsFingerprint::VendorErrorFilter(int32_t error,
|
||||
int32_t* vendorCode) {
|
||||
*vendorCode = 0;
|
||||
switch(error) {
|
||||
case FINGERPRINT_ERROR_HW_UNAVAILABLE:
|
||||
return FingerprintError::ERROR_HW_UNAVAILABLE;
|
||||
case FINGERPRINT_ERROR_UNABLE_TO_PROCESS:
|
||||
return FingerprintError::ERROR_UNABLE_TO_PROCESS;
|
||||
case FINGERPRINT_ERROR_TIMEOUT:
|
||||
return FingerprintError::ERROR_TIMEOUT;
|
||||
case FINGERPRINT_ERROR_NO_SPACE:
|
||||
return FingerprintError::ERROR_NO_SPACE;
|
||||
case FINGERPRINT_ERROR_CANCELED:
|
||||
return FingerprintError::ERROR_CANCELED;
|
||||
case FINGERPRINT_ERROR_UNABLE_TO_REMOVE:
|
||||
return FingerprintError::ERROR_UNABLE_TO_REMOVE;
|
||||
case FINGERPRINT_ERROR_LOCKOUT:
|
||||
return FingerprintError::ERROR_LOCKOUT;
|
||||
default:
|
||||
if (error >= FINGERPRINT_ERROR_VENDOR_BASE) {
|
||||
// vendor specific code.
|
||||
*vendorCode = error - FINGERPRINT_ERROR_VENDOR_BASE;
|
||||
return FingerprintError::ERROR_VENDOR;
|
||||
}
|
||||
}
|
||||
ALOGE("Unknown error from fingerprint vendor library: %d", error);
|
||||
return FingerprintError::ERROR_UNABLE_TO_PROCESS;
|
||||
}
|
||||
|
||||
// Translate acquired messages returned by traditional HAL (see fingerprint.h)
|
||||
// to HIDL-compliant FingerprintAcquiredInfo.
|
||||
FingerprintAcquiredInfo BiometricsFingerprint::VendorAcquiredFilter(
|
||||
int32_t info, int32_t* vendorCode) {
|
||||
*vendorCode = 0;
|
||||
switch(info) {
|
||||
case FINGERPRINT_ACQUIRED_GOOD:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_GOOD;
|
||||
case FINGERPRINT_ACQUIRED_PARTIAL:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_PARTIAL;
|
||||
case FINGERPRINT_ACQUIRED_INSUFFICIENT:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT;
|
||||
case FINGERPRINT_ACQUIRED_IMAGER_DIRTY:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_IMAGER_DIRTY;
|
||||
case FINGERPRINT_ACQUIRED_TOO_SLOW:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_TOO_SLOW;
|
||||
case FINGERPRINT_ACQUIRED_TOO_FAST:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_TOO_FAST;
|
||||
default:
|
||||
if (info >= FINGERPRINT_ACQUIRED_VENDOR_BASE) {
|
||||
// vendor specific code.
|
||||
*vendorCode = info - FINGERPRINT_ACQUIRED_VENDOR_BASE;
|
||||
return FingerprintAcquiredInfo::ACQUIRED_VENDOR;
|
||||
}
|
||||
}
|
||||
ALOGE("Unknown acquiredmsg from fingerprint vendor library: %d", info);
|
||||
return FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT;
|
||||
}
|
||||
|
||||
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
|
||||
// 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.
|
||||
return reinterpret_cast<uint64_t>(mDevice);
|
||||
}
|
||||
|
||||
Return<uint64_t> BiometricsFingerprint::preEnroll() {
|
||||
return mDevice->pre_enroll(mDevice);
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::enroll(const hidl_array<uint8_t, 69>& hat,
|
||||
uint32_t gid, uint32_t timeoutSec) {
|
||||
const hw_auth_token_t* authToken =
|
||||
reinterpret_cast<const hw_auth_token_t*>(hat.data());
|
||||
return ErrorFilter(mDevice->enroll(mDevice, authToken, gid, timeoutSec));
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::postEnroll() {
|
||||
return ErrorFilter(mDevice->post_enroll(mDevice));
|
||||
}
|
||||
|
||||
Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() {
|
||||
return mDevice->get_authenticator_id(mDevice);
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::cancel() {
|
||||
return ErrorFilter(mDevice->cancel(mDevice));
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::enumerate() {
|
||||
return ErrorFilter(mDevice->enumerate(mDevice));
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid) {
|
||||
return ErrorFilter(mDevice->remove(mDevice, gid, fid));
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid,
|
||||
const hidl_string& storePath) {
|
||||
if (storePath.size() >= PATH_MAX || storePath.size() <= 0) {
|
||||
ALOGE("Bad path length: %zd", storePath.size());
|
||||
return RequestStatus::SYS_EINVAL;
|
||||
}
|
||||
if (access(storePath.c_str(), W_OK)) {
|
||||
return RequestStatus::SYS_EINVAL;
|
||||
}
|
||||
|
||||
return ErrorFilter(mDevice->set_active_group(mDevice, gid,
|
||||
storePath.c_str()));
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId,
|
||||
uint32_t gid) {
|
||||
return ErrorFilter(mDevice->authenticate(mDevice, operationId, gid));
|
||||
}
|
||||
|
||||
IBiometricsFingerprint* BiometricsFingerprint::getInstance() {
|
||||
if (!sInstance) {
|
||||
sInstance = new BiometricsFingerprint();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
fingerprint_device_t* BiometricsFingerprint::openHal() {
|
||||
int err;
|
||||
const hw_module_t *hw_mdl = nullptr;
|
||||
ALOGD("Opening fingerprint hal library...");
|
||||
if (0 != (err = hw_get_module(FINGERPRINT_HARDWARE_MODULE_ID, &hw_mdl))) {
|
||||
ALOGE("Can't open fingerprint HW Module, error: %d", err);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (hw_mdl == nullptr) {
|
||||
ALOGE("No valid fingerprint module");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
fingerprint_module_t const *module =
|
||||
reinterpret_cast<const fingerprint_module_t*>(hw_mdl);
|
||||
if (module->common.methods->open == nullptr) {
|
||||
ALOGE("No valid open method");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
hw_device_t *device = nullptr;
|
||||
|
||||
if (0 != (err = module->common.methods->open(hw_mdl, nullptr, &device))) {
|
||||
ALOGE("Can't open fingerprint methods, error: %d", err);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (kVersion != device->version) {
|
||||
// enforce version on new devices because of HIDL@2.1 translation layer
|
||||
ALOGE("Wrong fp version. Expected %d, got %d", kVersion, device->version);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
fingerprint_device_t* fp_device =
|
||||
reinterpret_cast<fingerprint_device_t*>(device);
|
||||
|
||||
if (0 != (err =
|
||||
fp_device->set_notify(fp_device, BiometricsFingerprint::notify))) {
|
||||
ALOGE("Can't register fingerprint module callback, error: %d", err);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return fp_device;
|
||||
}
|
||||
|
||||
void BiometricsFingerprint::notify(const fingerprint_msg_t *msg) {
|
||||
BiometricsFingerprint* thisPtr = static_cast<BiometricsFingerprint*>(
|
||||
BiometricsFingerprint::getInstance());
|
||||
std::lock_guard<std::mutex> lock(thisPtr->mClientCallbackMutex);
|
||||
if (thisPtr == nullptr || thisPtr->mClientCallback == nullptr) {
|
||||
ALOGE("Receiving callbacks before the client callback is registered.");
|
||||
return;
|
||||
}
|
||||
const uint64_t devId = reinterpret_cast<uint64_t>(thisPtr->mDevice);
|
||||
switch (msg->type) {
|
||||
case FINGERPRINT_ERROR: {
|
||||
int32_t vendorCode = 0;
|
||||
FingerprintError result = VendorErrorFilter(msg->data.error, &vendorCode);
|
||||
ALOGD("onError(%d)", result);
|
||||
if (!thisPtr->mClientCallback->onError(devId, result, vendorCode).isOk()) {
|
||||
ALOGE("failed to invoke fingerprint onError callback");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FINGERPRINT_ACQUIRED: {
|
||||
int32_t vendorCode = 0;
|
||||
FingerprintAcquiredInfo result =
|
||||
VendorAcquiredFilter(msg->data.acquired.acquired_info, &vendorCode);
|
||||
ALOGD("onAcquired(%d)", result);
|
||||
if (!thisPtr->mClientCallback->onAcquired(devId, result, vendorCode).isOk()) {
|
||||
ALOGE("failed to invoke fingerprint onAcquired callback");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FINGERPRINT_TEMPLATE_ENROLLING:
|
||||
ALOGD("onEnrollResult(fid=%d, gid=%d, rem=%d)",
|
||||
msg->data.enroll.finger.fid,
|
||||
msg->data.enroll.finger.gid,
|
||||
msg->data.enroll.samples_remaining);
|
||||
if (!thisPtr->mClientCallback->onEnrollResult(devId,
|
||||
msg->data.enroll.finger.fid,
|
||||
msg->data.enroll.finger.gid,
|
||||
msg->data.enroll.samples_remaining).isOk()) {
|
||||
ALOGE("failed to invoke fingerprint onEnrollResult callback");
|
||||
}
|
||||
break;
|
||||
case FINGERPRINT_TEMPLATE_REMOVED:
|
||||
ALOGD("onRemove(fid=%d, gid=%d, rem=%d)",
|
||||
msg->data.removed.finger.fid,
|
||||
msg->data.removed.finger.gid,
|
||||
msg->data.removed.remaining_templates);
|
||||
if (!thisPtr->mClientCallback->onRemoved(devId,
|
||||
msg->data.removed.finger.fid,
|
||||
msg->data.removed.finger.gid,
|
||||
msg->data.removed.remaining_templates).isOk()) {
|
||||
ALOGE("failed to invoke fingerprint onRemoved callback");
|
||||
}
|
||||
break;
|
||||
case FINGERPRINT_AUTHENTICATED:
|
||||
if (msg->data.authenticated.finger.fid != 0) {
|
||||
ALOGD("onAuthenticated(fid=%d, gid=%d)",
|
||||
msg->data.authenticated.finger.fid,
|
||||
msg->data.authenticated.finger.gid);
|
||||
const uint8_t* hat =
|
||||
reinterpret_cast<const uint8_t *>(&msg->data.authenticated.hat);
|
||||
const hidl_vec<uint8_t> token(
|
||||
std::vector<uint8_t>(hat, hat + sizeof(msg->data.authenticated.hat)));
|
||||
if (!thisPtr->mClientCallback->onAuthenticated(devId,
|
||||
msg->data.authenticated.finger.fid,
|
||||
msg->data.authenticated.finger.gid,
|
||||
token).isOk()) {
|
||||
ALOGE("failed to invoke fingerprint onAuthenticated callback");
|
||||
}
|
||||
} else {
|
||||
// Not a recognized fingerprint
|
||||
if (!thisPtr->mClientCallback->onAuthenticated(devId,
|
||||
msg->data.authenticated.finger.fid,
|
||||
msg->data.authenticated.finger.gid,
|
||||
hidl_vec<uint8_t>()).isOk()) {
|
||||
ALOGE("failed to invoke fingerprint onAuthenticated callback");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FINGERPRINT_TEMPLATE_ENUMERATING:
|
||||
ALOGD("onEnumerate(fid=%d, gid=%d, rem=%d)",
|
||||
msg->data.enumerated.finger.fid,
|
||||
msg->data.enumerated.finger.gid,
|
||||
msg->data.enumerated.remaining_templates);
|
||||
if (!thisPtr->mClientCallback->onEnumerate(devId,
|
||||
msg->data.enumerated.finger.fid,
|
||||
msg->data.enumerated.finger.gid,
|
||||
msg->data.enumerated.remaining_templates).isOk()) {
|
||||
ALOGE("failed to invoke fingerprint onEnumerate callback");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (C) 2017 The Android Open Source 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 ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
|
||||
#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
|
||||
|
||||
#include <log/log.h>
|
||||
#include <android/log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/fingerprint.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace biometrics {
|
||||
namespace fingerprint {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
|
||||
struct BiometricsFingerprint : public IBiometricsFingerprint {
|
||||
public:
|
||||
BiometricsFingerprint();
|
||||
~BiometricsFingerprint();
|
||||
|
||||
// Method to wrap legacy HAL with BiometricsFingerprint class
|
||||
static IBiometricsFingerprint* getInstance();
|
||||
|
||||
// Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow.
|
||||
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> 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> authenticate(uint64_t operationId, uint32_t gid) override;
|
||||
|
||||
private:
|
||||
static fingerprint_device_t* openHal();
|
||||
static void notify(const fingerprint_msg_t *msg); /* Static callback for legacy HAL implementation */
|
||||
static Return<RequestStatus> ErrorFilter(int32_t error);
|
||||
static FingerprintError VendorErrorFilter(int32_t error, int32_t* vendorCode);
|
||||
static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode);
|
||||
static BiometricsFingerprint* sInstance;
|
||||
|
||||
std::mutex mClientCallbackMutex;
|
||||
sp<IBiometricsFingerprintClientCallback> mClientCallback;
|
||||
fingerprint_device_t *mDevice;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
|
|
@ -0,0 +1,7 @@
|
|||
service fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service
|
||||
# "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.
|
||||
class late_start
|
||||
user system
|
||||
group system input
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (C) 2017 The Android Open Source 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 "android.hardware.biometrics.fingerprint@2.1-service"
|
||||
|
||||
#include <android/log.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
|
||||
#include <android/hardware/biometrics/fingerprint/2.1/types.h>
|
||||
#include "BiometricsFingerprint.h"
|
||||
|
||||
using android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
|
||||
using android::hardware::biometrics::fingerprint::V2_1::implementation::BiometricsFingerprint;
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
using android::sp;
|
||||
|
||||
int main() {
|
||||
android::sp<IBiometricsFingerprint> bio = BiometricsFingerprint::getInstance();
|
||||
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
|
||||
if (bio != nullptr) {
|
||||
bio->registerAsService();
|
||||
} else {
|
||||
ALOGE("Can't create instance of BiometricsFingerprint, nullptr");
|
||||
}
|
||||
|
||||
joinRpcThreadpool();
|
||||
|
||||
return 0; // should never get here
|
||||
}
|
147
android/hardware/interfaces/biometrics/fingerprint/2.1/types.hal
Normal file
147
android/hardware/interfaces/biometrics/fingerprint/2.1/types.hal
Normal file
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* Copyright (C) 2017 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
package android.hardware.biometrics.fingerprint@2.1;
|
||||
|
||||
/**
|
||||
* Request status indicates whether the request is accepted by the vendor
|
||||
* implementation or not. These values are taken from the errno set,
|
||||
* except for the SYS_UNKNOWN
|
||||
*/
|
||||
enum RequestStatus : int32_t {
|
||||
SYS_UNKNOWN = 1,
|
||||
SYS_OK = 0,
|
||||
SYS_ENOENT = -2,
|
||||
SYS_EINTR = -4,
|
||||
SYS_EIO = -5,
|
||||
SYS_EAGAIN = -11,
|
||||
SYS_ENOMEM = -12,
|
||||
SYS_EACCES = -13,
|
||||
SYS_EFAULT = -14,
|
||||
SYS_EBUSY = -16,
|
||||
SYS_EINVAL = -22,
|
||||
SYS_ENOSPC = -28,
|
||||
SYS_ETIMEDOUT = -110,
|
||||
};
|
||||
|
||||
/**
|
||||
* Fingerprint errors are meant to tell the framework to terminate the current
|
||||
* operation and ask for the user to correct the situation. These will almost
|
||||
* always result in messaging and user interaction to correct the problem.
|
||||
*
|
||||
* For example, ERROR_CANCELED should follow any acquisition message that
|
||||
* results in a situation where the current operation can't continue without
|
||||
* user interaction. For example, if the sensor is dirty during enrollment and
|
||||
* no further enrollment progress can be made, send ACQUIRED_IMAGER_DIRTY
|
||||
* followed by ERROR_CANCELED.
|
||||
*/
|
||||
enum FingerprintError : int32_t {
|
||||
/** Used for testing, no error returned */
|
||||
ERROR_NO_ERROR = 0,
|
||||
/** The hardware has an error that can't be resolved. */
|
||||
ERROR_HW_UNAVAILABLE = 1,
|
||||
/** Bad data; operation can't continue */
|
||||
ERROR_UNABLE_TO_PROCESS = 2,
|
||||
/** The operation has timed out waiting for user input. */
|
||||
ERROR_TIMEOUT = 3,
|
||||
/** No space available to store a template */
|
||||
ERROR_NO_SPACE = 4,
|
||||
/** The current operation has been canceled */
|
||||
ERROR_CANCELED = 5,
|
||||
/** Unable to remove a template */
|
||||
ERROR_UNABLE_TO_REMOVE = 6,
|
||||
/** The hardware is in lockout due to too many attempts */
|
||||
ERROR_LOCKOUT = 7,
|
||||
/** Vendor-specific error message */
|
||||
ERROR_VENDOR = 8
|
||||
};
|
||||
|
||||
/**
|
||||
* Fingerprint acquisition info is meant as feedback for the current operation.
|
||||
* Anything but ACQUIRED_GOOD must be shown to the user as feedback on how to
|
||||
* take action on the current operation. For example, ACQUIRED_IMAGER_DIRTY may
|
||||
* be used to tell the user to clean the sensor if it is detected to be dirty.
|
||||
* If this causes the current operation to fail, an additional ERROR_CANCELED
|
||||
* must be sent to stop the operation in progress (e.g. enrollment).
|
||||
* In general, these messages will result in a "Try again" message.
|
||||
*/
|
||||
enum FingerprintAcquiredInfo : int32_t {
|
||||
ACQUIRED_GOOD = 0,
|
||||
/** sensor needs more data, i.e. longer swipe. */
|
||||
ACQUIRED_PARTIAL = 1,
|
||||
/**
|
||||
* image doesn't contain enough detail for recognition*/
|
||||
ACQUIRED_INSUFFICIENT = 2,
|
||||
/** sensor needs to be cleaned */
|
||||
ACQUIRED_IMAGER_DIRTY = 3,
|
||||
/** mostly swipe-type sensors; not enough data collected */
|
||||
ACQUIRED_TOO_SLOW = 4,
|
||||
/** vendor-specific acquisition messages start here */
|
||||
ACQUIRED_TOO_FAST = 5,
|
||||
/** vendor-specific acquisition messages */
|
||||
ACQUIRED_VENDOR = 6
|
||||
};
|
||||
|
||||
struct FingerprintFingerId {
|
||||
/** Group ID */
|
||||
uint32_t gid;
|
||||
/** Fingerprint template ID */
|
||||
uint32_t fid;
|
||||
};
|
||||
|
||||
struct FingerprintEnroll {
|
||||
/** Template ID */
|
||||
FingerprintFingerId finger;
|
||||
/**
|
||||
* samplesRemaining goes from N (no data collected, but N scans needed)
|
||||
* to 0 (no more data is needed to build a template). */
|
||||
uint32_t samplesRemaining;
|
||||
/** Vendor specific message. Used for user guidance */
|
||||
uint64_t msg;
|
||||
};
|
||||
|
||||
struct FingerprintIterator {
|
||||
/** Template ID */
|
||||
FingerprintFingerId finger;
|
||||
/** How many templates remain to iterate through */
|
||||
uint32_t remainingTemplates;
|
||||
};
|
||||
|
||||
typedef FingerprintIterator FingerprintEnumerated;
|
||||
typedef FingerprintIterator FingerprintRemoved;
|
||||
|
||||
struct FingerprintAcquired {
|
||||
/** information about the image */
|
||||
FingerprintAcquiredInfo acquiredInfo;
|
||||
};
|
||||
|
||||
struct FingerprintAuthenticated {
|
||||
/** Matched template ID */
|
||||
FingerprintFingerId finger;
|
||||
/** Authentication result from the keymaster */
|
||||
uint8_t[69] hat;
|
||||
};
|
||||
|
||||
/** Run time type identification for the notify() call payload. */
|
||||
enum FingerprintMsgType : int32_t {
|
||||
ERROR = -1,
|
||||
ACQUIRED = 1,
|
||||
TEMPLATE_ENROLLING = 3,
|
||||
TEMPLATE_REMOVED = 4,
|
||||
AUTHENTICATED = 5,
|
||||
TEMPLATE_ENUMERATING = 6,
|
||||
};
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Copyright (C) 2017 The Android Open Source 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.
|
||||
//
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalBiometricsFingerprintV2_1TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: ["VtsHalBiometricsFingerprintV2_1TargetTest.cpp"],
|
||||
static_libs: ["android.hardware.biometrics.fingerprint@2.1"],
|
||||
}
|
||||
|
|
@ -0,0 +1,462 @@
|
|||
/*
|
||||
* Copyright (C) 2017 The Android Open Source 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 "fingerprint_hidl_hal_test"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
|
||||
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <future>
|
||||
#include <utility>
|
||||
|
||||
using android::Condition;
|
||||
using android::hardware::biometrics::fingerprint::V2_1::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;
|
||||
using android::hardware::hidl_vec;
|
||||
using android::hardware::Return;
|
||||
using android::Mutex;
|
||||
using android::sp;
|
||||
|
||||
namespace {
|
||||
|
||||
static const uint32_t kTimeout = 3;
|
||||
static const std::chrono::seconds kTimeoutInSeconds = std::chrono::seconds(kTimeout);
|
||||
static const uint32_t kGroupId = 99;
|
||||
static const std::string kTmpDir = "/data/system/";
|
||||
static const uint32_t kIterations = 1000;
|
||||
|
||||
// Wait for a callback to occur (signaled by the given future) up to the
|
||||
// provided timeout. If the future is invalid or the callback does not come
|
||||
// within the given time, returns false.
|
||||
template<class ReturnType>
|
||||
bool waitForCallback(
|
||||
std::future<ReturnType> future,
|
||||
std::chrono::milliseconds timeout = kTimeoutInSeconds) {
|
||||
auto expiration = std::chrono::system_clock::now() + timeout;
|
||||
|
||||
EXPECT_TRUE(future.valid());
|
||||
if (future.valid()) {
|
||||
std::future_status status = future.wait_until(expiration);
|
||||
EXPECT_NE(std::future_status::timeout, status)
|
||||
<< "Timed out waiting for callback";
|
||||
if (status == std::future_status::ready) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Base callback implementation that just logs all callbacks by default
|
||||
class FingerprintCallbackBase : public IBiometricsFingerprintClientCallback {
|
||||
public:
|
||||
// implement methods of IBiometricsFingerprintClientCallback
|
||||
virtual Return<void> onEnrollResult(uint64_t, uint32_t, uint32_t, uint32_t)
|
||||
override {
|
||||
ALOGD("Enroll callback called.");
|
||||
return Return<void>();
|
||||
}
|
||||
|
||||
virtual Return<void> onAcquired(uint64_t, FingerprintAcquiredInfo, int32_t)
|
||||
override {
|
||||
ALOGD("Acquired callback called.");
|
||||
return Return<void>();
|
||||
}
|
||||
|
||||
virtual Return<void> onAuthenticated(uint64_t, uint32_t, uint32_t,
|
||||
const hidl_vec<uint8_t>&) override {
|
||||
ALOGD("Authenticated callback called.");
|
||||
return Return<void>();
|
||||
}
|
||||
|
||||
virtual Return<void> onError(uint64_t, FingerprintError, int32_t)
|
||||
override {
|
||||
ALOGD("Error callback called.");
|
||||
EXPECT_TRUE(false); // fail any test that triggers an error
|
||||
return Return<void>();
|
||||
}
|
||||
|
||||
virtual Return<void> onRemoved(uint64_t, uint32_t, uint32_t, uint32_t)
|
||||
override {
|
||||
ALOGD("Removed callback called.");
|
||||
return Return<void>();
|
||||
}
|
||||
|
||||
virtual Return<void> onEnumerate(uint64_t, uint32_t, uint32_t, uint32_t)
|
||||
override {
|
||||
ALOGD("Enumerate callback called.");
|
||||
return Return<void>();
|
||||
}
|
||||
};
|
||||
|
||||
class EnumerateCallback : public FingerprintCallbackBase {
|
||||
public:
|
||||
virtual Return<void> onEnumerate(uint64_t deviceId, uint32_t fingerId,
|
||||
uint32_t groupId, uint32_t remaining) override {
|
||||
this->deviceId = deviceId;
|
||||
this->fingerId = fingerId;
|
||||
this->groupId = groupId;
|
||||
this->remaining = remaining;
|
||||
|
||||
if(remaining == 0UL) {
|
||||
promise.set_value();
|
||||
}
|
||||
return Return<void>();
|
||||
}
|
||||
|
||||
uint64_t deviceId;
|
||||
uint32_t fingerId;
|
||||
uint32_t groupId;
|
||||
uint32_t remaining;
|
||||
std::promise<void> promise;
|
||||
};
|
||||
|
||||
class ErrorCallback : public FingerprintCallbackBase {
|
||||
public:
|
||||
ErrorCallback(
|
||||
bool filterErrors=false,
|
||||
FingerprintError errorType=FingerprintError::ERROR_NO_ERROR) {
|
||||
this->filterErrors = filterErrors;
|
||||
this->errorType = errorType;
|
||||
}
|
||||
|
||||
virtual Return<void> onError(uint64_t deviceId, FingerprintError error,
|
||||
int32_t vendorCode) override {
|
||||
if ((this->filterErrors && this->errorType == error) || !this->filterErrors) {
|
||||
this->deviceId = deviceId;
|
||||
this->error = error;
|
||||
this->vendorCode = vendorCode;
|
||||
promise.set_value();
|
||||
}
|
||||
return Return<void>();
|
||||
}
|
||||
|
||||
bool filterErrors;
|
||||
FingerprintError errorType;
|
||||
uint64_t deviceId;
|
||||
FingerprintError error;
|
||||
int32_t vendorCode;
|
||||
std::promise<void> promise;
|
||||
};
|
||||
|
||||
class RemoveCallback : public FingerprintCallbackBase {
|
||||
public:
|
||||
RemoveCallback(uint32_t groupId) {
|
||||
this->removeGroupId = groupId;
|
||||
}
|
||||
|
||||
virtual Return<void> onRemoved(uint64_t, uint32_t, uint32_t groupId,
|
||||
uint32_t remaining) override {
|
||||
EXPECT_EQ(this->removeGroupId, groupId);
|
||||
if(remaining == 0UL) {
|
||||
promise.set_value();
|
||||
}
|
||||
return Return<void>();
|
||||
}
|
||||
|
||||
uint32_t removeGroupId;
|
||||
std::promise<void> promise;
|
||||
};
|
||||
|
||||
class FingerprintHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
mService = ::testing::VtsHalHidlTargetTestBase::getService<IBiometricsFingerprint>();
|
||||
ASSERT_FALSE(mService == nullptr);
|
||||
|
||||
// Create an active group
|
||||
// FP service can only write to /data/system due to
|
||||
// SELinux Policy and Linux Dir Permissions
|
||||
Return<RequestStatus> res = mService->setActiveGroup(kGroupId, kTmpDir);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
}
|
||||
|
||||
virtual void TearDown() override {}
|
||||
|
||||
sp<IBiometricsFingerprint> mService;
|
||||
};
|
||||
|
||||
|
||||
// The service should be reachable.
|
||||
TEST_F(FingerprintHidlTest, ConnectTest) {
|
||||
sp<FingerprintCallbackBase> cb = new FingerprintCallbackBase();
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0UL, static_cast<uint64_t>(rc));
|
||||
}
|
||||
|
||||
// Starting the service with null callback should succeed.
|
||||
TEST_F(FingerprintHidlTest, ConnectNullTest) {
|
||||
Return<uint64_t> rc = mService->setNotify(NULL);
|
||||
ASSERT_NE(0UL, static_cast<uint64_t>(rc));
|
||||
}
|
||||
|
||||
// Pre-enroll should always return unique, cryptographically secure, non-zero number
|
||||
TEST_F(FingerprintHidlTest, PreEnrollTest) {
|
||||
std::map<uint64_t, uint64_t> m;
|
||||
|
||||
for(unsigned int i = 0; i < kIterations; ++i) {
|
||||
uint64_t res = static_cast<uint64_t>(mService->preEnroll());
|
||||
EXPECT_NE(0UL, res);
|
||||
m[res]++;
|
||||
EXPECT_EQ(1UL, m[res]);
|
||||
}
|
||||
}
|
||||
|
||||
// Enroll with an invalid (all zeroes) HAT should fail.
|
||||
TEST_F(FingerprintHidlTest, EnrollInvalidHatTest) {
|
||||
sp<ErrorCallback> cb = new ErrorCallback();
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0UL, static_cast<uint64_t>(rc));
|
||||
|
||||
uint8_t token[69];
|
||||
for(int i=0; i<69; i++) {
|
||||
token[i] = 0;
|
||||
}
|
||||
|
||||
Return<RequestStatus> res = mService->enroll(token, kGroupId, kTimeout);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// At least one call to onError should occur
|
||||
ASSERT_TRUE(waitForCallback(cb->promise.get_future()));
|
||||
ASSERT_NE(FingerprintError::ERROR_NO_ERROR, cb->error);
|
||||
}
|
||||
|
||||
// Enroll with an invalid (null) HAT should fail.
|
||||
TEST_F(FingerprintHidlTest, EnrollNullTest) {
|
||||
sp<ErrorCallback> cb = new ErrorCallback();
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0UL, static_cast<uint64_t>(rc));
|
||||
|
||||
uint8_t token[69];
|
||||
Return<RequestStatus> res = mService->enroll(token, kGroupId, kTimeout);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// At least one call to onError should occur
|
||||
ASSERT_TRUE(waitForCallback(cb->promise.get_future()));
|
||||
ASSERT_NE(FingerprintError::ERROR_NO_ERROR, cb->error);
|
||||
}
|
||||
|
||||
// PostEnroll should always return within 3s
|
||||
TEST_F(FingerprintHidlTest, PostEnrollTest) {
|
||||
sp<FingerprintCallbackBase> cb = new FingerprintCallbackBase();
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
|
||||
auto start = std::chrono::system_clock::now();
|
||||
Return<RequestStatus> res = mService->postEnroll();
|
||||
auto elapsed = std::chrono::system_clock::now() - start;
|
||||
ASSERT_GE(kTimeoutInSeconds, elapsed);
|
||||
}
|
||||
|
||||
// getAuthenticatorId should always return non-zero numbers
|
||||
TEST_F(FingerprintHidlTest, GetAuthenticatorIdTest) {
|
||||
Return<uint64_t> res = mService->getAuthenticatorId();
|
||||
EXPECT_NE(0UL, static_cast<uint64_t>(res));
|
||||
}
|
||||
|
||||
// Enumerate should always trigger onEnumerated(fid=0, rem=0) when there are no fingerprints
|
||||
TEST_F(FingerprintHidlTest, EnumerateTest) {
|
||||
sp<EnumerateCallback> cb = new EnumerateCallback();
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0UL, static_cast<uint64_t>(rc));
|
||||
|
||||
// Callback will return when rem=0 is found
|
||||
Return<RequestStatus> res = mService->enumerate();
|
||||
ASSERT_TRUE(waitForCallback(cb->promise.get_future()));
|
||||
EXPECT_EQ(0UL, cb->fingerId);
|
||||
EXPECT_EQ(0UL, cb->remaining);
|
||||
|
||||
}
|
||||
|
||||
// Remove should succeed on any inputs
|
||||
// At least one callback with "remaining=0" should occur
|
||||
TEST_F(FingerprintHidlTest, RemoveFingerprintTest) {
|
||||
// Register callback
|
||||
sp<RemoveCallback> cb = new RemoveCallback(kGroupId);
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0UL, static_cast<uint64_t>(rc));
|
||||
|
||||
// Remove a fingerprint
|
||||
Return<RequestStatus> res = mService->remove(kGroupId, 1);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// At least one call to onRemove with remaining=0 should occur
|
||||
ASSERT_TRUE(waitForCallback(cb->promise.get_future()));
|
||||
}
|
||||
|
||||
// Remove should accept 0 to delete all fingerprints
|
||||
// At least one callback with "remaining=0" should occur.
|
||||
TEST_F(FingerprintHidlTest, RemoveAllFingerprintsTest) {
|
||||
// Register callback
|
||||
sp<RemoveCallback> cb = new RemoveCallback(kGroupId);
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0UL, static_cast<uint64_t>(rc));
|
||||
|
||||
// Remove all fingerprints
|
||||
Return<RequestStatus> res = mService->remove(kGroupId, 0);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
ASSERT_TRUE(waitForCallback(cb->promise.get_future()));
|
||||
}
|
||||
|
||||
// Active group should successfully set to a writable location.
|
||||
TEST_F(FingerprintHidlTest, SetActiveGroupTest) {
|
||||
// Create an active group
|
||||
Return<RequestStatus> res = mService->setActiveGroup(2, kTmpDir);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// Reset active group
|
||||
res = mService->setActiveGroup(kGroupId, kTmpDir);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
}
|
||||
|
||||
// Active group should fail to set to an unwritable location.
|
||||
TEST_F(FingerprintHidlTest, SetActiveGroupUnwritableTest) {
|
||||
// Create an active group to an unwritable location (device root dir)
|
||||
Return<RequestStatus> res = mService->setActiveGroup(3, "/");
|
||||
ASSERT_NE(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// Reset active group
|
||||
res = mService->setActiveGroup(kGroupId, kTmpDir);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
}
|
||||
|
||||
// Active group should fail to set to a null location.
|
||||
TEST_F(FingerprintHidlTest, SetActiveGroupNullTest) {
|
||||
// Create an active group to a null location.
|
||||
Return<RequestStatus> res = mService->setActiveGroup(4, nullptr);
|
||||
ASSERT_NE(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// Reset active group
|
||||
res = mService->setActiveGroup(kGroupId, kTmpDir);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
}
|
||||
|
||||
// Cancel should always return ERROR_CANCELED from any starting state including
|
||||
// the IDLE state.
|
||||
TEST_F(FingerprintHidlTest, CancelTest) {
|
||||
sp<ErrorCallback> cb = new ErrorCallback(true, FingerprintError::ERROR_CANCELED);
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0UL, static_cast<uint64_t>(rc));
|
||||
|
||||
Return<RequestStatus> res = mService->cancel();
|
||||
// check that we were able to make an IPC request successfully
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// make sure callback was invoked within kTimeoutInSeconds
|
||||
ASSERT_TRUE(waitForCallback(cb->promise.get_future()));
|
||||
// check error should be ERROR_CANCELED
|
||||
ASSERT_EQ(FingerprintError::ERROR_CANCELED, cb->error);
|
||||
}
|
||||
|
||||
// A call to cancel should succeed during enroll.
|
||||
TEST_F(FingerprintHidlTest, CancelEnrollTest) {
|
||||
Return<RequestStatus> res = mService->setActiveGroup(kGroupId, kTmpDir);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
sp<ErrorCallback> cb = new ErrorCallback(true, FingerprintError::ERROR_CANCELED);
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0U, static_cast<uint64_t>(rc));
|
||||
|
||||
uint8_t token[69];
|
||||
res = mService->enroll(token, kGroupId, kTimeout);
|
||||
// check that we were able to make an IPC request successfully
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
res = mService->cancel();
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// make sure callback was invoked within kTimeoutInSeconds
|
||||
ASSERT_TRUE(waitForCallback(cb->promise.get_future()));
|
||||
|
||||
// check error should be ERROR_CANCELED
|
||||
ASSERT_EQ(FingerprintError::ERROR_CANCELED, cb->error);
|
||||
}
|
||||
|
||||
// A call to cancel should succeed during authentication.
|
||||
TEST_F(FingerprintHidlTest, CancelAuthTest) {
|
||||
sp<ErrorCallback> cb = new ErrorCallback(true, FingerprintError::ERROR_CANCELED);
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0U, static_cast<uint64_t>(rc));
|
||||
|
||||
Return<RequestStatus> res = mService->authenticate(0, kGroupId);
|
||||
// check that we were able to make an IPC request successfully
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
res = mService->cancel();
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// make sure callback was invoked within kTimeoutInSeconds
|
||||
ASSERT_TRUE(waitForCallback(cb->promise.get_future()));
|
||||
|
||||
// check error should be ERROR_CANCELED
|
||||
ASSERT_EQ(FingerprintError::ERROR_CANCELED, cb->error);
|
||||
}
|
||||
|
||||
// A call to cancel should succeed during authentication.
|
||||
TEST_F(FingerprintHidlTest, CancelRemoveTest) {
|
||||
sp<ErrorCallback> cb = new ErrorCallback(true, FingerprintError::ERROR_CANCELED);
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0U, static_cast<uint64_t>(rc));
|
||||
|
||||
// Remove a fingerprint
|
||||
Return<RequestStatus> res = mService->remove(kGroupId, 1);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
res = mService->cancel();
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// make sure callback was invoked within kTimeoutInSeconds
|
||||
ASSERT_TRUE(waitForCallback(cb->promise.get_future()));
|
||||
|
||||
// check error should be ERROR_CANCELED
|
||||
ASSERT_EQ(FingerprintError::ERROR_CANCELED, cb->error);
|
||||
}
|
||||
|
||||
// A call to cancel should succeed during authentication.
|
||||
TEST_F(FingerprintHidlTest, CancelRemoveAllTest) {
|
||||
sp<ErrorCallback> cb = new ErrorCallback(true, FingerprintError::ERROR_CANCELED);
|
||||
Return<uint64_t> rc = mService->setNotify(cb);
|
||||
ASSERT_NE(0U, static_cast<uint64_t>(rc));
|
||||
|
||||
// Remove a fingerprint
|
||||
Return<RequestStatus> res = mService->remove(kGroupId, 0);
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
res = mService->cancel();
|
||||
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
|
||||
|
||||
// make sure callback was invoked within kTimeoutInSeconds
|
||||
ASSERT_TRUE(waitForCallback(cb->promise.get_future()));
|
||||
|
||||
// check error should be ERROR_CANCELED
|
||||
ASSERT_EQ(FingerprintError::ERROR_CANCELED, cb->error);
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
LOG(INFO) << "Test result = " << status;
|
||||
return status;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue