From 50a605aa9eff7fd18cf42c0247b2ac724cbe7276 Mon Sep 17 00:00:00 2001 From: Tianshi Liu Date: Tue, 22 Feb 2022 11:07:48 +0800 Subject: [PATCH] sync code from main Change-Id: Id5d5cf58f609d38e35c80cbb362dc7155f8c4ac5 --- LICENSE | 0 sa_profile/942.xml | 0 sa_profile/face_auth_service.cfg | 10 +---- sa_profile/face_auth_service.rc | 0 .../include/face_auth_event_handler.h | 0 services/faceauth/include/face_auth_service.h | 0 services/faceauth/src/face_auth_camera.cpp | 7 ++- .../faceauth/src/face_auth_event_handler.cpp | 0 services/faceauth/src/face_auth_manager.cpp | 15 +++---- services/faceauth/src/face_auth_service.cpp | 0 services/temp/include/buffer.h | 1 - services/temp/src/buffer.cpp | 43 +++---------------- useriam.gni | 0 13 files changed, 19 insertions(+), 57 deletions(-) mode change 100644 => 100755 LICENSE mode change 100644 => 100755 sa_profile/942.xml mode change 100644 => 100755 sa_profile/face_auth_service.rc mode change 100644 => 100755 services/faceauth/include/face_auth_event_handler.h mode change 100644 => 100755 services/faceauth/include/face_auth_service.h mode change 100644 => 100755 services/faceauth/src/face_auth_event_handler.cpp mode change 100644 => 100755 services/faceauth/src/face_auth_manager.cpp mode change 100644 => 100755 services/faceauth/src/face_auth_service.cpp mode change 100644 => 100755 useriam.gni diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/sa_profile/942.xml b/sa_profile/942.xml old mode 100644 new mode 100755 diff --git a/sa_profile/face_auth_service.cfg b/sa_profile/face_auth_service.cfg index 28b51af..8dabe66 100644 --- a/sa_profile/face_auth_service.cfg +++ b/sa_profile/face_auth_service.cfg @@ -1,17 +1,9 @@ { - "jobs" : [{ - "name" : "late-fs", - "cmds" : [ - "start face_service" - ] - } - ], "services" : [{ "name" : "face_service", "path" : ["/system/bin/sa_main", "/system/profile/face_service.xml"], - "importance" : -20, "uid" : "system", - "gid" : ["system"], + "gid" : ["system", "shell"], "secon" : "u:r:face_service:s0" } ] diff --git a/sa_profile/face_auth_service.rc b/sa_profile/face_auth_service.rc old mode 100644 new mode 100755 diff --git a/services/faceauth/include/face_auth_event_handler.h b/services/faceauth/include/face_auth_event_handler.h old mode 100644 new mode 100755 diff --git a/services/faceauth/include/face_auth_service.h b/services/faceauth/include/face_auth_service.h old mode 100644 new mode 100755 diff --git a/services/faceauth/src/face_auth_camera.cpp b/services/faceauth/src/face_auth_camera.cpp index 9c1e030..417daec 100644 --- a/services/faceauth/src/face_auth_camera.cpp +++ b/services/faceauth/src/face_auth_camera.cpp @@ -96,6 +96,8 @@ int32_t FaceAuthCamera::CreateCamera(sptr surface) int32_t intResult = PrepareCamera(surface); if (intResult != 0) { FACEAUTH_HILOGE(MODULE_SERVICE, "Prepare Camera Failed"); + camInput_->Release(); + camInput_ = nullptr; return FA_RET_ERROR; } FACEAUTH_HILOGI(MODULE_SERVICE, "Create Camera end."); @@ -187,7 +189,6 @@ void FaceAuthCamera::Stop() void FaceAuthCamera::Release() { FACEAUTH_HILOGI(MODULE_SERVICE, "FaceAuthCamera::Release Start."); - camInput_ = nullptr; if (previewOutput_ != nullptr) { ((sptr &) previewOutput_)->Release(); FACEAUTH_HILOGI(MODULE_SERVICE, "FaceAuthCamera::previewOutput_ Release End."); @@ -205,6 +206,10 @@ void FaceAuthCamera::Release() capSession_->Release(); capSession_ = nullptr; } + if (camInput_ != nullptr) { + camInput_->Release(); + camInput_ = nullptr; + } if (instance_ != nullptr) { instance_.reset(); } diff --git a/services/faceauth/src/face_auth_event_handler.cpp b/services/faceauth/src/face_auth_event_handler.cpp old mode 100644 new mode 100755 diff --git a/services/faceauth/src/face_auth_manager.cpp b/services/faceauth/src/face_auth_manager.cpp old mode 100644 new mode 100755 index 638e8d1..df951e2 --- a/services/faceauth/src/face_auth_manager.cpp +++ b/services/faceauth/src/face_auth_manager.cpp @@ -47,7 +47,7 @@ std::shared_ptr FaceAuthManager::GetInstance() void CheckSystemAbility() { - const int CHECK_TIMES = 3; + const int CHECK_TIMES = 20; const int SLEEP_TIME = 1; sptr sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (sam == nullptr) { @@ -384,17 +384,13 @@ FIRetCode FaceAuthManager::OperForAlgorithm(uint64_t scheduleID) FACEAUTH_HILOGI(MODULE_SERVICE, "faceAuthCA is null."); return FI_RC_INVALID_ARGUMENT; } - int32_t retCode = 0; - std::vector retCoauthMsg; - std::vector m_msg; - std::shared_ptr msgInstance = std::make_shared(m_msg); - if (msgInstance == nullptr) { - return FI_RC_INVALID_ARGUMENT; - } + while (1) { + int32_t retCode = 0; + std::vector retCoauthMsg; faceAuthCA->GetAlgorithmState(retCode, retCoauthMsg); FACEAUTH_HILOGI(MODULE_SERVICE, "receive new co auth message."); - std::shared_ptr msg(msgInstance->FromUint8Array(retCoauthMsg)); + std::shared_ptr msg = std::make_shared(retCoauthMsg); if (msg != nullptr) { SendData(scheduleID, 0, TYPE_ALL_IN_ONE, TYPE_CO_AUTH, msg); } @@ -502,6 +498,7 @@ void FaceAuthManager::Finish(uint64_t scheduleId, { if (executorMessenger_ != nullptr) { executorMessenger_->Finish(scheduleId, srcType, resultCode, finalResult); + FACEAUTH_HILOGI(MODULE_SERVICE, "executorMessenger_ finish called."); } else { FACEAUTH_HILOGI(MODULE_SERVICE, "executorMessenger_ is null."); } diff --git a/services/faceauth/src/face_auth_service.cpp b/services/faceauth/src/face_auth_service.cpp old mode 100644 new mode 100755 diff --git a/services/temp/include/buffer.h b/services/temp/include/buffer.h index 49113ad..1684b14 100644 --- a/services/temp/include/buffer.h +++ b/services/temp/include/buffer.h @@ -34,7 +34,6 @@ ResultCode InitBuffer(Buffer *buffer, const uint8_t *buf, const uint32_t bufSize void DestoryBuffer(Buffer *buffer); Buffer *CopyBuffer(const Buffer *buffer); bool CompareBuffer(const Buffer *buffer1, const Buffer *buffer2); -Buffer *CreateBufferByData(const uint8_t *data, const uint32_t dataSize); ResultCode GetBufferData(const Buffer *buffer, uint8_t *data, uint32_t *dataSize); bool CheckBufferWithSize(const Buffer *buffer, const uint32_t size); } // namespace FaceAuth diff --git a/services/temp/src/buffer.cpp b/services/temp/src/buffer.cpp index 52e9676..925271e 100644 --- a/services/temp/src/buffer.cpp +++ b/services/temp/src/buffer.cpp @@ -48,7 +48,7 @@ Buffer *CreateBuffer(const uint32_t size) return nullptr; } - Buffer *buffer = new Buffer; + Buffer *buffer = (Buffer *)malloc(sizeof(Buffer)); if (buffer == nullptr) { FACEAUTH_HILOGE(MODULE_SERVICE, "Get buffer struct error"); return nullptr; @@ -57,13 +57,13 @@ Buffer *CreateBuffer(const uint32_t size) buffer->buf = (uint8_t *)malloc(size); if (buffer->buf == nullptr) { FACEAUTH_HILOGE(MODULE_SERVICE, "Get buffer error"); - delete buffer; + free(buffer); return nullptr; } if (memset_s(buffer->buf, size, 0, size) != EOK) { - delete buffer->buf; - delete buffer; + free(buffer->buf); + free(buffer); return nullptr; } buffer->maxSize = size; @@ -72,37 +72,6 @@ Buffer *CreateBuffer(const uint32_t size) return buffer; } -Buffer *CreateBufferByData(const uint8_t *data, const uint32_t dataSize) -{ - if ((data == nullptr) || (dataSize == 0) || (dataSize > MAX_BUFFER_SIZE)) { - FACEAUTH_HILOGE(MODULE_SERVICE, "Bad param size:%u", dataSize); - return nullptr; - } - - Buffer *buffer = new Buffer; - if (buffer == nullptr) { - FACEAUTH_HILOGE(MODULE_SERVICE, "Get buffer struct error"); - return nullptr; - } - - buffer->buf = new uint8_t; - if (buffer->buf == nullptr) { - FACEAUTH_HILOGE(MODULE_SERVICE, "Get buffer error"); - delete buffer; - return nullptr; - } - - if (memcpy_s(buffer->buf, dataSize, data, dataSize) != EOK) { - FACEAUTH_HILOGE(MODULE_SERVICE, "Cpy buffer error"); - DestoryBuffer(buffer); - return nullptr; - } - buffer->maxSize = dataSize; - buffer->contentSize = dataSize; - - return buffer; -} - ResultCode InitBuffer(Buffer *buffer, const uint8_t *buf, const uint32_t bufSize) { if (!IsBufferValid(buffer) || (buf == nullptr) || (bufSize == 0)) { @@ -126,12 +95,12 @@ void DestoryBuffer(Buffer *buffer) if (memset_s(buffer->buf, buffer->contentSize, 0, buffer->contentSize) != EOK) { FACEAUTH_HILOGE(MODULE_SERVICE, "DestoryBuffer memset fail!"); } - delete buffer->buf; + free(buffer->buf); buffer->buf = nullptr; buffer->contentSize = 0; buffer->maxSize = 0; } - delete buffer; + free(buffer); } } diff --git a/useriam.gni b/useriam.gni old mode 100644 new mode 100755 -- Gitee