From 060e14c3697ffb9e10f5c267a295ddc47c449cb2 Mon Sep 17 00:00:00 2001 From: baoyang Date: Wed, 22 Jan 2025 08:06:57 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!235=20:?= =?UTF-8?q?=20add=20retry'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/sec_comp_client.h | 3 -- .../src/sec_comp_client.cpp | 28 +------------------ .../security_component/src/sec_comp_proxy.cpp | 9 +++--- .../sa/sa_main/sec_comp_stub.cpp | 2 -- 4 files changed, 6 insertions(+), 36 deletions(-) diff --git a/frameworks/inner_api/security_component/include/sec_comp_client.h b/frameworks/inner_api/security_component/include/sec_comp_client.h index 134c2dd..e4c91c4 100644 --- a/frameworks/inner_api/security_component/include/sec_comp_client.h +++ b/frameworks/inner_api/security_component/include/sec_comp_client.h @@ -63,9 +63,6 @@ private: bool readyFlag_ = false; std::condition_variable secComCon_; std::mutex proxyMutex_; - bool secCompSAFlag_ = false; - std::condition_variable secCompSACon_; - std::mutex secCompSAMutex_; sptr proxy_ = nullptr; sptr serviceDeathObserver_ = nullptr; }; diff --git a/frameworks/inner_api/security_component/src/sec_comp_client.cpp b/frameworks/inner_api/security_component/src/sec_comp_client.cpp index 2f5ae80..b7815d6 100644 --- a/frameworks/inner_api/security_component/src/sec_comp_client.cpp +++ b/frameworks/inner_api/security_component/src/sec_comp_client.cpp @@ -19,10 +19,7 @@ #include "sec_comp_load_callback.h" #include "sec_comp_log.h" #include "sec_comp_proxy.h" -#include "sys_binder.h" #include "tokenid_kit.h" -#include -#include namespace OHOS { namespace Security { @@ -30,10 +27,6 @@ namespace SecurityComponent { namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompClient"}; static std::mutex g_instanceMutex; -static constexpr int32_t SENDREQ_FAIL_ERR = 32; -static const std::vector RETRY_CODE_LIST = { - SC_SERVICE_ERROR_SERVICE_NOT_EXIST, BR_DEAD_REPLY, BR_FAILED_REPLY, SENDREQ_FAIL_ERR }; -static const int32_t SA_DIED_TIME_OUT = 500; } // namespace SecCompClient& SecCompClient::GetInstance() @@ -71,17 +64,7 @@ int32_t SecCompClient::RegisterSecurityComponent(SecCompType type, return SC_SERVICE_ERROR_VALUE_INVALID; } - auto res = proxy->RegisterSecurityComponent(type, componentInfo, scId); - if (std::find(RETRY_CODE_LIST.begin(), RETRY_CODE_LIST.end(), res) != RETRY_CODE_LIST.end()) { - std::unique_lock lock(secCompSAMutex_); - auto waitStatus = secCompSACon_.wait_for(lock, std::chrono::milliseconds(SA_DIED_TIME_OUT), - [this]() { return secCompSAFlag_; }); - if (waitStatus) { - proxy = GetProxy(true); - return proxy->RegisterSecurityComponent(type, componentInfo, scId); - } - } - return res; + return proxy->RegisterSecurityComponent(type, componentInfo, scId); } int32_t SecCompClient::UpdateSecurityComponent(int32_t scId, const std::string& componentInfo) @@ -254,21 +237,12 @@ void SecCompClient::OnRemoteDiedHandle() { SC_LOG_ERROR(LABEL, "Remote service died"); std::unique_lock lock(proxyMutex_); - auto remoteObj = proxy_->AsObject(); - if ((remoteObj != nullptr) && (serviceDeathObserver_ != nullptr)) { - remoteObj->RemoveDeathRecipient(serviceDeathObserver_); - } proxy_ = nullptr; serviceDeathObserver_ = nullptr; { std::unique_lock lock1(cvLock_); readyFlag_ = false; } - { - std::unique_lock lock1(secCompSAMutex_); - secCompSAFlag_ = true; - secCompSACon_.notify_one(); - } } void SecCompClient::GetProxyFromRemoteObject(const sptr& remoteObject) diff --git a/frameworks/inner_api/security_component/src/sec_comp_proxy.cpp b/frameworks/inner_api/security_component/src/sec_comp_proxy.cpp index f8a897c..7cd7798 100644 --- a/frameworks/inner_api/security_component/src/sec_comp_proxy.cpp +++ b/frameworks/inner_api/security_component/src/sec_comp_proxy.cpp @@ -70,16 +70,17 @@ int32_t SecCompProxy::RegisterSecurityComponent(SecCompType type, int32_t requestResult = remote->SendRequest( static_cast(SecurityComponentServiceInterfaceCode::REGISTER_SECURITY_COMPONENT), data, reply, option); - if (requestResult != SC_OK) { - SC_LOG_ERROR(LABEL, "Register request failed, result: %{public}d.", requestResult); - return requestResult; - } if (!SecCompEnhanceAdapter::EnhanceClientDeserialize(reply, deserializedReply)) { SC_LOG_ERROR(LABEL, "Register deserialize session info failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } + if (requestResult != SC_OK) { + SC_LOG_ERROR(LABEL, "Register request failed, result: %{public}d.", requestResult); + return requestResult; + } + int32_t res; if (!deserializedReply.ReadInt32(res)) { SC_LOG_ERROR(LABEL, "Register read res failed."); diff --git a/services/security_component_service/sa/sa_main/sec_comp_stub.cpp b/services/security_component_service/sa/sa_main/sec_comp_stub.cpp index c3111f1..198b087 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_stub.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_stub.cpp @@ -15,7 +15,6 @@ #include "sec_comp_stub.h" #include "accesstoken_kit.h" -#include "delay_exit_task.h" #include "ipc_skeleton.h" #include "sec_comp_click_event_parcel.h" #include "sec_comp_enhance_adapter.h" @@ -53,7 +52,6 @@ int32_t SecCompStub::OnRemoteRequest( int32_t SecCompStub::RegisterSecurityComponentInner(MessageParcel& data, MessageParcel& reply) { - SecurityComponent::DelayExitTask::GetInstance().Stop(); MessageParcel deserializedData; if (!SecCompEnhanceAdapter::EnhanceSrvDeserialize(data, deserializedData, reply)) { SC_LOG_ERROR(LABEL, "Register deserialize session info failed"); -- Gitee