From 0031326e7d40ee006b5b6964862432714a67e953 Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Tue, 10 Mar 2020 23:26:03 +0100 Subject: [PATCH] Add Oppo fingerprint support, tested on Realme X2 Pro --- base.mk | 3 + framework_manifest.xml | 11 + hal/oppo-fp/Android.bp | 24 ++ hal/oppo-fp/BiometricsFingerprint.cpp | 267 ++++++++++++++++++ hal/oppo-fp/BiometricsFingerprint.h | 78 +++++ ...biometrics.fingerprint@2.1-service.oppo.rc | 9 + hal/oppo-fp/service.cpp | 61 ++++ rw-system.sh | 9 +- sepolicy/file_contexts | 2 + sepolicy/hal.te | 10 + sepolicy/oppo.te | 3 + 11 files changed, 476 insertions(+), 1 deletion(-) create mode 100644 hal/oppo-fp/Android.bp create mode 100644 hal/oppo-fp/BiometricsFingerprint.cpp create mode 100644 hal/oppo-fp/BiometricsFingerprint.h create mode 100644 hal/oppo-fp/android.hardware.biometrics.fingerprint@2.1-service.oppo.rc create mode 100644 hal/oppo-fp/service.cpp create mode 100644 sepolicy/hal.te create mode 100644 sepolicy/oppo.te diff --git a/base.mk b/base.mk index ded39dc..32df2fa 100644 --- a/base.mk +++ b/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.sh:system/bin/phh-remotectl.sh \ +PRODUCT_PACKAGES += \ + android.hardware.biometrics.fingerprint@2.1-service.oppo.compat \ + diff --git a/framework_manifest.xml b/framework_manifest.xml index d0f6d40..cb37b49 100644 --- a/framework_manifest.xml +++ b/framework_manifest.xml @@ -8,5 +8,16 @@ default + + + + android.hardware.biometrics.fingerprint + hwbinder + 2.1 + + IBiometricsFingerprint + default + + diff --git a/hal/oppo-fp/Android.bp b/hal/oppo-fp/Android.bp new file mode 100644 index 0000000..4f8bdcd --- /dev/null +++ b/hal/oppo-fp/Android.bp @@ -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", + ], +} diff --git a/hal/oppo-fp/BiometricsFingerprint.cpp b/hal/oppo-fp/BiometricsFingerprint.cpp new file mode 100644 index 0000000..d7174fd --- /dev/null +++ b/hal/oppo-fp/BiometricsFingerprint.cpp @@ -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 +#include +#include "BiometricsFingerprint.h" + +#include +#include +#include +#include + +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 knownFingers; +class OppoClientCallback : public vendor::oppo::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback { +public: + sp mClientCallback; + + OppoClientCallback(sp clientCallback) : mClientCallback(clientCallback) {} + Return 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 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 onAuthenticated(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, + const hidl_vec& token) { + ALOGE("onAuthenticated %lu %u %u", deviceId, fingerId, groupId); + if(mClientCallback != nullptr) + mClientCallback->onAuthenticated(deviceId, fingerId, groupId, token); + return Void(); + } + + Return 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 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 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 onTouchUp(uint64_t deviceId) { return Void(); } + Return onTouchDown(uint64_t deviceId) { return Void(); } + Return onSyncTemplates(uint64_t deviceId, const hidl_vec& 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 onFingerprintCmd(int32_t deviceId, const hidl_vec& groupId, uint32_t remaining) { return Void(); } + Return onImageInfoAcquired(uint32_t type, uint32_t quality, uint32_t match_score) { return Void(); } + Return onMonitorEventTriggered(uint32_t type, const hidl_string& data) { return Void(); } + Return onEngineeringInfoUpdated(uint32_t length, const hidl_vec& keys, const hidl_vec& values) { return Void(); } + Return onUIReady(int64_t deviceId) { return Void(); } + +private: + + Return 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 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 BiometricsFingerprint::setNotify( + const sp& clientCallback) { + ALOGE("setNotify"); + mOppoClientCallback = new OppoClientCallback(clientCallback); + return mOppoBiometricsFingerprint->setNotify(mOppoClientCallback); +} + +Return 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 BiometricsFingerprint::preEnroll() { + ALOGE("preEnroll"); + return mOppoBiometricsFingerprint->preEnroll(); +} + +Return BiometricsFingerprint::enroll(const hidl_array& hat, + uint32_t gid, uint32_t timeoutSec) { + ALOGE("enroll"); + return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->enroll(hat, gid, timeoutSec)); +} + +Return BiometricsFingerprint::postEnroll() { + ALOGE("postEnroll"); + return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->postEnroll()); +} + +Return BiometricsFingerprint::getAuthenticatorId() { + ALOGE("getAuthId"); + return mOppoBiometricsFingerprint->getAuthenticatorId(); +} + +Return 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 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 BiometricsFingerprint::remove(uint32_t gid, uint32_t fid) { + ALOGE("remove"); + return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->remove(gid, fid)); +} + +Return BiometricsFingerprint::setActiveGroup(uint32_t gid, + const hidl_string& storePath) { + ALOGE("setActiveGroup"); + return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->setActiveGroup(gid, storePath)); +} + +Return 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 diff --git a/hal/oppo-fp/BiometricsFingerprint.h b/hal/oppo-fp/BiometricsFingerprint.h new file mode 100644 index 0000000..5c4050f --- /dev/null +++ b/hal/oppo-fp/BiometricsFingerprint.h @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include + +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 setNotify(const sp& clientCallback) override; + Return preEnroll() override; + Return enroll(const hidl_array& hat, uint32_t gid, uint32_t timeoutSec) override; + Return postEnroll() override; + Return getAuthenticatorId() override; + Return cancel() override; + Return enumerate() override; + Return remove(uint32_t gid, uint32_t fid) override; + Return setActiveGroup(uint32_t gid, const hidl_string& storePath) override; + Return authenticate(uint64_t operationId, uint32_t gid) override; + +private: + sp mOppoBiometricsFingerprint; + sp mOppoClientCallback; + static Return 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 diff --git a/hal/oppo-fp/android.hardware.biometrics.fingerprint@2.1-service.oppo.rc b/hal/oppo-fp/android.hardware.biometrics.fingerprint@2.1-service.oppo.rc new file mode 100644 index 0000000..d5baffa --- /dev/null +++ b/hal/oppo-fp/android.hardware.biometrics.fingerprint@2.1-service.oppo.rc @@ -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 diff --git a/hal/oppo-fp/service.cpp b/hal/oppo-fp/service.cpp new file mode 100644 index 0000000..4b7623e --- /dev/null +++ b/hal/oppo-fp/service.cpp @@ -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 +#include + +#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; + 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; +} diff --git a/rw-system.sh b/rw-system.sh index 6bc0e36..a6d2a09 100644 --- a/rw-system.sh +++ b/rw-system.sh @@ -182,7 +182,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 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 fi diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts index 44049e9..5e13268 100644 --- a/sepolicy/file_contexts +++ b/sepolicy/file_contexts @@ -12,3 +12,5 @@ /sec_storage(/.*)? u:object_r:teecd_data_file: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 diff --git a/sepolicy/hal.te b/sepolicy/hal.te new file mode 100644 index 0000000..cb44422 --- /dev/null +++ b/sepolicy/hal.te @@ -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 }; diff --git a/sepolicy/oppo.te b/sepolicy/oppo.te new file mode 100644 index 0000000..7b2133d --- /dev/null +++ b/sepolicy/oppo.te @@ -0,0 +1,3 @@ +type sysfs_usb_supply, file_type; + +allow system_app sysfs_usb_supply:file rw_file_perms;