diff --git a/frameworks/native/test/fuzztest/drmservice_fuzzer/drmservice_fuzzer.cpp b/frameworks/native/test/fuzztest/drmservice_fuzzer/drmservice_fuzzer.cpp index b5506f8c..1aab4679 100644 --- a/frameworks/native/test/fuzztest/drmservice_fuzzer/drmservice_fuzzer.cpp +++ b/frameworks/native/test/fuzztest/drmservice_fuzzer/drmservice_fuzzer.cpp @@ -412,7 +412,7 @@ bool DrmServiceNdkFuzzer::DrmserviceGetMediaDecryptModuleTest(uint8_t *rawData, MessageOption option; MessageParcel data; data.WriteInterfaceToken(MEDIA_KEY_SESSION_TOKEN); - mediaKeySessionService->OnRemoteRequest(CREATE_MEDIA_DECRYPT_MODULE, data, reply, option); + mediaKeySessionService->OnRemoteRequest(GET_MEDIA_DECRYPT_MODULE, data, reply, option); return true; } diff --git a/services/drm_service/client/src/key_session_service_proxy.cpp b/services/drm_service/client/src/key_session_service_proxy.cpp index 7246f761..5480b91d 100644 --- a/services/drm_service/client/src/key_session_service_proxy.cpp +++ b/services/drm_service/client/src/key_session_service_proxy.cpp @@ -38,7 +38,7 @@ int32_t MediaKeySessionServiceProxy::GetMediaDecryptModule(sptrSendRequest(CREATE_MEDIA_DECRYPT_MODULE, data, reply, option); + int32_t ret = MediaKeySessionServiceProxy::Remote()->SendRequest(GET_MEDIA_DECRYPT_MODULE, data, reply, option); if (ret != ERR_NONE) { DRM_ERR_LOG("MediaKeySessionServiceProxy::GetMediaDecryptModule failed, ret: %{public}d", ret); return ret; diff --git a/services/drm_service/ipc/remote_request_code.h b/services/drm_service/ipc/remote_request_code.h index eadf04a9..d8c360df 100644 --- a/services/drm_service/ipc/remote_request_code.h +++ b/services/drm_service/ipc/remote_request_code.h @@ -46,7 +46,7 @@ enum MediaKeySystemServiceRequestCode { }; enum MediaKeySessionServiceRequestCode { - CREATE_MEDIA_DECRYPT_MODULE = 0, + GET_MEDIA_DECRYPT_MODULE = 0, KEY_SESSION_RELEASE, MEDIA_KEY_SESSION_GENERATE_LICENSE_REQUEST, MEDIA_KEY_SESSION_PROCESS_LICENSE_RESPONSE, diff --git a/services/drm_service/server/include/media_decrypt_module_service.h b/services/drm_service/server/include/media_decrypt_module_service.h index 9ea38c70..396a7820 100644 --- a/services/drm_service/server/include/media_decrypt_module_service.h +++ b/services/drm_service/server/include/media_decrypt_module_service.h @@ -60,7 +60,7 @@ private: std::mutex moduleLock_; sptr hdiMediaDecryptModule_; std::mutex statisticsMutex_; - DecryptStatistics decryptStatustics_; + DecryptStatistics decryptStatistics_; uint64_t instanceId_; }; } // DrmStandard diff --git a/services/drm_service/server/src/key_session_service_stub.cpp b/services/drm_service/server/src/key_session_service_stub.cpp index 5c1866ad..6dcb5abe 100644 --- a/services/drm_service/server/src/key_session_service_stub.cpp +++ b/services/drm_service/server/src/key_session_service_stub.cpp @@ -69,7 +69,7 @@ static int32_t ProcessSetListenerObject(MediaKeySessionServiceStub *stub, Messag MessageParcel &reply, MessageOption &option); static struct ProcessRemoteRequestFuncArray g_mediaKeySessionServiceStubRequestProcessFunc[] = { - {CREATE_MEDIA_DECRYPT_MODULE, ProcessGetMediaDecryptModule}, + {GET_MEDIA_DECRYPT_MODULE, ProcessGetMediaDecryptModule}, {KEY_SESSION_RELEASE, ProcessRleaseKeySession}, {MEDIA_KEY_SESSION_GENERATE_LICENSE_REQUEST, ProcessMediaKeyRequest}, {MEDIA_KEY_SESSION_PROCESS_LICENSE_RESPONSE, ProcessMediaKeyResponse}, @@ -421,7 +421,7 @@ int32_t MediaKeySessionServiceStub::OnRemoteRequest(uint32_t code, MessageParcel DRM_CHECK_AND_RETURN_RET_LOG(data.ReadInterfaceToken() == GetDescriptor(), errCode, "MediaKeySessionServiceStub: ReadInterfaceToken failed."); - DRM_CHECK_AND_RETURN_RET_LOG((code >= CREATE_MEDIA_DECRYPT_MODULE) && (code <= MEDIA_KEY_SESSION_GETSECURITYLEVEL), + DRM_CHECK_AND_RETURN_RET_LOG((code >= GET_MEDIA_DECRYPT_MODULE) && (code <= MEDIA_KEY_SESSION_GETSECURITYLEVEL), IPCObjectStub::OnRemoteRequest(code, data, reply, option), "code not match, need check MediaKeySessionServiceStub"); return g_mediaKeySessionServiceStubRequestProcessFunc[code].processFunc(this, data, reply, option); diff --git a/services/drm_service/server/src/media_decrypt_module_service.cpp b/services/drm_service/server/src/media_decrypt_module_service.cpp index 47939c81..71e899f6 100644 --- a/services/drm_service/server/src/media_decrypt_module_service.cpp +++ b/services/drm_service/server/src/media_decrypt_module_service.cpp @@ -146,20 +146,20 @@ void MediaDecryptModuleService::ReportDecryptionStatisticEvent() std::shared_ptr meta = std::make_shared(); 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, decryptStatustics_.errCode); - meta->SetData(Media::Tag::DRM_ERROR_MESG, decryptStatustics_.errMessage); - meta->SetData(Media::Tag::DRM_DECRYPT_TIMES, decryptStatustics_.decryptTimes); - if (decryptStatustics_.decryptTimes != 0) { + meta->SetData(Media::Tag::DRM_ERROR_CODE, decryptStatistics_.errCode); + meta->SetData(Media::Tag::DRM_ERROR_MESG, decryptStatistics_.errMessage); + meta->SetData(Media::Tag::DRM_DECRYPT_TIMES, decryptStatistics_.decryptTimes); + if (decryptStatistics_.decryptTimes != 0) { meta->SetData(Media::Tag::DRM_DECRYPT_AVG_SIZE, - static_cast(decryptStatustics_.decryptSumSize / decryptStatustics_.decryptTimes)); + static_cast(decryptStatistics_.decryptSumSize / decryptStatistics_.decryptTimes)); meta->SetData(Media::Tag::DRM_DECRYPT_AVG_DURATION, - static_cast(decryptStatustics_.decryptSumDuration / decryptStatustics_.decryptTimes)); + static_cast(decryptStatistics_.decryptSumDuration / decryptStatistics_.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); + meta->SetData(Media::Tag::DRM_DECRYPT_MAX_SIZE, decryptStatistics_.decryptMaxSize); + meta->SetData(Media::Tag::DRM_DECRYPT_MAX_DURATION, decryptStatistics_.decryptMaxDuration); DrmEvent::GetInstance().AppendMediaInfo(meta, instanceId_); DrmEvent::GetInstance().ReportMediaInfo(instanceId_); } @@ -168,20 +168,25 @@ void MediaDecryptModuleService::UpdateDecryptionStatistics(int32_t decryptionRes uint32_t bufLen, uint32_t curDuration) { std::lock_guard statisticsLock(statisticsMutex_); - decryptStatustics_.topThree.push(curDuration); - if (decryptStatustics_.topThree.size() > TOP_THREE_SIZE) { - decryptStatustics_.topThree.pop(); + decryptStatistics_.topThree.push(curDuration); + if (decryptStatistics_.topThree.size() > TOP_THREE_SIZE) { + decryptStatistics_.topThree.pop(); } - if (decryptStatustics_.decryptMaxSize < bufLen) { - decryptStatustics_.decryptMaxSize = bufLen; + if (decryptStatistics_.decryptMaxSize < bufLen) { + decryptStatistics_.decryptMaxSize = bufLen; } if (decryptionResult != DRM_OK) { - decryptStatustics_.errorDecryptTimes++; + decryptStatistics_.errorDecryptTimes++; } - decryptStatustics_.decryptTimes++; - decryptStatustics_.decryptSumSize += bufLen; - decryptStatustics_.decryptSumDuration += curDuration; + if (decryptStatistics_.decryptTimes == UINT32_MAX) { + decryptStatistics_.decryptTimes = 0; + decryptStatistics_.decryptSumSize = 0; + decryptStatistics_.decryptSumDuration = 0; + } + decryptStatistics_.decryptTimes++; + decryptStatistics_.decryptSumSize += bufLen; + decryptStatistics_.decryptSumDuration += curDuration; } const std::string MediaDecryptModuleService::GetTopThreeDecryptionDurations() @@ -189,14 +194,14 @@ const std::string MediaDecryptModuleService::GetTopThreeDecryptionDurations() DRM_INFO_LOG("MediaDecryptModuleService::GetTopThreeDecryptionDurations"); std::vector topThreeDurations(TOP_THREE_SIZE, 0); std::lock_guard statisticsLock(statisticsMutex_); - uint32_t currentTopThreeSize = decryptStatustics_.topThree.size(); + uint32_t currentTopThreeSize = decryptStatistics_.topThree.size(); for (uint32_t i = 0; i < currentTopThreeSize; i++) { - uint32_t tmp = decryptStatustics_.topThree.top(); - decryptStatustics_.topThree.pop(); + uint32_t tmp = decryptStatistics_.topThree.top(); + decryptStatistics_.topThree.pop(); topThreeDurations[i] = tmp; } for (uint32_t i = 0; i < currentTopThreeSize; i++) { - decryptStatustics_.topThree.push(topThreeDurations[i]); + decryptStatistics_.topThree.push(topThreeDurations[i]); } return std::to_string(topThreeDurations[TOP_ONE]) + " " + std::to_string(topThreeDurations[TOP_SEC]) + " " + @@ -206,8 +211,8 @@ const std::string MediaDecryptModuleService::GetTopThreeDecryptionDurations() std::string MediaDecryptModuleService::GetDumpInfo() { DRM_INFO_LOG("MediaDecryptModuleService::GetDumpInfo"); - std::string dumpInfo = "Total Decryption Times: " + std::to_string(decryptStatustics_.decryptTimes) + "\n" - "Error Decryption Times: " + std::to_string(decryptStatustics_.errorDecryptTimes) + "\n" + std::string dumpInfo = "Total Decryption Times: " + std::to_string(decryptStatistics_.decryptTimes) + "\n" + "Error Decryption Times: " + std::to_string(decryptStatistics_.errorDecryptTimes) + "\n" "Top3 Decryption Duration: " + GetTopThreeDecryptionDurations(); return dumpInfo; } diff --git a/services/drm_service/server/src/mediakeysystemfactory_service.cpp b/services/drm_service/server/src/mediakeysystemfactory_service.cpp index 75fe09d6..ec79609a 100644 --- a/services/drm_service/server/src/mediakeysystemfactory_service.cpp +++ b/services/drm_service/server/src/mediakeysystemfactory_service.cpp @@ -316,6 +316,7 @@ int32_t MediaKeySystemFactoryService::WriteDumpInfo(int32_t fd, std::string &dum dumpString += "#### MediaKeySystem " + std::to_string(systemNum) + " ####\n"; dumpString += "PID: " + std::to_string(pidIter.first) + "\n"; for (auto &system : pidIter.second) { + dumpString += "-------------------------------\n"; IMediaKeySystemService::CertificateStatus certStatus = IMediaKeySystemService::CERT_STATUS_UNAVAILABLE; system->GetCertificateStatus(&certStatus); dumpString += "Plugin Name: " + system->GetPluginName() + "\n"; diff --git a/services/utils/include/drm_dfx_utils.h b/services/utils/include/drm_dfx_utils.h index d6b6ca6c..8911b00f 100644 --- a/services/utils/include/drm_dfx_utils.h +++ b/services/utils/include/drm_dfx_utils.h @@ -32,10 +32,7 @@ namespace DrmStandard { uint32_t __attribute__((visibility("default"))) CalculateTimeDiff(std::chrono::system_clock::time_point timeBefore, std::chrono::system_clock::time_point timeAfter); const int minimumDigit = 2; - const std::string currentSessionNum = "currentSessionNum"; const std::string version = "version"; - const std::string errorDecryptNumber = "errorDecryptNumber"; - const std::string decryptTimes = "decryptTimes"; const std::string vendor = "vendor"; } // namespace DrmStandard } // namespace OHOS