mirror of
https://github.com/openharmony/multimedia_drm_framework.git
synced 2026-07-21 04:35:21 -04:00
@@ -56,7 +56,7 @@ ohos_unittest("drm_framework_capi_unittest_v1_0") {
|
||||
cflags += [ "-DENABLE_DRM_SYSEVENT_CONTROL" ]
|
||||
sources = [
|
||||
"../../../../frameworks/native/test/common/src/http.cpp",
|
||||
"../../../../frameworks/native/test/unittest/src/drm_framework_unittes_v2.cpp",
|
||||
"../../../../frameworks/native/test/unittest/src/drm_framework_dfx_unittest.cpp",
|
||||
"../../../../frameworks/native/test/unittest/src/drm_framework_unittest.cpp",
|
||||
"../../../../services/utils/drm_dfx.cpp",
|
||||
]
|
||||
@@ -72,6 +72,7 @@ ohos_unittest("drm_framework_capi_unittest_v1_0") {
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hidumper:lib_dump_usage",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
|
||||
+66
-16
@@ -17,6 +17,7 @@
|
||||
#include "cstdio"
|
||||
#include "cstdlib"
|
||||
#include "drm_dfx.h"
|
||||
#include "drm_dfx_utils.h"
|
||||
#include <securec.h>
|
||||
#include "native_drm_common.h"
|
||||
#include "native_drm_err.h"
|
||||
@@ -106,34 +107,82 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_Unittest_GetMediaKeySystemsAbnorm2, TestSize.
|
||||
EXPECT_NE(errNo, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_HiSysWriteFault, TestSize.Level0)
|
||||
HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_ReportFaultEvent, TestSize.Level0)
|
||||
{
|
||||
int32_t errNo = DRM_ERR_UNKNOWN;
|
||||
errNo = DrmEvent::HiSysWriteFault("DRM_COMMON_FAILURE", "APP_NAME", "bundleName", "INSTANCE_ID",
|
||||
"GetChainId", "ERROR_CODE", 0, "ERROR_MESG", "GenerateMediaKeyRequest failed",
|
||||
"EXTRA_MESG", "GenerateMediaKeyRequest failed");
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
uint32_t errorCode = 0;
|
||||
std::string errorMesg = "GenerateMediaKeyRequest failed";
|
||||
std::string extraMesg = "";
|
||||
ReportFaultEvent(errorCode, errorMesg, extraMesg);
|
||||
}
|
||||
|
||||
HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_HiSysWriteBehavior, TestSize.Level0)
|
||||
HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_ReportDecryptionFaultEvent, TestSize.Level0)
|
||||
{
|
||||
int32_t errNo = DRM_ERR_UNKNOWN;
|
||||
errNo = DrmEvent::HiSysWriteBehavior("DRM_SERVICE_INFO", "MODULE", "DRM_SERVICE", "TIME", 1, "SERVICE_NAME",
|
||||
"DRM_OEM_SERVICE", "ACTION", "start", "MEMORY", 1);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
uint32_t errorCode = 0;
|
||||
std::string errorMesg = "Decryption failed";
|
||||
std::string decryptAlgo = "decryptAlgo";
|
||||
std::string decryptKeyid = "decryptKeyid";
|
||||
std::string decryptIv = "decryptIv";
|
||||
ReportDecryptionFaultEvent(errorCode, errorMesg, decryptAlgo, decryptKeyid, decryptIv);
|
||||
}
|
||||
|
||||
HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_ReportServiceBehaviorEvent, TestSize.Level0)
|
||||
{
|
||||
std::string serviceName = "DRM_OEM_SERVICE";
|
||||
std::string action = "start";
|
||||
ReportServiceBehaviorEvent(serviceName, action);
|
||||
}
|
||||
|
||||
HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_ReportLicenseBehaviorEvent, TestSize.Level0)
|
||||
{
|
||||
std::string mediaKeyType = "keytype";
|
||||
std::string generationResult = "success";
|
||||
std::string processResult = "success";
|
||||
uint32_t generationDuration = 10;
|
||||
uint32_t processDuration = 1;
|
||||
struct StatisticsInfo statisticsInfo = {
|
||||
"123123",
|
||||
"clearplay",
|
||||
"vendor",
|
||||
"clearplay_v1",
|
||||
"bundleName",
|
||||
};
|
||||
ReportLicenseBehaviorEvent(statisticsInfo, mediaKeyType, generationDuration, generationResult,
|
||||
processDuration, processResult);
|
||||
}
|
||||
|
||||
HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_ReportCertificateBehaviorEvent, TestSize.Level0)
|
||||
{
|
||||
std::string mediaKeyType = "keytype";
|
||||
std::string generationResult = "success";
|
||||
std::string processResult = "success";
|
||||
uint32_t generationDuration = 10;
|
||||
uint32_t processDuration = 1;
|
||||
uint32_t callServerTime = 1;
|
||||
uint32_t serverCostDuration = 19;
|
||||
std::string serverResult = "serverResult";
|
||||
struct StatisticsInfo statisticsInfo = {
|
||||
"123123",
|
||||
"clearplay",
|
||||
"vendor",
|
||||
"clearplay_v1",
|
||||
"bundleName",
|
||||
};
|
||||
ReportCertificateBehaviorEvent(statisticsInfo, generationDuration, generationResult, processDuration,
|
||||
"GenerateKeySystemRequest failed", callServerTime, serverCostDuration, serverResult);
|
||||
}
|
||||
|
||||
HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_HiSysWriteStatistic, TestSize.Level0)
|
||||
{
|
||||
int32_t errNo = DRM_ERR_UNKNOWN;
|
||||
int32_t uid = 324442;
|
||||
errNo = DrmEvent::GetInstance().CreateMediaInfo(uid);
|
||||
int32_t instanceId = 324442;
|
||||
errNo = DrmEvent::GetInstance().CreateMediaInfo(uid, instanceId);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
std::shared_ptr<OHOS::Media::Meta> meta = std::make_shared<Media::Meta>();
|
||||
meta->SetData(Media::Tag::DRM_ERROR_MESG, "errMessage");
|
||||
errNo = DrmEvent::GetInstance().AppendMediaInfo(meta);
|
||||
errNo = DrmEvent::GetInstance().AppendMediaInfo(meta, instanceId);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = DrmEvent::GetInstance().ReportMediaInfo();
|
||||
errNo = DrmEvent::GetInstance().ReportMediaInfo(instanceId);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
|
||||
@@ -141,9 +190,10 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_HiSysWriteStatisticAbNormal, TestSiz
|
||||
{
|
||||
int32_t errNo = DRM_ERR_UNKNOWN;
|
||||
int32_t uid = 324442;
|
||||
DrmEvent::GetInstance().CreateMediaInfo(uid);
|
||||
int32_t instanceId = 324442;
|
||||
DrmEvent::GetInstance().CreateMediaInfo(uid, instanceId);
|
||||
std::shared_ptr<OHOS::Media::Meta> meta = std::make_shared<Media::Meta>();
|
||||
errNo = DrmEvent::GetInstance().AppendMediaInfo(meta);
|
||||
errNo = DrmEvent::GetInstance().AppendMediaInfo(meta, instanceId);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
}
|
||||
} // DrmStandard
|
||||
@@ -33,7 +33,7 @@ using namespace OHOS::HDI::Drm::V1_0;
|
||||
using namespace OHOS::HDI;
|
||||
struct DecryptStatustics {
|
||||
uint32_t decryptTimes = 0;
|
||||
uint32_t decryptSumSize = 0;
|
||||
uint64_t decryptSumSize = 0;
|
||||
uint32_t decryptSumDuration = 0;
|
||||
uint32_t decryptMaxSize = 0;
|
||||
uint32_t decryptMaxDuration = 0;
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
void SetDrmBufferInfo(OHOS::HDI::Drm::V1_0::DrmBuffer* drmSrcBuffer, OHOS::HDI::Drm::V1_0::DrmBuffer* drmDstBuffer,
|
||||
IMediaDecryptModuleService::DrmBuffer &srcBuffer, IMediaDecryptModuleService::DrmBuffer &dstBuffer,
|
||||
uint32_t bufLen);
|
||||
void ReportDecryptionStatisticEvent();
|
||||
uint32_t CalculateTimeDiff(std::chrono::system_clock::time_point timeBefore,
|
||||
std::chrono::system_clock::time_point timeAfter);
|
||||
private:
|
||||
@@ -59,6 +60,7 @@ private:
|
||||
DecryptStatustics decryptStatustics_;
|
||||
int32_t errCode_;
|
||||
std::string errMessage_;
|
||||
uint64_t instanceId_;
|
||||
};
|
||||
} // DrmStandard
|
||||
} // OHOS
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "drm_dfx_utils.h"
|
||||
#include "drm_log.h"
|
||||
#include "drm_error_code.h"
|
||||
#include "dump_usage.h"
|
||||
#include "napi_param_utils.h"
|
||||
#include "drm_host_manager.h"
|
||||
|
||||
@@ -86,12 +85,7 @@ void DrmHostManager::StopServiceThread()
|
||||
}
|
||||
loadedLibs.clear();
|
||||
|
||||
OHOS::HiviewDFX::DumpUsage dumpUse;
|
||||
uint32_t memoryUsage = dumpUse.GetPss(getpid());
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto currentTime = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
|
||||
HISYSEVENT_BEHAVIOR("DRM_SERVICE_INFO", "MODULE", "DRM_SERVICE", "TIME", currentTime, "SERVICE_NAME",
|
||||
"DRM_OEM_SERVICE", "ACTION", "end", "MEMORY", memoryUsage);
|
||||
ReportServiceBehaviorEvent("DRM_OEM_SERVICE", "end");
|
||||
DRM_INFO_LOG("DrmHostManager::StopServiceThread exit.");
|
||||
}
|
||||
|
||||
@@ -211,12 +205,7 @@ void DrmHostManager::ServiceThreadMain()
|
||||
}
|
||||
}
|
||||
}
|
||||
OHOS::HiviewDFX::DumpUsage dumpUse;
|
||||
uint32_t memoryUsage = dumpUse.GetPss(getpid());
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto currentTime = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
|
||||
HISYSEVENT_BEHAVIOR("DRM_SERVICE_INFO", "MODULE", "DRM_SERVICE", "TIME", currentTime, "SERVICE_NAME",
|
||||
"DRM_OEM_SERVICE", "ACTION", "start", "MEMORY", memoryUsage);
|
||||
ReportServiceBehaviorEvent("DRM_OEM_SERVICE", "start");
|
||||
DRM_INFO_LOG("DrmHostManager::ServiceThreadMain exit.");
|
||||
}
|
||||
|
||||
|
||||
@@ -127,19 +127,12 @@ int32_t MediaKeySessionService::GenerateMediaKeyRequest(
|
||||
auto timeAfter = std::chrono::system_clock::now();
|
||||
auto duration = timeAfter - timeBefore;
|
||||
generationDuration_ = duration.count();
|
||||
auto callTime = std::chrono::duration_cast<std::chrono::microseconds>(timeBefore.time_since_epoch()).count();
|
||||
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", "");
|
||||
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,
|
||||
"CLIENT_VERSION", statisticsInfo_.versionName, "LICENSE_TYPE", mediaKeyType_,
|
||||
"GENERATION_DURATION", generationDuration_, "GENERATION_RESULT", generationResult_,
|
||||
"PROCESS_DURATION", 0, "PROCESS_RESULT", "generation failed");
|
||||
ReportFaultEvent(ret, "GenerateMediaKeyRequest failed", "");
|
||||
ReportLicenseBehaviorEvent(statisticsInfo_, mediaKeyType_, generationDuration_, generationResult_, 0,
|
||||
"GenerateMediaKeyRequest failed");
|
||||
return ret;
|
||||
}
|
||||
generationResult_ = "success";
|
||||
@@ -162,31 +155,20 @@ int32_t MediaKeySessionService::ProcessMediaKeyResponse(std::vector<uint8_t> &li
|
||||
auto timeBefore = std::chrono::system_clock::now();
|
||||
ret = hdiMediaKeySession_->ProcessMediaKeyResponse(licenseResponse, licenseId);
|
||||
auto timeAfter = std::chrono::system_clock::now();
|
||||
auto callTime = std::chrono::duration_cast<std::chrono::microseconds>(timeBefore.time_since_epoch()).count();
|
||||
auto duration = timeAfter - timeBefore;
|
||||
auto processDuration = duration.count();
|
||||
if (ret != DRM_OK) {
|
||||
DRM_ERR_LOG("MediaKeySessionService::ProcessMediaKeyResponse failed.");
|
||||
std::string responseString = std::string(reinterpret_cast<const char*>(licenseResponse.data()),
|
||||
licenseResponse.size());
|
||||
HISYSEVENT_FAULT("DRM_COMMON_FAILURE", "APP_NAME", statisticsInfo_.bundleName, "INSTANCE_ID",
|
||||
std::to_string(HiTraceChain::GetId().GetChainId()), "ERROR_CODE", ret,
|
||||
"ERROR_MESG", "ProcessMediaKeyResponse failed", "EXTRA_MESG", responseString);
|
||||
|
||||
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, "CLIENT_VERSION",
|
||||
statisticsInfo_.versionName, "LICENSE_TYPE", mediaKeyType_,
|
||||
"GENERATION_DURATION", generationDuration_, "GENERATION_RESULT", generationResult_, "PROCESS_DURATION",
|
||||
processDuration, "PROCESS_RESULT", "failed");
|
||||
ReportFaultEvent(ret, "ProcessMediaKeyResponse failed", responseString);
|
||||
ReportLicenseBehaviorEvent(statisticsInfo_, mediaKeyType_, generationDuration_, generationResult_,
|
||||
processDuration, "failed");
|
||||
return ret;
|
||||
}
|
||||
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, "CLIENT_VERSION",
|
||||
statisticsInfo_.versionName, "LICENSE_TYPE", mediaKeyType_,
|
||||
"GENERATION_DURATION", generationDuration_, "GENERATION_RESULT", generationResult_, "PROCESS_DURATION",
|
||||
processDuration, "PROCESS_RESULT", "success");
|
||||
ReportLicenseBehaviorEvent(statisticsInfo_, mediaKeyType_, generationDuration_, generationResult_,
|
||||
processDuration, "success");
|
||||
DRM_INFO_LOG("MediaKeySessionService::ProcessMediaKeyResponse exit.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ MediaDecryptModuleService::MediaDecryptModuleService(
|
||||
DRM_DEBUG_LOG("MediaDecryptModuleService::MediaDecryptModuleService");
|
||||
hdiMediaDecryptModule_ = hdiMediaDecryptModule;
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
DrmEvent::GetInstance().CreateMediaInfo(uid);
|
||||
instanceId_ = HiTraceChain::GetId().GetChainId();
|
||||
DrmEvent::GetInstance().CreateMediaInfo(uid, instanceId_);
|
||||
}
|
||||
|
||||
MediaDecryptModuleService::~MediaDecryptModuleService()
|
||||
@@ -47,25 +48,7 @@ MediaDecryptModuleService::~MediaDecryptModuleService()
|
||||
if (hdiMediaDecryptModule_ != nullptr) {
|
||||
Release();
|
||||
}
|
||||
std::shared_ptr<Media::Meta> meta = std::make_shared<Media::Meta>();
|
||||
meta->SetData(Media::Tag::DRM_APP_NAME, GetClientBundleName(IPCSkeleton::GetCallingUid()));
|
||||
meta->SetData(Media::Tag::DRM_INSTANCE_ID, std::to_string(HiTraceChain::GetId().GetChainId()));
|
||||
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);
|
||||
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);
|
||||
DrmEvent::GetInstance().ReportMediaInfo();
|
||||
ReportDecryptionStatisticEvent();
|
||||
DRM_INFO_LOG("MediaDecryptModuleService::~MediaDecryptModuleService exit.");
|
||||
}
|
||||
|
||||
@@ -119,11 +102,8 @@ int32_t MediaDecryptModuleService::DecryptMediaData(bool secureDecodrtState,
|
||||
decryptKeyId.assign(cryptInfoTmp.keyId.begin(), cryptInfoTmp.keyId.end());
|
||||
std::string decryptKeyIv;
|
||||
decryptKeyIv.assign(cryptInfoTmp.iv.begin(), cryptInfoTmp.iv.end());
|
||||
HISYSEVENT_FAULT("DRM_DECRYPTION_FAILURE", "APP_NAME", GetClientBundleName(IPCSkeleton::GetCallingUid()),
|
||||
"INSTANCE_ID", std::to_string(HiTraceChain::GetId().GetChainId()), "ERROR_CODE", ret,
|
||||
"ERROR_MESG", "decrypt failed", "DECRYPT_ALGO", std::to_string(static_cast<int32_t>(cryptInfoTmp.type)),
|
||||
"DECRYPT_KEYID", decryptKeyId, "DECRYPT_IV", decryptKeyIv);
|
||||
errMessage_ = "DecryptMediaData error";
|
||||
ReportDecryptionFaultEvent(ret, "DecryptMediaData failed",
|
||||
std::to_string(static_cast<int32_t>(cryptInfoTmp.type)), decryptKeyId, decryptKeyIv);
|
||||
return ret;
|
||||
}
|
||||
(void)::close(srcBuffer.fd);
|
||||
@@ -179,5 +159,28 @@ void MediaDecryptModuleService::SetDrmBufferInfo(OHOS::HDI::Drm::V1_0::DrmBuffer
|
||||
drmDstBuffer->offset = dstBuffer.offset;
|
||||
drmDstBuffer->sharedMemType = dstBuffer.sharedMemType;
|
||||
}
|
||||
|
||||
void MediaDecryptModuleService::ReportDecryptionStatisticEvent()
|
||||
{
|
||||
std::shared_ptr<Media::Meta> meta = std::make_shared<Media::Meta>();
|
||||
meta->SetData(Media::Tag::DRM_APP_NAME, GetClientBundleName(IPCSkeleton::GetCallingUid()));
|
||||
meta->SetData(Media::Tag::DRM_INSTANCE_ID, std::to_string(instanceId_));
|
||||
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);
|
||||
if (decryptStatustics_.decryptTimes != 0) {
|
||||
meta->SetData(Media::Tag::DRM_DECRYPT_AVG_SIZE,
|
||||
static_cast<uint32_t>(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, instanceId_);
|
||||
DrmEvent::GetInstance().ReportMediaInfo(instanceId_);
|
||||
}
|
||||
} // DrmStandard
|
||||
} // OHOS
|
||||
@@ -120,18 +120,11 @@ int32_t MediaKeySystemService::GenerateKeySystemRequest(std::vector<uint8_t> &re
|
||||
auto duration = timeAfter - timeBefore;
|
||||
generationDuration_ = duration.count();
|
||||
if (ret != DRM_OK) {
|
||||
generationResult_ = "failed";
|
||||
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", "");
|
||||
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()),
|
||||
"DRM_name", statisticsInfo_.pluginName, "DRM_uuid", statisticsInfo_.pluginUuid, "CLIENT_VERSION",
|
||||
statisticsInfo_.versionName, "GENERATION_DURATION", generationDuration_, "GENERATION_RESULT",
|
||||
generationResult_, "PROCESS_DURATION", 0, "PROCESS_RESULT", "genration failed", "CALL_SERVER_TIME", 0,
|
||||
"SERVER_COST_DURATION", 0, "SERVER_RESULT", "");
|
||||
ReportFaultEvent(ret, "GenerateKeySystemRequest failed", "");
|
||||
generationResult_ = "failed";
|
||||
ReportCertificateBehaviorEvent(statisticsInfo_, generationDuration_, generationResult_, 0,
|
||||
"GenerateKeySystemRequest failed", 0, 0, "");
|
||||
return ret;
|
||||
}
|
||||
generationResult_ = "success";
|
||||
@@ -150,30 +143,19 @@ int32_t MediaKeySystemService::ProcessKeySystemResponse(const std::vector<uint8_
|
||||
auto timeBefore = std::chrono::system_clock::now();
|
||||
ret = hdiKeySystem_->ProcessKeySystemResponse(response);
|
||||
auto timeAfter = std::chrono::system_clock::now();
|
||||
auto callTime = std::chrono::duration_cast<std::chrono::microseconds>(timeBefore.time_since_epoch()).count();
|
||||
auto duration = timeAfter - timeBefore;
|
||||
auto processDuration = duration.count();
|
||||
if (ret != DRM_OK) {
|
||||
DRM_ERR_LOG("MediaKeySystemService::ProcessKeySystemResponse failed.");
|
||||
std::string responseString = std::string(reinterpret_cast<const char*>(response.data()), response.size());
|
||||
HISYSEVENT_FAULT("DRM_COMMON_FAILURE", "APP_NAME", statisticsInfo_.bundleName, "INSTANCE_ID",
|
||||
std::to_string(HiTraceChain::GetId().GetChainId()), "ERROR_CODE", ret,
|
||||
"ERROR_MESG", "ProcessKeySystemResponse failed", "EXTRA_MESG", responseString);
|
||||
HISYSEVENT_BEHAVIOR("DRM_CERTIFICATE_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,
|
||||
"CLIENT_VERSION", statisticsInfo_.versionName, "GENERATION_DURATION", generationDuration_,
|
||||
"GENERATION_RESULT", generationResult_, "PROCESS_DURATION", processDuration, "PROCESS_RESULT", "failed",
|
||||
"CALL_SERVER_TIME", 0, "SERVER_COST_DURATION", 0, "SERVER_RESULT", "");
|
||||
ReportFaultEvent(ret, "ProcessKeySystemResponse failed", responseString);
|
||||
ReportCertificateBehaviorEvent(statisticsInfo_, generationDuration_, generationResult_, processDuration,
|
||||
"failed", 0, 0, "");
|
||||
return ret;
|
||||
}
|
||||
DRM_INFO_LOG("MediaKeySystemService::ProcessKeySystemResponse exit.");
|
||||
HISYSEVENT_BEHAVIOR("DRM_CERTIFICATE_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, "CLIENT_VERSION",
|
||||
statisticsInfo_.versionName.c_str(), "GENERATION_DURATION", generationDuration_,
|
||||
"GENERATION_RESULT", generationResult_, "PROCESS_DURATION", processDuration, "PROCESS_RESULT", "success",
|
||||
"CALL_SERVER_TIME", 0, "SERVER_COST_DURATION", 0, "SERVER_RESULT", "");
|
||||
ReportCertificateBehaviorEvent(statisticsInfo_, generationDuration_, generationResult_, processDuration,
|
||||
"success", 0, 0, "");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -251,17 +233,13 @@ int32_t MediaKeySystemService::CreateMediaKeySession(IMediaKeySessionService::Co
|
||||
hdiMediaKeySession);
|
||||
if (hdiMediaKeySession == nullptr) {
|
||||
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", "");
|
||||
ReportFaultEvent(DRM_SERVICE_ERROR, "CreateMediaKeySession failed", "");
|
||||
return DRM_SERVICE_ERROR;
|
||||
}
|
||||
keySessionService = new (std::nothrow) MediaKeySessionService(hdiMediaKeySession, statisticsInfo_);
|
||||
if (keySessionService == nullptr) {
|
||||
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", "");
|
||||
ReportFaultEvent(DRM_ALLOC_ERROR, "CreateMediaKeySession failed", "");
|
||||
return DRM_ALLOC_ERROR;
|
||||
}
|
||||
keySessionService->SetMediaKeySessionServiceOperatorsCallback(this);
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "iservice_registry.h"
|
||||
#include "mediakeysystem_service.h"
|
||||
#include "mediakeysystemfactory_service.h"
|
||||
#include "dump_usage.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DrmStandard {
|
||||
@@ -64,15 +63,10 @@ void MediaKeySystemFactoryService::OnStart()
|
||||
if (res) {
|
||||
DRM_INFO_LOG("MediaKeySystemFactoryService OnStart res=%{public}d", res);
|
||||
}
|
||||
OHOS::HiviewDFX::DumpUsage dumpUse;
|
||||
int pid = getpid();
|
||||
/* 3012 is the saId of drm_service */
|
||||
Memory::MemMgrClient::GetInstance().NotifyProcessStatus(pid, 1, 1, 3012);
|
||||
uint32_t memoryUsage = dumpUse.GetPss(pid);
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto currentTime = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
|
||||
HISYSEVENT_BEHAVIOR("DRM_SERVICE_INFO", "MODULE", "DRM_SERVICE", "TIME", currentTime, "SERVICE_NAME", "DRM_SERVICE",
|
||||
"ACTION", "start", "MEMORY", memoryUsage);
|
||||
ReportServiceBehaviorEvent("DRM_SERVICE", "start");
|
||||
}
|
||||
|
||||
void MediaKeySystemFactoryService::OnDump()
|
||||
@@ -94,11 +88,7 @@ void MediaKeySystemFactoryService::OnStop()
|
||||
int pid = getpid();
|
||||
/* 3012 is the saId of drm_service */
|
||||
Memory::MemMgrClient::GetInstance().NotifyProcessStatus(pid, 1, 0, 3012);
|
||||
uint32_t memoryUsage = dumpUse.GetPss(pid);
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto currentTime = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
|
||||
HISYSEVENT_BEHAVIOR("DRM_SERVICE_INFO", "MODULE", "DRM_SERVICE", "TIME", currentTime,
|
||||
"SERVICE_NAME", "DRM_SERVICE", "ACTION", "end", "MEMORY", memoryUsage);
|
||||
ReportServiceBehaviorEvent("DRM_SERVICE", "end");
|
||||
}
|
||||
|
||||
int32_t MediaKeySystemFactoryService::Dump(int32_t fd, const std::vector<std::u16string>& args)
|
||||
@@ -139,9 +129,7 @@ int32_t MediaKeySystemFactoryService::CreateMediaKeySystem(std::string &name,
|
||||
int32_t ret = drmHostManager_->CreateMediaKeySystem(name, hdiMediaKeySystem);
|
||||
if (hdiMediaKeySystem == nullptr || ret != DRM_OK) {
|
||||
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", "");
|
||||
ReportFaultEvent(DRM_SERVICE_ERROR, "CreateMediaKeySystem failed", "");
|
||||
return DRM_SERVICE_ERROR;
|
||||
}
|
||||
StatisticsInfo statisticsInfo;
|
||||
@@ -149,6 +137,7 @@ int32_t MediaKeySystemFactoryService::CreateMediaKeySystem(std::string &name,
|
||||
mediaKeySystemService = new (std::nothrow) MediaKeySystemService(hdiMediaKeySystem, statisticsInfo);
|
||||
if (mediaKeySystemService == nullptr) {
|
||||
DRM_ERR_LOG("MediaKeySystemFactoryService::CreateMediaKeySystem allocation failed.");
|
||||
ReportFaultEvent(DRM_ALLOC_ERROR, "CreateMediaKeySystem failed", "");
|
||||
return DRM_ALLOC_ERROR;
|
||||
}
|
||||
mediaKeySystemService->SetMediaKeySystemServiceOperatorsCallback(this);
|
||||
|
||||
+209
-6
@@ -17,6 +17,7 @@
|
||||
#include "drm_dfx_utils.h"
|
||||
#include <unistd.h>
|
||||
#include "drm_log.h"
|
||||
#include "dump_usage.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "native_drm_err.h"
|
||||
#include "securec.h"
|
||||
@@ -117,14 +118,13 @@ void DrmEvent::StatisicsHiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::EventType t
|
||||
"EVENTS", infoArr);
|
||||
}
|
||||
|
||||
int32_t DrmEvent::AppendMediaInfo(const std::shared_ptr<Media::Meta>& meta)
|
||||
int32_t DrmEvent::AppendMediaInfo(const std::shared_ptr<Media::Meta>& meta, uint64_t instanceId)
|
||||
{
|
||||
DRM_INFO_LOG("AppendMediaInfo.");
|
||||
if (meta == nullptr || meta->Empty()) {
|
||||
DRM_INFO_LOG("Insert meta is empty.");
|
||||
return DRM_ERR_INVALID_STATE;
|
||||
}
|
||||
uint64_t instanceId = HiTraceChain::GetId().GetChainId();
|
||||
|
||||
std::lock_guard<std::mutex> lock(collectMut_);
|
||||
auto idMapIt = idMap_.find(instanceId);
|
||||
@@ -152,11 +152,10 @@ int32_t DrmEvent::AppendMediaInfo(const std::shared_ptr<Media::Meta>& meta)
|
||||
return DRM_ERR_OK;
|
||||
}
|
||||
|
||||
int32_t DrmEvent::CreateMediaInfo(int32_t uid)
|
||||
int32_t DrmEvent::CreateMediaInfo(int32_t uid, uint64_t instanceId)
|
||||
{
|
||||
DRM_INFO_LOG("CreateMediaInfo.");
|
||||
std::lock_guard<std::mutex> lock(collectMut_);
|
||||
uint64_t instanceId = HiTraceChain::GetId().GetChainId();
|
||||
DRM_INFO_LOG("CreateMediaInfo uid is: %{public}" PRId32 " instanceId is: %{public}." PRIu64, uid, instanceId);
|
||||
auto instanceIdMap = idMap_.find(instanceId);
|
||||
if (instanceIdMap != idMap_.end()) {
|
||||
@@ -177,9 +176,8 @@ int32_t DrmEvent::CreateMediaInfo(int32_t uid)
|
||||
return DRM_ERR_OK;
|
||||
}
|
||||
|
||||
int32_t DrmEvent::ReportMediaInfo()
|
||||
int32_t DrmEvent::ReportMediaInfo(uint64_t instanceId)
|
||||
{
|
||||
uint64_t instanceId = HiTraceChain::GetId().GetChainId();
|
||||
auto currentTime = std::chrono::system_clock::now();
|
||||
auto diff = currentTime - currentTime_;
|
||||
auto hour = std::chrono::duration_cast<std::chrono::hours>(diff).count();
|
||||
@@ -249,6 +247,211 @@ int32_t DrmEvent::StatisticsEventReport()
|
||||
reportMediaInfoMap_.clear();
|
||||
return DRM_ERR_OK;
|
||||
}
|
||||
|
||||
void DrmEvent::WriteServiceEvent(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
|
||||
DrmServiveInfo &info)
|
||||
{
|
||||
int32_t res = DRM_ERR_OK;
|
||||
res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MEDIA, eventName, type,
|
||||
"MODULE", info.module,
|
||||
"TIME", info.currentTime,
|
||||
"SERVICE_NAME", info.serviceName,
|
||||
"ACTION", info.action,
|
||||
"MEMORY", info.memoryUsage);
|
||||
if (res != DRM_ERR_OK) {
|
||||
DRM_ERR_LOG("EventWrite failed, res = %d", res);
|
||||
} else {
|
||||
DRM_INFO_LOG("EventWrite success");
|
||||
}
|
||||
}
|
||||
|
||||
void DrmEvent::WriteLicenseEvent(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
|
||||
DrmLicenseInfo &info)
|
||||
{
|
||||
int32_t res = DRM_ERR_OK;
|
||||
res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MEDIA, eventName, type,
|
||||
"MODULE", info.module,
|
||||
"TIME", info.currentTime,
|
||||
"APP_NAME", info.appName,
|
||||
"INSTANCE_ID", info.instanceId,
|
||||
"DRM_NAME", info.drmName,
|
||||
"DRM_UUID", info.drmUuid,
|
||||
"CLIENT_VERSION", info.clientVersion,
|
||||
"LICENSE_TYPE", info.licenseType,
|
||||
"GENERATION_DURATION", info.generationDuration,
|
||||
"GENERATION_RESULT", info.generationResult,
|
||||
"PROCESS_DURATION", info.processDuration,
|
||||
"PROCESS_RESULT", info.processResult);
|
||||
if (res != DRM_ERR_OK) {
|
||||
DRM_ERR_LOG("EventWrite failed, res = %d", res);
|
||||
} else {
|
||||
DRM_INFO_LOG("EventWrite success");
|
||||
}
|
||||
}
|
||||
|
||||
void DrmEvent::WriteCertificateEvent(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
|
||||
DrmCertificateInfo &info)
|
||||
{
|
||||
int32_t res = DRM_ERR_OK;
|
||||
res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MEDIA, eventName, type,
|
||||
"MODULE", info.module,
|
||||
"TIME", info.currentTime,
|
||||
"APP_NAME", info.appName,
|
||||
"INSTANCE_ID", info.instanceId,
|
||||
"DRM_NAME", info.drmName,
|
||||
"DRM_UUID", info.drmUuid,
|
||||
"CLIENT_VERSION", info.clientVersion,
|
||||
"GENERATION_DURATION", info.generationDuration,
|
||||
"GENERATION_RESULT", info.generationResult,
|
||||
"PROCESS_DURATION", info.processDuration,
|
||||
"PROCESS_RESULT", info.processResult,
|
||||
"CALL_SERVER_TIME", info.callServerTime,
|
||||
"SERVER_COST_DURATION", info.serverCostDuration,
|
||||
"SERVER_RESULT", info.serverResult);
|
||||
if (res != DRM_ERR_OK) {
|
||||
DRM_ERR_LOG("EventWrite failed, res = %d", res);
|
||||
} else {
|
||||
DRM_INFO_LOG("EventWrite success");
|
||||
}
|
||||
}
|
||||
|
||||
void DrmEvent::WriteFaultEvent(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type, DrmFaultInfo &info)
|
||||
{
|
||||
int32_t res = DRM_ERR_OK;
|
||||
res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MEDIA, eventName, type,
|
||||
"MODULE", info.module,
|
||||
"APP_NAME", info.appName,
|
||||
"INSTANCE_ID", info.instanceId,
|
||||
"ERROR_CODE", info.errorCode,
|
||||
"ERROR_MESG", info.errorMesg,
|
||||
"EXTRA_MESG", info.extraMesg);
|
||||
if (res != DRM_ERR_OK) {
|
||||
DRM_ERR_LOG("EventWrite failed, res = %d", res);
|
||||
} else {
|
||||
DRM_INFO_LOG("EventWrite success");
|
||||
}
|
||||
}
|
||||
|
||||
void DrmEvent::WriteDecryptionEvent(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
|
||||
DrmDecryptionInfo &info)
|
||||
{
|
||||
int32_t res = DRM_ERR_OK;
|
||||
|
||||
res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MEDIA, eventName, type,
|
||||
"MODULE", info.module,
|
||||
"APP_NAME", info.appName,
|
||||
"INSTANCE_ID", info.instanceId,
|
||||
"ERROR_CODE", info.errorCode,
|
||||
"ERROR_MESG", info.errorMesg,
|
||||
"DECRYPT_ALGO", info.decryptAlgo,
|
||||
"DECRYPT_KEYID", info.decryptKeyid,
|
||||
"DECRYPT_IV", info.decryptIv);
|
||||
if (res != DRM_ERR_OK) {
|
||||
DRM_ERR_LOG("EventWrite failed, res = %d", res);
|
||||
} else {
|
||||
DRM_INFO_LOG("EventWrite success");
|
||||
}
|
||||
}
|
||||
|
||||
void ReportServiceBehaviorEvent(std::string serviceName, std::string action)
|
||||
{
|
||||
DrmEvent event;
|
||||
OHOS::HiviewDFX::DumpUsage dumpUse;
|
||||
uint32_t memoryUsage = dumpUse.GetPss(getpid());
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto currentTime = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
|
||||
struct DrmServiveInfo drmServiveInfo = {
|
||||
"DRM_SERVICE",
|
||||
currentTime,
|
||||
serviceName,
|
||||
action,
|
||||
memoryUsage,
|
||||
};
|
||||
event.WriteServiceEvent("DRM_SERVICE_INFO", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, drmServiveInfo);
|
||||
}
|
||||
|
||||
void ReportLicenseBehaviorEvent(StatisticsInfo statisticsInfo, std::string licenseType, uint32_t generationDuration,
|
||||
std::string generationResult, uint32_t processDuration, std::string processResult)
|
||||
{
|
||||
DrmEvent event;
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto currentTime = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
|
||||
struct DrmLicenseInfo drmLicenseInfo = {
|
||||
"DRM_SERVICE",
|
||||
currentTime,
|
||||
GetClientBundleName(IPCSkeleton::GetCallingUid()),
|
||||
std::to_string(HiTraceChain::GetId().GetChainId()),
|
||||
statisticsInfo.pluginName,
|
||||
statisticsInfo.pluginUuid,
|
||||
statisticsInfo.versionName,
|
||||
licenseType,
|
||||
generationDuration,
|
||||
generationResult,
|
||||
processDuration,
|
||||
processResult,
|
||||
};
|
||||
event.WriteLicenseEvent("DRM_LICENSE_DOWNLOAD_INFO", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
|
||||
drmLicenseInfo);
|
||||
}
|
||||
|
||||
void ReportCertificateBehaviorEvent(StatisticsInfo statisticsInfo, uint32_t generationDuration,
|
||||
std::string generationResult, uint32_t processDuration, std::string processResult, uint32_t callServerTime,
|
||||
uint32_t serverCostDuration, std::string serverResult)
|
||||
{
|
||||
DrmEvent event;
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto currentTime = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
|
||||
struct DrmCertificateInfo DrmCertificateInfo = {
|
||||
"DRM_SERVICE",
|
||||
currentTime,
|
||||
GetClientBundleName(IPCSkeleton::GetCallingUid()),
|
||||
std::to_string(HiTraceChain::GetId().GetChainId()),
|
||||
statisticsInfo.pluginName,
|
||||
statisticsInfo.pluginUuid,
|
||||
statisticsInfo.versionName,
|
||||
generationDuration,
|
||||
generationResult,
|
||||
processDuration,
|
||||
processResult,
|
||||
callServerTime,
|
||||
serverCostDuration,
|
||||
serverResult,
|
||||
};
|
||||
event.WriteCertificateEvent("DRM_CERTIFICATE_DOWNLOWD_INFO", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
|
||||
DrmCertificateInfo);
|
||||
}
|
||||
|
||||
void ReportFaultEvent(uint32_t errorCode, std::string errorMesg, std::string extraMesg)
|
||||
{
|
||||
DrmEvent event;
|
||||
struct DrmFaultInfo drmFaultInfo = {
|
||||
"DRM_SERVICE",
|
||||
GetClientBundleName(IPCSkeleton::GetCallingUid()),
|
||||
std::to_string(HiTraceChain::GetId().GetChainId()),
|
||||
errorCode,
|
||||
errorMesg,
|
||||
extraMesg,
|
||||
};
|
||||
event.WriteFaultEvent("DRM_COMMON_FAILURE", OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, drmFaultInfo);
|
||||
}
|
||||
|
||||
void ReportDecryptionFaultEvent(int32_t errorCode, std::string errorMesg, std::string decryptAlgo,
|
||||
std::string decryptKeyid, std::string decryptIv)
|
||||
{
|
||||
DrmEvent event;
|
||||
struct DrmDecryptionInfo drmDecryptionInfo = {
|
||||
"DRM_SERVICE",
|
||||
GetClientBundleName(IPCSkeleton::GetCallingUid()),
|
||||
std::to_string(HiTraceChain::GetId().GetChainId()),
|
||||
errorCode,
|
||||
errorMesg,
|
||||
decryptAlgo,
|
||||
decryptKeyid,
|
||||
decryptIv,
|
||||
};
|
||||
event.WriteDecryptionEvent("DRM_DECRYPTION_FAILURE", OHOS::HiviewDFX::HiSysEvent::EventType::FAULT,
|
||||
drmDecryptionInfo);
|
||||
}
|
||||
#endif
|
||||
} // namespace DrmStandard
|
||||
} // namespace OHOS
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <refbase.h>
|
||||
#include "drm_dfx_utils.h"
|
||||
#include "nocopyable.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "meta/meta.h"
|
||||
@@ -34,24 +35,70 @@ namespace DrmStandard {
|
||||
using namespace OHOS::HiviewDFX;
|
||||
|
||||
#ifdef ENABLE_DRM_SYSEVENT_CONTROL
|
||||
struct DrmServiveInfo {
|
||||
std::string module;
|
||||
uint32_t currentTime;
|
||||
std::string serviceName;
|
||||
std::string action;
|
||||
uint32_t memoryUsage;
|
||||
};
|
||||
|
||||
struct DrmLicenseInfo {
|
||||
std::string module;
|
||||
uint32_t currentTime;
|
||||
std::string appName;
|
||||
std::string instanceId;
|
||||
std::string drmName;
|
||||
std::string drmUuid;
|
||||
std::string clientVersion;
|
||||
std::string licenseType;
|
||||
uint32_t generationDuration;
|
||||
std::string generationResult;
|
||||
uint32_t processDuration;
|
||||
std::string processResult;
|
||||
};
|
||||
|
||||
struct DrmCertificateInfo {
|
||||
std::string module;
|
||||
uint32_t currentTime;
|
||||
std::string appName;
|
||||
std::string instanceId;
|
||||
std::string drmName;
|
||||
std::string drmUuid;
|
||||
std::string clientVersion;
|
||||
uint32_t generationDuration;
|
||||
std::string generationResult;
|
||||
uint32_t processDuration;
|
||||
std::string processResult;
|
||||
uint32_t callServerTime;
|
||||
uint32_t serverCostDuration;
|
||||
std::string serverResult;
|
||||
};
|
||||
|
||||
struct DrmFaultInfo {
|
||||
std::string module;
|
||||
std::string appName;
|
||||
std::string instanceId;
|
||||
int32_t errorCode;
|
||||
std::string errorMesg;
|
||||
std::string extraMesg;
|
||||
};
|
||||
|
||||
struct DrmDecryptionInfo {
|
||||
std::string module;
|
||||
std::string appName;
|
||||
std::string instanceId;
|
||||
int32_t errorCode;
|
||||
std::string errorMesg;
|
||||
std::string decryptAlgo;
|
||||
std::string decryptKeyid;
|
||||
std::string decryptIv;
|
||||
};
|
||||
|
||||
class DrmEvent {
|
||||
public:
|
||||
static DrmEvent& GetInstance();
|
||||
|
||||
template<typename... Types>
|
||||
static int HiSysWriteFault(const std::string& eventName, Types... keyValues)
|
||||
{
|
||||
return HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MEDIA, eventName,
|
||||
OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, keyValues...);
|
||||
}
|
||||
|
||||
template<typename... Types>
|
||||
static int HiSysWriteBehavior(const std::string& eventName, Types... keyValues)
|
||||
{
|
||||
return HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MEDIA, eventName,
|
||||
OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, keyValues...);
|
||||
}
|
||||
|
||||
void DrmStatisicsEventWrite(OHOS::HiviewDFX::HiSysEvent::EventType type,
|
||||
const std::map<int32_t, std::list<std::pair<uint64_t, std::shared_ptr<Media::Meta>>>>& infoMap);
|
||||
void StatisicsHiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::EventType type,
|
||||
@@ -59,21 +106,31 @@ public:
|
||||
void ParseOneEvent(const std::pair<uint64_t, std::shared_ptr<OHOS::Media::Meta>> &listPair,
|
||||
nlohmann::json& metaInfoJson);
|
||||
void CollectReportMediaInfo(uint64_t instanceId);
|
||||
int32_t AppendMediaInfo(const std::shared_ptr<Media::Meta>& meta);
|
||||
int32_t CreateMediaInfo(int32_t uid);
|
||||
int32_t ReportMediaInfo();
|
||||
int32_t AppendMediaInfo(const std::shared_ptr<Media::Meta>& meta, uint64_t instanceId);
|
||||
int32_t CreateMediaInfo(int32_t uid, uint64_t instanceId);
|
||||
int32_t ReportMediaInfo(uint64_t instanceId);
|
||||
int32_t StatisticsEventReport();
|
||||
void WriteServiceEvent(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type, DrmServiveInfo &info);
|
||||
void WriteLicenseEvent(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type, DrmLicenseInfo &info);
|
||||
void WriteCertificateEvent(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
|
||||
DrmCertificateInfo &info);
|
||||
void WriteFaultEvent(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type, DrmFaultInfo &info);
|
||||
void WriteDecryptionEvent(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
|
||||
DrmDecryptionInfo &info);
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DRM_SYSEVENT_CONTROL
|
||||
#define HISYSEVENT_FAULT(eventName, ...) ((void)DrmEvent::HiSysWriteFault(eventName, __VA_ARGS__))
|
||||
#define HISYSEVENT_BEHAVIOR(eventName, ...) ((void)DrmEvent::HiSysWriteBehavior(eventName, __VA_ARGS__))
|
||||
#else
|
||||
#define HISYSEVENT_FAULT(...)
|
||||
#define HISYSEVENT_BEHAVIOR(...)
|
||||
#endif
|
||||
|
||||
__attribute__((visibility("default"))) void ReportServiceBehaviorEvent(std::string serviceName, std::string action);
|
||||
__attribute__((visibility("default"))) void ReportLicenseBehaviorEvent(StatisticsInfo statisticsInfo,
|
||||
std::string licenseType, uint32_t generationDuration, std::string generationResult, uint32_t processDuration,
|
||||
std::string processResult);
|
||||
__attribute__((visibility("default"))) void ReportCertificateBehaviorEvent(StatisticsInfo statisticsInfo,
|
||||
uint32_t generationDuration, std::string generationResult, uint32_t processDuration, std::string processResult,
|
||||
uint32_t callServerTime, uint32_t serverCostDuration, std::string serverResult);
|
||||
__attribute__((visibility("default"))) void ReportFaultEvent(uint32_t errorCode, std::string errorMesg,
|
||||
std::string extraMesg);
|
||||
__attribute__((visibility("default"))) void ReportDecryptionFaultEvent(int32_t errorCode, std::string errorMesg,
|
||||
std::string decryptAlgo, std::string decryptKeyid, std::string decryptIv);
|
||||
} // namespace DrmStandard
|
||||
} // namespace OHOS
|
||||
#endif // DRM_DFX_H
|
||||
@@ -29,7 +29,6 @@ namespace DrmStandard {
|
||||
std::string __attribute__((visibility("default"))) GetClientBundleName(int32_t uid);
|
||||
const std::string currentSessionNum = "currentSessionNum";
|
||||
const std::string version = "version";
|
||||
const std::string decryptNumber = "decryptNumber";
|
||||
const std::string errorDecryptNumber = "errorDecryptNumber";
|
||||
const std::string decryptTimes = "decryptTimes";
|
||||
const std::string vendor = "vendor";
|
||||
|
||||
Reference in New Issue
Block a user