Add Oppo fingerprint support, tested on Realme X2 Pro
This commit is contained in:
parent
71913ae9d2
commit
3133b832bf
3
base.mk
3
base.mk
@ -161,3 +161,6 @@ PRODUCT_COPY_FILES += \
|
|||||||
device/phh/treble/remote/phh-remotectl.rc:system/etc/init/phh-remotectl.rc \
|
device/phh/treble/remote/phh-remotectl.rc:system/etc/init/phh-remotectl.rc \
|
||||||
device/phh/treble/remote/phh-remotectl.sh:system/bin/phh-remotectl.sh \
|
device/phh/treble/remote/phh-remotectl.sh:system/bin/phh-remotectl.sh \
|
||||||
|
|
||||||
|
PRODUCT_PACKAGES += \
|
||||||
|
android.hardware.biometrics.fingerprint@2.1-service.oppo.compat \
|
||||||
|
|
||||||
|
@ -8,5 +8,16 @@
|
|||||||
<instance>default</instance>
|
<instance>default</instance>
|
||||||
</interface>
|
</interface>
|
||||||
</hal>
|
</hal>
|
||||||
|
|
||||||
|
<!-- For our Oppo/Realme friends -->
|
||||||
|
<hal>
|
||||||
|
<name>android.hardware.biometrics.fingerprint</name>
|
||||||
|
<transport>hwbinder</transport>
|
||||||
|
<version>2.1</version>
|
||||||
|
<interface>
|
||||||
|
<name>IBiometricsFingerprint</name>
|
||||||
|
<instance>default</instance>
|
||||||
|
</interface>
|
||||||
|
</hal>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
||||||
|
24
hal/oppo-fp/Android.bp
Normal file
24
hal/oppo-fp/Android.bp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
cc_binary {
|
||||||
|
name: "android.hardware.biometrics.fingerprint@2.1-service.oppo.compat",
|
||||||
|
defaults: ["hidl_defaults"],
|
||||||
|
init_rc: ["android.hardware.biometrics.fingerprint@2.1-service.oppo.rc"],
|
||||||
|
relative_install_path: "hw",
|
||||||
|
srcs: [
|
||||||
|
"BiometricsFingerprint.cpp",
|
||||||
|
"service.cpp",
|
||||||
|
],
|
||||||
|
cflags: [
|
||||||
|
"-Wno-unused-parameter",
|
||||||
|
],
|
||||||
|
shared_libs: [
|
||||||
|
"libcutils",
|
||||||
|
"liblog",
|
||||||
|
"libhidlbase",
|
||||||
|
"libhidltransport",
|
||||||
|
"libhardware",
|
||||||
|
"libutils",
|
||||||
|
"libbase",
|
||||||
|
"android.hardware.biometrics.fingerprint@2.1",
|
||||||
|
"vendor.oppo.hardware.biometrics.fingerprint@2.1",
|
||||||
|
],
|
||||||
|
}
|
267
hal/oppo-fp/BiometricsFingerprint.cpp
Normal file
267
hal/oppo-fp/BiometricsFingerprint.cpp
Normal file
@ -0,0 +1,267 @@
|
|||||||
|
/*
|
||||||
|
* 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.oppo.compat"
|
||||||
|
#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.1-service.oppo.compat"
|
||||||
|
|
||||||
|
#include <hardware/hardware.h>
|
||||||
|
#include <hardware/fingerprint.h>
|
||||||
|
#include "BiometricsFingerprint.h"
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <utils/Log.h>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
namespace hardware {
|
||||||
|
namespace biometrics {
|
||||||
|
namespace fingerprint {
|
||||||
|
namespace V2_1 {
|
||||||
|
namespace implementation {
|
||||||
|
|
||||||
|
BiometricsFingerprint::BiometricsFingerprint() {
|
||||||
|
for(int i=0; i<10; i++) {
|
||||||
|
mOppoBiometricsFingerprint = vendor::oppo::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint::tryGetService();
|
||||||
|
if(mOppoBiometricsFingerprint != nullptr) break;
|
||||||
|
sleep(10);
|
||||||
|
}
|
||||||
|
if(mOppoBiometricsFingerprint == nullptr) exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool receivedCancel;
|
||||||
|
static bool receivedEnumerate;
|
||||||
|
static uint64_t myDeviceId;
|
||||||
|
static std::vector<uint32_t> knownFingers;
|
||||||
|
class OppoClientCallback : public vendor::oppo::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback {
|
||||||
|
public:
|
||||||
|
sp<android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback> mClientCallback;
|
||||||
|
|
||||||
|
OppoClientCallback(sp<android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback> clientCallback) : mClientCallback(clientCallback) {}
|
||||||
|
Return<void> onEnrollResult(uint64_t deviceId, uint32_t fingerId,
|
||||||
|
uint32_t groupId, uint32_t remaining) {
|
||||||
|
ALOGE("onEnrollResult %lu %u %u %u", deviceId, fingerId, groupId, remaining);
|
||||||
|
if(mClientCallback != nullptr)
|
||||||
|
mClientCallback->onEnrollResult(deviceId, fingerId, groupId, remaining);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<void> onAcquired(uint64_t deviceId, vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo acquiredInfo,
|
||||||
|
int32_t vendorCode) {
|
||||||
|
ALOGE("onAcquired %lu %d", deviceId, vendorCode);
|
||||||
|
if(mClientCallback != nullptr)
|
||||||
|
mClientCallback->onAcquired(deviceId, OppoToAOSPFingerprintAcquiredInfo(acquiredInfo), vendorCode);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<void> onAuthenticated(uint64_t deviceId, uint32_t fingerId, uint32_t groupId,
|
||||||
|
const hidl_vec<uint8_t>& token) {
|
||||||
|
ALOGE("onAuthenticated %lu %u %u", deviceId, fingerId, groupId);
|
||||||
|
if(mClientCallback != nullptr)
|
||||||
|
mClientCallback->onAuthenticated(deviceId, fingerId, groupId, token);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<void> onError(uint64_t deviceId, vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError error, int32_t vendorCode) {
|
||||||
|
ALOGE("onError %lu %d", deviceId, vendorCode);
|
||||||
|
if(error == vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_CANCELED) {
|
||||||
|
receivedCancel = true;
|
||||||
|
}
|
||||||
|
if(mClientCallback != nullptr)
|
||||||
|
mClientCallback->onError(deviceId, OppoToAOSPFingerprintError(error), vendorCode);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<void> onRemoved(uint64_t deviceId, uint32_t fingerId, uint32_t groupId,
|
||||||
|
uint32_t remaining) {
|
||||||
|
ALOGE("onRemoved %lu %u", deviceId, fingerId);
|
||||||
|
if(mClientCallback != nullptr)
|
||||||
|
mClientCallback->onRemoved(deviceId, fingerId, groupId, remaining);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<void> onEnumerate(uint64_t deviceId, uint32_t fingerId, uint32_t groupId,
|
||||||
|
uint32_t remaining) {
|
||||||
|
receivedEnumerate = true;
|
||||||
|
ALOGE("onEnumerate %lu %u %u %u", deviceId, fingerId, groupId, remaining);
|
||||||
|
if(mClientCallback != nullptr)
|
||||||
|
mClientCallback->onEnumerate(deviceId, fingerId, groupId, remaining);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<void> onTouchUp(uint64_t deviceId) { return Void(); }
|
||||||
|
Return<void> onTouchDown(uint64_t deviceId) { return Void(); }
|
||||||
|
Return<void> onSyncTemplates(uint64_t deviceId, const hidl_vec<uint32_t>& fingerId, uint32_t remaining) {
|
||||||
|
ALOGE("onSyncTemplates %lu %zu %u", deviceId, fingerId.size(), remaining);
|
||||||
|
myDeviceId = deviceId;
|
||||||
|
|
||||||
|
for(auto fid : fingerId) {
|
||||||
|
ALOGE("\t- %u", fid);
|
||||||
|
}
|
||||||
|
knownFingers = fingerId;
|
||||||
|
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
Return<void> onFingerprintCmd(int32_t deviceId, const hidl_vec<uint32_t>& groupId, uint32_t remaining) { return Void(); }
|
||||||
|
Return<void> onImageInfoAcquired(uint32_t type, uint32_t quality, uint32_t match_score) { return Void(); }
|
||||||
|
Return<void> onMonitorEventTriggered(uint32_t type, const hidl_string& data) { return Void(); }
|
||||||
|
Return<void> onEngineeringInfoUpdated(uint32_t length, const hidl_vec<uint32_t>& keys, const hidl_vec<hidl_string>& values) { return Void(); }
|
||||||
|
Return<void> onUIReady(int64_t deviceId) { return Void(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Return<android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo> OppoToAOSPFingerprintAcquiredInfo(vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo info) {
|
||||||
|
switch(info) {
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_GOOD: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_GOOD;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_PARTIAL: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_PARTIAL;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_IMAGER_DIRTY: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_IMAGER_DIRTY;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_TOO_SLOW: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_TOO_SLOW;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_TOO_FAST: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_TOO_FAST;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_VENDOR: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_VENDOR;
|
||||||
|
default:
|
||||||
|
return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_GOOD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<android::hardware::biometrics::fingerprint::V2_1::FingerprintError> OppoToAOSPFingerprintError(vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError error) {
|
||||||
|
switch(error) {
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_NO_ERROR: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_NO_ERROR;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_HW_UNAVAILABLE: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_HW_UNAVAILABLE;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_UNABLE_TO_PROCESS: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_UNABLE_TO_PROCESS;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_TIMEOUT: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_TIMEOUT;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_NO_SPACE: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_NO_SPACE;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_CANCELED: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_CANCELED;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_UNABLE_TO_REMOVE: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_UNABLE_TO_REMOVE;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_LOCKOUT: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_LOCKOUT;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_VENDOR: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_VENDOR;
|
||||||
|
default:
|
||||||
|
return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_NO_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Return<uint64_t> BiometricsFingerprint::setNotify(
|
||||||
|
const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
|
||||||
|
ALOGE("setNotify");
|
||||||
|
mOppoClientCallback = new OppoClientCallback(clientCallback);
|
||||||
|
return mOppoBiometricsFingerprint->setNotify(mOppoClientCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<RequestStatus> BiometricsFingerprint::OppoToAOSPRequestStatus(vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus req) {
|
||||||
|
switch(req) {
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_UNKNOWN: return RequestStatus::SYS_UNKNOWN;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_OK: return RequestStatus::SYS_OK;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_ENOENT: return RequestStatus::SYS_ENOENT;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EINTR: return RequestStatus::SYS_EINTR;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EIO: return RequestStatus::SYS_EIO;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EAGAIN: return RequestStatus::SYS_EAGAIN;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_ENOMEM: return RequestStatus::SYS_ENOMEM;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EACCES: return RequestStatus::SYS_EACCES;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EFAULT: return RequestStatus::SYS_EFAULT;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EBUSY: return RequestStatus::SYS_EBUSY;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EINVAL: return RequestStatus::SYS_EINVAL;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_ENOSPC: return RequestStatus::SYS_ENOSPC;
|
||||||
|
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_ETIMEDOUT: return RequestStatus::SYS_ETIMEDOUT;
|
||||||
|
default:
|
||||||
|
return RequestStatus::SYS_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<uint64_t> BiometricsFingerprint::preEnroll() {
|
||||||
|
ALOGE("preEnroll");
|
||||||
|
return mOppoBiometricsFingerprint->preEnroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<RequestStatus> BiometricsFingerprint::enroll(const hidl_array<uint8_t, 69>& hat,
|
||||||
|
uint32_t gid, uint32_t timeoutSec) {
|
||||||
|
ALOGE("enroll");
|
||||||
|
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->enroll(hat, gid, timeoutSec));
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<RequestStatus> BiometricsFingerprint::postEnroll() {
|
||||||
|
ALOGE("postEnroll");
|
||||||
|
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->postEnroll());
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() {
|
||||||
|
ALOGE("getAuthId");
|
||||||
|
return mOppoBiometricsFingerprint->getAuthenticatorId();
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<RequestStatus> BiometricsFingerprint::cancel() {
|
||||||
|
receivedCancel = false;
|
||||||
|
RequestStatus ret = OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->cancel());
|
||||||
|
ALOGE("CANCELING");
|
||||||
|
if(!receivedCancel) {
|
||||||
|
ALOGE("Sending cancel error");
|
||||||
|
mOppoClientCallback->mClientCallback->onError(
|
||||||
|
myDeviceId,
|
||||||
|
android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_CANCELED,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<RequestStatus> BiometricsFingerprint::enumerate() {
|
||||||
|
receivedEnumerate = false;
|
||||||
|
RequestStatus ret = OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->enumerate());
|
||||||
|
ALOGE("ENUMERATING");
|
||||||
|
if(ret == RequestStatus::SYS_OK && !receivedEnumerate) {
|
||||||
|
size_t nFingers = knownFingers.size();
|
||||||
|
ALOGE("received fingers, sending our own %zu", nFingers);
|
||||||
|
if(nFingers > 0) {
|
||||||
|
for(auto finger: knownFingers) {
|
||||||
|
mOppoClientCallback->mClientCallback->onEnumerate(
|
||||||
|
myDeviceId,
|
||||||
|
finger,
|
||||||
|
0,
|
||||||
|
--nFingers);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mOppoClientCallback->mClientCallback->onEnumerate(
|
||||||
|
myDeviceId,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<RequestStatus> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid) {
|
||||||
|
ALOGE("remove");
|
||||||
|
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->remove(gid, fid));
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid,
|
||||||
|
const hidl_string& storePath) {
|
||||||
|
ALOGE("setActiveGroup");
|
||||||
|
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->setActiveGroup(gid, storePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid) {
|
||||||
|
ALOGE("auth");
|
||||||
|
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->authenticate(operationId, gid));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace implementation
|
||||||
|
} // namespace V2_1
|
||||||
|
} // namespace fingerprint
|
||||||
|
} // namespace biometrics
|
||||||
|
} // namespace hardware
|
||||||
|
} // namespace android
|
78
hal/oppo-fp/BiometricsFingerprint.h
Normal file
78
hal/oppo-fp/BiometricsFingerprint.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* 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>
|
||||||
|
#include <android/hardware/biometrics/fingerprint/2.1/types.h>
|
||||||
|
#include <vendor/oppo/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::OK;
|
||||||
|
using ::android::sp;
|
||||||
|
using ::android::status_t;
|
||||||
|
|
||||||
|
class OppoClientCallback;
|
||||||
|
struct BiometricsFingerprint : public IBiometricsFingerprint {
|
||||||
|
public:
|
||||||
|
BiometricsFingerprint();
|
||||||
|
|
||||||
|
// 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:
|
||||||
|
sp<vendor::oppo::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint> mOppoBiometricsFingerprint;
|
||||||
|
sp<OppoClientCallback> mOppoClientCallback;
|
||||||
|
static Return<RequestStatus> OppoToAOSPRequestStatus(vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus req);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // 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,9 @@
|
|||||||
|
service fps_hal.oppo.compat /system/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.oppo.compat
|
||||||
|
# "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 uhid
|
||||||
|
writepid /dev/cpuset/system-background/tasks
|
||||||
|
oneshot
|
61
hal/oppo-fp/service.cpp
Normal file
61
hal/oppo-fp/service.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* 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.realme_sdm710"
|
||||||
|
|
||||||
|
#include <android-base/logging.h>
|
||||||
|
#include <hidl/HidlTransportSupport.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::OK;
|
||||||
|
using android::sp;
|
||||||
|
using android::status_t;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
sp<BiometricsFingerprint> biometricsFingerprint;
|
||||||
|
status_t status;
|
||||||
|
|
||||||
|
LOG(INFO) << "Fingerprint HAL Adapter service is starting.";
|
||||||
|
|
||||||
|
biometricsFingerprint = new BiometricsFingerprint();
|
||||||
|
if (biometricsFingerprint == nullptr) {
|
||||||
|
LOG(ERROR) << "Can not create an instance of Fingerprint HAL Adapter BiometricsFingerprint Iface, exiting.";
|
||||||
|
goto shutdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||||
|
|
||||||
|
status = biometricsFingerprint->registerAsService();
|
||||||
|
if (status != OK) {
|
||||||
|
LOG(ERROR) << "Could not register service for Fingerprint HAL Adapter BiometricsFingerprint Iface ("
|
||||||
|
<< status << ")";
|
||||||
|
goto shutdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(INFO) << "Fingerprint HAL Adapter service is ready.";
|
||||||
|
joinRpcThreadpool();
|
||||||
|
// Should not pass this line
|
||||||
|
|
||||||
|
shutdown:
|
||||||
|
// In normal operation, we don't expect the thread pool to shutdown
|
||||||
|
LOG(ERROR) << "Fingerprint HAL Adapter service is shutting down.";
|
||||||
|
return 1;
|
||||||
|
}
|
@ -183,7 +183,14 @@ if grep vendor.huawei.hardware.biometrics.fingerprint /vendor/manifest.xml; then
|
|||||||
mount -o bind system/phh/huawei/fingerprint.kl /vendor/usr/keylayout/fingerprint.kl
|
mount -o bind system/phh/huawei/fingerprint.kl /vendor/usr/keylayout/fingerprint.kl
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! grep android.hardware.biometrics.fingerprint /vendor/manifest.xml && ! grep android.hardware.biometrics.fingerprint /vendor/etc/vintf/manifest.xml; then
|
foundFingerprint=false
|
||||||
|
for manifest in /vendor/manifest.xml /vendor/etc/vintf/manifest.xml;do
|
||||||
|
if grep -q -e android.hardware.biometrics.fingerprint -e vendor.oppo.hardware.biometrics.fingerprint $manifest;then
|
||||||
|
foundFingerprint=true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$foundFingerprint" = false ];then
|
||||||
mount -o bind system/phh/empty /system/etc/permissions/android.hardware.fingerprint.xml
|
mount -o bind system/phh/empty /system/etc/permissions/android.hardware.fingerprint.xml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -10,3 +10,5 @@
|
|||||||
|
|
||||||
/sec_storage(/.*)? u:object_r:teecd_data_file:s0
|
/sec_storage(/.*)? u:object_r:teecd_data_file:s0
|
||||||
/dev/dsm u:object_r:dmd_device:s0
|
/dev/dsm u:object_r:dmd_device:s0
|
||||||
|
|
||||||
|
/system/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.oppo.compat u:object_r:hal_fingerprint_oppo_compat_exec:s0
|
||||||
|
10
sepolicy/hal.te
Normal file
10
sepolicy/hal.te
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type hal_fingerprint_oppo_compat, domain;
|
||||||
|
hal_client_domain(hal_fingerprint_oppo_compat, hal_fingerprint)
|
||||||
|
hal_server_domain(hal_fingerprint_oppo_compat, hal_fingerprint)
|
||||||
|
|
||||||
|
type hal_fingerprint_oppo_compat_exec, exec_type, vendor_file_type, file_type;
|
||||||
|
init_daemon_domain(hal_fingerprint_oppo_compat)
|
||||||
|
|
||||||
|
|
||||||
|
type hal_fingerprint_oppo, domain;
|
||||||
|
allow hal_fingerprint_oppo vendor_default_prop:property_service { set };
|
3
sepolicy/oppo.te
Normal file
3
sepolicy/oppo.te
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
type sysfs_usb_supply, file_type;
|
||||||
|
|
||||||
|
allow system_app sysfs_usb_supply:file rw_file_perms;
|
Loading…
Reference in New Issue
Block a user