Loading biometrics/fingerprint/2.1/IBiometricsFingerprint.hal +16 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,23 @@ 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 isOk indicates if the request is accepted. * @return debugErrno is a value the framework logs in case isOk == false. */ @callflow(next={"setActiveGroup"}) @entry setNotify(IBiometricsFingerprintClientCallback clientCallback) generates (bool isOk, int32_t debugErrno); /* * Fingerprint pre-enroll enroll request: * Generates a unique token to upper layers to indicate the start of Loading Loading @@ -138,7 +154,6 @@ interface IBiometricsFingerprint { * @return debugErrno is a value the framework logs in case isOk == false. */ @callflow(next={"authenticate", "preEnroll", "enumerate", "remove"}) @entry setActiveGroup(uint32_t gid, string storePath) generates (bool isOk, int32_t debugErrno); Loading biometrics/fingerprint/2.1/default/Android.mk 0 → 100644 +17 −0 Original line number Diff line number Diff line LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.biometrics.fingerprint@2.1-impl LOCAL_MODULE_RELATIVE_PATH := hw LOCAL_SRC_FILES := \ BiometricsFingerprint.cpp \ LOCAL_SHARED_LIBRARIES := \ liblog \ libhidl \ libhardware \ libhwbinder \ libutils \ android.hardware.biometrics.fingerprint@2.1 \ include $(BUILD_SHARED_LIBRARY) biometrics/fingerprint/2.1/default/BiometricsFingerprint.cpp 0 → 100644 +153 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 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. */ #include <hardware/hardware.h> #include <hardware/fingerprint.h> #include "BiometricsFingerprint.h" namespace android { namespace hardware { namespace biometrics { namespace fingerprint { namespace V2_1 { namespace implementation { sp<IBiometricsFingerprintClientCallback> BiometricsFingerprint::mClientCallback = nullptr; BiometricsFingerprint::BiometricsFingerprint(fingerprint_device_t *device) : mDevice(device) {} BiometricsFingerprint::~BiometricsFingerprint() { ALOG(LOG_VERBOSE, LOG_TAG, "nativeCloseHal()\n"); if (mDevice == NULL) { 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 = NULL; } Return<void> BiometricsFingerprint::setNotify( const sp<IBiometricsFingerprintClientCallback>& clientCallback, setNotify_cb cb) { mClientCallback = clientCallback; int32_t debugErrno = mDevice->set_notify(mDevice, notify); cb(debugErrno == 0, debugErrno); return Void(); } Return<uint64_t> BiometricsFingerprint::preEnroll() { return mDevice->pre_enroll(mDevice); } Return<void> BiometricsFingerprint::enroll(const HwAuthToken& hat, uint32_t gid, uint32_t timeoutSec, enroll_cb cb) { const hw_auth_token_t* authToken = reinterpret_cast<const hw_auth_token_t*>(&hat); int32_t debugErrno = mDevice->enroll(mDevice, authToken, gid, timeoutSec); cb(debugErrno == 0, debugErrno); return Void(); } Return<void> BiometricsFingerprint::postEnroll(postEnroll_cb cb) { int32_t debugErrno = mDevice->post_enroll(mDevice); cb(debugErrno == 0, debugErrno); return Void(); } Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() { return mDevice->get_authenticator_id(mDevice); } Return<void> BiometricsFingerprint::cancel(cancel_cb cb) { int32_t debugErrno = mDevice->cancel(mDevice); cb(debugErrno == 0, debugErrno); return Void(); } Return<void> BiometricsFingerprint::enumerate(enumerate_cb cb) { int32_t debugErrno = mDevice->enumerate(mDevice); cb(debugErrno == 0, debugErrno); return Void(); } Return<void> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid, remove_cb cb) { int32_t debugErrno = mDevice->remove(mDevice, gid, fid); cb(debugErrno == 0, debugErrno); return Void(); } Return<void> BiometricsFingerprint::setActiveGroup(uint32_t gid, const hidl_string& storePath, setActiveGroup_cb cb) { if (storePath.size() >= PATH_MAX || storePath.size() <= 0) { ALOGE("Bad path length: %zd", storePath.size()); } int32_t debugErrno = mDevice->set_active_group(mDevice, gid, storePath.c_str()); cb(debugErrno == 0, debugErrno); return Void(); } Return<void> BiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid, authenticate_cb cb) { int32_t debugErrno = mDevice->authenticate(mDevice, operationId, gid); cb(debugErrno == 0, debugErrno); return Void(); } IBiometricsFingerprint* HIDL_FETCH_IBiometricsFingerprint(const char*) { int err; const hw_module_t *hw_mdl = NULL; 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 == NULL) { 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 == NULL) { ALOGE("No valid open method"); return nullptr; } hw_device_t *device = NULL; if (0 != (err = module->common.methods->open(hw_mdl, NULL, &device))) { ALOGE("Can't open fingerprint methods, error: %d", err); return nullptr; } return new BiometricsFingerprint( reinterpret_cast<fingerprint_device_t*>(device)); } } // namespace implementation } // namespace V2_1 } // namespace fingerprint } // namespace biometrics } // namespace hardware } // namespace android biometrics/fingerprint/2.1/default/BiometricsFingerprint.h 0 → 100644 +79 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 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 HIDL_GENERATED_android_hardware_biometrics_fingerprint_V2_1_BiometricsFingerprint_H_ #define HIDL_GENERATED_android_hardware_biometrics_fingerprint_V2_1_BiometricsFingerprint_H_ #include <utils/Log.h> #include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h> #include <hidl/Status.h> #include <hidl/MQDescriptor.h> namespace android { namespace hardware { namespace biometrics { namespace fingerprint { namespace V2_1 { namespace implementation { using ::android::hardware::biometrics::fingerprint::V2_1::HwAuthToken; using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint; using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback; 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(fingerprint_device_t *device); ~BiometricsFingerprint(); // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow. Return<void> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback, setNotify_cb _hidl_cb) override; Return<uint64_t> preEnroll() override; Return<void> enroll(const HwAuthToken& hat, uint32_t gid, uint32_t timeoutSec, enroll_cb _hidl_cb) override; Return<void> postEnroll(postEnroll_cb _hidl_cb) override; Return<uint64_t> getAuthenticatorId() override; Return<void> cancel(cancel_cb _hidl_cb) override; Return<void> enumerate(enumerate_cb _hidl_cb) override; Return<void> remove(uint32_t gid, uint32_t fid, remove_cb _hidl_cb) override; Return<void> setActiveGroup(uint32_t gid, const hidl_string& storePath, setActiveGroup_cb _hidl_cb) override; Return<void> authenticate(uint64_t operationId, uint32_t gid, authenticate_cb _hidl_cb) override; static void notify(const fingerprint_msg_t *notify_msg) { if (mClientCallback == nullptr) { ALOGE("Receiving callbacks before the client callback is registered."); return; } FingerprintMsg msg = {}; memcpy(&msg, notify_msg, sizeof(msg)); mClientCallback->notify(msg); } private: static sp<IBiometricsFingerprintClientCallback> mClientCallback; fingerprint_device_t *mDevice; }; extern "C" IBiometricsFingerprint* HIDL_FETCH_IBiometricsFingerprint(const char* name); } // namespace implementation } // namespace V2_1 } // namespace fingerprint } // namespace biometrics } // namespace hardware } // namespace android #endif // HIDL_GENERATED_android_hardware_biometrics_fingerprint_V2_1_BiometricsFingerprint_H_ biometrics/fingerprint/2.1/default/android.hardware.biometrics.fingerprint@2.1-service.rc 0 → 100644 +4 −0 Original line number Diff line number Diff line service fingerprint@2.1 /system/bin/hw/android.hardware.biometrics.fingerprint@2.1-service class hal user system group system No newline at end of file Loading
biometrics/fingerprint/2.1/IBiometricsFingerprint.hal +16 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,23 @@ 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 isOk indicates if the request is accepted. * @return debugErrno is a value the framework logs in case isOk == false. */ @callflow(next={"setActiveGroup"}) @entry setNotify(IBiometricsFingerprintClientCallback clientCallback) generates (bool isOk, int32_t debugErrno); /* * Fingerprint pre-enroll enroll request: * Generates a unique token to upper layers to indicate the start of Loading Loading @@ -138,7 +154,6 @@ interface IBiometricsFingerprint { * @return debugErrno is a value the framework logs in case isOk == false. */ @callflow(next={"authenticate", "preEnroll", "enumerate", "remove"}) @entry setActiveGroup(uint32_t gid, string storePath) generates (bool isOk, int32_t debugErrno); Loading
biometrics/fingerprint/2.1/default/Android.mk 0 → 100644 +17 −0 Original line number Diff line number Diff line LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.biometrics.fingerprint@2.1-impl LOCAL_MODULE_RELATIVE_PATH := hw LOCAL_SRC_FILES := \ BiometricsFingerprint.cpp \ LOCAL_SHARED_LIBRARIES := \ liblog \ libhidl \ libhardware \ libhwbinder \ libutils \ android.hardware.biometrics.fingerprint@2.1 \ include $(BUILD_SHARED_LIBRARY)
biometrics/fingerprint/2.1/default/BiometricsFingerprint.cpp 0 → 100644 +153 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 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. */ #include <hardware/hardware.h> #include <hardware/fingerprint.h> #include "BiometricsFingerprint.h" namespace android { namespace hardware { namespace biometrics { namespace fingerprint { namespace V2_1 { namespace implementation { sp<IBiometricsFingerprintClientCallback> BiometricsFingerprint::mClientCallback = nullptr; BiometricsFingerprint::BiometricsFingerprint(fingerprint_device_t *device) : mDevice(device) {} BiometricsFingerprint::~BiometricsFingerprint() { ALOG(LOG_VERBOSE, LOG_TAG, "nativeCloseHal()\n"); if (mDevice == NULL) { 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 = NULL; } Return<void> BiometricsFingerprint::setNotify( const sp<IBiometricsFingerprintClientCallback>& clientCallback, setNotify_cb cb) { mClientCallback = clientCallback; int32_t debugErrno = mDevice->set_notify(mDevice, notify); cb(debugErrno == 0, debugErrno); return Void(); } Return<uint64_t> BiometricsFingerprint::preEnroll() { return mDevice->pre_enroll(mDevice); } Return<void> BiometricsFingerprint::enroll(const HwAuthToken& hat, uint32_t gid, uint32_t timeoutSec, enroll_cb cb) { const hw_auth_token_t* authToken = reinterpret_cast<const hw_auth_token_t*>(&hat); int32_t debugErrno = mDevice->enroll(mDevice, authToken, gid, timeoutSec); cb(debugErrno == 0, debugErrno); return Void(); } Return<void> BiometricsFingerprint::postEnroll(postEnroll_cb cb) { int32_t debugErrno = mDevice->post_enroll(mDevice); cb(debugErrno == 0, debugErrno); return Void(); } Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() { return mDevice->get_authenticator_id(mDevice); } Return<void> BiometricsFingerprint::cancel(cancel_cb cb) { int32_t debugErrno = mDevice->cancel(mDevice); cb(debugErrno == 0, debugErrno); return Void(); } Return<void> BiometricsFingerprint::enumerate(enumerate_cb cb) { int32_t debugErrno = mDevice->enumerate(mDevice); cb(debugErrno == 0, debugErrno); return Void(); } Return<void> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid, remove_cb cb) { int32_t debugErrno = mDevice->remove(mDevice, gid, fid); cb(debugErrno == 0, debugErrno); return Void(); } Return<void> BiometricsFingerprint::setActiveGroup(uint32_t gid, const hidl_string& storePath, setActiveGroup_cb cb) { if (storePath.size() >= PATH_MAX || storePath.size() <= 0) { ALOGE("Bad path length: %zd", storePath.size()); } int32_t debugErrno = mDevice->set_active_group(mDevice, gid, storePath.c_str()); cb(debugErrno == 0, debugErrno); return Void(); } Return<void> BiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid, authenticate_cb cb) { int32_t debugErrno = mDevice->authenticate(mDevice, operationId, gid); cb(debugErrno == 0, debugErrno); return Void(); } IBiometricsFingerprint* HIDL_FETCH_IBiometricsFingerprint(const char*) { int err; const hw_module_t *hw_mdl = NULL; 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 == NULL) { 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 == NULL) { ALOGE("No valid open method"); return nullptr; } hw_device_t *device = NULL; if (0 != (err = module->common.methods->open(hw_mdl, NULL, &device))) { ALOGE("Can't open fingerprint methods, error: %d", err); return nullptr; } return new BiometricsFingerprint( reinterpret_cast<fingerprint_device_t*>(device)); } } // namespace implementation } // namespace V2_1 } // namespace fingerprint } // namespace biometrics } // namespace hardware } // namespace android
biometrics/fingerprint/2.1/default/BiometricsFingerprint.h 0 → 100644 +79 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 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 HIDL_GENERATED_android_hardware_biometrics_fingerprint_V2_1_BiometricsFingerprint_H_ #define HIDL_GENERATED_android_hardware_biometrics_fingerprint_V2_1_BiometricsFingerprint_H_ #include <utils/Log.h> #include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h> #include <hidl/Status.h> #include <hidl/MQDescriptor.h> namespace android { namespace hardware { namespace biometrics { namespace fingerprint { namespace V2_1 { namespace implementation { using ::android::hardware::biometrics::fingerprint::V2_1::HwAuthToken; using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint; using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback; 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(fingerprint_device_t *device); ~BiometricsFingerprint(); // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow. Return<void> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback, setNotify_cb _hidl_cb) override; Return<uint64_t> preEnroll() override; Return<void> enroll(const HwAuthToken& hat, uint32_t gid, uint32_t timeoutSec, enroll_cb _hidl_cb) override; Return<void> postEnroll(postEnroll_cb _hidl_cb) override; Return<uint64_t> getAuthenticatorId() override; Return<void> cancel(cancel_cb _hidl_cb) override; Return<void> enumerate(enumerate_cb _hidl_cb) override; Return<void> remove(uint32_t gid, uint32_t fid, remove_cb _hidl_cb) override; Return<void> setActiveGroup(uint32_t gid, const hidl_string& storePath, setActiveGroup_cb _hidl_cb) override; Return<void> authenticate(uint64_t operationId, uint32_t gid, authenticate_cb _hidl_cb) override; static void notify(const fingerprint_msg_t *notify_msg) { if (mClientCallback == nullptr) { ALOGE("Receiving callbacks before the client callback is registered."); return; } FingerprintMsg msg = {}; memcpy(&msg, notify_msg, sizeof(msg)); mClientCallback->notify(msg); } private: static sp<IBiometricsFingerprintClientCallback> mClientCallback; fingerprint_device_t *mDevice; }; extern "C" IBiometricsFingerprint* HIDL_FETCH_IBiometricsFingerprint(const char* name); } // namespace implementation } // namespace V2_1 } // namespace fingerprint } // namespace biometrics } // namespace hardware } // namespace android #endif // HIDL_GENERATED_android_hardware_biometrics_fingerprint_V2_1_BiometricsFingerprint_H_
biometrics/fingerprint/2.1/default/android.hardware.biometrics.fingerprint@2.1-service.rc 0 → 100644 +4 −0 Original line number Diff line number Diff line service fingerprint@2.1 /system/bin/hw/android.hardware.biometrics.fingerprint@2.1-service class hal user system group system No newline at end of file