!182 modify_traceid

Merge pull request !182 from caochuan/modify_trace
This commit is contained in:
openharmony_ci
2024-05-07 11:28:31 +00:00
committed by Gitee
9 changed files with 37 additions and 25 deletions
+2
View File
@@ -58,6 +58,7 @@ ohos_shared_library("drm_framework") {
"-fPIC",
"-Wall",
]
cflags += [ "-DENABLE_DRM_SYSEVENT_CONTROL" ]
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
@@ -89,6 +90,7 @@ ohos_shared_library("drm_framework") {
"hilog:libhilog",
"hisysevent:libhisysevent",
"hitrace:hitrace_meter",
"hitrace:libhitracechain",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
@@ -20,17 +20,24 @@
namespace OHOS {
namespace DrmStandard {
using namespace OHOS::HiviewDFX;
sptr<MediaKeySystemFactoryImpl> MediaKeySystemFactoryImpl::mediaKeySystemFactoryImpl_;
MediaKeySystemFactoryImpl::MediaKeySystemFactoryImpl()
{
DRM_DEBUG_LOG("MediaKeySystemFactoryImpl:0x%{public}06" PRIXPTR "MediaKeySystemFactoryImpl Instances create",
FAKE_POINTER(this));
#ifdef ENABLE_DRM_SYSEVENT_CONTROL
traceId_ = HiTraceChain::Begin("MediaKeySystemFactory", HITRACE_FLAG_DEFAULT);
#endif
Init();
}
MediaKeySystemFactoryImpl::~MediaKeySystemFactoryImpl()
{
DRM_INFO_LOG("MediaKeySystemFactoryImpl::~MediaKeySystemFactoryImpl enter.");
#ifdef ENABLE_DRM_SYSEVENT_CONTROL
HiTraceChain::End(traceId_);
#endif
serviceProxy_ = nullptr;
DRM_INFO_LOG("MediaKeySystemFactoryImpl::~MediaKeySystemFactoryImpl exit.");
deathRecipient_ = nullptr;
@@ -94,7 +101,9 @@ void MediaKeySystemFactoryImpl::Init()
if (!result) {
DRM_ERR_LOG("failed to add deathRecipient");
}
#ifdef ENABLE_DRM_SYSEVENT_CONTROL
HiTraceChain::SetId(traceId_);
#endif
CreateListenerObject();
DRM_INFO_LOG("MediaKeySystemFactoryImpl::Init exit.");
}
@@ -24,6 +24,9 @@
#include "i_mediakeysystemfactory_service.h"
#include "drm_death_recipient.h"
#include "drm_log.h"
#ifdef ENABLE_DRM_SYSEVENT_CONTROL
#include "hitrace/tracechain.h"
#endif
namespace OHOS {
namespace DrmStandard {
@@ -49,6 +52,9 @@ private:
sptr<OHOS::DrmStandard::IMediaKeySystemFactoryService> serviceProxy_;
sptr<DrmDeathRecipient> deathRecipient_ = nullptr;
sptr<DrmListenerStub> listenerStub_ = nullptr;
#ifdef ENABLE_DRM_SYSEVENT_CONTROL
HiviewDFX::HiTraceId traceId_;
#endif
};
} // DrmStandard
} // OHOS
@@ -74,7 +74,6 @@ private:
wptr<IMediaKeySessionServiceOperatorsCallback> sessionOperatorsCallback_;
sptr<OHOS::HDI::Drm::V1_0::IMediaKeySession> hdiMediaKeySession_;
StatisticsInfo statisticsInfo_;
HiviewDFX::HiTraceId traceId_;
std::string generationResult_;
std::string mediaKeyType_;
uint32_t generationDuration_;
@@ -87,7 +87,6 @@ private:
std::set<sptr<MediaKeySessionService>> sessionsSet_;
sptr<OHOS::HDI::Drm::V1_0::IMediaKeySystem> hdiKeySystem_;
StatisticsInfo statisticsInfo_;
HiviewDFX::HiTraceId traceId_;
std::string generationResult_;
uint32_t generationDuration_;
};
@@ -24,6 +24,7 @@
namespace OHOS {
namespace DrmStandard {
using namespace OHOS::HiviewDFX;
static std::mutex sessionMutex_;
MediaKeySessionService::MediaKeySessionService(sptr<OHOS::HDI::Drm::V1_0::IMediaKeySession> hdiMediaKeySession)
@@ -31,7 +32,6 @@ MediaKeySessionService::MediaKeySessionService(sptr<OHOS::HDI::Drm::V1_0::IMedia
DRM_DEBUG_LOG("MediaKeySessionService::MediaKeySessionService.");
sessionOperatorsCallback_ = nullptr;
hdiMediaKeySession_ = hdiMediaKeySession;
traceId_ = HiTraceChain::Begin("hiPlayerImpl", HITRACE_FLAG_DEFAULT);
}
MediaKeySessionService::MediaKeySessionService(sptr<OHOS::HDI::Drm::V1_0::IMediaKeySession> hdiMediaKeySession,
@@ -53,7 +53,6 @@ MediaKeySessionService::~MediaKeySessionService()
if (hdiMediaKeySession_ != nullptr) {
DRM_ERR_LOG("hdiMediaKeySession_ != nullptr");
}
HiTraceChain::End(traceId_);
DRM_INFO_LOG("MediaKeySessionService::~MediaKeySessionService exit.");
}
@@ -129,13 +128,12 @@ int32_t MediaKeySessionService::GenerateMediaKeyRequest(
auto duration = timeAfter - timeBefore;
generationDuration_ = duration.count();
auto callTime = std::chrono::duration_cast<std::chrono::microseconds>(timeBefore.time_since_epoch()).count();
HiTraceChain::SetId(traceId_);
if (ret != DRM_OK) {
generationResult_ = "failed";
DRM_ERR_LOG("MediaKeySessionService::GenerateMediaKeyRequest failed.");
HISYSEVENT_FAULT("DRM_COMMON_FAILURE", "APP_NAME", statisticsInfo_.bundleName, "INSTANCE_ID",
std::to_string(HiTraceChain::GetId().GetChainId()), "ERROR_CODE", ret,
"ERROR_MESG", "GenerateMediaKeyRequest failed", "EXTRA_MESG", "GenerateMediaKeyRequest failed");
"ERROR_MESG", "GenerateMediaKeyRequest failed", "EXTRA_MESG", "");
HISYSEVENT_BEHAVIOR("DRM_LICENSE_DOWNLOAD_INFO", "MODULE", "DRM_SERVICE", "TIME", callTime,
"APP_NAME", statisticsInfo_.bundleName, "INSTANCE_ID", std::to_string(HiTraceChain::GetId().GetChainId()),
"DRM_name", statisticsInfo_.pluginName, "DRM_uuid", statisticsInfo_.pluginUuid,
@@ -167,7 +165,6 @@ int32_t MediaKeySessionService::ProcessMediaKeyResponse(std::vector<uint8_t> &li
auto callTime = std::chrono::duration_cast<std::chrono::microseconds>(timeBefore.time_since_epoch()).count();
auto duration = timeAfter - timeBefore;
auto processDuration = duration.count();
HiTraceChain::SetId(traceId_);
if (ret != DRM_OK) {
DRM_ERR_LOG("MediaKeySessionService::ProcessMediaKeyResponse failed.");
std::string responseString = std::string(reinterpret_cast<const char*>(licenseResponse.data()),
@@ -50,9 +50,15 @@ MediaDecryptModuleService::~MediaDecryptModuleService()
meta->SetData(Media::Tag::DRM_ERROR_CODE, errCode_);
meta->SetData(Media::Tag::DRM_ERROR_MESG, errMessage_);
meta->SetData(Media::Tag::DRM_DECRYPT_TIMES, decryptStatustics_.decryptTimes);
meta->SetData(Media::Tag::DRM_DECRYPT_AVG_SIZE, decryptStatustics_.decryptSumSize/decryptStatustics_.decryptTimes);
meta->SetData(Media::Tag::DRM_DECRYPT_AVG_DURATION,
decryptStatustics_.decryptSumDuration/decryptStatustics_.decryptTimes);
if (decryptStatustics_.decryptTimes != 0) {
meta->SetData(Media::Tag::DRM_DECRYPT_AVG_SIZE,
decryptStatustics_.decryptSumSize/decryptStatustics_.decryptTimes);
meta->SetData(Media::Tag::DRM_DECRYPT_AVG_DURATION,
decryptStatustics_.decryptSumDuration/decryptStatustics_.decryptTimes);
} else {
meta->SetData(Media::Tag::DRM_DECRYPT_AVG_SIZE, 0);
meta->SetData(Media::Tag::DRM_DECRYPT_AVG_DURATION, 0);
}
meta->SetData(Media::Tag::DRM_DECRYPT_MAX_SIZE, decryptStatustics_.decryptMaxSize);
meta->SetData(Media::Tag::DRM_DECRYPT_MAX_DURATION, decryptStatustics_.decryptMaxDuration);
DrmEvent::GetInstance().AppendMediaInfo(meta);
@@ -29,12 +29,12 @@
namespace OHOS {
namespace DrmStandard {
using namespace OHOS::HiviewDFX;
MediaKeySystemService::MediaKeySystemService(sptr<OHOS::HDI::Drm::V1_0::IMediaKeySystem> hdiKeySystem)
{
DRM_DEBUG_LOG("MediaKeySystemService::MediaKeySystemService enter.");
keySystemOperatoersCallback_ = nullptr;
hdiKeySystem_ = hdiKeySystem;
traceId_ = HiTraceChain::Begin("hiPlayerImpl", HITRACE_FLAG_DEFAULT);
}
MediaKeySystemService::MediaKeySystemService(sptr<OHOS::HDI::Drm::V1_0::IMediaKeySystem> hdiKeySystem,
@@ -54,7 +54,6 @@ MediaKeySystemService::~MediaKeySystemService()
if (hdiKeySystem_ != nullptr) {
DRM_ERR_LOG("hdiKeySystem != nullptr");
}
HiTraceChain::End(traceId_);
}
int32_t MediaKeySystemService::CloseMediaKeySystemServiceByCallback()
@@ -115,7 +114,6 @@ int32_t MediaKeySystemService::GenerateKeySystemRequest(std::vector<uint8_t> &re
"version:%{public}s,\n", statisticsInfo_.pluginName.c_str(), statisticsInfo_.pluginUuid.c_str(),
statisticsInfo_.bundleName.c_str(), statisticsInfo_.vendorName.c_str(), statisticsInfo_.versionName.c_str());
int32_t ret = DRM_OK;
HiTraceChain::SetId(traceId_);
auto timeBefore = std::chrono::system_clock::now();
ret = hdiKeySystem_->GenerateKeySystemRequest(defaultUrl, request);
auto timeAfter = std::chrono::system_clock::now();
@@ -126,7 +124,7 @@ int32_t MediaKeySystemService::GenerateKeySystemRequest(std::vector<uint8_t> &re
DRM_ERR_LOG("MediaKeySystemService::GenerateKeySystemRequest failed.");
HISYSEVENT_FAULT("DRM_COMMON_FAILURE", "APP_NAME", statisticsInfo_.bundleName, "INSTANCE_ID",
std::to_string(HiTraceChain::GetId().GetChainId()), "ERROR_CODE", ret,
"ERROR_MESG", "CreateMediaKeySystem failed", "EXTRA_MESG", "CreateMediaKeySystem failed");
"ERROR_MESG", "CreateMediaKeySystem failed", "EXTRA_MESG", "");
auto callTime = std::chrono::duration_cast<std::chrono::microseconds>(timeBefore.time_since_epoch()).count();
HISYSEVENT_BEHAVIOR("DRM_CERTIFICATE_DOWNLOAD_INFO", "MODULE", "DRM_SERVICE", "TIME", callTime,
"APP_NAME", statisticsInfo_.bundleName, "INSTANCE_ID", std::to_string(HiTraceChain::GetId().GetChainId()),
@@ -136,7 +134,7 @@ int32_t MediaKeySystemService::GenerateKeySystemRequest(std::vector<uint8_t> &re
"SERVER_COST_DURATION", 0, "SERVER_RESULT", "");
return ret;
}
generationResult_ = "seccess";
generationResult_ = "success";
DRM_INFO_LOG("MediaKeySystemService::GenerateKeySystemRequest exit.");
return ret;
}
@@ -155,7 +153,6 @@ int32_t MediaKeySystemService::ProcessKeySystemResponse(const std::vector<uint8_
auto callTime = std::chrono::duration_cast<std::chrono::microseconds>(timeBefore.time_since_epoch()).count();
auto duration = timeAfter - timeBefore;
auto processDuration = duration.count();
HiTraceChain::SetId(traceId_);
if (ret != DRM_OK) {
DRM_ERR_LOG("MediaKeySystemService::ProcessKeySystemResponse failed.");
std::string responseString = std::string(reinterpret_cast<const char*>(response.data()), response.size());
@@ -241,7 +238,6 @@ int32_t MediaKeySystemService::GetConfigurationByteArray(std::string &configName
int32_t MediaKeySystemService::CreateMediaKeySession(IMediaKeySessionService::ContentProtectionLevel securityLevel,
sptr<IMediaKeySessionService> &keySessionProxy)
{
HiTraceChain::SetId(traceId_);
DrmTrace trace("MediaKeySystemService::CreateMediaKeySession");
DRM_INFO_LOG("MediaKeySystemService::CreateMediaKeySession enter, securityLevel:%{public}d.", securityLevel);
DRM_DEBUG_LOG("pluginName:%{public}s, pluginUuid:%{public}s\nbundleName:%{public}s,\nvendor:%{public}s,\n"
@@ -257,7 +253,7 @@ int32_t MediaKeySystemService::CreateMediaKeySession(IMediaKeySessionService::Co
DRM_ERR_LOG("hdiKeySystem_ CreateMediaKeySession failed.");
HISYSEVENT_FAULT("DRM_COMMON_FAILURE", "APP_NAME", statisticsInfo_.bundleName, "INSTANCE_ID",
std::to_string(HiTraceChain::GetId().GetChainId()), "ERROR_CODE", DRM_SERVICE_ERROR,
"ERROR_MESG", "CreateMediaKeySession failed", "EXTRA_MESG", "CreateMediaKeySystem failed");
"ERROR_MESG", "CreateMediaKeySession failed", "EXTRA_MESG", "");
return DRM_SERVICE_ERROR;
}
keySessionService = new (std::nothrow) MediaKeySessionService(hdiMediaKeySession, statisticsInfo_);
@@ -265,7 +261,7 @@ int32_t MediaKeySystemService::CreateMediaKeySession(IMediaKeySessionService::Co
DRM_ERR_LOG("MediaKeySystemService::CreateMediaKeySession allocation failed.");
HISYSEVENT_FAULT("DRM_COMMON_FAILURE", "APP_NAME", statisticsInfo_.bundleName, "INSTANCE_ID",
std::to_string(HiTraceChain::GetId().GetChainId()), "ERROR_CODE", DRM_ALLOC_ERROR,
"ERROR_MESG", "CreateMediaKeySession failed", "EXTRA_MESG", "CreateMediaKeySystem failed");
"ERROR_MESG", "CreateMediaKeySession failed", "EXTRA_MESG", "");
return DRM_ALLOC_ERROR;
}
keySessionService->SetMediaKeySessionServiceOperatorsCallback(this);
@@ -33,15 +33,12 @@
namespace OHOS {
namespace DrmStandard {
using namespace OHOS::HiviewDFX;
HiviewDFX::HiTraceId traceId;
REGISTER_SYSTEM_ABILITY_BY_ID(MediaKeySystemFactoryService, MEDIA_KEY_SYSTEM_SERVICE_ID, true)
MediaKeySystemFactoryService::MediaKeySystemFactoryService(int32_t systemAbilityId, bool runOnCreate)
: SystemAbility(systemAbilityId, runOnCreate), drmHostManager_(nullptr)
{
traceId = HiTraceChain::Begin("hiPlayerImpl", HITRACE_FLAG_DEFAULT);
HiTraceChain::SetId(traceId);
}
MediaKeySystemFactoryService::~MediaKeySystemFactoryService()
@@ -136,7 +133,7 @@ int32_t MediaKeySystemFactoryService::CreateMediaKeySystem(std::string &uuid,
DRM_ERR_LOG("MediaKeySystemFactoryService:: drmHostManager_ return hdiMediaKeySystem nullptr");
HISYSEVENT_FAULT("DRM_COMMON_FAILURE", "APP_NAME", GetClientBundleName(IPCSkeleton::GetCallingUid()),
"INSTANCE_ID", std::to_string(HiTraceChain::GetId().GetChainId()), "ERROR_CODE", DRM_SERVICE_ERROR,
"ERROR_MESG", "CreateMediaKeySystem failed", "EXTRA_MESG", "CreateMediaKeySystem failed");
"ERROR_MESG", "CreateMediaKeySystem failed", "EXTRA_MESG", "");
return DRM_SERVICE_ERROR;
}
StatisticsInfo statisticsInfo;
@@ -288,6 +285,7 @@ int32_t MediaKeySystemFactoryService::WriteDumpInfo(int32_t fd, std::string &dum
iter->GetStatistics(metrics);
DumpMetricsInfo(dumpString, metrics);
dumpString += "\n";
metrics.clear();
}
}
if (fd != -1) {
@@ -304,7 +302,7 @@ int32_t MediaKeySystemFactoryService::DumpMetricsInfo(std::string &dumpString,
std::vector<IMediaKeySystemService::MetircKeyValue> metrics)
{
for (auto &iter : metrics) {
if (iter.name == currentSessionNum || iter.name == decryptNumber || iter.name == errorDecryptNumber) {
if (iter.name == currentSessionNum || iter.name == decryptTimes || iter.name == errorDecryptNumber) {
dumpString += iter.name + ":" + iter.value + " ";
}
}