From 9102da1c6cc44d9d522f548a6381c2b3f383e34d Mon Sep 17 00:00:00 2001 From: Tianshi Liu Date: Thu, 11 Apr 2024 22:43:23 +0800 Subject: [PATCH] support msg distribute Signed-off-by: Tianshi Liu Change-Id: If39383d0ddeeefcce458820a48201123c2e23ec5 Signed-off-by: Tianshi Liu --- .../client/inc/executor_callback_service.h | 1 + .../client/inc/executor_messenger_client.h | 5 +- .../client/src/executor_callback_service.cpp | 10 +++ .../client/src/executor_messenger_client.cpp | 10 +-- frameworks/native/executors/BUILD.gn | 2 + .../async_command/async_command_base.h | 8 +- .../include/async_command/auth_command.h | 2 - .../include/async_command/collect_command.h | 45 ++++++++++ .../include/async_command/custom_command.h | 1 + .../include/async_command/enroll_command.h | 2 - .../include/async_command/identify_command.h | 2 - .../native/executors/include/executor.h | 2 + .../framework/framework_executor_callback.h | 2 + .../src/async_command/async_command_base.cpp | 61 ++++++++++++- .../src/async_command/auth_command.cpp | 23 +---- .../src/async_command/collect_command.cpp | 78 +++++++++++++++++ .../src/async_command/custom_command.cpp | 5 ++ .../src/async_command/enroll_command.cpp | 23 +---- .../src/async_command/identify_command.cpp | 23 +---- frameworks/native/executors/src/executor.cpp | 6 ++ .../framework/framework_executor_callback.cpp | 40 +++++++++ .../executors/src/iauth_executor_hdi.cpp | 86 +++++++++++++++++++ .../native/executors/user_auth_executors_map | 1 + .../ipc/common_defines/co_auth_interface.h | 1 + .../executor_callback_interface.h | 1 + ...or_callback_interface_ipc_interface_code.h | 1 + .../executor_messenger_interface.h | 4 +- .../native/ipc/inc/executor_callback_proxy.h | 1 + .../native/ipc/inc/executor_callback_stub.h | 1 + .../native/ipc/inc/executor_messenger_proxy.h | 4 +- frameworks/native/ipc/src/co_auth_proxy.cpp | 4 + frameworks/native/ipc/src/co_auth_stub.cpp | 6 ++ .../ipc/src/executor_callback_proxy.cpp | 32 +++++++ .../native/ipc/src/executor_callback_stub.cpp | 25 ++++++ .../ipc/src/executor_messenger_proxy.cpp | 16 +--- .../ipc/src/executor_messenger_stub.cpp | 20 +---- interfaces/inner_api/attributes.h | 4 + .../inner_api/co_auth_client_callback.h | 9 ++ interfaces/inner_api/co_auth_client_defines.h | 13 ++- interfaces/inner_api/iam_common_defines.h | 2 + .../iam_executor_framework_types.h | 22 ++--- .../iam_executor_iauth_executor_hdi.h | 59 +++++++++---- .../iam_executor_iexecute_callback.h | 8 ++ services/base/inc/user_auth_hdi.h | 1 + services/core/BUILD.gn | 2 + .../core/inc/hdi_message_callback_service.h | 36 ++++++++ services/core/inc/resource_node.h | 1 + services/core/inc/schedule_node.h | 3 +- .../core/src/hdi_message_callback_service.cpp | 66 ++++++++++++++ services/core/src/resource_node_impl.cpp | 11 +++ services/core/src/schedule_node_impl.cpp | 39 +++++++-- services/core/src/schedule_node_impl.h | 3 +- services/ipc/inc/executor_messenger_service.h | 6 +- services/ipc/src/co_auth_service.cpp | 5 ++ .../ipc/src/executor_messenger_service.cpp | 7 +- .../co_auth_client_fuzzer.cpp | 23 ++--- .../executor_callback_stub_fuzzer.cpp | 8 ++ test/fuzztest/common_fuzzer/BUILD.gn | 1 + .../userauthdrivermanager_fuzzer/BUILD.gn | 1 + .../user_auth_driver_manager_fuzzer.cpp | 9 ++ .../userauthexecutor_fuzzer/BUILD.gn | 1 + .../user_auth_executor_fuzzer.cpp | 18 ++-- .../services/coauthservice_fuzzer/BUILD.gn | 1 + .../co_auth_service_fuzzer.cpp | 22 +++-- .../services/coauthstub_fuzzer/BUILD.gn | 1 + .../services/servicecore_fuzzer/BUILD.gn | 5 +- .../servicecore_fuzzer/inc/common_dummy.h | 8 ++ .../src/resource_node_fuzzer.cpp | 8 ++ .../src/schedule_node_fuzzer.cpp | 12 ++- .../services/userauthservice_fuzzer/BUILD.gn | 1 + .../services/userauthstub_fuzzer/BUILD.gn | 1 + .../services/useridmservice_fuzzer/BUILD.gn | 1 + .../services/useridmstub_fuzzer/BUILD.gn | 1 + test/unittest/executors/BUILD.gn | 2 + .../executors/auth_command_unit_test.cpp | 46 ++++------ .../executors/enroll_command_unit_test.cpp | 47 ++++------ .../unittest/executors/executor_unit_test.cpp | 59 +++++++------ .../executors/identify_command_unit_test.cpp | 46 ++++------ .../executors/mock/mock_iauth_executor_hdi.h | 7 +- .../executors/mock/mock_iexecutor_messenger.h | 6 +- .../mocks/mock_executor_callback_service.h | 1 + .../mocks/mock_executor_messenger_service.h | 5 +- .../mocks/mock_executor_register_callback.h | 1 + .../src/executor_messenger_client_test.cpp | 34 +++----- .../src/executor_messenger_proxy_test.cpp | 10 +-- .../src/executor_messenger_stub_test.cpp | 10 +-- test/unittest/services/BUILD.gn | 2 + .../services/mocks/mock_executor_callback.h | 1 + .../services/mocks/mock_resource_node.h | 2 + .../services/mocks/mock_schedule_node.h | 3 +- .../services/src/co_auth_stub_test.cpp | 2 + .../src/context_appstate_observer_test.cpp | 1 - .../src/executor_messenger_service_test.cpp | 18 ++-- .../services/src/schedule_node_test.cpp | 15 ++-- .../services/src/user_auth_service_test.cpp | 2 +- .../services/src/user_idm_service_test.cpp | 2 +- 96 files changed, 899 insertions(+), 396 deletions(-) create mode 100644 frameworks/native/executors/include/async_command/collect_command.h create mode 100644 frameworks/native/executors/src/async_command/collect_command.cpp create mode 100644 frameworks/native/executors/src/iauth_executor_hdi.cpp create mode 100644 services/core/inc/hdi_message_callback_service.h create mode 100644 services/core/src/hdi_message_callback_service.cpp diff --git a/frameworks/native/client/inc/executor_callback_service.h b/frameworks/native/client/inc/executor_callback_service.h index efe481834..ec84f9cc6 100644 --- a/frameworks/native/client/inc/executor_callback_service.h +++ b/frameworks/native/client/inc/executor_callback_service.h @@ -34,6 +34,7 @@ public: int32_t OnEndExecute(uint64_t scheduleId, const Attributes &command) override; int32_t OnSetProperty(const Attributes &properties) override; int32_t OnGetProperty(const Attributes &condition, Attributes &values) override; + int32_t OnSendData(uint64_t scheduleId, const Attributes &data) override; private: std::shared_ptr callback_ {nullptr}; diff --git a/frameworks/native/client/inc/executor_messenger_client.h b/frameworks/native/client/inc/executor_messenger_client.h index cf7589d6b..ead15fbb7 100644 --- a/frameworks/native/client/inc/executor_messenger_client.h +++ b/frameworks/native/client/inc/executor_messenger_client.h @@ -25,9 +25,8 @@ namespace UserAuth { class ExecutorMessengerClient final : public ExecutorMessenger { public: explicit ExecutorMessengerClient(const sptr &messenger); - int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg) override; - int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, + int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) override; + int32_t Finish(uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) override; private: diff --git a/frameworks/native/client/src/executor_callback_service.cpp b/frameworks/native/client/src/executor_callback_service.cpp index bb90837dc..0a49742d4 100644 --- a/frameworks/native/client/src/executor_callback_service.cpp +++ b/frameworks/native/client/src/executor_callback_service.cpp @@ -85,6 +85,16 @@ int32_t ExecutorCallbackService::OnGetProperty(const Attributes &condition, Attr } return callback_->OnGetProperty(condition, values); } + +int32_t ExecutorCallbackService::OnSendData(uint64_t scheduleId, const Attributes &data) +{ + IAM_LOGI("start"); + if (callback_ == nullptr) { + IAM_LOGE("callback is nullptr"); + return GENERAL_ERROR; + } + return callback_->OnSendData(scheduleId, data); +} } // namespace UserAuth } // namespace UserIam } // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/client/src/executor_messenger_client.cpp b/frameworks/native/client/src/executor_messenger_client.cpp index 672021891..313dcb980 100644 --- a/frameworks/native/client/src/executor_messenger_client.cpp +++ b/frameworks/native/client/src/executor_messenger_client.cpp @@ -29,8 +29,8 @@ ExecutorMessengerClient::ExecutorMessengerClient(const sptr &msg) +int32_t ExecutorMessengerClient::SendData(uint64_t scheduleId, ExecutorRole dstRole, + const std::shared_ptr &msg) { IAM_LOGI("start"); if (messenger_ == nullptr) { @@ -44,10 +44,10 @@ int32_t ExecutorMessengerClient::SendData(uint64_t scheduleId, uint64_t transNum } else { buffer = AuthMessageImpl::GetMsgBuffer(msg); } - return messenger_->SendData(scheduleId, transNum, srcRole, dstRole, buffer); + return messenger_->SendData(scheduleId, dstRole, buffer); } -int32_t ExecutorMessengerClient::Finish(uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, +int32_t ExecutorMessengerClient::Finish(uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { IAM_LOGI("start"); @@ -60,7 +60,7 @@ int32_t ExecutorMessengerClient::Finish(uint64_t scheduleId, ExecutorRole srcRol IAM_LOGE("failed to create attributes"); return GENERAL_ERROR; } - return messenger_->Finish(scheduleId, srcRole, static_cast(resultCode), attr); + return messenger_->Finish(scheduleId, static_cast(resultCode), attr); } } // namespace UserAuth } // namespace UserIam diff --git a/frameworks/native/executors/BUILD.gn b/frameworks/native/executors/BUILD.gn index a0fc77dcb..2fdbf6f27 100644 --- a/frameworks/native/executors/BUILD.gn +++ b/frameworks/native/executors/BUILD.gn @@ -34,6 +34,7 @@ ohos_shared_library("userauth_executors") { sources = [ "src/async_command/async_command_base.cpp", "src/async_command/auth_command.cpp", + "src/async_command/collect_command.cpp", "src/async_command/custom_command.cpp", "src/async_command/enroll_command.cpp", "src/async_command/identify_command.cpp", @@ -42,6 +43,7 @@ ohos_shared_library("userauth_executors") { "src/executor.cpp", "src/framework/executor_mgr_wrapper.cpp", "src/framework/framework_executor_callback.cpp", + "src/iauth_executor_hdi.cpp", "src/idriver_manager.cpp", "src/listener/auth_executor_mgr_status_listener.cpp", "src/listener/driver_manager_status_listener.cpp", diff --git a/frameworks/native/executors/include/async_command/async_command_base.h b/frameworks/native/executors/include/async_command/async_command_base.h index debec5384..2b55912d3 100644 --- a/frameworks/native/executors/include/async_command/async_command_base.h +++ b/frameworks/native/executors/include/async_command/async_command_base.h @@ -41,6 +41,7 @@ public: ResultCode StartProcess() override; void OnResult(ResultCode result) override; void OnResult(ResultCode result, const std::vector &extraInfo) override; + void OnMessage(int destRole, const std::vector &msg) override; void OnAcquireInfo(int32_t acquire, const std::vector &extraInfo) override; int32_t GetAuthType(); @@ -48,11 +49,12 @@ protected: static uint32_t GenerateCommandId(); virtual ResultCode SendRequest() = 0; virtual void OnResultInner(ResultCode result, const std::vector &extraInfo) = 0; - virtual void OnAcquireInfoInner(int32_t acquire, const std::vector &extraInfo) = 0; + virtual void OnAcquireInfoInner(int32_t acquire, const std::vector &extraInfo); + virtual void OnMessageInner(int destRole, const std::vector &msg); std::shared_ptr GetExecutorHdi(); - int32_t MessengerSendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcType, ExecutorRole dstType, + int32_t MessengerSendData(uint64_t scheduleId, ExecutorRole dstType, std::shared_ptr msg); - int32_t MessengerFinish(uint64_t scheduleId, ExecutorRole srcType, int32_t resultCode, + int32_t MessengerFinish(uint64_t scheduleId, int32_t resultCode, std::shared_ptr finalResult); const char *GetDescription(); diff --git a/frameworks/native/executors/include/async_command/auth_command.h b/frameworks/native/executors/include/async_command/auth_command.h index 922fd7bb8..5e8153edc 100644 --- a/frameworks/native/executors/include/async_command/auth_command.h +++ b/frameworks/native/executors/include/async_command/auth_command.h @@ -32,11 +32,9 @@ public: protected: ResultCode SendRequest() override; - void OnAcquireInfoInner(int32_t acquire, const std::vector &extraInfo) override; void OnResultInner(ResultCode result, const std::vector &extraInfo) override; private: - uint32_t transNum_ = 1; std::shared_ptr attributes_; std::shared_ptr iamHitraceHelper_; }; diff --git a/frameworks/native/executors/include/async_command/collect_command.h b/frameworks/native/executors/include/async_command/collect_command.h new file mode 100644 index 000000000..53c1ca836 --- /dev/null +++ b/frameworks/native/executors/include/async_command/collect_command.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 COLLECT_COMMAND_H +#define COLLECT_COMMAND_H + +#include "iam_hitrace_helper.h" + +#include "async_command_base.h" + +namespace OHOS { +namespace UserIam { +namespace UserAuth { +class CollectCommand : public AsyncCommandBase { +public: + CollectCommand(std::weak_ptr executor, uint64_t scheduleId, + const Attributes &commandAttrs, + std::shared_ptr executorMessenger); + ~CollectCommand() override = default; + +protected: + ResultCode SendRequest() override; + void OnResultInner(ResultCode result, const std::vector &extraInfo) override; + +private: + std::shared_ptr attributes_; + std::shared_ptr iamHitraceHelper_; +}; +} // namespace UserAuth +} // namespace UserIam +} // namespace OHOS + +#endif // COLLECT_COMMAND_H \ No newline at end of file diff --git a/frameworks/native/executors/include/async_command/custom_command.h b/frameworks/native/executors/include/async_command/custom_command.h index f8c6197c2..9a5f1fc4b 100644 --- a/frameworks/native/executors/include/async_command/custom_command.h +++ b/frameworks/native/executors/include/async_command/custom_command.h @@ -33,6 +33,7 @@ protected: ResultCode SendRequest() override; void OnAcquireInfoInner(int32_t acquire, const std::vector &extraInfo) override; void OnResultInner(ResultCode result, const std::vector &extraInfo) override; + void OnMessageInner(int destRole, const std::vector &msg) override; private: void SetResult(ResultCode resultCode); diff --git a/frameworks/native/executors/include/async_command/enroll_command.h b/frameworks/native/executors/include/async_command/enroll_command.h index 50144e1c0..6ea307377 100644 --- a/frameworks/native/executors/include/async_command/enroll_command.h +++ b/frameworks/native/executors/include/async_command/enroll_command.h @@ -31,11 +31,9 @@ public: protected: ResultCode SendRequest() override; - void OnAcquireInfoInner(int32_t acquire, const std::vector &extraInfo) override; void OnResultInner(ResultCode result, const std::vector &extraInfo) override; private: - uint32_t transNum_ = 1; std::shared_ptr attributes_; std::shared_ptr iamHitraceHelper_; }; diff --git a/frameworks/native/executors/include/async_command/identify_command.h b/frameworks/native/executors/include/async_command/identify_command.h index a4ebbd7bd..3a0076a18 100644 --- a/frameworks/native/executors/include/async_command/identify_command.h +++ b/frameworks/native/executors/include/async_command/identify_command.h @@ -31,11 +31,9 @@ public: protected: ResultCode SendRequest() override; - void OnAcquireInfoInner(int32_t acquire, const std::vector &extraInfo) override; void OnResultInner(ResultCode result, const std::vector &extraInfo) override; private: - uint32_t transNum_ = 1; std::shared_ptr attributes_; std::shared_ptr iamHitraceHelper_; }; diff --git a/frameworks/native/executors/include/executor.h b/frameworks/native/executors/include/executor.h index f081b53a9..5cd0d001e 100644 --- a/frameworks/native/executors/include/executor.h +++ b/frameworks/native/executors/include/executor.h @@ -45,6 +45,7 @@ public: std::shared_ptr GetExecutorHdi(); const char *GetDescription(); int32_t GetAuthType() const; + int32_t GetExecutorRole() const; private: void RegisterExecutorCallback(ExecutorInfo &executorInfo); @@ -57,6 +58,7 @@ private: std::string description_; uint16_t hdiId_; int32_t authType_; + int32_t executorRole_; }; } // namespace UserAuth } // namespace UserIam diff --git a/frameworks/native/executors/include/framework/framework_executor_callback.h b/frameworks/native/executors/include/framework/framework_executor_callback.h index d209d0ce0..03c050bd8 100644 --- a/frameworks/native/executors/include/framework/framework_executor_callback.h +++ b/frameworks/native/executors/include/framework/framework_executor_callback.h @@ -43,6 +43,7 @@ public: int32_t OnSetProperty(const Attributes &properties) override; int32_t OnGetProperty(const Attributes &conditions, Attributes &results) override; + int32_t OnSendData(uint64_t scheduleId, const Attributes &data) override; private: static uint32_t GenerateExecutorCallbackId(); @@ -58,6 +59,7 @@ private: ResultCode ProcessCancelCommand(uint64_t scheduleId); ResultCode ProcessDeleteTemplateCommand(const Attributes &properties); ResultCode ProcessSetCachedTemplates(const Attributes &properties); + ResultCode ProcessNotifyExecutorReady(const Attributes &properties); ResultCode ProcessCustomCommand(const Attributes &properties); ResultCode ProcessGetPropertyCommand(std::shared_ptr conditions, std::shared_ptr values); ResultCode FillPropertyToAttribute(const std::vector &keyList, const Property property, diff --git a/frameworks/native/executors/src/async_command/async_command_base.cpp b/frameworks/native/executors/src/async_command/async_command_base.cpp index eccdb7d94..aac5976e9 100644 --- a/frameworks/native/executors/src/async_command/async_command_base.cpp +++ b/frameworks/native/executors/src/async_command/async_command_base.cpp @@ -98,6 +98,59 @@ void AsyncCommandBase::OnAcquireInfo(int32_t acquire, const std::vector OnAcquireInfoInner(acquire, extraInfo); } +void AsyncCommandBase::OnAcquireInfoInner(int32_t acquire, const std::vector &extraInfo) +{ + IAM_LOGI("%{public}s start", GetDescription()); + + Attributes attr; + bool setAcquireRet = attr.SetInt32Value(Attributes::ATTR_TIP_INFO, acquire); + IF_FALSE_LOGE_AND_RETURN(setAcquireRet); + bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo); + IF_FALSE_LOGE_AND_RETURN(setExtraInfoRet); + + auto data = AuthMessage::As(attr.Serialize()); + IF_FALSE_LOGE_AND_RETURN(data != nullptr); + int32_t ret = MessengerSendData(scheduleId_, SCHEDULER, data); + if (ret != USERAUTH_SUCCESS) { + IAM_LOGE("%{public}s call SendData fail", GetDescription()); + return; + } + IAM_LOGI("%{public}s end, acquire %{public}d", GetDescription(), acquire); +} + +void AsyncCommandBase::OnMessage(int destRole, const std::vector &msg) +{ + std::lock_guard guard(mutex_); + if (isFinished_) { + IAM_LOGE("command is finished, invocation of OnMessage is invalid"); + return; + } + OnMessageInner(destRole, msg); +} + +void AsyncCommandBase::OnMessageInner(int destRole, const std::vector &msg) +{ + IAM_LOGI("%{public}s start", GetDescription()); + + std::shared_ptr executor = executor_.lock(); + IF_FALSE_LOGE_AND_RETURN(executor != nullptr); + + Attributes attr; + bool setAcquireRet = attr.SetInt32Value(Attributes::ATTR_SRC_ROLE, executor->GetExecutorRole()); + IF_FALSE_LOGE_AND_RETURN(setAcquireRet); + bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, msg); + IF_FALSE_LOGE_AND_RETURN(setExtraInfoRet); + + auto data = AuthMessage::As(attr.Serialize()); + IF_FALSE_LOGE_AND_RETURN(data != nullptr); + int32_t ret = MessengerSendData(scheduleId_, static_cast(destRole), data); + if (ret != USERAUTH_SUCCESS) { + IAM_LOGE("%{public}s call SendData fail", GetDescription()); + return; + } + IAM_LOGI("%{public}s end, msg size %{public}uz", GetDescription(), msg.size()); +} + int32_t AsyncCommandBase::GetAuthType() { auto executor = executor_.lock(); @@ -142,20 +195,20 @@ std::shared_ptr AsyncCommandBase::GetExecutorHdi() return executor->GetExecutorHdi(); } -int32_t AsyncCommandBase::MessengerSendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcType, +int32_t AsyncCommandBase::MessengerSendData(uint64_t scheduleId, ExecutorRole dstType, std::shared_ptr msg) { auto messenger = executorMessenger_; IF_FALSE_LOGE_AND_RETURN_VAL(messenger != nullptr, USERAUTH_ERROR); - return messenger->SendData(scheduleId, transNum, srcType, dstType, msg); + return messenger->SendData(scheduleId, dstType, msg); } -int32_t AsyncCommandBase::MessengerFinish(uint64_t scheduleId, ExecutorRole srcType, int32_t resultCode, +int32_t AsyncCommandBase::MessengerFinish(uint64_t scheduleId, int32_t resultCode, std::shared_ptr finalResult) { auto messenger = executorMessenger_; IF_FALSE_LOGE_AND_RETURN_VAL(messenger != nullptr, USERAUTH_ERROR); - int32_t ret = messenger->Finish(scheduleId, srcType, resultCode, *finalResult); + int32_t ret = messenger->Finish(scheduleId, resultCode, *finalResult); executorMessenger_ = nullptr; return ret; } diff --git a/frameworks/native/executors/src/async_command/auth_command.cpp b/frameworks/native/executors/src/async_command/auth_command.cpp index b839f2350..59de9cae4 100644 --- a/frameworks/native/executors/src/async_command/auth_command.cpp +++ b/frameworks/native/executors/src/async_command/auth_command.cpp @@ -76,34 +76,13 @@ void AuthCommand::OnResultInner(ResultCode result, const std::vector &e authAttributes->SetUint8ArrayValue(Attributes::ATTR_RESULT, nonConstExtraInfo); IF_FALSE_LOGE_AND_RETURN(setAuthResultRet == true); iamHitraceHelper_ = nullptr; - int32_t ret = MessengerFinish(scheduleId_, ALL_IN_ONE, result, authAttributes); + int32_t ret = MessengerFinish(scheduleId_, result, authAttributes); if (ret != USERAUTH_SUCCESS) { IAM_LOGE("%{public}s call finish fail", GetDescription()); return; } IAM_LOGI("%{public}s call finish success result %{public}d", GetDescription(), result); } - -void AuthCommand::OnAcquireInfoInner(int32_t acquire, const std::vector &extraInfo) -{ - IAM_LOGI("%{public}s on acquire info start", GetDescription()); - - Attributes attr; - bool setAcquireRet = attr.SetInt32Value(Attributes::ATTR_TIP_INFO, acquire); - IF_FALSE_LOGE_AND_RETURN(setAcquireRet); - bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo); - IF_FALSE_LOGE_AND_RETURN(setExtraInfoRet); - - auto msg = AuthMessage::As(attr.Serialize()); - IF_FALSE_LOGE_AND_RETURN(msg != nullptr); - int32_t ret = MessengerSendData(scheduleId_, transNum_, ALL_IN_ONE, SCHEDULER, msg); - ++transNum_; - if (ret != USERAUTH_SUCCESS) { - IAM_LOGE("%{public}s call SendData fail", GetDescription()); - return; - } - IAM_LOGI("%{public}s call SendData success acquire %{public}d", GetDescription(), acquire); -} } // namespace UserAuth } // namespace UserIam } // namespace OHOS diff --git a/frameworks/native/executors/src/async_command/collect_command.cpp b/frameworks/native/executors/src/async_command/collect_command.cpp new file mode 100644 index 000000000..da39d814b --- /dev/null +++ b/frameworks/native/executors/src/async_command/collect_command.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 "collect_command.h" + +#include "iam_check.h" +#include "iam_common_defines.h" +#include "iam_executor_framework_types.h" +#include "iam_logger.h" +#include "iam_para2str.h" +#include "iam_ptr.h" + +#define LOG_TAG "USER_COLLECT_EXECUTOR" + +namespace OHOS { +namespace UserIam { +namespace UserAuth { +CollectCommand::CollectCommand(std::weak_ptr executor, uint64_t scheduleId, + const Attributes &attributes, std::shared_ptr executorMessenger) + : AsyncCommandBase("COLLECT", scheduleId, executor, executorMessenger), + attributes_(Common::MakeShared(attributes.Serialize())), + iamHitraceHelper_(Common::MakeShared("CollectCommand")) +{ +} + +ResultCode CollectCommand::SendRequest() +{ + IAM_LOGI("%{public}s send request start", GetDescription()); + IF_FALSE_LOGE_AND_RETURN_VAL(attributes_ != nullptr, ResultCode::GENERAL_ERROR); + + auto hdi = GetExecutorHdi(); + IF_FALSE_LOGE_AND_RETURN_VAL(hdi != nullptr, ResultCode::GENERAL_ERROR); + + std::vector extraInfo; + bool getExtraInfoRet = attributes_->GetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo); + IF_FALSE_LOGE_AND_RETURN_VAL(getExtraInfoRet == true, ResultCode::GENERAL_ERROR); + + IamHitraceHelper traceHelper("hdi collect"); + ResultCode ret = hdi->Collect(scheduleId_, (CollectParam) { extraInfo }, shared_from_this()); + IAM_LOGI("%{public}s collect result %{public}d", GetDescription(), ret); + return ret; +} + +void CollectCommand::OnResultInner(ResultCode result, const std::vector &extraInfo) +{ + IAM_LOGI("%{public}s on result start", GetDescription()); + + std::vector nonConstExtraInfo(extraInfo.begin(), extraInfo.end()); + auto authAttributes = Common::MakeShared(); + IF_FALSE_LOGE_AND_RETURN(authAttributes != nullptr); + bool setResultCodeRet = authAttributes->SetUint32Value(Attributes::ATTR_RESULT_CODE, result); + IF_FALSE_LOGE_AND_RETURN(setResultCodeRet == true); + bool setCollectResultRet = + authAttributes->SetUint8ArrayValue(Attributes::ATTR_RESULT, nonConstExtraInfo); + IF_FALSE_LOGE_AND_RETURN(setCollectResultRet == true); + iamHitraceHelper_ = nullptr; + int32_t ret = MessengerFinish(scheduleId_, result, authAttributes); + if (ret != USERAUTH_SUCCESS) { + IAM_LOGE("%{public}s call finish fail", GetDescription()); + return; + } + IAM_LOGI("%{public}s call finish success result %{public}d", GetDescription(), result); +} +} // namespace UserAuth +} // namespace UserIam +} // namespace OHOS diff --git a/frameworks/native/executors/src/async_command/custom_command.cpp b/frameworks/native/executors/src/async_command/custom_command.cpp index 05dbcdb73..112c8b952 100644 --- a/frameworks/native/executors/src/async_command/custom_command.cpp +++ b/frameworks/native/executors/src/async_command/custom_command.cpp @@ -78,6 +78,11 @@ void CustomCommand::OnAcquireInfoInner(int32_t acquire, const std::vector &msg) +{ + IAM_LOGE("%{public}s not support", GetDescription()); +} + ResultCode CustomCommand::GetResult() { if (!future_.valid()) { diff --git a/frameworks/native/executors/src/async_command/enroll_command.cpp b/frameworks/native/executors/src/async_command/enroll_command.cpp index 5378676e7..bda71c652 100644 --- a/frameworks/native/executors/src/async_command/enroll_command.cpp +++ b/frameworks/native/executors/src/async_command/enroll_command.cpp @@ -77,34 +77,13 @@ void EnrollCommand::OnResultInner(ResultCode result, const std::vector authAttributes->SetUint8ArrayValue(Attributes::ATTR_RESULT, nonConstExtraInfo); IF_FALSE_LOGE_AND_RETURN(setAuthResultRet == true); iamHitraceHelper_ = nullptr; - int32_t ret = MessengerFinish(scheduleId_, ALL_IN_ONE, result, authAttributes); + int32_t ret = MessengerFinish(scheduleId_, result, authAttributes); if (ret != USERAUTH_SUCCESS) { IAM_LOGE("%{public}s call finish fail", GetDescription()); return; } IAM_LOGI("%{public}s call finish success result %{public}d", GetDescription(), result); } - -void EnrollCommand::OnAcquireInfoInner(int32_t acquire, const std::vector &extraInfo) -{ - IAM_LOGI("%{public}s on acquire info start", GetDescription()); - - Attributes attr; - bool setAcquireRet = attr.SetInt32Value(Attributes::ATTR_TIP_INFO, acquire); - IF_FALSE_LOGE_AND_RETURN(setAcquireRet); - bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo); - IF_FALSE_LOGE_AND_RETURN(setExtraInfoRet); - - auto msg = AuthMessage::As(attr.Serialize()); - IF_FALSE_LOGE_AND_RETURN(msg != nullptr); - int32_t ret = MessengerSendData(scheduleId_, transNum_, ALL_IN_ONE, SCHEDULER, msg); - ++transNum_; - if (ret != USERAUTH_SUCCESS) { - IAM_LOGE("%{public}s call SendData fail", GetDescription()); - return; - } - IAM_LOGI("%{public}s call SendData success acquire %{public}d", GetDescription(), acquire); -} } // namespace UserAuth } // namespace UserIam } // namespace OHOS diff --git a/frameworks/native/executors/src/async_command/identify_command.cpp b/frameworks/native/executors/src/async_command/identify_command.cpp index b7e00703b..70f9796ea 100644 --- a/frameworks/native/executors/src/async_command/identify_command.cpp +++ b/frameworks/native/executors/src/async_command/identify_command.cpp @@ -68,34 +68,13 @@ void IdentifyCommand::OnResultInner(ResultCode result, const std::vectorSetUint8ArrayValue(Attributes::ATTR_RESULT, nonConstExtraInfo); IF_FALSE_LOGE_AND_RETURN(setAuthResultRet == true); iamHitraceHelper_ = nullptr; - int32_t ret = MessengerFinish(scheduleId_, ALL_IN_ONE, result, authAttributes); + int32_t ret = MessengerFinish(scheduleId_, result, authAttributes); if (ret != USERAUTH_SUCCESS) { IAM_LOGE("%{public}s call finish fail", GetDescription()); return; } IAM_LOGI("%{public}s call finish success result %{public}d", GetDescription(), result); } - -void IdentifyCommand::OnAcquireInfoInner(int32_t acquire, const std::vector &extraInfo) -{ - IAM_LOGI("%{public}s on acquire info start", GetDescription()); - - Attributes attr; - bool setAcquireRet = attr.SetInt32Value(Attributes::ATTR_TIP_INFO, acquire); - IF_FALSE_LOGE_AND_RETURN(setAcquireRet); - bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo); - IF_FALSE_LOGE_AND_RETURN(setExtraInfoRet); - - auto msg = AuthMessage::As(attr.Serialize()); - IF_FALSE_LOGE_AND_RETURN(msg != nullptr); - int32_t ret = MessengerSendData(scheduleId_, transNum_, ALL_IN_ONE, SCHEDULER, msg); - ++transNum_; - if (ret != USERAUTH_SUCCESS) { - IAM_LOGE("%{public}s call SendData fail", GetDescription()); - return; - } - IAM_LOGI("%{public}s call SendData success acquire %{public}d", GetDescription(), acquire); -} } // namespace UserAuth } // namespace UserIam } // namespace OHOS diff --git a/frameworks/native/executors/src/executor.cpp b/frameworks/native/executors/src/executor.cpp index c0fb8588e..20c1a4ce0 100644 --- a/frameworks/native/executors/src/executor.cpp +++ b/frameworks/native/executors/src/executor.cpp @@ -41,6 +41,7 @@ Executor::Executor(std::shared_ptr executorMgrWrapper, ExecutorInfo executorInfo = {}; IF_FALSE_LOGE_AND_RETURN(hdi->GetExecutorInfo(executorInfo) == ResultCode::SUCCESS); authType_ = executorInfo.authType; + executorRole_ = executorInfo.executorRole; std::ostringstream ss; uint32_t combineExecutorId = Common::CombineUint16ToUint32(hdiId_, static_cast(executorInfo.executorSensorHint)); @@ -151,6 +152,11 @@ int32_t Executor::GetAuthType() const { return authType_; } + +int32_t Executor::GetExecutorRole() const +{ + return executorRole_; +} } // namespace UserAuth } // namespace UserIam } // namespace OHOS diff --git a/frameworks/native/executors/src/framework/framework_executor_callback.cpp b/frameworks/native/executors/src/framework/framework_executor_callback.cpp index 47e5b0381..afe31cc8c 100644 --- a/frameworks/native/executors/src/framework/framework_executor_callback.cpp +++ b/frameworks/native/executors/src/framework/framework_executor_callback.cpp @@ -127,6 +127,8 @@ ResultCode FrameworkExecutorCallback::OnSetPropertyInner(const Attributes &prope ret = ProcessDeleteTemplateCommand(properties); } else if (commandId == PROPERTY_MODE_SET_CACHED_TEMPLATES) { ret = ProcessSetCachedTemplates(properties); + } else if (commandId == PROPERTY_MODE_NOTIFY_COLLECTOR_READY) { + ret = ProcessNotifyExecutorReady(properties); } else { ret = ProcessCustomCommand(properties); } @@ -145,6 +147,25 @@ int32_t FrameworkExecutorCallback::OnGetProperty(const Attributes &conditions, A return ret; } +int32_t FrameworkExecutorCallback::OnSendData(uint64_t scheduleId, const Attributes &data) +{ + int32_t srcRole = 0; + bool getDestRoleRet = data.GetInt32Value(Attributes::ATTR_SRC_ROLE, srcRole); + IF_FALSE_LOGE_AND_RETURN_VAL(getDestRoleRet == true, ResultCode::GENERAL_ERROR); + std::vector extraInfo; + bool getExtraInfoRet = data.GetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, extraInfo); + IF_FALSE_LOGE_AND_RETURN_VAL(getExtraInfoRet == true, ResultCode::GENERAL_ERROR); + + auto executor = executor_.lock(); + if (executor == nullptr) { + IAM_LOGE("executor has been released, process failed"); + return ResultCode::GENERAL_ERROR; + } + auto hdi = executor->GetExecutorHdi(); + IF_FALSE_LOGE_AND_RETURN_VAL(hdi != nullptr, ResultCode::GENERAL_ERROR); + return hdi->SendMessage(scheduleId, srcRole, extraInfo); +} + ResultCode FrameworkExecutorCallback::OnGetPropertyInner(std::shared_ptr conditions, std::shared_ptr values) { @@ -246,6 +267,25 @@ ResultCode FrameworkExecutorCallback::ProcessSetCachedTemplates(const Attributes return hdi->SetCachedTemplates(templateIdList); } +ResultCode FrameworkExecutorCallback::ProcessNotifyExecutorReady(const Attributes &properties) +{ + IAM_LOGI("start"); + auto executor = executor_.lock(); + if (executor == nullptr) { + IAM_LOGE("executor has been released, process failed"); + return ResultCode::GENERAL_ERROR; + } + + auto hdi = executor->GetExecutorHdi(); + IF_FALSE_LOGE_AND_RETURN_VAL(hdi != nullptr, ResultCode::GENERAL_ERROR); + + uint64_t scheduleId; + bool getScheduleIdRet = properties.GetUint64Value(Attributes::ATTR_SCHEDULE_ID, scheduleId); + IF_FALSE_LOGE_AND_RETURN_VAL(getScheduleIdRet == true, ResultCode::GENERAL_ERROR); + + return hdi->NotifyCollectorReady(scheduleId); +} + ResultCode FrameworkExecutorCallback::ProcessCustomCommand(const Attributes &properties) { auto command = Common::MakeShared(executor_, properties); diff --git a/frameworks/native/executors/src/iauth_executor_hdi.cpp b/frameworks/native/executors/src/iauth_executor_hdi.cpp new file mode 100644 index 000000000..7f703407a --- /dev/null +++ b/frameworks/native/executors/src/iauth_executor_hdi.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 "iam_executor_iauth_executor_hdi.h" + +#include "iam_logger.h" + +#define LOG_TAG "USER_AUTH_EXECUTOR" + +namespace OHOS { +namespace UserIam { +namespace UserAuth { +ResultCode IAuthExecutorHdi::Enroll(uint64_t scheduleId, const EnrollParam ¶m, + const std::shared_ptr &callbackObj) +{ + IAM_LOGE("method not implemented"); + return GENERAL_ERROR; +} + +ResultCode IAuthExecutorHdi::Authenticate(uint64_t scheduleId, const AuthenticateParam ¶m, + const std::shared_ptr &callbackObj) +{ + IAM_LOGE("method not implemented"); + return GENERAL_ERROR; +} + +ResultCode IAuthExecutorHdi::Collect(uint64_t scheduleId, const CollectParam ¶m, + const std::shared_ptr &callbackObj) +{ + IAM_LOGE("method not implemented"); + return GENERAL_ERROR; +} + +ResultCode IAuthExecutorHdi::Identify(uint64_t scheduleId, const IdentifyParam ¶m, + const std::shared_ptr &callbackObj) +{ + IAM_LOGE("method not implemented"); + return GENERAL_ERROR; +} + +ResultCode IAuthExecutorHdi::Delete(const std::vector &templateIdList) +{ + IAM_LOGE("method not implemented"); + return GENERAL_ERROR; +} + +ResultCode IAuthExecutorHdi::SendCommand(PropertyMode commandId, const std::vector &extraInfo, + const std::shared_ptr &callbackObj) +{ + IAM_LOGE("method not implemented"); + return GENERAL_ERROR; +} + +ResultCode IAuthExecutorHdi::GetProperty(const std::vector &templateIdList, + const std::vector &keys, Property &property) +{ + IAM_LOGE("method not implemented"); + return GENERAL_ERROR; +} + +ResultCode IAuthExecutorHdi::SetCachedTemplates(const std::vector &templateIdList) +{ + IAM_LOGE("method not implemented"); + return GENERAL_ERROR; +} + +ResultCode IAuthExecutorHdi::NotifyCollectorReady(uint64_t scheduleId) +{ + IAM_LOGE("method not implemented"); + return GENERAL_ERROR; +} +} // namespace UserAuth +} // namespace UserIam +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/executors/user_auth_executors_map b/frameworks/native/executors/user_auth_executors_map index fd1d13927..f8e2ab482 100644 --- a/frameworks/native/executors/user_auth_executors_map +++ b/frameworks/native/executors/user_auth_executors_map @@ -15,6 +15,7 @@ global: extern "C++" { OHOS::UserIam::UserAuth::IDriverManager::Start*; + OHOS::UserIam::UserAuth::IAuthExecutorHdi::*; }; local: *; diff --git a/frameworks/native/ipc/common_defines/co_auth_interface.h b/frameworks/native/ipc/common_defines/co_auth_interface.h index abe5970d1..88161d250 100644 --- a/frameworks/native/ipc/common_defines/co_auth_interface.h +++ b/frameworks/native/ipc/common_defines/co_auth_interface.h @@ -36,6 +36,7 @@ public: uint32_t executorSensorHint; // for multiple sensors index uint32_t executorMatcher; // for executors matcher ExecutorSecureLevel esl; + uint32_t maxTemplateAcl {0}; std::vector publicKey; }; diff --git a/frameworks/native/ipc/common_defines/executor_callback_interface.h b/frameworks/native/ipc/common_defines/executor_callback_interface.h index 5b0f077e8..4f15fd863 100644 --- a/frameworks/native/ipc/common_defines/executor_callback_interface.h +++ b/frameworks/native/ipc/common_defines/executor_callback_interface.h @@ -34,6 +34,7 @@ public: virtual int32_t OnEndExecute(uint64_t scheduleId, const Attributes &command) = 0; virtual int32_t OnSetProperty(const Attributes &properties) = 0; virtual int32_t OnGetProperty(const Attributes &condition, Attributes &values) = 0; + virtual int32_t OnSendData(uint64_t scheduleId, const Attributes &data) = 0; DECLARE_INTERFACE_DESCRIPTOR(u"ohos.UserIam.AuthResPool.ExecutorCallback"); }; } // namespace UserAuth diff --git a/frameworks/native/ipc/common_defines/executor_callback_interface_ipc_interface_code.h b/frameworks/native/ipc/common_defines/executor_callback_interface_ipc_interface_code.h index 003db7706..67b773c9b 100644 --- a/frameworks/native/ipc/common_defines/executor_callback_interface_ipc_interface_code.h +++ b/frameworks/native/ipc/common_defines/executor_callback_interface_ipc_interface_code.h @@ -26,6 +26,7 @@ enum ExecutorCallbackInterfaceCode : uint32_t { ON_END_EXECUTE, ON_SET_PROPERTY, ON_GET_PROPERTY, + ON_SEND_DATA, }; } // namespace UserAuth } // namespace UserIam diff --git a/frameworks/native/ipc/common_defines/executor_messenger_interface.h b/frameworks/native/ipc/common_defines/executor_messenger_interface.h index 5b04273de..98e49cfe4 100644 --- a/frameworks/native/ipc/common_defines/executor_messenger_interface.h +++ b/frameworks/native/ipc/common_defines/executor_messenger_interface.h @@ -27,9 +27,9 @@ namespace UserIam { namespace UserAuth { class ExecutorMessengerInterface : public IRemoteBroker { public: - virtual int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + virtual int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::vector &msg) = 0; - virtual int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode, + virtual int32_t Finish(uint64_t scheduleId, ResultCode resultCode, const std::shared_ptr &finalResult) = 0; DECLARE_INTERFACE_DESCRIPTOR(u"ohos.UserIam.AuthResPool.IExecutor_Messenger"); }; diff --git a/frameworks/native/ipc/inc/executor_callback_proxy.h b/frameworks/native/ipc/inc/executor_callback_proxy.h index aca7c5d5c..cd18cdd31 100644 --- a/frameworks/native/ipc/inc/executor_callback_proxy.h +++ b/frameworks/native/ipc/inc/executor_callback_proxy.h @@ -36,6 +36,7 @@ public: int32_t OnEndExecute(uint64_t scheduleId, const Attributes &command) override; int32_t OnSetProperty(const Attributes &properties) override; int32_t OnGetProperty(const Attributes &condition, Attributes &values) override; + int32_t OnSendData(uint64_t scheduleId, const Attributes &data) override; private: static inline BrokerDelegator delegator_; diff --git a/frameworks/native/ipc/inc/executor_callback_stub.h b/frameworks/native/ipc/inc/executor_callback_stub.h index 37b0fb7d0..c89163888 100644 --- a/frameworks/native/ipc/inc/executor_callback_stub.h +++ b/frameworks/native/ipc/inc/executor_callback_stub.h @@ -34,6 +34,7 @@ private: int32_t OnEndExecuteStub(MessageParcel &data, MessageParcel &reply); int32_t OnSetPropertyStub(MessageParcel &data, MessageParcel &reply); int32_t OnGetPropertyStub(MessageParcel &data, MessageParcel &reply); + int32_t OnSendDataStub(MessageParcel &data, MessageParcel &reply); }; } // namespace UserAuth } // namespace UserIam diff --git a/frameworks/native/ipc/inc/executor_messenger_proxy.h b/frameworks/native/ipc/inc/executor_messenger_proxy.h index fb0b6e2a3..812e6b571 100644 --- a/frameworks/native/ipc/inc/executor_messenger_proxy.h +++ b/frameworks/native/ipc/inc/executor_messenger_proxy.h @@ -28,9 +28,9 @@ class ExecutorMessengerProxy : public IRemoteProxy, public: explicit ExecutorMessengerProxy(const sptr &impl); ~ExecutorMessengerProxy() override = default; - int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::vector &msg) override; - int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode, + int32_t Finish(uint64_t scheduleId, ResultCode resultCode, const std::shared_ptr &finalResult) override; private: diff --git a/frameworks/native/ipc/src/co_auth_proxy.cpp b/frameworks/native/ipc/src/co_auth_proxy.cpp index 82631bda2..3c73ac153 100644 --- a/frameworks/native/ipc/src/co_auth_proxy.cpp +++ b/frameworks/native/ipc/src/co_auth_proxy.cpp @@ -51,6 +51,10 @@ int32_t CoAuthProxy::WriteExecutorInfo(const ExecutorRegisterInfo &info, Message IAM_LOGE("failed to write esl"); return WRITE_PARCEL_ERROR; } + if (!data.WriteUint32(info.maxTemplateAcl)) { + IAM_LOGE("failed to write esl"); + return WRITE_PARCEL_ERROR; + } if (!data.WriteUInt8Vector(info.publicKey)) { IAM_LOGE("failed to write publicKey"); return WRITE_PARCEL_ERROR; diff --git a/frameworks/native/ipc/src/co_auth_stub.cpp b/frameworks/native/ipc/src/co_auth_stub.cpp index c3f22403e..561f3ff3d 100644 --- a/frameworks/native/ipc/src/co_auth_stub.cpp +++ b/frameworks/native/ipc/src/co_auth_stub.cpp @@ -83,6 +83,7 @@ int32_t CoAuthStub::ReadExecutorRegisterInfo(ExecutorRegisterInfo &executorInfo, uint32_t executorSensorHint; uint32_t executorMatcher; int32_t esl; + uint32_t maxTemplateAcl; if (!data.ReadInt32(authType)) { IAM_LOGE("failed to read authType"); @@ -104,6 +105,10 @@ int32_t CoAuthStub::ReadExecutorRegisterInfo(ExecutorRegisterInfo &executorInfo, IAM_LOGE("failed to read esl"); return READ_PARCEL_ERROR; } + if (!data.ReadUint32(maxTemplateAcl)) { + IAM_LOGE("failed to read esl"); + return READ_PARCEL_ERROR; + } if (!data.ReadUInt8Vector(&executorInfo.publicKey)) { IAM_LOGE("failed to read publicKey"); return READ_PARCEL_ERROR; @@ -113,6 +118,7 @@ int32_t CoAuthStub::ReadExecutorRegisterInfo(ExecutorRegisterInfo &executorInfo, executorInfo.executorRole = static_cast(executorRole); executorInfo.executorSensorHint = executorSensorHint; executorInfo.executorMatcher = executorMatcher; + executorInfo.maxTemplateAcl = maxTemplateAcl; executorInfo.esl = static_cast(esl); return SUCCESS; } diff --git a/frameworks/native/ipc/src/executor_callback_proxy.cpp b/frameworks/native/ipc/src/executor_callback_proxy.cpp index c57679be4..971e1a720 100644 --- a/frameworks/native/ipc/src/executor_callback_proxy.cpp +++ b/frameworks/native/ipc/src/executor_callback_proxy.cpp @@ -190,6 +190,38 @@ int32_t ExecutorCallbackProxy::OnGetProperty(const Attributes &condition, Attrib return result; } +int32_t ExecutorCallbackProxy::OnSendData(uint64_t scheduleId, const Attributes &data) +{ + MessageParcel dataParcel; + MessageParcel reply; + + if (!dataParcel.WriteInterfaceToken(ExecutorCallbackProxy::GetDescriptor())) { + IAM_LOGE("write descriptor failed"); + return GENERAL_ERROR; + } + if (!dataParcel.WriteUint64(scheduleId)) { + IAM_LOGE("write scheduleId failed"); + return GENERAL_ERROR; + } + auto attr = data.Serialize(); + if (!dataParcel.WriteUInt8Vector(attr)) { + IAM_LOGE("write data failed"); + return GENERAL_ERROR; + } + + bool ret = SendRequest(ExecutorCallbackInterfaceCode::ON_SEND_DATA, dataParcel, reply); + if (!ret) { + IAM_LOGE("send request failed"); + return GENERAL_ERROR; + } + int32_t result = GENERAL_ERROR; + if (!reply.ReadInt32(result)) { + IAM_LOGE("read request result failed"); + return GENERAL_ERROR; + } + return result; +} + bool ExecutorCallbackProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply) { IAM_LOGI("code = %{public}u", code); diff --git a/frameworks/native/ipc/src/executor_callback_stub.cpp b/frameworks/native/ipc/src/executor_callback_stub.cpp index 2cb17a143..77573404f 100644 --- a/frameworks/native/ipc/src/executor_callback_stub.cpp +++ b/frameworks/native/ipc/src/executor_callback_stub.cpp @@ -43,6 +43,8 @@ int32_t ExecutorCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data return OnSetPropertyStub(data, reply); case ExecutorCallbackInterfaceCode::ON_GET_PROPERTY: return OnGetPropertyStub(data, reply); + case ExecutorCallbackInterfaceCode::ON_SEND_DATA: + return OnSendDataStub(data, reply); default: return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } @@ -168,6 +170,29 @@ int32_t ExecutorCallbackStub::OnGetPropertyStub(MessageParcel &data, MessageParc } return SUCCESS; } + +int32_t ExecutorCallbackStub::OnSendDataStub(MessageParcel &data, MessageParcel &reply) +{ + uint64_t scheduleId; + std::vector buffer; + + if (!data.ReadUint64(scheduleId)) { + IAM_LOGE("failed to read scheduleId"); + return READ_PARCEL_ERROR; + } + if (!data.ReadUInt8Vector(&buffer)) { + IAM_LOGE("failed to read data"); + return READ_PARCEL_ERROR; + } + Attributes dataAttr(buffer); + + int32_t result = OnSendData(scheduleId, dataAttr); + if (!reply.WriteInt32(result)) { + IAM_LOGE("failed to write OnSendData result"); + return WRITE_PARCEL_ERROR; + } + return SUCCESS; +} } // namespace UserAuth } // namespace UserIam } // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/ipc/src/executor_messenger_proxy.cpp b/frameworks/native/ipc/src/executor_messenger_proxy.cpp index f435dfad5..eec52dd14 100644 --- a/frameworks/native/ipc/src/executor_messenger_proxy.cpp +++ b/frameworks/native/ipc/src/executor_messenger_proxy.cpp @@ -27,7 +27,7 @@ ExecutorMessengerProxy::ExecutorMessengerProxy(const sptr &impl) { } -int32_t ExecutorMessengerProxy::SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, +int32_t ExecutorMessengerProxy::SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::vector &msg) { MessageParcel data; @@ -41,14 +41,6 @@ int32_t ExecutorMessengerProxy::SendData(uint64_t scheduleId, uint64_t transNum, IAM_LOGE("failed to write scheduleId"); return WRITE_PARCEL_ERROR; } - if (!data.WriteUint64(transNum)) { - IAM_LOGE("failed to write transNum"); - return WRITE_PARCEL_ERROR; - } - if (!data.WriteInt32(srcRole)) { - IAM_LOGE("failed to write srcRole"); - return WRITE_PARCEL_ERROR; - } if (!data.WriteInt32(dstRole)) { IAM_LOGE("failed to write dstRole"); return WRITE_PARCEL_ERROR; @@ -71,7 +63,7 @@ int32_t ExecutorMessengerProxy::SendData(uint64_t scheduleId, uint64_t transNum, return result; } -int32_t ExecutorMessengerProxy::Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode, +int32_t ExecutorMessengerProxy::Finish(uint64_t scheduleId, ResultCode resultCode, const std::shared_ptr &finalResult) { if (finalResult == nullptr) { @@ -89,10 +81,6 @@ int32_t ExecutorMessengerProxy::Finish(uint64_t scheduleId, ExecutorRole srcRole IAM_LOGE("failed to write scheduleId"); return WRITE_PARCEL_ERROR; } - if (!data.WriteInt32(srcRole)) { - IAM_LOGE("failed to write srcRole"); - return WRITE_PARCEL_ERROR; - } if (!data.WriteInt32(resultCode)) { IAM_LOGE("failed to write resultCode"); return WRITE_PARCEL_ERROR; diff --git a/frameworks/native/ipc/src/executor_messenger_stub.cpp b/frameworks/native/ipc/src/executor_messenger_stub.cpp index 7541a57ce..1d5bf9ac7 100644 --- a/frameworks/native/ipc/src/executor_messenger_stub.cpp +++ b/frameworks/native/ipc/src/executor_messenger_stub.cpp @@ -52,8 +52,6 @@ int32_t ExecutorMessengerStub::OnRemoteRequest(uint32_t code, MessageParcel &dat int32_t ExecutorMessengerStub::SendDataStub(MessageParcel &data, MessageParcel &reply) { uint64_t scheduleId; - uint64_t transNum; - int32_t srcRole; int32_t dstRole; std::vector msg; @@ -61,14 +59,6 @@ int32_t ExecutorMessengerStub::SendDataStub(MessageParcel &data, MessageParcel & IAM_LOGE("read scheduleId failed"); return READ_PARCEL_ERROR; } - if (!data.ReadUint64(transNum)) { - IAM_LOGE("read transNum failed"); - return READ_PARCEL_ERROR; - } - if (!data.ReadInt32(srcRole)) { - IAM_LOGE("read srcRole failed"); - return READ_PARCEL_ERROR; - } if (!data.ReadInt32(dstRole)) { IAM_LOGE("read dstRole failed"); return READ_PARCEL_ERROR; @@ -78,8 +68,7 @@ int32_t ExecutorMessengerStub::SendDataStub(MessageParcel &data, MessageParcel & return GENERAL_ERROR; } - int32_t result = - SendData(scheduleId, transNum, static_cast(srcRole), static_cast(dstRole), msg); + int32_t result = SendData(scheduleId, static_cast(dstRole), msg); if (!reply.WriteInt32(result)) { IAM_LOGE("write SendData result failed"); return WRITE_PARCEL_ERROR; @@ -90,7 +79,6 @@ int32_t ExecutorMessengerStub::SendDataStub(MessageParcel &data, MessageParcel & int32_t ExecutorMessengerStub::FinishStub(MessageParcel &data, MessageParcel &reply) { uint64_t scheduleId; - int32_t srcRole; int32_t resultCode; std::vector attributes; @@ -98,10 +86,6 @@ int32_t ExecutorMessengerStub::FinishStub(MessageParcel &data, MessageParcel &re IAM_LOGE("read scheduleId failed"); return READ_PARCEL_ERROR; } - if (!data.ReadInt32(srcRole)) { - IAM_LOGE("read srcRole failed"); - return READ_PARCEL_ERROR; - } if (!data.ReadInt32(resultCode)) { IAM_LOGE("read resultCode failed"); return READ_PARCEL_ERROR; @@ -113,7 +97,7 @@ int32_t ExecutorMessengerStub::FinishStub(MessageParcel &data, MessageParcel &re auto finalResult = Common::MakeShared(attributes); IF_FALSE_LOGE_AND_RETURN_VAL(finalResult != nullptr, WRITE_PARCEL_ERROR); int32_t result = - Finish(scheduleId, static_cast(srcRole), static_cast(resultCode), finalResult); + Finish(scheduleId, static_cast(resultCode), finalResult); if (!reply.WriteInt32(result)) { IAM_LOGE("write Finish result failed"); return WRITE_PARCEL_ERROR; diff --git a/interfaces/inner_api/attributes.h b/interfaces/inner_api/attributes.h index dc5db6bf3..07e28d31b 100644 --- a/interfaces/inner_api/attributes.h +++ b/interfaces/inner_api/attributes.h @@ -53,8 +53,10 @@ public: ATTR_ERROR_COUNT = 100008, /** Remain time, the value type is int32_t. */ ATTR_REMAIN_TIMES = 100009, + ATTR_REMAIN_ATTEMPTS = ATTR_REMAIN_TIMES, /** Freezing time, the value type is int32_t. */ ATTR_FREEZING_TIME = 100010, + ATTR_LOCKOUT_DURATION = ATTR_FREEZING_TIME, /** Session ID, the value type is uint64_t. */ ATTR_SESSION_ID = 100014, /** Schedule version, the value type is uint32_t. */ @@ -101,6 +103,8 @@ public: ATTR_OLD_ROOT_SECRET = 100040, /** Old credential ID, the value type is uint64_t. */ ATTR_OLD_CREDENTIAL_ID = 100041, + /** Source role, the value type is int32_t. */ + ATTR_SRC_ROLE = 100042, /** * Private attrs. * User ID, the value type is int32_t. diff --git a/interfaces/inner_api/co_auth_client_callback.h b/interfaces/inner_api/co_auth_client_callback.h index d78135a36..bbcdb0cfd 100644 --- a/interfaces/inner_api/co_auth_client_callback.h +++ b/interfaces/inner_api/co_auth_client_callback.h @@ -78,6 +78,15 @@ public: * @return Return get property success or not(0:success; other:failed). */ virtual int32_t OnGetProperty(const Attributes &conditions, Attributes &results) = 0; + + /** + * @brief Called by coAuth resource pool to send data. + * + * @param scheduleId Specify the current schedule. + * @param results The result of get property. + * @return data Data. + */ + virtual int32_t OnSendData(uint64_t scheduleId, const Attributes &data) = 0; }; } // namespace UserAuth } // namespace UserIam diff --git a/interfaces/inner_api/co_auth_client_defines.h b/interfaces/inner_api/co_auth_client_defines.h index 5f3cf5dfb..2ad3d5d48 100644 --- a/interfaces/inner_api/co_auth_client_defines.h +++ b/interfaces/inner_api/co_auth_client_defines.h @@ -46,6 +46,8 @@ struct ExecutorInfo { uint32_t executorMatcher {0}; /** Executor secure level. */ ExecutorSecureLevel esl {0}; + /** Max template acl. */ + uint32_t maxTemplateAcl {0}; /** Used to verify the result issued by the authenticator. */ std::vector publicKey {}; }; @@ -67,26 +69,21 @@ public: * @brief Called by the executor, send authentication data to resource pool. * * @param scheduleId Specify the current schedule. - * @param transNum Properties of this operation. - * @param srcRole Source executor role. * @param dstRole Destination executor role. * @param msg Authentication message. * @return Return send data success or not(0:success; other:failed). */ - virtual int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg) = 0; + virtual int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) = 0; /** * @brief Called by the executor, send finish data to resource pool. * * @param scheduleId Specify the current schedule. - * @param srcRole Source executor role. - * @param resultcode Authentication result code. + * @param resultCode Authentication result code. * @param finalResult Authentication final result. * @return Return finish success or not(0:success; other:failed). */ - virtual int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, - const Attributes &finalResult) = 0; + virtual int32_t Finish(uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) = 0; }; } // namespace UserAuth } // namespace UserIam diff --git a/interfaces/inner_api/iam_common_defines.h b/interfaces/inner_api/iam_common_defines.h index 1c4f142a6..09ecf62db 100644 --- a/interfaces/inner_api/iam_common_defines.h +++ b/interfaces/inner_api/iam_common_defines.h @@ -133,6 +133,8 @@ enum PropertyMode : uint32_t { PROPERTY_MODE_UNFREEZE = 6, /** The property mode is set cached templates. */ PROPERTY_MODE_SET_CACHED_TEMPLATES = 7, + /** The property mode is notify collector ready. */ + PROPERTY_MODE_NOTIFY_COLLECTOR_READY = 8, }; /** diff --git a/interfaces/inner_api/iam_executor/iam_executor_framework_types.h b/interfaces/inner_api/iam_executor/iam_executor_framework_types.h index 1fc9221bf..f31c28534 100644 --- a/interfaces/inner_api/iam_executor/iam_executor_framework_types.h +++ b/interfaces/inner_api/iam_executor/iam_executor_framework_types.h @@ -41,20 +41,6 @@ enum UserAuthResult : int32_t { USERAUTH_ERROR = 1, }; -/** - * @brief Defines Template infomation. - */ -struct TemplateInfo { - /** Executor type. */ - uint32_t executorType; - /** Freezing time. */ - int32_t freezingTime; - /** Remain time. */ - int32_t remainTimes; - /** Extra Info. */ - std::vector extraInfo; -}; - /** * @brief Defines Enroll parameter. */ @@ -79,6 +65,14 @@ struct AuthenticateParam { bool endAfterFirstFail; }; +/** + * @brief Defines Collect parameter. + */ +struct CollectParam { + /** Extra info. */ + std::vector extraInfo; +}; + /** * @brief Defines Identify parameter. */ diff --git a/interfaces/inner_api/iam_executor/iam_executor_iauth_executor_hdi.h b/interfaces/inner_api/iam_executor/iam_executor_iauth_executor_hdi.h index 2ea4f6233..34a7e483f 100644 --- a/interfaces/inner_api/iam_executor/iam_executor_iauth_executor_hdi.h +++ b/interfaces/inner_api/iam_executor/iam_executor_iauth_executor_hdi.h @@ -66,6 +66,24 @@ public: virtual ResultCode OnRegisterFinish(const std::vector &templateIdList, const std::vector &frameworkPublicKey, const std::vector &extraInfo) = 0; + /** + * @brief Cancel the action of executor. + * + * @param scheduleId Current working schedule ID. + * @return Return the result success or error code{@link ResultCode}. + */ + virtual ResultCode Cancel(uint64_t scheduleId) = 0; + + /** + * @brief Cancel the action of executor. + * + * @param scheduleId Current working schedule ID. + * @param srcRole Source role. + * @param msg Message. + * @return Return the result success or error code{@link ResultCode}. + */ + virtual ResultCode SendMessage(uint64_t scheduleId, int32_t srcRole, const std::vector &msg) = 0; + /** * @brief Begin enroll. * @@ -75,7 +93,7 @@ public: * @return Return the result success or error code{@link ResultCode}. */ virtual ResultCode Enroll(uint64_t scheduleId, const EnrollParam ¶m, - const std::shared_ptr &callbackObj) = 0; + const std::shared_ptr &callbackObj); /** * @brief Begin authenticate. @@ -86,7 +104,18 @@ public: * @return Return the result success or error code{@link ResultCode}. */ virtual ResultCode Authenticate(uint64_t scheduleId, const AuthenticateParam ¶m, - const std::shared_ptr &callbackObj) = 0; + const std::shared_ptr &callbackObj); + + /** + * @brief Begin collect. + * + * @param scheduleId Current collect schedule ID. + * @param param Collect param. + * @param callbackObj Callback of authenticate result. + * @return Return the result success or error code{@link ResultCode}. + */ + virtual ResultCode Collect(uint64_t scheduleId, const CollectParam ¶m, + const std::shared_ptr &callbackObj); /** * @brief Begin identify. @@ -97,7 +126,7 @@ public: * @return Return the result success or error code{@link ResultCode}. */ virtual ResultCode Identify(uint64_t scheduleId, const IdentifyParam ¶m, - const std::shared_ptr &callbackObj) = 0; + const std::shared_ptr &callbackObj); /** * @brief Delete. @@ -105,15 +134,7 @@ public: * @param templateIdList Template ID list. * @return Return the result success or error code{@link ResultCode}. */ - virtual ResultCode Delete(const std::vector &templateIdList) = 0; - - /** - * @brief Cancel the action of executor. - * - * @param scheduleId Current working schedule ID. - * @return Return the result success or error code{@link ResultCode}. - */ - virtual ResultCode Cancel(uint64_t scheduleId) = 0; + virtual ResultCode Delete(const std::vector &templateIdList); /** * @brief Send command. @@ -124,7 +145,7 @@ public: * @return Return the result success or error code{@link ResultCode}. */ virtual ResultCode SendCommand(PropertyMode commandId, const std::vector &extraInfo, - const std::shared_ptr &callbackObj) = 0; + const std::shared_ptr &callbackObj); /** * @brief Get property. @@ -135,7 +156,7 @@ public: * @return Return the result success or error code{@link ResultCode}. */ virtual ResultCode GetProperty(const std::vector &templateIdList, - const std::vector &keys, Property &property) = 0; + const std::vector &keys, Property &property); /** * @brief Set cached templates. @@ -143,7 +164,15 @@ public: * @param templateIdList Template id list. * @return Return the result success or error code{@link ResultCode}. */ - virtual ResultCode SetCachedTemplates(const std::vector &templateIdList) = 0; + virtual ResultCode SetCachedTemplates(const std::vector &templateIdList); + + /** + * @brief Notify collector ready. + * + * @param scheduleId Current collect schedule ID. + * @return Return the result success or error code{@link ResultCode}. + */ + virtual ResultCode NotifyCollectorReady(uint64_t scheduleId); }; } // namespace UserAuth } // namespace UserIam diff --git a/interfaces/inner_api/iam_executor/iam_executor_iexecute_callback.h b/interfaces/inner_api/iam_executor/iam_executor_iexecute_callback.h index 4fbd86ad4..5364990a2 100644 --- a/interfaces/inner_api/iam_executor/iam_executor_iexecute_callback.h +++ b/interfaces/inner_api/iam_executor/iam_executor_iexecute_callback.h @@ -68,6 +68,14 @@ public: * @param extraInfo Other related information about execute. */ virtual void OnAcquireInfo(int32_t acquire, const std::vector &extraInfo) = 0; + + /** + * @brief The callback send message information. + * + * @param destRole Destination role. + * @param msg Message. + */ + virtual void OnMessage(int destRole, const std::vector &msg) = 0; }; } // namespace UserAuth } // namespace UserIam diff --git a/services/base/inc/user_auth_hdi.h b/services/base/inc/user_auth_hdi.h index 25ac697e9..93239386e 100644 --- a/services/base/inc/user_auth_hdi.h +++ b/services/base/inc/user_auth_hdi.h @@ -17,6 +17,7 @@ #define USER_AUTH_HDI #include "v2_0/iuser_auth_interface.h" +#include "v2_0/message_callback_stub.h" #include "v2_0/user_auth_types.h" #include "v2_0/user_auth_interface_service.h" diff --git a/services/core/BUILD.gn b/services/core/BUILD.gn index 4bd1aa102..5c9a58140 100644 --- a/services/core/BUILD.gn +++ b/services/core/BUILD.gn @@ -54,6 +54,7 @@ ohos_source_set("userauth_service_core") { "src/credential_info_impl.cpp", "src/enrolled_info_impl.cpp", "src/enrollment_impl.cpp", + "src/hdi_message_callback_service.cpp", "src/identification_impl.cpp", "src/resource_node_impl.cpp", "src/resource_node_pool_impl.cpp", @@ -81,6 +82,7 @@ ohos_source_set("userauth_service_core") { "ability_runtime:app_manager", "c_utils:utils", "drivers_interface_user_auth:libuser_auth_proxy_2.0", + "hdf_core:libhdi", "hilog:libhilog", "hitrace:hitrace_meter", "init:libbegetutil", diff --git a/services/core/inc/hdi_message_callback_service.h b/services/core/inc/hdi_message_callback_service.h new file mode 100644 index 000000000..32ed15023 --- /dev/null +++ b/services/core/inc/hdi_message_callback_service.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 HDI_MESSAGE_CALLBACK_IMPL_H +#define HDI_MESSAGE_CALLBACK_IMPL_H + +#include "user_auth_hdi.h" + +namespace OHOS { +namespace UserIam { +namespace UserAuth { +class HdiMessageCallbackService : public HdiIMessageCallback { +public: + static sptr GetInstance(); + void OnHdiConnect(); + + int32_t OnMessage(uint64_t scheduleId, int32_t destRole, const std::vector& msg) override; +private: + ~HdiMessageCallbackService() override = default; +}; +} // namespace UserAuth +} // namespace UserIam +} // namespace OHOS +#endif // HDI_MESSAGE_CALLBACK_IMPL_H \ No newline at end of file diff --git a/services/core/inc/resource_node.h b/services/core/inc/resource_node.h index d2793b7f9..5dd034edb 100644 --- a/services/core/inc/resource_node.h +++ b/services/core/inc/resource_node.h @@ -45,6 +45,7 @@ public: virtual int32_t EndExecute(uint64_t scheduleId, const Attributes &command) = 0; virtual int32_t SetProperty(const Attributes &properties) = 0; virtual int32_t GetProperty(const Attributes &condition, Attributes &values) = 0; + virtual int32_t SendData(uint64_t scheduleId, const Attributes &data) = 0; virtual void Detach() = 0; static std::shared_ptr MakeNewResource(const ExecutorRegisterInfo &info, diff --git a/services/core/inc/schedule_node.h b/services/core/inc/schedule_node.h index b9da014c1..6df647063 100644 --- a/services/core/inc/schedule_node.h +++ b/services/core/inc/schedule_node.h @@ -70,8 +70,7 @@ public: virtual void ClearScheduleCallback() = 0; virtual bool StartSchedule() = 0; virtual bool StopSchedule() = 0; - virtual bool ContinueSchedule(ExecutorRole srcRole, ExecutorRole dstRole, uint64_t transNum, - const std::vector &msg) = 0; + virtual bool SendMessage(ExecutorRole dstRole, const std::vector &msg) = 0; virtual bool ContinueSchedule(ResultCode resultCode, const std::shared_ptr &finalResult) = 0; }; diff --git a/services/core/src/hdi_message_callback_service.cpp b/services/core/src/hdi_message_callback_service.cpp new file mode 100644 index 000000000..4bc176f2a --- /dev/null +++ b/services/core/src/hdi_message_callback_service.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 "hdi_message_callback_service.h" + +#include + +#include "context_pool.h" +#include "attributes.h" +#include "iam_logger.h" +#include "iam_check.h" +#include "hdi_wrapper.h" + +#define LOG_TAG "USER_AUTH_SA" + +namespace OHOS { +namespace UserIam { +namespace UserAuth { +sptr HdiMessageCallbackService::GetInstance() +{ + static sptr instance = new HdiMessageCallbackService(); + IF_FALSE_LOGE_AND_RETURN_VAL(instance != nullptr, nullptr); + return instance; +} + +void HdiMessageCallbackService::OnHdiConnect() +{ + auto hdi = HdiWrapper::GetHdiInstance(); + IF_FALSE_LOGE_AND_RETURN(hdi != nullptr); + + int32_t ret = hdi->RegisterMessageCallback(GetInstance()); + IF_FALSE_LOGE_AND_RETURN(ret == HDF_SUCCESS); + IAM_LOGI("success"); +} + +int32_t HdiMessageCallbackService::OnMessage(uint64_t scheduleId, int32_t destRole, const std::vector& msg) +{ + std::shared_ptr scheduleNode = ContextPool::Instance().SelectScheduleNodeByScheduleId(scheduleId); + IF_FALSE_LOGE_AND_RETURN_VAL(scheduleNode != nullptr, HDF_FAILURE); + + Attributes attr; + bool roleRet = attr.SetInt32Value(Attributes::ATTR_SRC_ROLE, SCHEDULER); + IF_FALSE_LOGE_AND_RETURN_VAL(roleRet, HDF_FAILURE); + bool setExtraInfoRet = attr.SetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, msg); + IF_FALSE_LOGE_AND_RETURN_VAL(setExtraInfoRet, HDF_FAILURE); + + bool ret = scheduleNode->SendMessage(static_cast(destRole), attr.Serialize()); + IF_FALSE_LOGE_AND_RETURN_VAL(ret == true, HDF_FAILURE); + + return HDF_SUCCESS; +} +} // namespace UserAuth +} // namespace UserIam +} // namespace OHOS diff --git a/services/core/src/resource_node_impl.cpp b/services/core/src/resource_node_impl.cpp index cef954c48..7e016fb2f 100644 --- a/services/core/src/resource_node_impl.cpp +++ b/services/core/src/resource_node_impl.cpp @@ -49,6 +49,7 @@ public: int32_t EndExecute(uint64_t scheduleId, const Attributes &command) override; int32_t SetProperty(const Attributes &properties) override; int32_t GetProperty(const Attributes &condition, Attributes &values) override; + int32_t SendData(uint64_t scheduleId, const Attributes &data) override; void Detach() override; friend ResourceNode; @@ -168,6 +169,16 @@ int32_t ResourceNodeImpl::GetProperty(const Attributes &condition, Attributes &v return GENERAL_ERROR; } +int32_t ResourceNodeImpl::SendData(uint64_t scheduleId, const Attributes &data) +{ + IAM_LOGI("start"); + + if (callback_ != nullptr) { + return callback_->OnSendData(scheduleId, data); + } + return GENERAL_ERROR; +} + void ResourceNodeImpl::Detach() { IAM_LOGI("start"); diff --git a/services/core/src/schedule_node_impl.cpp b/services/core/src/schedule_node_impl.cpp index 17eedd8e2..4f5f9d886 100644 --- a/services/core/src/schedule_node_impl.cpp +++ b/services/core/src/schedule_node_impl.cpp @@ -19,6 +19,8 @@ #include "nocopyable.h" +#include "hdi_wrapper.h" +#include "iam_check.h" #include "iam_logger.h" #include "iam_ptr.h" #include "iam_para2str.h" @@ -152,19 +154,40 @@ bool ScheduleNodeImpl::StopSchedule() return TryKickMachine(E_STOP_AUTH); } -bool ScheduleNodeImpl::ContinueSchedule(ExecutorRole srcRole, ExecutorRole dstRole, uint64_t transNum, - const std::vector &msg) +bool ScheduleNodeImpl::SendMessage(ExecutorRole dstRole, const std::vector &msg) { - if (dstRole != SCHEDULER) { - IAM_LOGE("not supported yet"); - return false; + Attributes attr(msg); + if (dstRole == SCHEDULER) { + int32_t tip; + if (attr.GetInt32Value(Attributes::ATTR_TIP_INFO, tip)) { + std::shared_ptr callback = GetScheduleCallback(); + IF_FALSE_LOGE_AND_RETURN_VAL(callback != nullptr, false); + callback->OnScheduleProcessed(dstRole, GetAuthType(), msg); + return true; + } else { + int srcRole; + std::vector msg; + bool getAcquireRet = attr.GetInt32Value(Attributes::ATTR_SRC_ROLE, srcRole); + IF_FALSE_LOGE_AND_RETURN_VAL(getAcquireRet, false); + bool getExtraInfoRet = attr.GetUint8ArrayValue(Attributes::ATTR_EXTRA_INFO, msg); + IF_FALSE_LOGE_AND_RETURN_VAL(getExtraInfoRet, false); + auto hdi = HdiWrapper::GetHdiInstance(); + IF_FALSE_LOGE_AND_RETURN_VAL(hdi != nullptr, false); + int sendMsgRet = hdi->SendMessage(GetScheduleId(), srcRole, msg); + IF_FALSE_LOGE_AND_RETURN_VAL(sendMsgRet == HDF_SUCCESS, false); + return true; + } } - std::shared_ptr callback = GetScheduleCallback(); - if (callback) { - callback->OnScheduleProcessed(srcRole, GetAuthType(), msg); + std::shared_ptr node = nullptr; + if (dstRole == ALL_IN_ONE || dstRole == VERIFIER) { + node = info_.verifier.lock(); + } else if (dstRole == COLLECTOR) { + node = info_.collector.lock(); } + IF_FALSE_LOGE_AND_RETURN_VAL(node != nullptr, false); + node->SendData(GetScheduleId(), attr); return true; } diff --git a/services/core/src/schedule_node_impl.h b/services/core/src/schedule_node_impl.h index 91c455627..36370e788 100644 --- a/services/core/src/schedule_node_impl.h +++ b/services/core/src/schedule_node_impl.h @@ -70,8 +70,7 @@ public: void ClearScheduleCallback() override; bool StartSchedule() override; bool StopSchedule() override; - bool ContinueSchedule(ExecutorRole srcRole, ExecutorRole dstRole, uint64_t transNum, - const std::vector &msg) override; + bool SendMessage(ExecutorRole dstRole, const std::vector &msg) override; bool ContinueSchedule(ResultCode resultCode, const std::shared_ptr &finalResult) override; private: diff --git a/services/ipc/inc/executor_messenger_service.h b/services/ipc/inc/executor_messenger_service.h index c8458aff0..769c1226f 100644 --- a/services/ipc/inc/executor_messenger_service.h +++ b/services/ipc/inc/executor_messenger_service.h @@ -25,13 +25,13 @@ namespace UserAuth { class ExecutorMessengerService : public ExecutorMessengerStub { public: static sptr GetInstance(); - int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::vector &msg) override; - int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode, + int32_t Finish(uint64_t scheduleId, ResultCode resultCode, const std::shared_ptr &finalResult) override; private: - ExecutorMessengerService(); + explicit ExecutorMessengerService(); ~ExecutorMessengerService() override = default; }; } // namespace UserAuth diff --git a/services/ipc/src/co_auth_service.cpp b/services/ipc/src/co_auth_service.cpp index 417fe3054..67b639de5 100644 --- a/services/ipc/src/co_auth_service.cpp +++ b/services/ipc/src/co_auth_service.cpp @@ -22,12 +22,14 @@ #include "string_ex.h" #include "executor_messenger_service.h" +#include "hdi_message_callback_service.h" #include "hdi_wrapper.h" #include "hisysevent_adapter.h" #include "iam_logger.h" #include "iam_ptr.h" #include "iam_para2str.h" #include "ipc_common.h" +#include "iam_check.h" #include "iam_time.h" #include "iam_common_defines.h" #include "ipc_skeleton.h" @@ -125,6 +127,9 @@ void CoAuthService::Init() IAM_LOGI("delete all executors for hdi dead"); UserIam::UserAuth::ReportSystemFault(Common::GetNowTimeString(), "user_auth_hdi host"); })); + auto callbackService = HdiMessageCallbackService::GetInstance(); + IF_FALSE_LOGE_AND_RETURN(callbackService != nullptr); + callbackService->OnHdiConnect(); IAM_LOGI("set fwk ready parameter"); SetParameter("bootevent.useriam.fwkready", "false"); SetParameter("bootevent.useriam.fwkready", "true"); diff --git a/services/ipc/src/executor_messenger_service.cpp b/services/ipc/src/executor_messenger_service.cpp index ff631f659..8a342b227 100644 --- a/services/ipc/src/executor_messenger_service.cpp +++ b/services/ipc/src/executor_messenger_service.cpp @@ -39,15 +39,14 @@ sptr ExecutorMessengerService::GetInstance() return instance; } -int32_t ExecutorMessengerService::SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, - ExecutorRole dstRole, const std::vector &msg) +int32_t ExecutorMessengerService::SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::vector &msg) { auto scheduleNode = ContextPool::Instance().SelectScheduleNodeByScheduleId(scheduleId); if (scheduleNode == nullptr) { IAM_LOGE("selected schedule node is nullptr"); return GENERAL_ERROR; } - bool result = scheduleNode->ContinueSchedule(srcRole, dstRole, transNum, msg); + bool result = scheduleNode->SendMessage(dstRole, msg); if (!result) { IAM_LOGE("continue schedule failed"); return GENERAL_ERROR; @@ -55,7 +54,7 @@ int32_t ExecutorMessengerService::SendData(uint64_t scheduleId, uint64_t transNu return SUCCESS; } -int32_t ExecutorMessengerService::Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode, +int32_t ExecutorMessengerService::Finish(uint64_t scheduleId, ResultCode resultCode, const std::shared_ptr &finalResult) { auto scheduleNode = ContextPool::Instance().SelectScheduleNodeByScheduleId(scheduleId); diff --git a/test/fuzztest/clients/coauthclient_fuzzer/co_auth_client_fuzzer.cpp b/test/fuzztest/clients/coauthclient_fuzzer/co_auth_client_fuzzer.cpp index b3a4c5398..1f3d9612b 100644 --- a/test/fuzztest/clients/coauthclient_fuzzer/co_auth_client_fuzzer.cpp +++ b/test/fuzztest/clients/coauthclient_fuzzer/co_auth_client_fuzzer.cpp @@ -73,28 +73,32 @@ public: static_cast(results); return SUCCESS; } + + int32_t OnSendData(uint64_t scheduleId, const Attributes &data) + { + IAM_LOGI("start"); + static_cast(scheduleId); + static_cast(data); + return SUCCESS; + } }; class DummyExecutorMessengerInterface final : public ExecutorMessengerInterface { public: - int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::vector &msg) override { IAM_LOGI("start"); static_cast(scheduleId); - static_cast(transNum); - static_cast(srcRole); static_cast(dstRole); static_cast(msg); return SUCCESS; } - int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode, - const std::shared_ptr &finalResult) override + int32_t Finish(uint64_t scheduleId, ResultCode resultCode, const std::shared_ptr &finalResult) override { IAM_LOGI("start"); static_cast(scheduleId); - static_cast(srcRole); static_cast(resultCode); static_cast(finalResult); return SUCCESS; @@ -213,14 +217,12 @@ void FuzzExecutorMessengerClientSendData(Parcel &parcel) { IAM_LOGI("start"); uint64_t scheduleId = parcel.ReadUint64(); - uint64_t transNum = parcel.ReadUint64(); - auto srcRole = static_cast(parcel.ReadInt32()); auto dstRole = static_cast(parcel.ReadInt32()); std::vector testMessage; Common::FillFuzzUint8Vector(parcel, testMessage); auto msg = AuthMessage::As(testMessage); if (g_ExecutorMessengerClient != nullptr) { - g_ExecutorMessengerClient->SendData(scheduleId, transNum, srcRole, dstRole, msg); + g_ExecutorMessengerClient->SendData(scheduleId, dstRole, msg); } IAM_LOGI("end"); } @@ -229,13 +231,12 @@ void FuzzExecutorMessengerClientFinish(Parcel &parcel) { IAM_LOGI("start"); uint64_t scheduleId = parcel.ReadUint64(); - auto srcRole = static_cast(parcel.ReadInt32()); int32_t resultCode = parcel.ReadInt32(); std::vector attr; Common::FillFuzzUint8Vector(parcel, attr); Attributes finalResult(attr); if (g_ExecutorMessengerClient != nullptr) { - g_ExecutorMessengerClient->Finish(scheduleId, srcRole, resultCode, finalResult); + g_ExecutorMessengerClient->Finish(scheduleId, resultCode, finalResult); } IAM_LOGI("end"); } diff --git a/test/fuzztest/clients/executorcallbackstub_fuzzer/executor_callback_stub_fuzzer.cpp b/test/fuzztest/clients/executorcallbackstub_fuzzer/executor_callback_stub_fuzzer.cpp index 43873fcd2..f9c7782bf 100644 --- a/test/fuzztest/clients/executorcallbackstub_fuzzer/executor_callback_stub_fuzzer.cpp +++ b/test/fuzztest/clients/executorcallbackstub_fuzzer/executor_callback_stub_fuzzer.cpp @@ -77,6 +77,14 @@ public: static_cast(results); return SUCCESS; } + + int32_t OnSendData(uint64_t scheduleId, const Attributes &data) + { + IAM_LOGI("start"); + static_cast(scheduleId); + static_cast(data); + return SUCCESS; + } }; auto g_ExecutorCallbackService = diff --git a/test/fuzztest/common_fuzzer/BUILD.gn b/test/fuzztest/common_fuzzer/BUILD.gn index 15b9a386e..fa530560c 100644 --- a/test/fuzztest/common_fuzzer/BUILD.gn +++ b/test/fuzztest/common_fuzzer/BUILD.gn @@ -156,6 +156,7 @@ ohos_source_set("userauth_service_core_fuzzer") { "../../../services/core/src/credential_info_impl.cpp", "../../../services/core/src/enrolled_info_impl.cpp", "../../../services/core/src/enrollment_impl.cpp", + "../../../services/core/src/hdi_message_callback_service.cpp", "../../../services/core/src/identification_impl.cpp", "../../../services/core/src/resource_node_impl.cpp", "../../../services/core/src/resource_node_pool_impl.cpp", diff --git a/test/fuzztest/executors/userauthdrivermanager_fuzzer/BUILD.gn b/test/fuzztest/executors/userauthdrivermanager_fuzzer/BUILD.gn index 85b506e38..47a8668df 100644 --- a/test/fuzztest/executors/userauthdrivermanager_fuzzer/BUILD.gn +++ b/test/fuzztest/executors/userauthdrivermanager_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("UserAuthDriverManagerFuzzTest") { "../../../../frameworks/native/executors/src/executor.cpp", "../../../../frameworks/native/executors/src/framework/executor_mgr_wrapper.cpp", "../../../../frameworks/native/executors/src/framework/framework_executor_callback.cpp", + "../../../../frameworks/native/executors/src/iauth_executor_hdi.cpp", "../../../../frameworks/native/executors/src/idriver_manager.cpp", "../../../../frameworks/native/executors/src/listener/auth_executor_mgr_status_listener.cpp", "../../../../frameworks/native/executors/src/listener/driver_manager_status_listener.cpp", diff --git a/test/fuzztest/executors/userauthdrivermanager_fuzzer/user_auth_driver_manager_fuzzer.cpp b/test/fuzztest/executors/userauthdrivermanager_fuzzer/user_auth_driver_manager_fuzzer.cpp index 8abebe8c1..a85e4bb8c 100644 --- a/test/fuzztest/executors/userauthdrivermanager_fuzzer/user_auth_driver_manager_fuzzer.cpp +++ b/test/fuzztest/executors/userauthdrivermanager_fuzzer/user_auth_driver_manager_fuzzer.cpp @@ -41,6 +41,15 @@ public: DummyAuthExecutorHdi() = default; ~DummyAuthExecutorHdi() override = default; + ResultCode SendMessage(uint64_t scheduleId, int32_t srcRole, const std::vector &msg) override + { + std::lock_guard lock(mutex_); + if (fuzzParcel_ == nullptr) { + return ResultCode::GENERAL_ERROR; + } + return static_cast(fuzzParcel_->ReadInt32()); + } + ResultCode GetExecutorInfo(ExecutorInfo &executorInfo) override { std::lock_guard lock(mutex_); diff --git a/test/fuzztest/executors/userauthexecutor_fuzzer/BUILD.gn b/test/fuzztest/executors/userauthexecutor_fuzzer/BUILD.gn index b25f077be..5bbbee3c0 100644 --- a/test/fuzztest/executors/userauthexecutor_fuzzer/BUILD.gn +++ b/test/fuzztest/executors/userauthexecutor_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("UserAuthExecutorFuzzTest") { "../../../../frameworks/native/executors/src/executor.cpp", "../../../../frameworks/native/executors/src/framework/executor_mgr_wrapper.cpp", "../../../../frameworks/native/executors/src/framework/framework_executor_callback.cpp", + "../../../../frameworks/native/executors/src/iauth_executor_hdi.cpp", "../../../../frameworks/native/executors/src/idriver_manager.cpp", "../../../../frameworks/native/executors/src/listener/auth_executor_mgr_status_listener.cpp", "../../../../frameworks/native/executors/src/listener/driver_manager_status_listener.cpp", diff --git a/test/fuzztest/executors/userauthexecutor_fuzzer/user_auth_executor_fuzzer.cpp b/test/fuzztest/executors/userauthexecutor_fuzzer/user_auth_executor_fuzzer.cpp index 7b04eba8a..c91ed9094 100644 --- a/test/fuzztest/executors/userauthexecutor_fuzzer/user_auth_executor_fuzzer.cpp +++ b/test/fuzztest/executors/userauthexecutor_fuzzer/user_auth_executor_fuzzer.cpp @@ -46,6 +46,15 @@ public: DummyAuthExecutorHdi() = default; ~DummyAuthExecutorHdi() override = default; + ResultCode SendMessage(uint64_t scheduleId, int32_t srcRole, const std::vector &msg) override + { + std::lock_guard lock(mutex_); + if (fuzzParcel_ == nullptr) { + return ResultCode::GENERAL_ERROR; + } + return static_cast(fuzzParcel_->ReadInt32()); + } + ResultCode GetExecutorInfo(ExecutorInfo &executorInfo) override { std::lock_guard lock(mutex_); @@ -205,22 +214,17 @@ public: class DummyExecutorMessenger : public ExecutorMessenger { public: virtual ~DummyExecutorMessenger() = default; - int32_t SendData(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg) override + int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) override { static_cast(scheduleId); - static_cast(transNum); - static_cast(srcRole); static_cast(dstRole); static_cast(msg); return fuzzParcel_->ReadInt32(); } - int32_t Finish(uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, - const Attributes &finalResult) override + int32_t Finish(uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) override { static_cast(scheduleId); - static_cast(srcRole); static_cast(resultCode); static_cast(finalResult); return fuzzParcel_->ReadInt32(); diff --git a/test/fuzztest/services/coauthservice_fuzzer/BUILD.gn b/test/fuzztest/services/coauthservice_fuzzer/BUILD.gn index 583d3a4a5..2056b2b6a 100644 --- a/test/fuzztest/services/coauthservice_fuzzer/BUILD.gn +++ b/test/fuzztest/services/coauthservice_fuzzer/BUILD.gn @@ -52,6 +52,7 @@ ohos_fuzztest("CoAuthServiceFuzzTest") { "c_utils:utils", "drivers_interface_user_auth:libuser_auth_proxy_2.0", "eventhandler:libeventhandler", + "hdf_core:libhdi", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", diff --git a/test/fuzztest/services/coauthservice_fuzzer/co_auth_service_fuzzer.cpp b/test/fuzztest/services/coauthservice_fuzzer/co_auth_service_fuzzer.cpp index 86674e07e..4179cf1f6 100644 --- a/test/fuzztest/services/coauthservice_fuzzer/co_auth_service_fuzzer.cpp +++ b/test/fuzztest/services/coauthservice_fuzzer/co_auth_service_fuzzer.cpp @@ -45,11 +45,12 @@ std::u16string cmd[] = {u"-h", u"-lc", u"-ls", u"-c", u"-c [base system]", u"-s" class CoAuthServiceFuzzer : public ExecutorCallbackInterface { public: CoAuthServiceFuzzer(int32_t onBeginExecuteResult, int32_t onEndExecuteResult, int32_t onSetPropertyResult, - int32_t onGetPropertyResult) + int32_t onGetPropertyResult, int32_t onSendDataResult) : onBeginExecuteResult_(onBeginExecuteResult), onEndExecuteResult_(onEndExecuteResult), onSetPropertyResult_(onSetPropertyResult), - onGetPropertyResult_(onGetPropertyResult) + onGetPropertyResult_(onGetPropertyResult), + onSendDataResult_(onSendDataResult) { } @@ -87,6 +88,12 @@ public: return onGetPropertyResult_; } + int32_t OnSendData(uint64_t scheduleId, const Attributes &data) override + { + IAM_LOGI("start"); + return onSendDataResult_; + } + sptr AsObject() override { sptr tmp(nullptr); @@ -98,6 +105,7 @@ private: int32_t onEndExecuteResult_; int32_t onSetPropertyResult_; int32_t onGetPropertyResult_; + int32_t onSendDataResult_; }; void FillFuzzExecutorRegisterInfo(Parcel &parcel, ExecutorRegisterInfo &executorInfo) @@ -122,7 +130,8 @@ void FuzzRegister(Parcel &parcel) sptr callback(nullptr); if (parcel.ReadBool()) { callback = sptr(new (std::nothrow) - CoAuthServiceFuzzer(parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadInt32())); + CoAuthServiceFuzzer(parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadInt32(), + parcel.ReadInt32())); } g_coAuthService.ExecutorRegister(executorInfo, callback); IAM_LOGI("FuzzRegister end"); @@ -132,14 +141,12 @@ void FuzzSendData(Parcel &parcel) { IAM_LOGI("FuzzSendData begin"); uint64_t scheduleId = parcel.ReadUint64(); - uint64_t transNum = parcel.ReadUint64(); - ExecutorRole srcRole = static_cast(parcel.ReadInt32()); ExecutorRole dstRole = static_cast(parcel.ReadInt32()); std::vector msg; Common::FillFuzzUint8Vector(parcel, msg); if (executorMessengerService != nullptr) { - executorMessengerService->SendData(scheduleId, transNum, srcRole, dstRole, msg); + executorMessengerService->SendData(scheduleId, dstRole, msg); } IAM_LOGI("FuzzSendData end"); } @@ -148,12 +155,11 @@ void FuzzFinish(Parcel &parcel) { IAM_LOGI("FuzzFinish begin"); uint64_t scheduleId = parcel.ReadUint64(); - ExecutorRole srcRole = static_cast(parcel.ReadInt32()); ResultCode resultCode = static_cast(parcel.ReadInt32()); auto finalResult = Common::MakeShared(); if (executorMessengerService != nullptr) { - executorMessengerService->Finish(scheduleId, srcRole, resultCode, finalResult); + executorMessengerService->Finish(scheduleId, resultCode, finalResult); } IAM_LOGI("FuzzFinish end"); } diff --git a/test/fuzztest/services/coauthstub_fuzzer/BUILD.gn b/test/fuzztest/services/coauthstub_fuzzer/BUILD.gn index 19e335e4b..b67f1c33a 100644 --- a/test/fuzztest/services/coauthstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/coauthstub_fuzzer/BUILD.gn @@ -48,6 +48,7 @@ ohos_fuzztest("CoAuthStubFuzzTest") { "c_utils:utils", "drivers_interface_user_auth:libuser_auth_proxy_2.0", "eventhandler:libeventhandler", + "hdf_core:libhdi", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", diff --git a/test/fuzztest/services/servicecore_fuzzer/BUILD.gn b/test/fuzztest/services/servicecore_fuzzer/BUILD.gn index 586a7ca25..b029e8d75 100644 --- a/test/fuzztest/services/servicecore_fuzzer/BUILD.gn +++ b/test/fuzztest/services/servicecore_fuzzer/BUILD.gn @@ -52,7 +52,10 @@ ohos_fuzztest("ServiceCoreFuzzTest") { remove_configs = [ "//build/config/compiler:no_exceptions" ] - external_deps = [ "hilog:libhilog" ] + external_deps = [ + "hdf_core:libhdi", + "hilog:libhilog", + ] subsystem_name = "useriam" part_name = "user_auth_framework" diff --git a/test/fuzztest/services/servicecore_fuzzer/inc/common_dummy.h b/test/fuzztest/services/servicecore_fuzzer/inc/common_dummy.h index ac062ae1c..cd27e052b 100644 --- a/test/fuzztest/services/servicecore_fuzzer/inc/common_dummy.h +++ b/test/fuzztest/services/servicecore_fuzzer/inc/common_dummy.h @@ -116,6 +116,14 @@ public: return SUCCESS; } + int32_t SendData(uint64_t scheduleId, const Attributes &data) + { + IAM_LOGI("start"); + static_cast(scheduleId); + static_cast(data); + return SUCCESS; + } + void Detach() { IAM_LOGI("start"); diff --git a/test/fuzztest/services/servicecore_fuzzer/src/resource_node_fuzzer.cpp b/test/fuzztest/services/servicecore_fuzzer/src/resource_node_fuzzer.cpp index b0f61839a..b02a01d20 100644 --- a/test/fuzztest/services/servicecore_fuzzer/src/resource_node_fuzzer.cpp +++ b/test/fuzztest/services/servicecore_fuzzer/src/resource_node_fuzzer.cpp @@ -70,6 +70,14 @@ public: return SUCCESS; } + int32_t OnSendData(uint64_t scheduleId, const Attributes &data) override + { + IAM_LOGI("start"); + static_cast(scheduleId); + static_cast(data); + return SUCCESS; + } + sptr AsObject() override { sptr tmp(nullptr); diff --git a/test/fuzztest/services/servicecore_fuzzer/src/schedule_node_fuzzer.cpp b/test/fuzztest/services/servicecore_fuzzer/src/schedule_node_fuzzer.cpp index 80347e2ea..bdd5853dc 100644 --- a/test/fuzztest/services/servicecore_fuzzer/src/schedule_node_fuzzer.cpp +++ b/test/fuzztest/services/servicecore_fuzzer/src/schedule_node_fuzzer.cpp @@ -163,22 +163,20 @@ void FuzzScheduleNodeStopSchedule(Parcel &parcel) IAM_LOGI("end"); } -void FuzzScheduleNodeContinueSchedule001(Parcel &parcel) +void FuzzScheduleNodeSendMessage(Parcel &parcel) { IAM_LOGI("start"); - auto srcRole = static_cast(parcel.ReadInt32()); auto dstRole = static_cast(parcel.ReadInt32()); - uint64_t transNum = parcel.ReadUint64(); std::vector msg; Common::FillFuzzUint8Vector(parcel, msg); auto node = GetScheduleNode(parcel); if (node != nullptr) { - node->ContinueSchedule(srcRole, dstRole, transNum, msg); + node->SendMessage(dstRole, msg); } IAM_LOGI("end"); } -void FuzzScheduleNodeContinueSchedule002(Parcel &parcel) +void FuzzScheduleNodeContinueSchedule(Parcel &parcel) { IAM_LOGI("start"); auto resultCode = static_cast(parcel.ReadInt32()); @@ -205,8 +203,8 @@ ScheduleNodeFuzzFunc *g_ScheduleNodeFuzzFuncs[] = { FuzzScheduleNodeGetCurrentScheduleState, FuzzScheduleNodeStartSchedule, FuzzScheduleNodeStopSchedule, - FuzzScheduleNodeContinueSchedule001, - FuzzScheduleNodeContinueSchedule002, + FuzzScheduleNodeSendMessage, + FuzzScheduleNodeContinueSchedule, }; } // namespace diff --git a/test/fuzztest/services/userauthservice_fuzzer/BUILD.gn b/test/fuzztest/services/userauthservice_fuzzer/BUILD.gn index f3c6934bb..048d6237d 100644 --- a/test/fuzztest/services/userauthservice_fuzzer/BUILD.gn +++ b/test/fuzztest/services/userauthservice_fuzzer/BUILD.gn @@ -48,6 +48,7 @@ ohos_fuzztest("UserAuthServiceFuzzTest") { "c_utils:utils", "drivers_interface_user_auth:libuser_auth_proxy_2.0", "eventhandler:libeventhandler", + "hdf_core:libhdi", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", diff --git a/test/fuzztest/services/userauthstub_fuzzer/BUILD.gn b/test/fuzztest/services/userauthstub_fuzzer/BUILD.gn index ea6976208..fa6a1ce6a 100644 --- a/test/fuzztest/services/userauthstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/userauthstub_fuzzer/BUILD.gn @@ -48,6 +48,7 @@ ohos_fuzztest("UserAuthStubFuzzTest") { "c_utils:utils", "drivers_interface_user_auth:libuser_auth_proxy_2.0", "eventhandler:libeventhandler", + "hdf_core:libhdi", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", diff --git a/test/fuzztest/services/useridmservice_fuzzer/BUILD.gn b/test/fuzztest/services/useridmservice_fuzzer/BUILD.gn index 1c3e2af51..4a7ec7f28 100644 --- a/test/fuzztest/services/useridmservice_fuzzer/BUILD.gn +++ b/test/fuzztest/services/useridmservice_fuzzer/BUILD.gn @@ -48,6 +48,7 @@ ohos_fuzztest("UserIdmServiceFuzzTest") { external_deps = [ "c_utils:utils", + "hdf_core:libhdi", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", diff --git a/test/fuzztest/services/useridmstub_fuzzer/BUILD.gn b/test/fuzztest/services/useridmstub_fuzzer/BUILD.gn index 311d3b82a..ae1cfa99b 100644 --- a/test/fuzztest/services/useridmstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/useridmstub_fuzzer/BUILD.gn @@ -48,6 +48,7 @@ ohos_fuzztest("UserIdmStubFuzzTest") { "c_utils:utils", "drivers_interface_user_auth:libuser_auth_proxy_2.0", "eventhandler:libeventhandler", + "hdf_core:libhdi", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", diff --git a/test/unittest/executors/BUILD.gn b/test/unittest/executors/BUILD.gn index 2c63b0d7d..a61641316 100644 --- a/test/unittest/executors/BUILD.gn +++ b/test/unittest/executors/BUILD.gn @@ -38,6 +38,7 @@ ohos_unittest("iam_executors_test") { sources = [ "../../../frameworks/native/executors/src/async_command/async_command_base.cpp", "../../../frameworks/native/executors/src/async_command/auth_command.cpp", + "../../../frameworks/native/executors/src/async_command/collect_command.cpp", "../../../frameworks/native/executors/src/async_command/custom_command.cpp", "../../../frameworks/native/executors/src/async_command/enroll_command.cpp", "../../../frameworks/native/executors/src/async_command/identify_command.cpp", @@ -46,6 +47,7 @@ ohos_unittest("iam_executors_test") { "../../../frameworks/native/executors/src/executor.cpp", "../../../frameworks/native/executors/src/framework/executor_mgr_wrapper.cpp", "../../../frameworks/native/executors/src/framework/framework_executor_callback.cpp", + "../../../frameworks/native/executors/src/iauth_executor_hdi.cpp", "../../../frameworks/native/executors/src/idriver_manager.cpp", "../../../frameworks/native/executors/src/listener/auth_executor_mgr_status_listener.cpp", "../../../frameworks/native/executors/src/listener/driver_manager_status_listener.cpp", diff --git a/test/unittest/executors/auth_command_unit_test.cpp b/test/unittest/executors/auth_command_unit_test.cpp index 53493d794..9fe76d12e 100644 --- a/test/unittest/executors/auth_command_unit_test.cpp +++ b/test/unittest/executors/auth_command_unit_test.cpp @@ -68,11 +68,10 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnResultTest_001, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) { + .WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(srcRole, ALL_IN_ONE); EXPECT_EQ(resultCode, testResultCode); uint32_t attrResultCode; EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true); @@ -98,9 +97,9 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnResultTest_002, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) { + .WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { return USERAUTH_ERROR; }); auto executor = Common::MakeShared(nullptr, nullptr, 3); @@ -119,11 +118,10 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnResultTest_003, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) { + .WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(srcRole, ALL_IN_ONE); EXPECT_EQ(resultCode, testResultCode); uint32_t attrResultCode; EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true); @@ -149,7 +147,7 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnResultTest_004, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1)); + EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1)); auto executor = Common::MakeShared(nullptr, nullptr, 3); ASSERT_NE(executor, nullptr); Attributes attr; @@ -168,13 +166,11 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnAcquireInfoTest_001, TestSize.Level0 auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(transNum, static_cast(1)); - EXPECT_EQ(srcRole, ALL_IN_ONE); EXPECT_EQ(dstRole, SCHEDULER); EXPECT_NE(msg, nullptr); return USERAUTH_SUCCESS; @@ -195,9 +191,9 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnAcquireInfoTest_002, TestSize.Level0 auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_ERROR; }); auto executor = Common::MakeShared(nullptr, nullptr, 3); ASSERT_NE(executor, nullptr); @@ -215,21 +211,15 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_OnAcquireInfoTest_003, TestSize.Level0 auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(3)) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg) { - EXPECT_EQ(transNum, static_cast(1)); + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_SUCCESS; }) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg) { - EXPECT_EQ(transNum, static_cast(2)); + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_ERROR; }) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg) { - EXPECT_EQ(transNum, static_cast(3)); + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_SUCCESS; }); auto executor = Common::MakeShared(nullptr, nullptr, 3); @@ -251,10 +241,10 @@ HWTEST_F(AuthCommandUnitTest, AuthCommand_MixTest_003, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1)); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1)); + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(3)) - .WillRepeatedly([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + .WillRepeatedly([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_SUCCESS; }); auto executor = Common::MakeShared(nullptr, nullptr, 3); ASSERT_NE(executor, nullptr); diff --git a/test/unittest/executors/enroll_command_unit_test.cpp b/test/unittest/executors/enroll_command_unit_test.cpp index eb51ed63f..33a00f24e 100644 --- a/test/unittest/executors/enroll_command_unit_test.cpp +++ b/test/unittest/executors/enroll_command_unit_test.cpp @@ -68,11 +68,10 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnResultTest_001, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) { + .WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(srcRole, ALL_IN_ONE); EXPECT_EQ(resultCode, testResultCode); uint32_t attrResultCode; EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true); @@ -98,9 +97,9 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnResultTest_002, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) { + .WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { // return error return USERAUTH_ERROR; }); @@ -120,11 +119,10 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnResultTest_003, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) { + .WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(srcRole, ALL_IN_ONE); EXPECT_EQ(resultCode, testResultCode); uint32_t attrResultCode; EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true); @@ -150,7 +148,7 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnResultTest_004, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1)); + EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1)); auto executor = Common::MakeShared(nullptr, nullptr, 3); ASSERT_NE(executor, nullptr); Attributes attr; @@ -169,13 +167,10 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnAcquireInfoTest_001, TestSize.Le auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg) { + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(transNum, static_cast(1)); - EXPECT_EQ(srcRole, ALL_IN_ONE); EXPECT_EQ(dstRole, SCHEDULER); EXPECT_NE(msg, nullptr); std::vector extraInfo; @@ -197,9 +192,9 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnAcquireInfoTest_002, TestSize.Le auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_ERROR; }); auto executor = Common::MakeShared(nullptr, nullptr, 3); ASSERT_NE(executor, nullptr); @@ -217,21 +212,15 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_OnAcquireInfoTest_003, TestSize.Le auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(3)) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, int32_t srcType, int32_t dstType, - std::shared_ptr msg) { - EXPECT_EQ(transNum, static_cast(1)); + .WillOnce([](uint64_t scheduleId, int32_t dstType, std::shared_ptr msg) { return USERAUTH_SUCCESS; }) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, int32_t srcType, int32_t dstType, - std::shared_ptr msg) { - EXPECT_EQ(transNum, static_cast(2)); + .WillOnce([](uint64_t scheduleId, int32_t dstType, std::shared_ptr msg) { return USERAUTH_ERROR; }) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, int32_t srcType, int32_t dstType, - std::shared_ptr msg) { - EXPECT_EQ(transNum, static_cast(3)); + .WillOnce([](uint64_t scheduleId, int32_t dstType, std::shared_ptr msg) { return USERAUTH_SUCCESS; }); auto executor = Common::MakeShared(nullptr, nullptr, 3); @@ -253,10 +242,10 @@ HWTEST_F(EnrollCommandUnitTest, EnrollCommand_MixTest_003, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1)); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1)); + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(3)) - .WillRepeatedly([](uint64_t scheduleId, uint64_t transNum, int32_t srcType, int32_t dstType, + .WillRepeatedly([](uint64_t scheduleId, int32_t dstType, std::shared_ptr msg) { return USERAUTH_SUCCESS; }); auto executor = Common::MakeShared(nullptr, nullptr, 3); ASSERT_NE(executor, nullptr); diff --git a/test/unittest/executors/executor_unit_test.cpp b/test/unittest/executors/executor_unit_test.cpp index b0f4109b6..5c3a73c28 100644 --- a/test/unittest/executors/executor_unit_test.cpp +++ b/test/unittest/executors/executor_unit_test.cpp @@ -367,8 +367,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_CommonErrorTest_001, int32_t ret = GetExecutorAndMockStub(executor, executorCallback, mockExecutorHdi, mockMessenger); ASSERT_EQ(ret, ResultCode::SUCCESS); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; Attributes attr; @@ -387,8 +387,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_CommonErrorTest_002, int32_t ret = GetExecutorAndMockStub(executor, executorCallback, mockExecutorHdi, mockMessenger); ASSERT_EQ(ret, ResultCode::SUCCESS); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -410,8 +410,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_CommonErrorTest_003, int32_t ret = GetExecutorAndMockStub(executor, executorCallback, mockExecutorHdi, mockMessenger); ASSERT_EQ(ret, ResultCode::SUCCESS); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -442,13 +442,12 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_ExecutorDisconnectTest_001, TestSize [](uint64_t scheduleId, const EnrollParam ¶m, const std::shared_ptr &callbackObj) { return ResultCode::SUCCESS; }); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)) + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)) .Times(Exactly(2)) .WillRepeatedly( - [](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) { + [](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(srcRole, static_cast(ALL_IN_ONE)); EXPECT_EQ(resultCode, ResultCode::GENERAL_ERROR); std::vector extraInfo; EXPECT_EQ(finalResult.GetUint8ArrayValue(Attributes::ATTR_RESULT, extraInfo), true); @@ -497,8 +496,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_EnrollTest_001, TestS return ResultCode::SUCCESS; }); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -524,8 +523,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_EnrollTest_002, TestS EXPECT_CALL(*mockExecutorHdi, Enroll(_, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -550,8 +549,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_EnrollTest_003, TestS EXPECT_CALL(*mockExecutorHdi, Enroll(_, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -594,8 +593,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_AuthTest_001, TestSiz return ResultCode::SUCCESS; }); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -623,8 +622,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_AuthTest_002, TestSiz EXPECT_CALL(*mockExecutorHdi, Authenticate(_, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -649,8 +648,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_AuthTest_003, TestSiz EXPECT_CALL(*mockExecutorHdi, Authenticate(_, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -677,8 +676,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_AuthTest_004, TestSiz EXPECT_CALL(*mockExecutorHdi, Authenticate(_, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -717,8 +716,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_IdentifyTest_001, Tes return ResultCode::SUCCESS; }); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -744,8 +743,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_IdentifyTest_002, Tes EXPECT_CALL(*mockExecutorHdi, Identify(_, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); @@ -770,8 +769,8 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnBeginExecute_IdentifyTest_003, Tes EXPECT_CALL(*mockExecutorHdi, Identify(_, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, SendData(_, _, _, _, _)).Times(Exactly(0)); - EXPECT_CALL(*mockMessenger, Finish(_, _, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, SendData(_, _, _)).Times(Exactly(0)); + EXPECT_CALL(*mockMessenger, Finish(_, _, _)).Times(Exactly(0)); vector uselessPublicKey; auto commandAttrs = MakeShared(); diff --git a/test/unittest/executors/identify_command_unit_test.cpp b/test/unittest/executors/identify_command_unit_test.cpp index 53c1370ba..d086bd669 100644 --- a/test/unittest/executors/identify_command_unit_test.cpp +++ b/test/unittest/executors/identify_command_unit_test.cpp @@ -68,11 +68,10 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnResultTest_001, TestSize.Lev auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) { + .WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(srcRole, ALL_IN_ONE); EXPECT_EQ(resultCode, testResultCode); uint32_t attrResultCode; EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true); @@ -98,9 +97,9 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnResultTest_002, TestSize.Lev auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) { + .WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { // return error return USERAUTH_ERROR; }); @@ -120,11 +119,10 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnResultTest_003, TestSize.Lev auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult) { + .WillOnce([](uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(srcRole, ALL_IN_ONE); EXPECT_EQ(resultCode, testResultCode); uint32_t attrResultCode; EXPECT_EQ(finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode), true); @@ -150,7 +148,7 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnResultTest_004, TestSize.Lev auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1)); + EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1)); auto executor = Common::MakeShared(nullptr, nullptr, 3); ASSERT_NE(executor, nullptr); Attributes attr; @@ -169,13 +167,11 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnAcquireInfoTest_001, TestSiz auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(transNum, static_cast(1)); - EXPECT_EQ(srcRole, ALL_IN_ONE); EXPECT_EQ(dstRole, SCHEDULER); EXPECT_NE(msg, nullptr); return USERAUTH_SUCCESS; @@ -196,9 +192,9 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnAcquireInfoTest_002, TestSiz auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(1)) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_ERROR; }); auto executor = Common::MakeShared(nullptr, nullptr, 3); ASSERT_NE(executor, nullptr); @@ -216,21 +212,15 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_OnAcquireInfoTest_003, TestSiz auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(3)) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg) { - EXPECT_EQ(transNum, static_cast(1)); + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_SUCCESS; }) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg) { - EXPECT_EQ(transNum, static_cast(2)); + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_ERROR; }) - .WillOnce([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg) { - EXPECT_EQ(transNum, static_cast(3)); + .WillOnce([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_SUCCESS; }); auto executor = Common::MakeShared(nullptr, nullptr, 3); @@ -252,10 +242,10 @@ HWTEST_F(IdentifyCommandUnitTest, IdentifyCommand_MixTest_003, TestSize.Level0) auto messenger = MakeShared(); ASSERT_NE(messenger, nullptr); - EXPECT_CALL(*messenger, Finish(_, _, _, _)).Times(Exactly(1)); - EXPECT_CALL(*messenger, SendData(_, _, _, _, _)) + EXPECT_CALL(*messenger, Finish(_, _, _)).Times(Exactly(1)); + EXPECT_CALL(*messenger, SendData(_, _, _)) .Times(Exactly(3)) - .WillRepeatedly([](uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, + .WillRepeatedly([](uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg) { return USERAUTH_SUCCESS; }); auto executor = Common::MakeShared(nullptr, nullptr, 3); ASSERT_NE(executor, nullptr); diff --git a/test/unittest/executors/mock/mock_iauth_executor_hdi.h b/test/unittest/executors/mock/mock_iauth_executor_hdi.h index adc5b980a..5a97d3c1f 100644 --- a/test/unittest/executors/mock/mock_iauth_executor_hdi.h +++ b/test/unittest/executors/mock/mock_iauth_executor_hdi.h @@ -34,20 +34,25 @@ public: MOCK_METHOD3( OnRegisterFinish, ResultCode(const std::vector &templateIdList, const std::vector &frameworkPublicKey, const std::vector &extraInfo)); + MOCK_METHOD1(Cancel, ResultCode(uint64_t scheduleId)); + MOCK_METHOD3(SendMessage, ResultCode(uint64_t scheduleId, int32_t srcRole, const std::vector &msg)); MOCK_METHOD3(Enroll, ResultCode(uint64_t scheduleId, const EnrollParam ¶m, const std::shared_ptr &callbackObj)); MOCK_METHOD3(Authenticate, ResultCode(uint64_t scheduleId, const AuthenticateParam ¶m, const std::shared_ptr &callbackObj)); + MOCK_METHOD3(Collect, + ResultCode(uint64_t scheduleId, const CollectParam ¶m, + const std::shared_ptr &callbackObj)); MOCK_METHOD3(Identify, ResultCode(uint64_t scheduleId, const IdentifyParam ¶m, const std::shared_ptr &callbackObj)); MOCK_METHOD1(Delete, ResultCode(const std::vector &templateIdList)); - MOCK_METHOD1(Cancel, ResultCode(uint64_t scheduleId)); MOCK_METHOD3(SendCommand, ResultCode(PropertyMode commandId, const std::vector &extraInfo, const std::shared_ptr &callbackObj)); MOCK_METHOD3(GetProperty, ResultCode (const std::vector &templateIdList, const std::vector &keys, Property &property)); MOCK_METHOD1(SetCachedTemplates, ResultCode(const std::vector &templateIdList)); + MOCK_METHOD1(NotifyCollectorReady, ResultCode(uint64_t scheduleId)); }; } // namespace UserAuth } // namespace UserIam diff --git a/test/unittest/executors/mock/mock_iexecutor_messenger.h b/test/unittest/executors/mock/mock_iexecutor_messenger.h index afa7c472c..568a9e8a7 100644 --- a/test/unittest/executors/mock/mock_iexecutor_messenger.h +++ b/test/unittest/executors/mock/mock_iexecutor_messenger.h @@ -30,10 +30,8 @@ class MockIExecutorMessenger : public ExecutorMessenger { public: virtual ~MockIExecutorMessenger() = default; - MOCK_METHOD5(SendData, int32_t(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, - const std::shared_ptr &msg)); - MOCK_METHOD4(Finish, - int32_t(uint64_t scheduleId, ExecutorRole srcRole, int32_t resultCode, const Attributes &finalResult)); + MOCK_METHOD3(SendData, int32_t(uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr &msg)); + MOCK_METHOD3(Finish, int32_t(uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult)); }; } // namespace UserAuth } // namespace UserIam diff --git a/test/unittest/inner_api/mocks/mock_executor_callback_service.h b/test/unittest/inner_api/mocks/mock_executor_callback_service.h index 3cba650bb..88087ed43 100644 --- a/test/unittest/inner_api/mocks/mock_executor_callback_service.h +++ b/test/unittest/inner_api/mocks/mock_executor_callback_service.h @@ -32,6 +32,7 @@ public: MOCK_METHOD2(OnEndExecute, int32_t(uint64_t scheduleId, const Attributes &command)); MOCK_METHOD1(OnSetProperty, int32_t(const Attributes &properties)); MOCK_METHOD2(OnGetProperty, int32_t(const Attributes &condition, Attributes &values)); + MOCK_METHOD2(OnSendData, int32_t(uint64_t scheduleId, const Attributes &data)); }; } // namespace UserAuth } // namespace UserIam diff --git a/test/unittest/inner_api/mocks/mock_executor_messenger_service.h b/test/unittest/inner_api/mocks/mock_executor_messenger_service.h index 850761e54..55191404f 100644 --- a/test/unittest/inner_api/mocks/mock_executor_messenger_service.h +++ b/test/unittest/inner_api/mocks/mock_executor_messenger_service.h @@ -26,9 +26,8 @@ namespace UserIam { namespace UserAuth { class MockExecutorMessengerService final : public ExecutorMessengerStub { public: - MOCK_METHOD5(SendData, int32_t(uint64_t scheduleId, uint64_t transNum, ExecutorRole srcRole, - ExecutorRole dstRole, const std::vector &msg)); - MOCK_METHOD4(Finish, int32_t(uint64_t scheduleId, ExecutorRole srcRole, ResultCode resultCode, + MOCK_METHOD3(SendData, int32_t(uint64_t scheduleId, ExecutorRole dstRole, const std::vector &msg)); + MOCK_METHOD3(Finish, int32_t(uint64_t scheduleId, ResultCode resultCode, const std::shared_ptr &finalResult)); }; } // namespace UserAuth diff --git a/test/unittest/inner_api/mocks/mock_executor_register_callback.h b/test/unittest/inner_api/mocks/mock_executor_register_callback.h index 6da36fea8..87f51aad6 100644 --- a/test/unittest/inner_api/mocks/mock_executor_register_callback.h +++ b/test/unittest/inner_api/mocks/mock_executor_register_callback.h @@ -34,6 +34,7 @@ public: MOCK_METHOD2(OnEndExecute, int32_t(uint64_t scheduleId, const Attributes &commandAttrs)); MOCK_METHOD1(OnSetProperty, int32_t(const Attributes &properties)); MOCK_METHOD2(OnGetProperty, int32_t(const Attributes &conditions, Attributes &results)); + MOCK_METHOD2(OnSendData, int32_t(uint64_t scheduleId, const Attributes &data)); }; } // namespace UserAuth } // namespace UserIam diff --git a/test/unittest/inner_api/src/executor_messenger_client_test.cpp b/test/unittest/inner_api/src/executor_messenger_client_test.cpp index 71cc9f0bf..424474a43 100644 --- a/test/unittest/inner_api/src/executor_messenger_client_test.cpp +++ b/test/unittest/inner_api/src/executor_messenger_client_test.cpp @@ -44,8 +44,6 @@ void ExecutorMessengerClientTest::TearDown() HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData001, TestSize.Level0) { uint64_t testScheduleId = 6598; - uint64_t testTransNum = 8784; - ExecutorRole testSrcRole = SCHEDULER; ExecutorRole testDstRole = COLLECTOR; std::vector message = {1, 2, 4, 6}; std::shared_ptr testMsg = AuthMessage::As(message); @@ -54,15 +52,13 @@ HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData001, Te sptr testMessenger(nullptr); auto service = Common::MakeShared(testMessenger); EXPECT_NE(service, nullptr); - int32_t result = service->SendData(testScheduleId, testTransNum, testSrcRole, testDstRole, testMsg); + int32_t result = service->SendData(testScheduleId, testDstRole, testMsg); EXPECT_EQ(result, GENERAL_ERROR); } HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData002, TestSize.Level0) { uint64_t testScheduleId = 6598; - uint64_t testTransNum = 8784; - ExecutorRole testSrcRole = SCHEDULER; ExecutorRole testDstRole = COLLECTOR; std::shared_ptr testMsg = nullptr; @@ -70,15 +66,13 @@ HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData002, Te EXPECT_NE(testMessenger, nullptr); auto service = Common::MakeShared(testMessenger); EXPECT_NE(service, nullptr); - int32_t result = service->SendData(testScheduleId, testTransNum, testSrcRole, testDstRole, testMsg); + int32_t result = service->SendData(testScheduleId, testDstRole, testMsg); EXPECT_EQ(result, GENERAL_ERROR); } HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData003, TestSize.Level0) { uint64_t testScheduleId = 6598; - uint64_t testTransNum = 8784; - ExecutorRole testSrcRole = SCHEDULER; ExecutorRole testDstRole = COLLECTOR; std::vector message = {1, 2, 4, 6}; std::shared_ptr testMsg = AuthMessage::As(message); @@ -86,61 +80,55 @@ HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestSendData003, Te sptr testMessenger(new (std::nothrow) MockExecutorMessengerService()); EXPECT_NE(testMessenger, nullptr); - EXPECT_CALL(*testMessenger, SendData(_, _, _, _, _)).Times(1); + EXPECT_CALL(*testMessenger, SendData(_, _, _)).Times(1); ON_CALL(*testMessenger, SendData) .WillByDefault( - [&testScheduleId, &testTransNum, &testSrcRole, &testDstRole, &message](uint64_t scheduleId, - uint64_t transNum, ExecutorRole srcRole, ExecutorRole dstRole, const std::vector &msg) { + [&testScheduleId, &testDstRole, &message](uint64_t scheduleId, ExecutorRole dstRole, + const std::vector &msg) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(transNum, testTransNum); - EXPECT_EQ(srcRole, testSrcRole); - EXPECT_EQ(dstRole, testDstRole); EXPECT_THAT(msg, ElementsAreArray(message)); return SUCCESS; } ); auto service = Common::MakeShared(testMessenger); EXPECT_NE(service, nullptr); - int32_t result = service->SendData(testScheduleId, testTransNum, testSrcRole, testDstRole, testMsg); + int32_t result = service->SendData(testScheduleId, testDstRole, testMsg); EXPECT_EQ(result, SUCCESS); } HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestFinish001, TestSize.Level0) { uint64_t testScheduleId = 6598; - ExecutorRole testSrcRole = SCHEDULER; int32_t testResultCode = FAIL; Attributes finalResult; sptr testMessenger(nullptr); auto service = Common::MakeShared(testMessenger); EXPECT_NE(service, nullptr); - int32_t result = service->Finish(testScheduleId, testSrcRole, testResultCode, finalResult); + int32_t result = service->Finish(testScheduleId, testResultCode, finalResult); EXPECT_EQ(result, GENERAL_ERROR); } HWTEST_F(ExecutorMessengerClientTest, ExecutorMessengerClientTestFinish002, TestSize.Level0) { uint64_t testScheduleId = 6598; - ExecutorRole testSrcRole = SCHEDULER; int32_t testResultCode = FAIL; Attributes finalResult; sptr testMessenger(new (std::nothrow) MockExecutorMessengerService()); EXPECT_NE(testMessenger, nullptr); - EXPECT_CALL(*testMessenger, Finish(_, _, _, _)).Times(1); + EXPECT_CALL(*testMessenger, Finish(_, _, _)).Times(1); ON_CALL(*testMessenger, Finish) .WillByDefault( - [&testScheduleId, &testSrcRole, &testResultCode](uint64_t scheduleId, ExecutorRole srcRole, - ResultCode resultCode, const std::shared_ptr &finalResult) { + [&testScheduleId, &testResultCode](uint64_t scheduleId, ResultCode resultCode, + const std::shared_ptr &finalResult) { EXPECT_EQ(scheduleId, testScheduleId); - EXPECT_EQ(srcRole, testSrcRole); EXPECT_EQ(resultCode, testResultCode); return SUCCESS; } ); auto service = Common::MakeShared(testMessenger); - int32_t result = service->Finish(testScheduleId, testSrcRole, testResultCode, finalResult); + int32_t result = service->Finish(testScheduleId, testResultCode, finalResult); EXPECT_EQ(result, SUCCESS); } } // namespace UserAuth diff --git a/test/unittest/inner_api/src/executor_messenger_proxy_test.cpp b/test/unittest/inner_api/src/executor_messenger_proxy_test.cpp index e4475e2a1..e429b9d55 100644 --- a/test/unittest/inner_api/src/executor_messenger_proxy_test.cpp +++ b/test/unittest/inner_api/src/executor_messenger_proxy_test.cpp @@ -55,20 +55,17 @@ HWTEST_F(ExecutorMessengerProxyTest, TestSendData_001, TestSize.Level0) ); uint64_t scheduleId = 6598; - uint64_t transNum = 8784; - ExecutorRole srcRole = SCHEDULER; ExecutorRole dstRole = COLLECTOR; std::vector message = {1, 2, 4, 6}; auto proxy = Common::MakeShared(obj); EXPECT_NE(proxy, nullptr); - EXPECT_EQ(proxy->SendData(scheduleId, transNum, srcRole, dstRole, message), SUCCESS); + EXPECT_EQ(proxy->SendData(scheduleId, dstRole, message), SUCCESS); } HWTEST_F(ExecutorMessengerProxyTest, TestFinish_001, TestSize.Level0) { uint64_t scheduleId = 6598; - ExecutorRole srcRole = SCHEDULER; ResultCode resultCode = SUCCESS; std::shared_ptr finalResult = nullptr; @@ -76,7 +73,7 @@ HWTEST_F(ExecutorMessengerProxyTest, TestFinish_001, TestSize.Level0) EXPECT_NE(obj, nullptr); auto proxy = Common::MakeShared(obj); EXPECT_NE(proxy, nullptr); - EXPECT_EQ(proxy->Finish(scheduleId, srcRole, resultCode, finalResult), INVALID_PARAMETERS); + EXPECT_EQ(proxy->Finish(scheduleId, resultCode, finalResult), INVALID_PARAMETERS); } HWTEST_F(ExecutorMessengerProxyTest, TestFinish_002, TestSize.Level0) @@ -93,14 +90,13 @@ HWTEST_F(ExecutorMessengerProxyTest, TestFinish_002, TestSize.Level0) ); uint64_t scheduleId = 6598; - ExecutorRole srcRole = SCHEDULER; ResultCode resultCode = SUCCESS; std::shared_ptr finalResult = Common::MakeShared(); EXPECT_NE(finalResult, nullptr); auto proxy = Common::MakeShared(obj); EXPECT_NE(proxy, nullptr); - EXPECT_EQ(proxy->Finish(scheduleId, srcRole, resultCode, finalResult), SUCCESS); + EXPECT_EQ(proxy->Finish(scheduleId, resultCode, finalResult), SUCCESS); } } // namespace UserAuth } // namespace UserIam diff --git a/test/unittest/inner_api/src/executor_messenger_stub_test.cpp b/test/unittest/inner_api/src/executor_messenger_stub_test.cpp index fed41e4ba..d9dfbbc2a 100644 --- a/test/unittest/inner_api/src/executor_messenger_stub_test.cpp +++ b/test/unittest/inner_api/src/executor_messenger_stub_test.cpp @@ -45,8 +45,6 @@ void ExecutorMessengerStubTest::TearDown() HWTEST_F(ExecutorMessengerStubTest, TestSendDataStub_001, TestSize.Level0) { uint64_t scheduleId = 6598; - uint64_t transNum = 8784; - ExecutorRole srcRole = SCHEDULER; ExecutorRole dstRole = COLLECTOR; std::vector message = {1, 2, 4, 6}; @@ -57,14 +55,12 @@ HWTEST_F(ExecutorMessengerStubTest, TestSendDataStub_001, TestSize.Level0) EXPECT_TRUE(data.WriteInterfaceToken(ExecutorMessengerInterface::GetDescriptor())); EXPECT_TRUE(data.WriteUint64(scheduleId)); - EXPECT_TRUE(data.WriteUint64(transNum)); - EXPECT_TRUE(data.WriteInt32(srcRole)); EXPECT_TRUE(data.WriteInt32(dstRole)); EXPECT_TRUE(data.WriteUInt8Vector(message)); auto service = Common::MakeShared(); EXPECT_NE(service, nullptr); - EXPECT_CALL(*service, SendData(_, _, _, _, _)).Times(1); + EXPECT_CALL(*service, SendData(_, _, _)).Times(1); EXPECT_EQ(service->OnRemoteRequest(code, data, reply, option), SUCCESS); } @@ -72,7 +68,6 @@ HWTEST_F(ExecutorMessengerStubTest, TestSendDataStub_001, TestSize.Level0) HWTEST_F(ExecutorMessengerStubTest, TestFinishStub_001, TestSize.Level0) { uint64_t scheduleId = 6598; - ExecutorRole srcRole = SCHEDULER; ResultCode resultCode = SUCCESS; std::vector finalResult = {1, 2, 4, 6}; @@ -83,13 +78,12 @@ HWTEST_F(ExecutorMessengerStubTest, TestFinishStub_001, TestSize.Level0) EXPECT_TRUE(data.WriteInterfaceToken(ExecutorMessengerInterface::GetDescriptor())); EXPECT_TRUE(data.WriteUint64(scheduleId)); - EXPECT_TRUE(data.WriteInt32(srcRole)); EXPECT_TRUE(data.WriteInt32(resultCode)); EXPECT_TRUE(data.WriteUInt8Vector(finalResult)); auto service = Common::MakeShared(); EXPECT_NE(service, nullptr); - EXPECT_CALL(*service, Finish(_, _, _, _)).Times(1); + EXPECT_CALL(*service, Finish(_, _, _)).Times(1); EXPECT_EQ(service->OnRemoteRequest(code, data, reply, option), SUCCESS); } diff --git a/test/unittest/services/BUILD.gn b/test/unittest/services/BUILD.gn index 6143d39cf..96fd6cb97 100644 --- a/test/unittest/services/BUILD.gn +++ b/test/unittest/services/BUILD.gn @@ -67,6 +67,7 @@ ohos_unittest("iam_services_test") { "../../../services/core/src/credential_info_impl.cpp", "../../../services/core/src/enrolled_info_impl.cpp", "../../../services/core/src/enrollment_impl.cpp", + "../../../services/core/src/hdi_message_callback_service.cpp", "../../../services/core/src/identification_impl.cpp", "../../../services/core/src/resource_node_impl.cpp", "../../../services/core/src/resource_node_pool_impl.cpp", @@ -154,6 +155,7 @@ ohos_unittest("iam_services_test") { "access_token:libtokenid_sdk", "c_utils:utils", "drivers_interface_user_auth:libuser_auth_proxy_2.0", + "hdf_core:libhdi", "hilog:libhilog", "hitrace:hitrace_meter", "init:libbeget_proxy", diff --git a/test/unittest/services/mocks/mock_executor_callback.h b/test/unittest/services/mocks/mock_executor_callback.h index d9ef5fa80..313651c53 100644 --- a/test/unittest/services/mocks/mock_executor_callback.h +++ b/test/unittest/services/mocks/mock_executor_callback.h @@ -35,6 +35,7 @@ public: MOCK_METHOD2(OnEndExecute, int32_t(uint64_t scheduleId, const Attributes &command)); MOCK_METHOD1(OnSetProperty, int32_t(const Attributes &properties)); MOCK_METHOD2(OnGetProperty, int32_t(const Attributes &condition, Attributes &values)); + MOCK_METHOD2(OnSendData, int32_t(uint64_t scheduleId, const Attributes &data)); }; } // namespace UserAuth } // namespace UserIam diff --git a/test/unittest/services/mocks/mock_resource_node.h b/test/unittest/services/mocks/mock_resource_node.h index ba7e8bf54..f871ba435 100644 --- a/test/unittest/services/mocks/mock_resource_node.h +++ b/test/unittest/services/mocks/mock_resource_node.h @@ -41,6 +41,8 @@ public: MOCK_METHOD2(EndExecute, int32_t(uint64_t scheduleId, const Attributes &command)); MOCK_METHOD1(SetProperty, int32_t(const Attributes &properties)); MOCK_METHOD2(GetProperty, int32_t(const Attributes &condition, Attributes &values)); + MOCK_METHOD2(SendData, int32_t(uint64_t scheduleId, const Attributes &data)); + MOCK_METHOD0(OnRegisterFinish, int32_t()); MOCK_METHOD0(Detach, void()); static std::shared_ptr CreateWithExecuteIndex(uint64_t executorId, bool detach = false) diff --git a/test/unittest/services/mocks/mock_schedule_node.h b/test/unittest/services/mocks/mock_schedule_node.h index 77a02fe9c..3e3766040 100644 --- a/test/unittest/services/mocks/mock_schedule_node.h +++ b/test/unittest/services/mocks/mock_schedule_node.h @@ -42,8 +42,7 @@ public: MOCK_METHOD1(SetExpiredTime, bool(uint32_t ms)); MOCK_METHOD0(StartSchedule, bool()); MOCK_METHOD0(StopSchedule, bool()); - MOCK_METHOD4(ContinueSchedule, - bool(ExecutorRole srcRole, ExecutorRole dstRole, uint64_t transNum, const std::vector &msg)); + MOCK_METHOD2(SendMessage, bool(ExecutorRole dstRole, const std::vector &msg)); MOCK_METHOD2(ContinueSchedule, bool(ResultCode resultCode, const std::shared_ptr &finalResult)); static std::shared_ptr CreateWithScheduleId(uint64_t scheduleId) diff --git a/test/unittest/services/src/co_auth_stub_test.cpp b/test/unittest/services/src/co_auth_stub_test.cpp index 2d4b817a1..175ae5c33 100644 --- a/test/unittest/services/src/co_auth_stub_test.cpp +++ b/test/unittest/services/src/co_auth_stub_test.cpp @@ -51,6 +51,7 @@ HWTEST_F(CoAuthStubTest, CoAuthStubTestExecutorRegister001, TestSize.Level0) testInfo.executorSensorHint = 0; testInfo.executorMatcher = 0; testInfo.esl = ESL1; + testInfo.maxTemplateAcl = 0; testInfo.publicKey = {'a', 'b', 'c', 'd'}; uint64_t testContextId = 124545; @@ -79,6 +80,7 @@ HWTEST_F(CoAuthStubTest, CoAuthStubTestExecutorRegister001, TestSize.Level0) EXPECT_TRUE(data.WriteUint32(testInfo.executorSensorHint)); EXPECT_TRUE(data.WriteUint32(testInfo.executorMatcher)); EXPECT_TRUE(data.WriteInt32(testInfo.esl)); + EXPECT_TRUE(data.WriteUint32(testInfo.maxTemplateAcl)); EXPECT_TRUE(data.WriteUInt8Vector(testInfo.publicKey)); EXPECT_NE(callback->AsObject(), nullptr); EXPECT_TRUE(data.WriteRemoteObject(callback->AsObject())); diff --git a/test/unittest/services/src/context_appstate_observer_test.cpp b/test/unittest/services/src/context_appstate_observer_test.cpp index fb89c3c8b..4fafa9afe 100644 --- a/test/unittest/services/src/context_appstate_observer_test.cpp +++ b/test/unittest/services/src/context_appstate_observer_test.cpp @@ -30,7 +30,6 @@ namespace UserAuth { using namespace std; using namespace testing; using namespace testing::ext; - void ContextAppStateObserverTest::SetUpTestCase() { } diff --git a/test/unittest/services/src/executor_messenger_service_test.cpp b/test/unittest/services/src/executor_messenger_service_test.cpp index 4f5a320f1..6028ad681 100644 --- a/test/unittest/services/src/executor_messenger_service_test.cpp +++ b/test/unittest/services/src/executor_messenger_service_test.cpp @@ -56,8 +56,6 @@ HWTEST_F(ExecutorMessengerServiceTest, ExecutorMessengerServiceTest002, TestSize uint64_t testScheduleId1 = 1545; uint64_t testScheduleId2 = 1876; uint64_t testContextId = 78545; - uint64_t testTransNum = 8751; - ExecutorRole testSrcRole = SCHEDULER; ExecutorRole testDstRole = VERIFIER; ResultCode testResultCode = FAIL; std::shared_ptr testFinalResult = nullptr; @@ -66,19 +64,19 @@ HWTEST_F(ExecutorMessengerServiceTest, ExecutorMessengerServiceTest002, TestSize auto service = ExecutorMessengerService::GetInstance(); EXPECT_NE(service, nullptr); - int32_t result1 = service->SendData(testScheduleId1, testTransNum, testSrcRole, testDstRole, testMsg); + int32_t result1 = service->SendData(testScheduleId1, testDstRole, testMsg); EXPECT_EQ(result1, GENERAL_ERROR); - int32_t result2 = service->Finish(testScheduleId1, testSrcRole, testResultCode, testFinalResult); + int32_t result2 = service->Finish(testScheduleId1, testResultCode, testFinalResult); EXPECT_EQ(result2, GENERAL_ERROR); auto scheduleNode1 = MockScheduleNode::CreateWithScheduleId(testScheduleId1); EXPECT_NE(scheduleNode1, nullptr); - EXPECT_CALL(*scheduleNode1, ContinueSchedule(_, _, _, _)).WillRepeatedly(Return(false)); + EXPECT_CALL(*scheduleNode1, SendMessage(_, _)).WillRepeatedly(Return(false)); EXPECT_CALL(*scheduleNode1, ContinueSchedule(_, _)).WillRepeatedly(Return(false)); auto scheduleNode2 = MockScheduleNode::CreateWithScheduleId(testScheduleId2); EXPECT_NE(scheduleNode2, nullptr); - EXPECT_CALL(*scheduleNode2, ContinueSchedule(_, _, _, _)).WillRepeatedly(Return(true)); + EXPECT_CALL(*scheduleNode2, SendMessage(_, _)).WillRepeatedly(Return(true)); EXPECT_CALL(*scheduleNode2, ContinueSchedule(_, _)).WillRepeatedly(Return(true)); std::set> scheduleNodeSet; scheduleNodeSet.insert(scheduleNode1); @@ -88,14 +86,14 @@ HWTEST_F(ExecutorMessengerServiceTest, ExecutorMessengerServiceTest002, TestSize EXPECT_NE(context, nullptr); EXPECT_TRUE(ContextPool::Instance().Insert(context)); - result1 = service->SendData(testScheduleId1, testTransNum, testSrcRole, testDstRole, testMsg); + result1 = service->SendData(testScheduleId1, testDstRole, testMsg); EXPECT_EQ(result1, GENERAL_ERROR); - result1 = service->SendData(testScheduleId2, testTransNum, testSrcRole, testDstRole, testMsg); + result1 = service->SendData(testScheduleId2, testDstRole, testMsg); EXPECT_EQ(result1, SUCCESS); - result2 = service->Finish(testScheduleId1, testSrcRole, testResultCode, testFinalResult); + result2 = service->Finish(testScheduleId1, testResultCode, testFinalResult); EXPECT_EQ(result2, GENERAL_ERROR); - result2 = service->Finish(testScheduleId2, testSrcRole, testResultCode, testFinalResult); + result2 = service->Finish(testScheduleId2, testResultCode, testFinalResult); EXPECT_EQ(result2, SUCCESS); EXPECT_TRUE(ContextPool::Instance().Delete(testContextId)); diff --git a/test/unittest/services/src/schedule_node_test.cpp b/test/unittest/services/src/schedule_node_test.cpp index a06431208..8ca69c348 100644 --- a/test/unittest/services/src/schedule_node_test.cpp +++ b/test/unittest/services/src/schedule_node_test.cpp @@ -569,11 +569,8 @@ HWTEST_F(ScheduleNodeTest, ScheduleNodeStartAllInOneUserStopAndEndFailed, TestSi handler->EnsureTask(nullptr); } -HWTEST_F(ScheduleNodeTest, ScheduleNodeTestContinueSchedule, TestSize.Level0) +HWTEST_F(ScheduleNodeTest, ScheduleNodeTestSendMessage, TestSize.Level0) { - ExecutorRole testSrcRole = COLLECTOR; - ExecutorRole testDstRole = COLLECTOR; - uint64_t testTransNum = 58786; std::vector testMsg; constexpr uint32_t EXECUTOR_INDEX = 0xAAAAAAA; @@ -592,11 +589,15 @@ HWTEST_F(ScheduleNodeTest, ScheduleNodeTestContinueSchedule, TestSize.Level0) auto scheduleNode = builder->Build(); EXPECT_NE(scheduleNode, nullptr); - EXPECT_FALSE(scheduleNode->ContinueSchedule(testSrcRole, testDstRole, testTransNum, testMsg)); + ExecutorRole testDstRole = COLLECTOR; + EXPECT_TRUE(scheduleNode->SendMessage(testDstRole, testMsg)); testDstRole = SCHEDULER; scheduleNode = builder->Build(); EXPECT_NE(scheduleNode, nullptr); - EXPECT_TRUE(scheduleNode->ContinueSchedule(testSrcRole, testDstRole, testTransNum, testMsg)); + Attributes attr; + EXPECT_TRUE(attr.SetInt32Value(Attributes::ATTR_TIP_INFO, 40)); + testMsg = attr.Serialize(); + EXPECT_FALSE(scheduleNode->SendMessage(testDstRole, testMsg)); callback = Common::MakeShared(); EXPECT_NE(callback, nullptr); EXPECT_CALL(*callback, OnScheduleProcessed(_, _, _)).Times(1); @@ -604,7 +605,7 @@ HWTEST_F(ScheduleNodeTest, ScheduleNodeTestContinueSchedule, TestSize.Level0) builder->SetAuthType(FACE); scheduleNode = builder->Build(); EXPECT_NE(scheduleNode, nullptr); - EXPECT_TRUE(scheduleNode->ContinueSchedule(testSrcRole, testDstRole, testTransNum, testMsg)); + EXPECT_TRUE(scheduleNode->SendMessage(testDstRole, testMsg)); } } // namespace UserAuth } // namespace UserIam diff --git a/test/unittest/services/src/user_auth_service_test.cpp b/test/unittest/services/src/user_auth_service_test.cpp index 17494a929..b2c483473 100644 --- a/test/unittest/services/src/user_auth_service_test.cpp +++ b/test/unittest/services/src/user_auth_service_test.cpp @@ -463,7 +463,7 @@ static void MockForAuthResourceNode(std::shared_ptr &resourceN EXPECT_NE(finalResult, nullptr); std::vector scheduleResult = {1, 2, 3, 4}; EXPECT_TRUE(finalResult->SetUint8ArrayValue(Attributes::ATTR_RESULT, scheduleResult)); - EXPECT_EQ(messenger->Finish(testScheduleId, ALL_IN_ONE, SUCCESS, finalResult), SUCCESS); + EXPECT_EQ(messenger->Finish(testScheduleId, SUCCESS, finalResult), SUCCESS); return SUCCESS; }); } diff --git a/test/unittest/services/src/user_idm_service_test.cpp b/test/unittest/services/src/user_idm_service_test.cpp index dcf0208ab..3a90ae857 100644 --- a/test/unittest/services/src/user_idm_service_test.cpp +++ b/test/unittest/services/src/user_idm_service_test.cpp @@ -390,7 +390,7 @@ static void MockForIdmResourceNode(std::shared_ptr &resourceNo EXPECT_NE(finalResult, nullptr); std::vector scheduleResult = {1, 2, 3, 4}; EXPECT_TRUE(finalResult->SetUint8ArrayValue(Attributes::ATTR_RESULT, scheduleResult)); - EXPECT_EQ(messenger->Finish(testScheduleId, ALL_IN_ONE, SUCCESS, finalResult), SUCCESS); + EXPECT_EQ(messenger->Finish(testScheduleId, SUCCESS, finalResult), SUCCESS); return SUCCESS; }); }