!9610 wantAgent增加超时监控

Merge pull request !9610 from panyue/master
This commit is contained in:
openharmony_ci 2024-07-29 01:57:56 +00:00 committed by Gitee
commit b16b996ca7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 33 additions and 2 deletions

View File

@ -76,6 +76,7 @@ ohos_shared_library("wantagent_innerkits") {
external_deps = [
"ability_base:want",
"c_utils:utils",
"hicollie:libhicollie",
"hilog:libhilog",
"hitrace:hitrace_meter",
"ipc:ipc_core",

View File

@ -24,10 +24,14 @@
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "xcollie/xcollie.h"
#include "xcollie/xcollie_define.h"
using namespace OHOS::AbilityRuntime;
namespace OHOS {
namespace AAFwk {
const unsigned int XCOLLIE_TIMEOUT = 10;
WantAgentClient &WantAgentClient::GetInstance()
{
static WantAgentClient client;
@ -150,6 +154,12 @@ ErrCode WantAgentClient::GetPendingWantUserId(const sptr<IWantSender> &target, i
ErrCode WantAgentClient::GetPendingWantBundleName(const sptr<IWantSender> &target, std::string &bundleName)
{
int id = HiviewDFX::XCollie::GetInstance().SetTimer(
"OHOS::AAFwk::WantAgentClient::GetPendingWantBundleName",
XCOLLIE_TIMEOUT,
nullptr,
nullptr,
HiviewDFX::XCOLLIE_FLAG_LOG | HiviewDFX::XCOLLIE_FLAG_RECOVERY);
CHECK_POINTER_AND_RETURN(target, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT);
auto abms = GetAbilityManager();
CHECK_POINTER_AND_RETURN(abms, ERR_ABILITY_RUNTIME_EXTERNAL_SERVICE_BUSY);
@ -160,6 +170,7 @@ ErrCode WantAgentClient::GetPendingWantBundleName(const sptr<IWantSender> &targe
return error;
}
bundleName = Str16ToStr8(reply.ReadString16());
HiviewDFX::XCollie::GetInstance().CancelTimer(id);
return ERR_OK;
}
@ -180,6 +191,12 @@ ErrCode WantAgentClient::GetPendingWantCode(const sptr<IWantSender> &target, int
ErrCode WantAgentClient::GetPendingWantType(sptr<IWantSender> target, int32_t &type)
{
int id = HiviewDFX::XCollie::GetInstance().SetTimer(
"OHOS::AAFwk::WantAgentClient::GetPendingWantType",
XCOLLIE_TIMEOUT,
nullptr,
nullptr,
HiviewDFX::XCOLLIE_FLAG_LOG|HiviewDFX::XCOLLIE_FLAG_RECOVERY);
CHECK_POINTER_AND_RETURN(target, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT);
auto abms = GetAbilityManager();
CHECK_POINTER_AND_RETURN(abms, ERR_ABILITY_RUNTIME_EXTERNAL_SERVICE_BUSY);
@ -191,6 +208,7 @@ ErrCode WantAgentClient::GetPendingWantType(sptr<IWantSender> target, int32_t &t
}
type = reply.ReadInt32();
type < 0 ? type = 0 : type;
HiviewDFX::XCollie::GetInstance().CancelTimer(id);
return ERR_OK;
}

View File

@ -24,11 +24,16 @@
#include "want_agent_log_wrapper.h"
#include "want_sender_info.h"
#include "want_sender_interface.h"
#include "xcollie/xcollie.h"
#include "xcollie/xcollie_define.h"
using namespace OHOS::AAFwk;
using namespace OHOS::AppExecFwk;
using namespace OHOS::AbilityRuntime;
namespace OHOS::AbilityRuntime::WantAgent {
const unsigned int XCOLLIE_TIMEOUT = 10;
WantAgentHelper::WantAgentHelper()
{}
@ -474,11 +479,18 @@ ErrCode WantAgentHelper::GetType(const std::shared_ptr<WantAgent> &agent, int32_
ErrCode WantAgentHelper::GetWant(const std::shared_ptr<WantAgent> &agent, std::shared_ptr<AAFwk::Want> &want)
{
int id = HiviewDFX::XCollie::GetInstance().SetTimer(
"OHOS::AbilityRuntime::WantAgent::WantAgentHelper::GetWant",
XCOLLIE_TIMEOUT,
nullptr,
nullptr,
HiviewDFX::XCOLLIE_FLAG_LOG|HiviewDFX::XCOLLIE_FLAG_RECOVERY);
if ((agent == nullptr) || (agent->GetPendingWant() == nullptr)) {
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgent or PendingWant invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT;
}
return agent->GetPendingWant()->GetWant(agent->GetPendingWant()->GetTarget(), want);
ErrCode result = agent->GetPendingWant()->GetWant(agent->GetPendingWant()->GetTarget(), want);
HiviewDFX::XCollie::GetInstance().CancelTimer(id);
return result;
}
} // namespace OHOS::AbilityRuntime::WantAgent