diff options
| author | Nick Desaulniers <ndesaulniers@google.com> | 2016-11-29 10:45:10 -0800 |
|---|---|---|
| committer | Jim Miller <jaggies@google.com> | 2017-01-17 11:45:41 -0800 |
| commit | e5b69e1e70a982e64716dee1fd995f3d779e05d0 (patch) | |
| tree | 8e81201aa2c2e5a90415ee564e554064be1aa320 /fingerprintd | |
| parent | 2f8b6aeaff401490493f2d27e5f62becf9dd0899 (diff) | |
| download | core-e5b69e1e70a982e64716dee1fd995f3d779e05d0.tar.gz core-e5b69e1e70a982e64716dee1fd995f3d779e05d0.tar.bz2 core-e5b69e1e70a982e64716dee1fd995f3d779e05d0.zip | |
remove fingerprintd from the build
in favor of HADL2.1 implementation.
Test: fingerprints are add-able
Bug: 33199080
Change-Id: Ie22723fd7dddbe8ea240c1d3e4dd7879aee06200
Diffstat (limited to 'fingerprintd')
| -rw-r--r-- | fingerprintd/Android.mk | 36 | ||||
| -rw-r--r-- | fingerprintd/FingerprintDaemonProxy.cpp | 311 | ||||
| -rw-r--r-- | fingerprintd/FingerprintDaemonProxy.h | 65 | ||||
| -rw-r--r-- | fingerprintd/IFingerprintDaemon.cpp | 205 | ||||
| -rw-r--r-- | fingerprintd/IFingerprintDaemon.h | 90 | ||||
| -rw-r--r-- | fingerprintd/IFingerprintDaemonCallback.cpp | 91 | ||||
| -rw-r--r-- | fingerprintd/IFingerprintDaemonCallback.h | 54 | ||||
| -rw-r--r-- | fingerprintd/fingerprintd.cpp | 52 |
8 files changed, 0 insertions, 904 deletions
diff --git a/fingerprintd/Android.mk b/fingerprintd/Android.mk deleted file mode 100644 index 55803cfe1..000000000 --- a/fingerprintd/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright (C) 2015 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. -# - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_CFLAGS := -Wall -Wextra -Werror -Wunused -LOCAL_SRC_FILES := \ - FingerprintDaemonProxy.cpp \ - IFingerprintDaemon.cpp \ - IFingerprintDaemonCallback.cpp \ - fingerprintd.cpp -LOCAL_MODULE := fingerprintd -LOCAL_SHARED_LIBRARIES := \ - libbinder \ - libhidlbase \ - libhidltransport \ - liblog \ - libhardware \ - libutils \ - libkeystore_binder \ - android.hardware.biometrics.fingerprint@2.1 -include $(BUILD_EXECUTABLE) diff --git a/fingerprintd/FingerprintDaemonProxy.cpp b/fingerprintd/FingerprintDaemonProxy.cpp deleted file mode 100644 index 73748f2d1..000000000 --- a/fingerprintd/FingerprintDaemonProxy.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright (C) 2015 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 "fingerprintd" - -#include <android/hardware/biometrics/fingerprint/2.1/types.h> -#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h> -#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.h> -#include <binder/IServiceManager.h> -#include <keystore/IKeystoreService.h> -#include <keystore/keystore.h> // for error codes -#include <utils/Log.h> - -#include "FingerprintDaemonProxy.h" - -namespace android { - -using hardware::hidl_string; -using hardware::Return; -using hardware::biometrics::fingerprint::V2_1::FingerprintMsg; -using hardware::biometrics::fingerprint::V2_1::RequestStatus; -using hardware::biometrics::fingerprint::V2_1::FingerprintError; -using hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback; -using Type = hardware::biometrics::fingerprint::V2_1::FingerprintMsgType; -using IBiometricsFingerprint = hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint; - -FingerprintDaemonProxy* FingerprintDaemonProxy::sInstance = nullptr; -static sp<IBiometricsFingerprint> gBFP = nullptr; -static sp<IBiometricsFingerprintClientCallback> gClientCallback = nullptr; - -template <typename E> -constexpr typename std::underlying_type<E>::type to_native(E e) { - return static_cast<typename std::underlying_type<E>::type>(e); -} - -const ssize_t hw_auth_token_size = 69; - -namespace hardware { - -class BiometricsFingerprintClientCallback : public IBiometricsFingerprintClientCallback { - public: - BiometricsFingerprintClientCallback() {}; - virtual ~BiometricsFingerprintClientCallback() = default; - Return<void> notify(const FingerprintMsg& msg) { - FingerprintDaemonProxy::hal_notify_callback(msg); - return Void(); - } -}; - -IBiometricsFingerprintClientCallback* HIDL_FETCH_IBiometricsFingerprintClientCallback(const char* /* name */) { - return new BiometricsFingerprintClientCallback(); -} - -} // namespace hardware - -FingerprintDaemonProxy::FingerprintDaemonProxy() : mCallback(nullptr) { - -} - -FingerprintDaemonProxy::~FingerprintDaemonProxy() { - closeHal(); -} - -void FingerprintDaemonProxy::hal_notify_callback(const hardware::biometrics::fingerprint::V2_1::FingerprintMsg &msg) { - FingerprintDaemonProxy* instance = FingerprintDaemonProxy::getInstance(); - const sp<IFingerprintDaemonCallback> callback = instance->mCallback; - if (callback == nullptr) { - ALOGE("Invalid callback object"); - return; - } - switch (msg.type) { - case Type::ERROR: - ALOGD("onError(%d)", msg.data.error); - callback->onError(0, to_native(msg.data.error)); - break; - case Type::ACQUIRED: - ALOGD("onAcquired(%d)", msg.data.acquired.acquiredInfo); - callback->onAcquired(0, to_native(msg.data.acquired.acquiredInfo)); - break; - case Type::AUTHENTICATED: - ALOGD("onAuthenticated(fid=%d, gid=%d)", - msg.data.authenticated.finger.fid, - msg.data.authenticated.finger.gid); - if (msg.data.authenticated.finger.fid != 0) { - const uint8_t* hat = reinterpret_cast<const uint8_t *>(&msg.data.authenticated.hat); - instance->notifyKeystore(hat, sizeof(msg.data.authenticated.hat)); - } - callback->onAuthenticated(0, - msg.data.authenticated.finger.fid, - msg.data.authenticated.finger.gid); - break; - case Type::TEMPLATE_ENROLLING: - ALOGD("onEnrollResult(fid=%d, gid=%d, rem=%d)", - msg.data.enroll.finger.fid, - msg.data.enroll.finger.gid, - msg.data.enroll.samplesRemaining); - callback->onEnrollResult(0, - msg.data.enroll.finger.fid, - msg.data.enroll.finger.gid, - msg.data.enroll.samplesRemaining); - break; - case Type::TEMPLATE_REMOVED: - ALOGD("onRemove(fid=%d, gid=%d)", - msg.data.removed.finger.fid, - msg.data.removed.finger.gid); - callback->onRemoved(0, - msg.data.removed.finger.fid, - msg.data.removed.finger.gid); - break; - case Type::TEMPLATE_ENUMERATING: - ALOGD("onEnumerate(fid=%d, gid=%d, rem=%d)", - msg.data.enumerated.finger.fid, - msg.data.enumerated.finger.gid, - msg.data.enumerated.remainingTemplates); - callback->onEnumerate(0, - msg.data.enumerated.finger.fid, - msg.data.enumerated.finger.gid, - msg.data.enumerated.remainingTemplates); - break; - default: - ALOGE("invalid msg type: %d", msg.type); - return; - } -} - -void FingerprintDaemonProxy::notifyKeystore(const uint8_t *auth_token, const size_t auth_token_length) { - if (auth_token != nullptr && auth_token_length > 0) { - // TODO: cache service? - sp < IServiceManager > sm = defaultServiceManager(); - sp < IBinder > binder = sm->getService(String16("android.security.keystore")); - sp < IKeystoreService > service = interface_cast < IKeystoreService > (binder); - if (service != nullptr) { - status_t ret = service->addAuthToken(auth_token, auth_token_length); - if (ret != ResponseCode::NO_ERROR) { - ALOGE("Falure sending auth token to KeyStore: %d", ret); - } - } else { - ALOGE("Unable to communicate with KeyStore"); - } - } -} - -void FingerprintDaemonProxy::init(const sp<IFingerprintDaemonCallback>& callback) { - if (mCallback != nullptr && IInterface::asBinder(callback) != IInterface::asBinder(mCallback)) { - IInterface::asBinder(mCallback)->unlinkToDeath(this); - } - IInterface::asBinder(callback)->linkToDeath(this); - mCallback = callback; -} - -int32_t FingerprintDaemonProxy::enroll(const uint8_t* token, ssize_t tokenSize, int32_t groupId, - int32_t timeout) { - ALOG(LOG_VERBOSE, LOG_TAG, "enroll(gid=%d, timeout=%d)\n", groupId, timeout); - if (tokenSize != hw_auth_token_size) { - ALOG(LOG_VERBOSE, LOG_TAG, "enroll() : invalid token size %zd, expected %zd\n", tokenSize, hw_auth_token_size); - return -1; - } - - hardware::hidl_array<uint8_t, hw_auth_token_size> hat(token); - Return<RequestStatus> ret = gBFP->enroll(hat, groupId, timeout); - if (!ret.isOk()) { - ALOGE("Unknown transport error"); - return -1; - } - - RequestStatus status = ret; - return to_native(status); -} - -uint64_t FingerprintDaemonProxy::preEnroll() { - return gBFP->preEnroll(); -} - -int32_t FingerprintDaemonProxy::postEnroll() { - Return<RequestStatus> ret = gBFP->postEnroll(); - if (!ret.isOk()) { - ALOGE("Unknown transport error"); - return -1; - } - - RequestStatus status = ret; - return to_native(status); -} - -int32_t FingerprintDaemonProxy::stopEnrollment() { - ALOG(LOG_VERBOSE, LOG_TAG, "stopEnrollment()\n"); - Return<RequestStatus> ret = gBFP->cancel(); - if (!ret.isOk()) { - ALOGE("Unknown transport error"); - return -1; - } - - RequestStatus status = ret; - return to_native(status); -} - -int32_t FingerprintDaemonProxy::authenticate(uint64_t sessionId, uint32_t groupId) { - ALOG(LOG_VERBOSE, LOG_TAG, "authenticate(sid=%" PRId64 ", gid=%d)\n", sessionId, groupId); - Return<RequestStatus> ret = gBFP->authenticate(sessionId, groupId); - if (!ret.isOk()) { - ALOGE("Unknown transport error"); - return -1; - } - - RequestStatus status = ret; - return to_native(status); -} - -int32_t FingerprintDaemonProxy::stopAuthentication() { - ALOG(LOG_VERBOSE, LOG_TAG, "stopAuthentication()\n"); - Return<RequestStatus> ret = gBFP->cancel(); - if (!ret.isOk()) { - ALOGE("Unknown transport error"); - return -1; - } - - RequestStatus status = ret; - return to_native(status); -} - -int32_t FingerprintDaemonProxy::remove(int32_t fingerId, int32_t groupId) { - ALOG(LOG_VERBOSE, LOG_TAG, "remove(fid=%d, gid=%d)\n", fingerId, groupId); - Return<RequestStatus> ret = gBFP->remove(groupId, fingerId); - if (!ret.isOk()) { - ALOGE("Unknown transport error"); - return -1; - } - - RequestStatus status = ret; - return to_native(status); -} - -int32_t FingerprintDaemonProxy::enumerate() { - ALOG(LOG_VERBOSE, LOG_TAG, "enumerate()\n"); - Return<RequestStatus> ret = gBFP->enumerate(); - if (!ret.isOk()) { - ALOGE("Unknown transport error"); - return -1; - } - - RequestStatus status = ret; - return to_native(status); -} - -uint64_t FingerprintDaemonProxy::getAuthenticatorId() { - return gBFP->getAuthenticatorId(); -} - -int32_t FingerprintDaemonProxy::setActiveGroup(int32_t groupId, const uint8_t* path, - ssize_t pathlen) { - if (pathlen >= PATH_MAX || pathlen <= 0) { - ALOGE("Bad path length: %zd", pathlen); - return -1; - } - hidl_string pathname; - pathname.setToExternal(reinterpret_cast<const char*>(path), pathlen); - ALOG(LOG_VERBOSE, LOG_TAG, "setActiveGroup(%d, %s, %zu)", groupId, pathname.c_str(), pathlen); - Return<RequestStatus> ret = gBFP->setActiveGroup(groupId, pathname); - if (!ret.isOk()) { - ALOGE("Unknown transport error"); - return -1; - } - - RequestStatus status = ret; - return to_native(status); -} - -int64_t FingerprintDaemonProxy::openHal() { - if (gBFP == nullptr) { - // TODO(b/31632518) - gBFP = IBiometricsFingerprint::getService("fingerprint"); - if(gBFP == nullptr) { - ALOGE("Can't get service fingerprint"); - return 0; - } - } - gClientCallback = hardware::HIDL_FETCH_IBiometricsFingerprintClientCallback(nullptr); - gBFP->setNotify(gClientCallback); - return reinterpret_cast<int64_t>(gBFP.get()); -} - -int32_t FingerprintDaemonProxy::closeHal() { - // Obsolete, return 0 for compatibility reasons. - return 0; -} - -void FingerprintDaemonProxy::binderDied(const wp<IBinder>& who) { - ALOGD("binder died"); - int err; - if (0 != (err = closeHal())) { - ALOGE("Can't close fingerprint device, error: %d", err); - } - if (IInterface::asBinder(mCallback) == who) { - mCallback = nullptr; - } -} - -} // namespace android diff --git a/fingerprintd/FingerprintDaemonProxy.h b/fingerprintd/FingerprintDaemonProxy.h deleted file mode 100644 index 715344c85..000000000 --- a/fingerprintd/FingerprintDaemonProxy.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2015 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 FINGERPRINT_DAEMON_PROXY_H_ -#define FINGERPRINT_DAEMON_PROXY_H_ - -#include "IFingerprintDaemon.h" -#include "IFingerprintDaemonCallback.h" - -namespace android { - -using hardware::biometrics::fingerprint::V2_1::RequestStatus; - -class FingerprintDaemonProxy : public BnFingerprintDaemon { - public: - static FingerprintDaemonProxy* getInstance() { - if (sInstance == NULL) { - sInstance = new FingerprintDaemonProxy(); - } - return sInstance; - } - - // These reflect binder methods. - virtual void init(const sp<IFingerprintDaemonCallback>& callback); - virtual int32_t enroll(const uint8_t* token, ssize_t tokenLength, int32_t groupId, int32_t timeout); - virtual uint64_t preEnroll(); - virtual int32_t postEnroll(); - virtual int32_t stopEnrollment(); - virtual int32_t authenticate(uint64_t sessionId, uint32_t groupId); - virtual int32_t stopAuthentication(); - virtual int32_t remove(int32_t fingerId, int32_t groupId); - virtual int32_t enumerate(); - virtual uint64_t getAuthenticatorId(); - virtual int32_t setActiveGroup(int32_t groupId, const uint8_t* path, ssize_t pathLen); - virtual int64_t openHal(); - virtual int32_t closeHal(); - static void hal_notify_callback(const hardware::biometrics::fingerprint::V2_1::FingerprintMsg &msg); - - private: - FingerprintDaemonProxy(); - virtual ~FingerprintDaemonProxy(); - void binderDied(const wp<IBinder>& who); - void notifyKeystore(const uint8_t *auth_token, const size_t auth_token_length); - int32_t HandleTransportError(const RequestStatus error); - - static FingerprintDaemonProxy* sInstance; - sp<IFingerprintDaemonCallback> mCallback; -}; - -} // namespace android - -#endif // FINGERPRINT_DAEMON_PROXY_H_ diff --git a/fingerprintd/IFingerprintDaemon.cpp b/fingerprintd/IFingerprintDaemon.cpp deleted file mode 100644 index bc4af5685..000000000 --- a/fingerprintd/IFingerprintDaemon.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2015, 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 <inttypes.h> - -#include <binder/IPCThreadState.h> -#include <binder/IServiceManager.h> -#include <binder/PermissionCache.h> -#include <utils/String16.h> -#include <utils/Looper.h> -#include <keystore/IKeystoreService.h> -#include <keystore/keystore.h> // for error code -#include <hardware/hardware.h> -#include <hardware/fingerprint.h> -#include <hardware/hw_auth_token.h> -#include "IFingerprintDaemon.h" -#include "IFingerprintDaemonCallback.h" - -namespace android { - -static const String16 USE_FINGERPRINT_PERMISSION("android.permission.USE_FINGERPRINT"); -static const String16 MANAGE_FINGERPRINT_PERMISSION("android.permission.MANAGE_FINGERPRINT"); -static const String16 HAL_FINGERPRINT_PERMISSION("android.permission.MANAGE_FINGERPRINT"); // TODO -static const String16 DUMP_PERMISSION("android.permission.DUMP"); - -const android::String16 -IFingerprintDaemon::descriptor("android.hardware.fingerprint.IFingerprintDaemon"); - -const android::String16& -IFingerprintDaemon::getInterfaceDescriptor() const { - return IFingerprintDaemon::descriptor; -} - -status_t BnFingerprintDaemon::onTransact(uint32_t code, const Parcel& data, Parcel* reply, - uint32_t flags) { - switch(code) { - case AUTHENTICATE: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const uint64_t sessionId = data.readInt64(); - const uint32_t groupId = data.readInt32(); - const int32_t ret = authenticate(sessionId, groupId); - reply->writeNoException(); - reply->writeInt32(ret); - return NO_ERROR; - }; - case CANCEL_AUTHENTICATION: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const int32_t ret = stopAuthentication(); - reply->writeNoException(); - reply->writeInt32(ret); - return NO_ERROR; - } - case ENROLL: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const ssize_t tokenSize = data.readInt32(); - const uint8_t* token = static_cast<const uint8_t *>(data.readInplace(tokenSize)); - const int32_t groupId = data.readInt32(); - const int32_t timeout = data.readInt32(); - const int32_t ret = enroll(token, tokenSize, groupId, timeout); - reply->writeNoException(); - reply->writeInt32(ret); - return NO_ERROR; - } - case CANCEL_ENROLLMENT: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const int32_t ret = stopEnrollment(); - reply->writeNoException(); - reply->writeInt32(ret); - return NO_ERROR; - } - case PRE_ENROLL: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const uint64_t ret = preEnroll(); - reply->writeNoException(); - reply->writeInt64(ret); - return NO_ERROR; - } - case POST_ENROLL: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const int32_t ret = postEnroll(); - reply->writeNoException(); - reply->writeInt32(ret); - return NO_ERROR; - } - case REMOVE: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const int32_t fingerId = data.readInt32(); - const int32_t groupId = data.readInt32(); - const int32_t ret = remove(fingerId, groupId); - reply->writeNoException(); - reply->writeInt32(ret); - return NO_ERROR; - } - case ENUMERATE: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const int32_t ret = enumerate(); - reply->writeNoException(); - reply->writeInt32(ret); - return NO_ERROR; - } - case GET_AUTHENTICATOR_ID: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const uint64_t ret = getAuthenticatorId(); - reply->writeNoException(); - reply->writeInt64(ret); - return NO_ERROR; - } - case SET_ACTIVE_GROUP: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const int32_t group = data.readInt32(); - const ssize_t pathSize = data.readInt32(); - const uint8_t* path = static_cast<const uint8_t *>(data.readInplace(pathSize)); - const int32_t ret = setActiveGroup(group, path, pathSize); - reply->writeNoException(); - reply->writeInt32(ret); - return NO_ERROR; - } - case OPEN_HAL: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const int64_t ret = openHal(); - reply->writeNoException(); - reply->writeInt64(ret); - return NO_ERROR; - } - case CLOSE_HAL: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - const int32_t ret = closeHal(); - reply->writeNoException(); - reply->writeInt32(ret); - return NO_ERROR; - } - case INIT: { - CHECK_INTERFACE(IFingerprintDaemon, data, reply); - if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { - return PERMISSION_DENIED; - } - sp<IFingerprintDaemonCallback> callback = - interface_cast<IFingerprintDaemonCallback>(data.readStrongBinder()); - init(callback); - reply->writeNoException(); - return NO_ERROR; - } - default: - return BBinder::onTransact(code, data, reply, flags); - } -}; - -bool BnFingerprintDaemon::checkPermission(const String16& permission) { - const IPCThreadState* ipc = IPCThreadState::self(); - const int calling_pid = ipc->getCallingPid(); - const int calling_uid = ipc->getCallingUid(); - return PermissionCache::checkPermission(permission, calling_pid, calling_uid); -} - - -}; // namespace android diff --git a/fingerprintd/IFingerprintDaemon.h b/fingerprintd/IFingerprintDaemon.h deleted file mode 100644 index c5cdbfe18..000000000 --- a/fingerprintd/IFingerprintDaemon.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2015 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 IFINGERPRINT_DAEMON_H_ -#define IFINGERPRINT_DAEMON_H_ - -#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h> -#include <android/hardware/biometrics/fingerprint/2.1/types.h> -#include <binder/IInterface.h> -#include <binder/Parcel.h> - -namespace android { - -class IFingerprintDaemonCallback; - -/* -* Abstract base class for native implementation of FingerprintService. -* -* Note: This must be kept manually in sync with IFingerprintDaemon.aidl -*/ -class IFingerprintDaemon : public IInterface, public IBinder::DeathRecipient { - public: - enum { - AUTHENTICATE = IBinder::FIRST_CALL_TRANSACTION + 0, - CANCEL_AUTHENTICATION = IBinder::FIRST_CALL_TRANSACTION + 1, - ENROLL = IBinder::FIRST_CALL_TRANSACTION + 2, - CANCEL_ENROLLMENT = IBinder::FIRST_CALL_TRANSACTION + 3, - PRE_ENROLL = IBinder::FIRST_CALL_TRANSACTION + 4, - REMOVE = IBinder::FIRST_CALL_TRANSACTION + 5, - GET_AUTHENTICATOR_ID = IBinder::FIRST_CALL_TRANSACTION + 6, - SET_ACTIVE_GROUP = IBinder::FIRST_CALL_TRANSACTION + 7, - OPEN_HAL = IBinder::FIRST_CALL_TRANSACTION + 8, - CLOSE_HAL = IBinder::FIRST_CALL_TRANSACTION + 9, - INIT = IBinder::FIRST_CALL_TRANSACTION + 10, - POST_ENROLL = IBinder::FIRST_CALL_TRANSACTION + 11, - ENUMERATE = IBinder::FIRST_CALL_TRANSACTION + 12, - }; - - IFingerprintDaemon() { } - virtual ~IFingerprintDaemon() { } - virtual const android::String16& getInterfaceDescriptor() const; - - // Binder interface methods - virtual void init(const sp<IFingerprintDaemonCallback>& callback) = 0; - virtual int32_t enroll(const uint8_t* token, ssize_t tokenLength, int32_t groupId, - int32_t timeout) = 0; - virtual uint64_t preEnroll() = 0; - virtual int32_t postEnroll() = 0; - virtual int32_t stopEnrollment() = 0; - virtual int32_t authenticate(uint64_t sessionId, uint32_t groupId) = 0; - virtual int32_t stopAuthentication() = 0; - virtual int32_t remove(int32_t fingerId, int32_t groupId) = 0; - virtual int32_t enumerate() = 0; - virtual uint64_t getAuthenticatorId() = 0; - virtual int32_t setActiveGroup(int32_t groupId, const uint8_t* path, ssize_t pathLen) = 0; - virtual int64_t openHal() = 0; - virtual int32_t closeHal() = 0; - - // DECLARE_META_INTERFACE - C++ client interface not needed - static const android::String16 descriptor; - static void hal_notify_callback(const hardware::biometrics::fingerprint::V2_1::FingerprintMsg &msg); -}; - -// ---------------------------------------------------------------------------- - -class BnFingerprintDaemon: public BnInterface<IFingerprintDaemon> { - public: - virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, - uint32_t flags = 0); - private: - bool checkPermission(const String16& permission); -}; - -} // namespace android - -#endif // IFINGERPRINT_DAEMON_H_ - diff --git a/fingerprintd/IFingerprintDaemonCallback.cpp b/fingerprintd/IFingerprintDaemonCallback.cpp deleted file mode 100644 index 1d75aa7fc..000000000 --- a/fingerprintd/IFingerprintDaemonCallback.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2015 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 "IFingerprintDaemonCallback" -#include <stdint.h> -#include <sys/types.h> -#include <utils/Log.h> -#include <binder/Parcel.h> - -#include "IFingerprintDaemonCallback.h" - -namespace android { - -class BpFingerprintDaemonCallback : public BpInterface<IFingerprintDaemonCallback> -{ -public: - explicit BpFingerprintDaemonCallback(const sp<IBinder>& impl) : - BpInterface<IFingerprintDaemonCallback>(impl) { - } - virtual status_t onEnrollResult(int64_t devId, int32_t fpId, int32_t gpId, int32_t rem) { - Parcel data, reply; - data.writeInterfaceToken(IFingerprintDaemonCallback::getInterfaceDescriptor()); - data.writeInt64(devId); - data.writeInt32(fpId); - data.writeInt32(gpId); - data.writeInt32(rem); - return remote()->transact(ON_ENROLL_RESULT, data, &reply, IBinder::FLAG_ONEWAY); - } - - virtual status_t onAcquired(int64_t devId, int32_t acquiredInfo) { - Parcel data, reply; - data.writeInterfaceToken(IFingerprintDaemonCallback::getInterfaceDescriptor()); - data.writeInt64(devId); - data.writeInt32(acquiredInfo); - return remote()->transact(ON_ACQUIRED, data, &reply, IBinder::FLAG_ONEWAY); - } - - virtual status_t onAuthenticated(int64_t devId, int32_t fpId, int32_t gpId) { - Parcel data, reply; - data.writeInterfaceToken(IFingerprintDaemonCallback::getInterfaceDescriptor()); - data.writeInt64(devId); - data.writeInt32(fpId); - data.writeInt32(gpId); - return remote()->transact(ON_AUTHENTICATED, data, &reply, IBinder::FLAG_ONEWAY); - } - - virtual status_t onError(int64_t devId, int32_t error) { - Parcel data, reply; - data.writeInterfaceToken(IFingerprintDaemonCallback::getInterfaceDescriptor()); - data.writeInt64(devId); - data.writeInt32(error); - return remote()->transact(ON_ERROR, data, &reply, IBinder::FLAG_ONEWAY); - } - - virtual status_t onRemoved(int64_t devId, int32_t fpId, int32_t gpId) { - Parcel data, reply; - data.writeInterfaceToken(IFingerprintDaemonCallback::getInterfaceDescriptor()); - data.writeInt64(devId); - data.writeInt32(fpId); - data.writeInt32(gpId); - return remote()->transact(ON_REMOVED, data, &reply, IBinder::FLAG_ONEWAY); - } - - virtual status_t onEnumerate(int64_t devId, int32_t fpId, int32_t gpId, int32_t rem) { - Parcel data, reply; - data.writeInterfaceToken(IFingerprintDaemonCallback::getInterfaceDescriptor()); - data.writeInt64(devId); - data.writeInt32(fpId); - data.writeInt32(gpId); - data.writeInt32(rem); - return remote()->transact(ON_ENUMERATE, data, &reply, IBinder::FLAG_ONEWAY); - } -}; - -IMPLEMENT_META_INTERFACE(FingerprintDaemonCallback, - "android.hardware.fingerprint.IFingerprintDaemonCallback"); - -}; // namespace android diff --git a/fingerprintd/IFingerprintDaemonCallback.h b/fingerprintd/IFingerprintDaemonCallback.h deleted file mode 100644 index e343cb4f6..000000000 --- a/fingerprintd/IFingerprintDaemonCallback.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2015 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 IFINGERPRINT_DAEMON_CALLBACK_H_ -#define IFINGERPRINT_DAEMON_CALLBACK_H_ - -#include <inttypes.h> -#include <utils/Errors.h> -#include <binder/IInterface.h> -#include <binder/Parcel.h> - -namespace android { - -/* -* Communication channel back to FingerprintService.java -*/ -class IFingerprintDaemonCallback : public IInterface { - public: - // must be kept in sync with IFingerprintService.aidl - enum { - ON_ENROLL_RESULT = IBinder::FIRST_CALL_TRANSACTION + 0, - ON_ACQUIRED = IBinder::FIRST_CALL_TRANSACTION + 1, - ON_AUTHENTICATED = IBinder::FIRST_CALL_TRANSACTION + 2, - ON_ERROR = IBinder::FIRST_CALL_TRANSACTION + 3, - ON_REMOVED = IBinder::FIRST_CALL_TRANSACTION + 4, - ON_ENUMERATE = IBinder::FIRST_CALL_TRANSACTION + 5, - }; - - virtual status_t onEnrollResult(int64_t devId, int32_t fpId, int32_t gpId, int32_t rem) = 0; - virtual status_t onAcquired(int64_t devId, int32_t acquiredInfo) = 0; - virtual status_t onAuthenticated(int64_t devId, int32_t fingerId, int32_t groupId) = 0; - virtual status_t onError(int64_t devId, int32_t error) = 0; - virtual status_t onRemoved(int64_t devId, int32_t fingerId, int32_t groupId) = 0; - virtual status_t onEnumerate(int64_t devId, int32_t fingerId, int32_t groupId, int32_t rem) = 0; - - DECLARE_META_INTERFACE(FingerprintDaemonCallback); -}; - -}; // namespace android - -#endif // IFINGERPRINT_DAEMON_CALLBACK_H_ diff --git a/fingerprintd/fingerprintd.cpp b/fingerprintd/fingerprintd.cpp deleted file mode 100644 index 2fc2d0aec..000000000 --- a/fingerprintd/fingerprintd.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2015 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 "fingerprintd" - -#include <binder/IPCThreadState.h> -#include <binder/IServiceManager.h> -#include <binder/PermissionCache.h> -#include <hardware/hardware.h> -#include <hardware/fingerprint.h> -#include <hardware/hw_auth_token.h> -#include <keystore/IKeystoreService.h> -#include <keystore/keystore.h> // for error codes -#include <log/log.h> -#include <utils/Log.h> -#include <utils/String16.h> - -#include "FingerprintDaemonProxy.h" - -int main() { - ALOGI("Starting " LOG_TAG); - android::sp<android::IServiceManager> serviceManager = android::defaultServiceManager(); - android::sp<android::FingerprintDaemonProxy> proxy = - android::FingerprintDaemonProxy::getInstance(); - android::status_t ret = serviceManager->addService( - android::FingerprintDaemonProxy::descriptor, proxy); - if (ret != android::OK) { - ALOGE("Couldn't register " LOG_TAG " binder service!"); - return -1; - } - - /* - * We're the only thread in existence, so we're just going to process - * Binder transaction as a single-threaded program. - */ - android::IPCThreadState::self()->joinThreadPool(); - ALOGI("Done"); - return 0; -} |
