Rename aidl_ include and src directories.
Test: unit tests Test: Google TV and Netflix Test: atest GtsMediaTestCases Bug: 216527109 Change-Id: I3fd02c2c60da588dba3db27cea3593de25a7180f
This commit is contained in:
21
libwvdrmengine/src/WVCreatePluginFactories.cpp
Normal file
21
libwvdrmengine/src/WVCreatePluginFactories.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
|
||||
#include "WVCreatePluginFactories.h"
|
||||
|
||||
namespace wvdrm {
|
||||
namespace hardware {
|
||||
namespace drm {
|
||||
namespace widevine {
|
||||
|
||||
std::shared_ptr<WVDrmFactory> createDrmFactory() {
|
||||
return ndk::SharedRefBase::make<WVDrmFactory>();
|
||||
}
|
||||
|
||||
} // namespace widevine
|
||||
} // namespace drm
|
||||
} // namespace hardware
|
||||
} // namespace wvdrm
|
||||
311
libwvdrmengine/src/WVDrmFactory.cpp
Normal file
311
libwvdrmengine/src/WVDrmFactory.cpp
Normal file
@@ -0,0 +1,311 @@
|
||||
//
|
||||
// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
|
||||
//#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "WVCdm-DrmFactory"
|
||||
|
||||
#include "WVDrmFactory.h"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
#include <android/binder_ibinder_platform.h>
|
||||
#include <binder/IPCThreadState.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "Utils.h"
|
||||
#include "WVCDMSingleton.h"
|
||||
#include "WVCryptoPlugin.h"
|
||||
#include "WVDrmPlugin.h"
|
||||
#include "WVUUID.h"
|
||||
#include "android-base/properties.h"
|
||||
#include "cutils/properties.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "wv_content_decryption_module.h"
|
||||
#include "wv_metrics.h"
|
||||
|
||||
namespace wvdrm {
|
||||
namespace hardware {
|
||||
namespace drm {
|
||||
namespace widevine {
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
using ::aidl::android::hardware::drm::CryptoSchemes;
|
||||
using ::aidl::android::hardware::drm::SecurityLevel;
|
||||
using ::aidl::android::hardware::drm::Status;
|
||||
using ::aidl::android::hardware::drm::SupportedContentType;
|
||||
using ::aidl::android::hardware::drm::Uuid;
|
||||
|
||||
WVGenericCryptoInterface WVDrmFactory::sOemCryptoInterface;
|
||||
|
||||
bool WVDrmFactory::isCryptoSchemeSupported(const Uuid& in_uuid) {
|
||||
return isWidevineUUID(in_uuid.uuid.data());
|
||||
}
|
||||
|
||||
|
||||
::ndk::SpAIBinder WVDrmFactory::createBinder() {
|
||||
auto binder = BnDrmFactory::createBinder();
|
||||
AIBinder_setRequestingSid(binder.get(), true);
|
||||
return binder;
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus WVDrmFactory::createCryptoPlugin(
|
||||
const ::aidl::android::hardware::drm::Uuid& in_uuid,
|
||||
const std::vector<uint8_t>& in_initData,
|
||||
std::shared_ptr<::aidl::android::hardware::drm::ICryptoPlugin>*
|
||||
_aidl_return) {
|
||||
const char* sid = AIBinder_getCallingSid();
|
||||
sid = sid ? (std::strstr(sid, "mediadrmserver") ? sid : "app") : "nullptr";
|
||||
ALOGI("[%s] calling %s", sid, __PRETTY_FUNCTION__);
|
||||
|
||||
if (!isCryptoSchemeSupported(in_uuid)) {
|
||||
ALOGE(
|
||||
"Widevine Drm HAL: failed to create crypto plugin, "
|
||||
"invalid crypto scheme");
|
||||
*_aidl_return = nullptr;
|
||||
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE);
|
||||
}
|
||||
|
||||
std::shared_ptr<WVCryptoPlugin> plugin =
|
||||
::ndk::SharedRefBase::make<WVCryptoPlugin>(in_initData.data(),
|
||||
in_initData.size(), getCDM());
|
||||
*_aidl_return = std::move(plugin);
|
||||
return toNdkScopedAStatus(Status::OK);
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus WVDrmFactory::createDrmPlugin(
|
||||
const Uuid& in_uuid, const string& in_appPackageName,
|
||||
std::shared_ptr<::aidl::android::hardware::drm::IDrmPlugin>* _aidl_return) {
|
||||
const char* sid = AIBinder_getCallingSid();
|
||||
sid = sid ? (std::strstr(sid, "mediadrmserver") ? sid : "app") : "nullptr";
|
||||
ALOGI("[%s][%s] calling %s", sid, in_appPackageName.c_str(),
|
||||
__PRETTY_FUNCTION__);
|
||||
|
||||
if (!isCryptoSchemeSupported(in_uuid)) {
|
||||
ALOGE(
|
||||
"Widevine Drm HAL: failed to create drm plugin, "
|
||||
"invalid crypto scheme");
|
||||
*_aidl_return = nullptr;
|
||||
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE);
|
||||
}
|
||||
|
||||
if (!isBlankAppPackageNameAllowed() && in_appPackageName.empty()) {
|
||||
ALOGE(
|
||||
"Widevine Drm HAL: Failed to create DRM Plugin, blank App Package "
|
||||
"Name disallowed.");
|
||||
*_aidl_return = nullptr;
|
||||
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE);
|
||||
}
|
||||
|
||||
std::shared_ptr<WVDrmPlugin> plugin = ::ndk::SharedRefBase::make<WVDrmPlugin>(
|
||||
getCDM(), in_appPackageName.c_str(), &sOemCryptoInterface,
|
||||
areSpoidsEnabled());
|
||||
|
||||
*_aidl_return = plugin;
|
||||
return toNdkScopedAStatus(Status::OK);
|
||||
}
|
||||
|
||||
bool WVDrmFactory::areSpoidsEnabled() {
|
||||
return firstApiLevel() >= 26; // Android O
|
||||
}
|
||||
|
||||
bool WVDrmFactory::isBlankAppPackageNameAllowed() {
|
||||
return firstApiLevel() < 29; // Android Q
|
||||
}
|
||||
|
||||
int32_t WVDrmFactory::firstApiLevel() {
|
||||
// Check what this device's first API level was.
|
||||
int32_t firstApiLevel =
|
||||
android::base::GetIntProperty<int32_t>("ro.product.first_api_level", 0);
|
||||
if (firstApiLevel == 0) {
|
||||
// First API Level is 0 on factory ROMs, but we can assume the current SDK
|
||||
// version is the first if it's a factory ROM.
|
||||
firstApiLevel =
|
||||
android::base::GetIntProperty<int32_t>("ro.build.version.sdk", 0);
|
||||
}
|
||||
return firstApiLevel;
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus WVDrmFactory::getSupportedCryptoSchemes(
|
||||
CryptoSchemes* _aidl_return) {
|
||||
CryptoSchemes schemes{};
|
||||
for (const auto& uuid : wvdrm::getSupportedCryptoSchemes()) {
|
||||
schemes.uuids.push_back({uuid});
|
||||
}
|
||||
|
||||
bool isL1 = wvcdm::WvContentDecryptionModule::IsSecurityLevelSupported(wvcdm::kSecurityLevelL1);
|
||||
for (auto mime : {wvcdm::ISO_BMFF_VIDEO_MIME_TYPE, wvcdm::ISO_BMFF_AUDIO_MIME_TYPE,
|
||||
wvcdm::WEBM_VIDEO_MIME_TYPE, wvcdm::WEBM_AUDIO_MIME_TYPE,
|
||||
wvcdm::CENC_INIT_DATA_FORMAT, wvcdm::HLS_INIT_DATA_FORMAT,
|
||||
wvcdm::WEBM_INIT_DATA_FORMAT}) {
|
||||
bool isAudio = wvcdm::WvContentDecryptionModule::IsAudio(mime);
|
||||
SupportedContentType ct{mime, SecurityLevel::SW_SECURE_CRYPTO, SecurityLevel::SW_SECURE_DECODE};
|
||||
if (isL1) {
|
||||
ct.maxLevel = isAudio ? SecurityLevel::HW_SECURE_DECODE : SecurityLevel::HW_SECURE_ALL;
|
||||
}
|
||||
schemes.mimeTypes.push_back(ct);
|
||||
}
|
||||
*_aidl_return = schemes;
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
string WVDrmFactory::stringToHex(const string& s) {
|
||||
string input(s.c_str());
|
||||
bool toHex = false;
|
||||
for (const char ch : input) {
|
||||
if (!isprint(ch)) {
|
||||
toHex = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!toHex) return input;
|
||||
|
||||
static constexpr char hex[] = "0123456789ABCDEF";
|
||||
|
||||
string output;
|
||||
output.reserve(input.length() * 2);
|
||||
for (const unsigned char ch : input) {
|
||||
output.push_back(hex[ch >> 4]);
|
||||
output.push_back(hex[ch & 15]);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
void WVDrmFactory::printCdmMetrics(int fd) {
|
||||
dprintf(fd, "\n**** Widevine Cdm Metrics ****\n");
|
||||
|
||||
// Verify that the version of the library that we linked against is
|
||||
// compatible with the version of the headers we compiled against.
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
android::sp<wvcdm::WvContentDecryptionModule> cdm(getCDM());
|
||||
|
||||
vector<drm_metrics::WvCdmMetrics> metrics;
|
||||
bool full_list_returned = true;
|
||||
wvcdm::CdmResponseType result =
|
||||
cdm->GetMetrics(&metrics, &full_list_returned);
|
||||
if (metrics.empty()) {
|
||||
dprintf(fd,
|
||||
"Metrics not available, please retry while streaming a video\n");
|
||||
} else if (!full_list_returned) {
|
||||
dprintf(fd,
|
||||
"Not all metrics are returned due to some GetMetric error, "
|
||||
"please check logcat for possible GetMetric errors.\n");
|
||||
}
|
||||
if (result == wvcdm::NO_ERROR) {
|
||||
for (auto& metric : metrics) {
|
||||
dprintf(fd, "*** Metric size=%zu\n", metric.DebugString().size());
|
||||
string formatted;
|
||||
wv_metrics::FormatWvCdmMetrics(metric, formatted);
|
||||
dprintf(fd, "%s\n", formatted.c_str());
|
||||
}
|
||||
} else {
|
||||
dprintf(fd, "GetMetrics failed, error=%d\n", result);
|
||||
}
|
||||
}
|
||||
|
||||
void WVDrmFactory::printCdmProperties(int fd) {
|
||||
dprintf(fd, "\nwidevine_cdm_properties:\n");
|
||||
|
||||
android::sp<wvcdm::WvContentDecryptionModule> cdm(getCDM());
|
||||
|
||||
const bool isLevel1 =
|
||||
cdm->IsSecurityLevelSupported(wvcdm::CdmSecurityLevel::kSecurityLevelL1);
|
||||
dprintf(fd, " default_security_level: '%s'\n", isLevel1 ? "L1" : "L3");
|
||||
|
||||
const std::map<string, string> cdmProperties = {
|
||||
{"version_widevine_cdm", wvcdm::QUERY_KEY_WVCDM_VERSION},
|
||||
{"version_current_srm", wvcdm::QUERY_KEY_CURRENT_SRM_VERSION},
|
||||
{"version_major_oemcrypto_api",
|
||||
wvcdm::QUERY_KEY_OEMCRYPTO_API_VERSION},
|
||||
{"version_minor_oemcrypto_api",
|
||||
wvcdm::QUERY_KEY_OEMCRYPTO_API_MINOR_VERSION},
|
||||
{"device_id", wvcdm::QUERY_KEY_DEVICE_ID},
|
||||
{"system_id", wvcdm::QUERY_KEY_SYSTEM_ID},
|
||||
{"renewal_server_url", wvcdm::QUERY_KEY_RENEWAL_SERVER_URL},
|
||||
{"hdcp_level_max", wvcdm::QUERY_KEY_MAX_HDCP_LEVEL},
|
||||
{"hdcp_level_current", wvcdm::QUERY_KEY_CURRENT_HDCP_LEVEL},
|
||||
{"num_sessions_max_supported", wvcdm::QUERY_KEY_MAX_NUMBER_OF_SESSIONS},
|
||||
{"num_sessions_opened", wvcdm::QUERY_KEY_NUMBER_OF_OPEN_SESSIONS},
|
||||
{"resource_rating_tier", wvcdm::QUERY_KEY_RESOURCE_RATING_TIER},
|
||||
{"support_decrypt_hash", wvcdm::QUERY_KEY_DECRYPT_HASH_SUPPORT},
|
||||
{"support_SRM_update", wvcdm::QUERY_KEY_SRM_UPDATE_SUPPORT},
|
||||
{"support_usage_table", wvcdm::QUERY_KEY_USAGE_SUPPORT},
|
||||
{"max_usage_table_entries", wvcdm::QUERY_KEY_MAX_USAGE_TABLE_ENTRIES},
|
||||
{"oemcrypto_build_info", wvcdm::QUERY_KEY_OEMCRYPTO_BUILD_INFORMATION},
|
||||
{"provisioning_id", wvcdm::QUERY_KEY_PROVISIONING_ID},
|
||||
{"provisioning_model", wvcdm::QUERY_KEY_PROVISIONING_MODEL},
|
||||
{"analog_capabilities", wvcdm::QUERY_KEY_ANALOG_OUTPUT_CAPABILITIES},
|
||||
{"can_disable_analog_output",
|
||||
wvcdm::QUERY_KEY_CAN_DISABLE_ANALOG_OUTPUT},
|
||||
{"watermarking_support", wvcdm::QUERY_KEY_WATERMARKING_SUPPORT},
|
||||
{"production_ready", wvcdm::QUERY_KEY_PRODUCTION_READY},
|
||||
};
|
||||
|
||||
string value;
|
||||
for (const auto& property : cdmProperties) {
|
||||
cdm->QueryStatus(wvcdm::RequestedSecurityLevel::kLevelDefault,
|
||||
property.second, &value);
|
||||
string outString = stringToHex(value);
|
||||
dprintf(fd, " %s: '%s'\n", property.first.c_str(), outString.c_str());
|
||||
value.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void WVDrmFactory::printUsage(int fd) {
|
||||
dprintf(fd, "\nDefault to print all info if no arguments are used.\n");
|
||||
dprintf(fd, "Optional arguments are:\n");
|
||||
dprintf(fd, "\ta:print all info | m:cdm metrics | p:cdm properties\n");
|
||||
dprintf(fd,
|
||||
"Usage: adb shell dumpsys "
|
||||
"android.hardware.drm.IDrmFactory/widevine [-a|-h|-m|-p]\n");
|
||||
}
|
||||
|
||||
binder_status_t WVDrmFactory::dump(int fd, const char** args,
|
||||
uint32_t numArgs) {
|
||||
if (fd < 0) {
|
||||
ALOGE("%s: missing fd for writing", __FUNCTION__);
|
||||
return STATUS_BAD_VALUE;
|
||||
}
|
||||
|
||||
bool dumpCdmProperties, dumpCdmMetrics = false;
|
||||
if (numArgs == 0) {
|
||||
// default to print all info if no arguments are given
|
||||
dumpCdmProperties = dumpCdmMetrics = true;
|
||||
} else {
|
||||
for (auto&& str : std::vector<std::string_view>{args, args + numArgs}) {
|
||||
string option = str.data();
|
||||
if (option.find("-a") != string::npos ||
|
||||
option.find("-A") != string::npos) {
|
||||
dumpCdmProperties = dumpCdmMetrics = true;
|
||||
} else if (option.find("-m") != string::npos ||
|
||||
option.find("-M") != string::npos) {
|
||||
dumpCdmMetrics = true;
|
||||
} else if (option.find("-p") != string::npos ||
|
||||
option.find("-P") != string::npos) {
|
||||
dumpCdmProperties = true;
|
||||
} else if (option.find("-h") != string::npos ||
|
||||
option.find("-H") != string::npos) {
|
||||
printUsage(fd);
|
||||
} else {
|
||||
dprintf(fd, "Invalid arg: %s\n", option.c_str());
|
||||
printUsage(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dumpCdmMetrics) printCdmMetrics(fd);
|
||||
if (dumpCdmProperties) printCdmProperties(fd);
|
||||
fsync(fd);
|
||||
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
||||
} // namespace widevine
|
||||
} // namespace drm
|
||||
} // namespace hardware
|
||||
} // namespace wvdrm
|
||||
@@ -0,0 +1,12 @@
|
||||
on property:init.svc.mediadrm=running
|
||||
mkdir /data/vendor/mediadrm 0770 media mediadrm
|
||||
|
||||
service vendor.drm-widevine-hal /vendor/bin/hw/android.hardware.drm-service-lazy.widevine
|
||||
interface aidl android.hardware.drm.IDrmFactory/widevine
|
||||
oneshot
|
||||
disabled
|
||||
class hal
|
||||
user media
|
||||
group media mediadrm drmrpc system
|
||||
ioprio rt 4
|
||||
task_profiles ProcessCapacityHigh
|
||||
10
libwvdrmengine/src/android.hardware.drm-service.widevine.rc
Normal file
10
libwvdrmengine/src/android.hardware.drm-service.widevine.rc
Normal file
@@ -0,0 +1,10 @@
|
||||
on property:init.svc.mediadrm=running
|
||||
mkdir /data/vendor/mediadrm 0770 media mediadrm
|
||||
|
||||
service vendor.drm-widevine-hal /vendor/bin/hw/android.hardware.drm-service.widevine
|
||||
interface aidl android.hardware.drm::IDrmFactory/widevine
|
||||
class hal
|
||||
user media
|
||||
group media mediadrm drmrpc system
|
||||
ioprio rt 4
|
||||
task_profiles ProcessCapacityHigh
|
||||
31
libwvdrmengine/src/fuzzer/README.md
Normal file
31
libwvdrmengine/src/fuzzer/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# About Widevine aidl binder fuzzer
|
||||
|
||||
## Build the binaries
|
||||
|
||||
See [go/build-fast][1] to setup the RBE environment.
|
||||
|
||||
From Android root:
|
||||
|
||||
1. source build/make/rbesetup.sh
|
||||
2. `SANITIZE_TARGET`=hwaddress m `android.hardware.drm-service.widevine.aidl_fuzzer` -j128
|
||||
|
||||
## Push to target for testing
|
||||
|
||||
adb push $(OUT)/data/fuzz/arm64/lib/ /data/fuzz/arm64/lib/
|
||||
|
||||
## Run test
|
||||
|
||||
adb shell<br>
|
||||
cd /data/fuzz/arm64<br>
|
||||
`LD_LIBRARY_PATH=/data/fuzz/arm65/lib /data/fuzz/arm64/android.hardware.drm-service.widevine.aidl_fuzzer/vendor/hw/android.hardware.drm-service.widevine.aidl_fuzzer`
|
||||
|
||||
## Monitoring
|
||||
|
||||
By using `cc_fuzz` in Android.bp, the fuzz binary and its dependency sanitized shared libraries will be installed on the device.<br>
|
||||
Libraries are installed in `/data/fuzz/<arch>/lib`, and the binary is installed in /data/fuzz/<arch>/<`binary_name`>/vendor/hw.<br>
|
||||
|
||||
Within 24-48 hours of merge, you can monitor the coverage data [here][2].<br>
|
||||
Bugs will be filed automatically, and the owner of the fuzzer(the cc in the config section) will be notified.<br>
|
||||
|
||||
[1]: https://g3doc.corp.google.com/company/teams/android/developing/update/build-fast.md?cl=head
|
||||
[2]: https://android-coverage.googleplex.com/
|
||||
34
libwvdrmengine/src/fuzzer/fuzzer.cpp
Normal file
34
libwvdrmengine/src/fuzzer/fuzzer.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <fuzzbinder/libbinder_ndk_driver.h>
|
||||
#include <fuzzer/FuzzedDataProvider.h>
|
||||
|
||||
#include "WVCreatePluginFactories.h"
|
||||
|
||||
using ::wvdrm::hardware::drm::widevine::createDrmFactory;
|
||||
using ::wvdrm::hardware::drm::widevine::WVDrmFactory;
|
||||
|
||||
using android::fuzzService;
|
||||
using ndk::SharedRefBase;
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
std::shared_ptr<WVDrmFactory> drmFactory = createDrmFactory();
|
||||
fuzzService(drmFactory->asBinder().get(), FuzzedDataProvider(data, size));
|
||||
|
||||
return 0;
|
||||
}
|
||||
42
libwvdrmengine/src/service.cpp
Normal file
42
libwvdrmengine/src/service.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "WidevineAidlService"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_ibinder_platform.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
#include "WVCreatePluginFactories.h"
|
||||
#include "WVDrmFactory.h"
|
||||
|
||||
using ::wvdrm::hardware::drm::widevine::createDrmFactory;
|
||||
using ::wvdrm::hardware::drm::widevine::WVDrmFactory;
|
||||
|
||||
int main(int /* argc */, char** /* argv */) {
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(8);
|
||||
|
||||
std::shared_ptr<WVDrmFactory> drmFactory = createDrmFactory();
|
||||
|
||||
const std::string drmInstance =
|
||||
std::string(WVDrmFactory::descriptor) + "/widevine";
|
||||
binder_status_t status = AServiceManager_addService(
|
||||
drmFactory->asBinder().get(), drmInstance.c_str());
|
||||
CHECK(status == STATUS_OK)
|
||||
<< "Failed to add Widevine Factory HAL, status=" << status;
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
}
|
||||
42
libwvdrmengine/src/serviceLazy.cpp
Normal file
42
libwvdrmengine/src/serviceLazy.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "WidevineAidlService"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_ibinder_platform.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
#include "WVCreatePluginFactories.h"
|
||||
#include "WVDrmFactory.h"
|
||||
|
||||
using ::wvdrm::hardware::drm::widevine::createDrmFactory;
|
||||
using ::wvdrm::hardware::drm::widevine::WVDrmFactory;
|
||||
|
||||
int main(int /* argc */, char** /* argv */) {
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(8);
|
||||
|
||||
std::shared_ptr<WVDrmFactory> drmFactory = createDrmFactory();
|
||||
|
||||
const std::string drmInstance =
|
||||
std::string(WVDrmFactory::descriptor) + "/widevine";
|
||||
binder_status_t status = AServiceManager_registerLazyService(
|
||||
drmFactory->asBinder().get(), drmInstance.c_str());
|
||||
CHECK(status == STATUS_OK)
|
||||
<< "Failed to add Widevine Factory HAL, status=" << status;
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
}
|
||||
451
libwvdrmengine/src/wv_metrics.cpp
Normal file
451
libwvdrmengine/src/wv_metrics.cpp
Normal file
@@ -0,0 +1,451 @@
|
||||
// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// Format widevine protobuf metrics
|
||||
|
||||
#include "wv_metrics.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
using namespace drm_metrics;
|
||||
using std::string;
|
||||
using std::to_string;
|
||||
|
||||
namespace {
|
||||
const string kIndentPerLine = " ";
|
||||
|
||||
string FormatCdmErrorTranslation(int error_code) {
|
||||
std::stringstream os;
|
||||
os << static_cast<wvcdm::CdmResponseType>(error_code);
|
||||
return " " + os.str();
|
||||
}
|
||||
|
||||
string FormatOEMCryptoResult(int oemcrypto_result) {
|
||||
std::stringstream os;
|
||||
os << static_cast<OEMCryptoResult>(oemcrypto_result);
|
||||
return " " + os.str();
|
||||
}
|
||||
|
||||
string FormatOEMCryptoInitializeMode(const ValueMetric& vm) {
|
||||
std::map<int, string> translations = {
|
||||
{0, "USING_IN_APP"},
|
||||
{1, "FORCING_L3"},
|
||||
{2, "USING_L3_NO_L1_LIBRARY_PATH"},
|
||||
{3, "USING_L3_L1_OPEN_FAILED"},
|
||||
{4, "USING_L3_L1_LOAD_FAILED"},
|
||||
{5, "USING_L3_COULD_NOT_INITIALIZE_L1"},
|
||||
{6, "USING_L3_WRONG_L1_VERSION"},
|
||||
{7, "USING_L1_WITH_KEYBOX"},
|
||||
{8, "USING_L1_WITH_CERTIFICATE"},
|
||||
{9, "USING_L1_CERTIFICATE_MIX"},
|
||||
{10, "USING_L3_BAD_KEYBOX"},
|
||||
{11, "USING_L3_COULD_NOT_OPEN_FACTORY_KEYBOX"},
|
||||
{12, "USING_L3_COULD_NOT_INSTALL_KEYBOX"},
|
||||
{13, "USING_L1_INSTALLED_KEYBOX"},
|
||||
{14, "USING_L3_INVALID_L1"},
|
||||
{15, "USING_L1_WITH_PROVISIONING_3_0"},
|
||||
{16, "L3_INITIALIZATION_GENERAL_FAILED"},
|
||||
{17, "L3_INITIALIZATION_RNG_FAILED"},
|
||||
{18, "L3_INITIALIZATION_SAVE_DEVICE_KEYS_FAILED"},
|
||||
{19, "L3_INITIALIZATION_READ_DEVICE_KEYS_FAILED"},
|
||||
{20, "L3_INITIALIZATION_VERIFY_DEVIE_KEYS_FAILED"}};
|
||||
return translations[vm.int_value()];
|
||||
}
|
||||
|
||||
string FormatOEMCryptoHdcpCapability(const ValueMetric& vm) {
|
||||
std::map<int, string> translations = {
|
||||
{0, "HDCP_NONE"}, {1, "HDCP_V1"}, {2, "HDCP_V2"},
|
||||
{3, "HDCP_V2_1"}, {4, "HDCP_V2_2"}, {5, "HDCP_V2_3"},
|
||||
{0xff, "NO_DIGITAL_OUTPUT"}};
|
||||
return translations[vm.int_value()];
|
||||
}
|
||||
|
||||
string FormatOEMCryptoProvisioningMethod(const ValueMetric& vm) {
|
||||
std::map<int, string> translations = {{0, "PROVISIONING_ERROR"},
|
||||
{1, "DRM_CERTIFICATE"},
|
||||
{2, "KEYBOX"},
|
||||
{3, "OEM_CERTIFICATE"}};
|
||||
return translations[vm.int_value()];
|
||||
}
|
||||
|
||||
string FormatAttributes(const Attributes& attributes) {
|
||||
string result;
|
||||
if (attributes.has_error_code()) {
|
||||
result.append("error_code:");
|
||||
result.append(to_string(attributes.error_code()));
|
||||
result.append(FormatCdmErrorTranslation(attributes.error_code()));
|
||||
}
|
||||
if (attributes.has_error_code_bool()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("success:");
|
||||
result.append(attributes.error_code_bool() ? "true" : "false");
|
||||
}
|
||||
if (attributes.has_cdm_security_level()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("cdm_security_level:");
|
||||
result.append(to_string(attributes.cdm_security_level()));
|
||||
}
|
||||
if (attributes.has_security_level()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("security_level:");
|
||||
result.append(to_string(attributes.security_level()));
|
||||
}
|
||||
if (attributes.has_length()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("length:");
|
||||
result.append(to_string(attributes.length()));
|
||||
}
|
||||
if (attributes.has_encryption_algorithm()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("encryption_algorithm:");
|
||||
result.append(to_string(attributes.encryption_algorithm()));
|
||||
}
|
||||
if (attributes.has_signing_algorithm()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("signing_algorithm:");
|
||||
result.append(to_string(attributes.signing_algorithm()));
|
||||
}
|
||||
if (attributes.has_oem_crypto_result()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("oemcrypto_result:");
|
||||
result.append(to_string(attributes.oem_crypto_result()));
|
||||
result.append(FormatOEMCryptoResult(attributes.oem_crypto_result()));
|
||||
}
|
||||
if (attributes.has_key_status_type()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("key_status_type:");
|
||||
result.append(to_string(attributes.key_status_type()));
|
||||
}
|
||||
if (attributes.has_event_type()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("event_type:");
|
||||
result.append(to_string(attributes.event_type()));
|
||||
}
|
||||
if (attributes.has_key_request_type()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("key_request_type:");
|
||||
result.append(to_string(attributes.key_request_type()));
|
||||
}
|
||||
if (attributes.has_license_type()) {
|
||||
if (result.size()) result.append(",");
|
||||
result.append("license_type:");
|
||||
result.append(to_string(attributes.license_type()));
|
||||
}
|
||||
if (result.size()) {
|
||||
return string(" {") + result + "}";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
string FormatCounterMetric(const CounterMetric& cm) {
|
||||
string result;
|
||||
if (cm.has_count()) {
|
||||
result = string("count=") + to_string(cm.count());
|
||||
if (cm.has_attributes()) {
|
||||
result.append(FormatAttributes(cm.attributes()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string FormatDistributionMetric(const DistributionMetric& dm) {
|
||||
string result;
|
||||
if (dm.has_min()) {
|
||||
std::ostringstream buffer;
|
||||
buffer << dm.min();
|
||||
result = string("min=") + buffer.str();
|
||||
}
|
||||
if (dm.has_max()) {
|
||||
std::ostringstream buffer;
|
||||
buffer << dm.max();
|
||||
if (result.size()) result.append(" ");
|
||||
result += string("max=") + buffer.str();
|
||||
}
|
||||
if (dm.has_mean()) {
|
||||
std::ostringstream buffer;
|
||||
buffer << dm.mean();
|
||||
if (result.size()) result.append(" ");
|
||||
result += string("mean=") + buffer.str();
|
||||
}
|
||||
if (dm.has_variance()) {
|
||||
std::ostringstream buffer;
|
||||
buffer << dm.variance();
|
||||
if (result.size()) result.append(" ");
|
||||
result += string("variance=") + buffer.str();
|
||||
}
|
||||
if (dm.has_operation_count()) {
|
||||
if (result.size()) result.append(" ");
|
||||
result += string("count=") + to_string(dm.operation_count());
|
||||
}
|
||||
if (dm.has_attributes()) {
|
||||
result.append(FormatAttributes(dm.attributes()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string FormatValueMetric(const ValueMetric& vm) {
|
||||
string result;
|
||||
if (vm.has_error_code()) {
|
||||
result.append("error(" + to_string(vm.error_code()));
|
||||
result.append(FormatCdmErrorTranslation(vm.error_code()));
|
||||
result.append(")");
|
||||
}
|
||||
if (vm.has_int_value()) {
|
||||
result.append(to_string(vm.int_value()));
|
||||
}
|
||||
if (vm.has_double_value()) {
|
||||
std::ostringstream buffer;
|
||||
buffer << vm.double_value();
|
||||
result.append(buffer.str());
|
||||
}
|
||||
if (vm.has_string_value()) {
|
||||
result.append("\"");
|
||||
result.append(vm.string_value());
|
||||
result.append("\"");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#define FORMAT_REPEATED_DISTRIBUTION(NAME, INDENT) \
|
||||
if (metrics.NAME##_size() == 1) { \
|
||||
result.append(INDENT + #NAME + ": "); \
|
||||
result.append(FormatDistributionMetric(metrics.NAME(0)) + "\n"); \
|
||||
} else { \
|
||||
for (int i = 0; i < metrics.NAME##_size(); i++) { \
|
||||
result.append(INDENT + #NAME "[" + to_string(i) + "]: "); \
|
||||
result.append(FormatDistributionMetric(metrics.NAME(i)) + "\n"); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FORMAT_REPEATED_COUNTER(NAME, INDENT) \
|
||||
if (metrics.NAME##_size() == 1) { \
|
||||
result.append(INDENT + #NAME ": "); \
|
||||
result.append(FormatCounterMetric(metrics.NAME(0)) + "\n"); \
|
||||
} else { \
|
||||
for (int i = 0; i < metrics.NAME##_size(); i++) { \
|
||||
result.append(INDENT + #NAME "[" + to_string(i) + "]: "); \
|
||||
result.append(FormatCounterMetric(metrics.NAME(i)) + "\n"); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FORMAT_OPTIONAL_VALUE(NAME, INDENT) \
|
||||
if (metrics.has_##NAME()) { \
|
||||
result.append(INDENT + #NAME ": " + FormatValueMetric(metrics.NAME()) + \
|
||||
"\n"); \
|
||||
}
|
||||
|
||||
#define FORMAT_OPTIONAL_INITIALIZATION_MODE(NAME, INDENT) \
|
||||
if (metrics.has_##NAME()) { \
|
||||
result.append(INDENT + #NAME ": "); \
|
||||
result.append(FormatOEMCryptoInitializeMode(metrics.NAME()) + "\n"); \
|
||||
}
|
||||
|
||||
#define FORMAT_OPTIONAL_HDCP_CAPABILITY(NAME, INDENT) \
|
||||
if (metrics.has_##NAME()) { \
|
||||
result.append(INDENT + #NAME ": "); \
|
||||
result.append(FormatOEMCryptoHdcpCapability(metrics.NAME()) + "\n"); \
|
||||
}
|
||||
|
||||
#define FORMAT_OPTIONAL_PROVISIONING_METHOD(NAME, INDENT) \
|
||||
if (metrics.has_##NAME()) { \
|
||||
result.append(INDENT + #NAME ": "); \
|
||||
result.append(FormatOEMCryptoProvisioningMethod(metrics.NAME()) + "\n"); \
|
||||
}
|
||||
|
||||
#define FORMAT_OPTIONAL_CRYPTO_METRICS(NAME, INDENT) \
|
||||
if (metrics.has_##NAME()) { \
|
||||
FormatCryptoMetrics(metrics.NAME(), INDENT + kIndentPerLine, result); \
|
||||
}
|
||||
|
||||
void FormatCryptoMetrics(const WvCdmMetrics_CryptoMetrics metrics,
|
||||
const string& indent, string& result) {
|
||||
// Crypto Session Metrics.
|
||||
FORMAT_OPTIONAL_VALUE(crypto_session_security_level, indent);
|
||||
FORMAT_REPEATED_COUNTER(crypto_session_delete_all_usage_reports, indent);
|
||||
FORMAT_REPEATED_COUNTER(crypto_session_delete_multiple_usage_information,
|
||||
indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(crypto_session_generic_decrypt_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(crypto_session_generic_encrypt_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(crypto_session_generic_sign_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(crypto_session_generic_verify_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(crypto_session_get_device_unique_id, indent);
|
||||
FORMAT_REPEATED_COUNTER(crypto_session_get_token, indent);
|
||||
FORMAT_OPTIONAL_VALUE(crypto_session_life_span, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(
|
||||
crypto_session_load_certificate_private_key_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(crypto_session_open_time_us, indent);
|
||||
FORMAT_OPTIONAL_VALUE(crypto_session_system_id, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(crypto_session_update_usage_information_time_us,
|
||||
indent);
|
||||
FORMAT_OPTIONAL_VALUE(crypto_session_usage_information_support, indent);
|
||||
|
||||
// Usage Table Metrics
|
||||
FORMAT_OPTIONAL_VALUE(usage_table_header_initial_size, indent);
|
||||
FORMAT_REPEATED_COUNTER(usage_table_header_add_entry, indent);
|
||||
FORMAT_REPEATED_COUNTER(usage_table_header_delete_entry, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(usage_table_header_update_entry_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(usage_table_header_load_entry, indent);
|
||||
|
||||
// Usage Table LRU Metrics
|
||||
FORMAT_OPTIONAL_VALUE(usage_table_header_lru_usage_info_count, indent);
|
||||
FORMAT_OPTIONAL_VALUE(usage_table_header_lru_offline_license_count, indent);
|
||||
FORMAT_OPTIONAL_VALUE(usage_table_header_lru_evicted_entry_staleness_s,
|
||||
indent);
|
||||
|
||||
// |usage_table_header_lru_evicted_entry_type| refers to the enumeration
|
||||
// CdmUsageEntryStorageType in wv_cdm_types.h.
|
||||
FORMAT_OPTIONAL_VALUE(usage_table_header_lru_evicted_entry_type, indent);
|
||||
|
||||
// OemCrypto metrics.
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_api_version, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_close_session, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_copy_buffer_time_us, indent);
|
||||
FORMAT_OPTIONAL_HDCP_CAPABILITY(oemcrypto_current_hdcp_capability, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_deactivate_usage_entry, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_decrypt_cenc_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_delete_usage_entry, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_delete_usage_table, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_derive_keys_from_session_key_time_us,
|
||||
indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_force_delete_usage_entry, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_generate_derived_keys_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_generate_nonce, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_generate_rsa_signature_time_us,
|
||||
indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_generate_signature_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_generic_decrypt_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_generic_encrypt_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_generic_sign_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_generic_verify_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_get_device_id, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_get_key_data_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_get_oem_public_certificate, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_get_random, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_initialize_time_us, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_is_anti_rollback_hw_present, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_is_keybox_valid, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_device_drm_key_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_entitled_keys_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_keys_time_us, indent);
|
||||
FORMAT_OPTIONAL_HDCP_CAPABILITY(oemcrypto_max_hdcp_capability, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_max_number_of_sessions, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_number_of_open_sessions, indent);
|
||||
FORMAT_OPTIONAL_PROVISIONING_METHOD(oemcrypto_provisioning_method, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_refresh_keys_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_report_usage, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_rewrap_device_rsa_key_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_rewrap_device_rsa_key_30_time_us,
|
||||
indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_security_patch_level, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_select_key_time_us, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_usage_table_support, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_update_usage_table, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_update_usage_entry, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_create_usage_table_header, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_load_usage_table_header, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_shrink_usage_table_header, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_create_new_usage_entry, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_load_usage_entry, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_move_entry, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_create_old_usage_entry, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_copy_old_usage_entry, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_set_sandbox, indent);
|
||||
FORMAT_REPEATED_COUNTER(oemcrypto_set_decrypt_hash, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_resource_rating_tier, indent);
|
||||
|
||||
// Oemcrypto V16 metrics below
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_prep_and_sign_license_request_time_us,
|
||||
indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_prep_and_sign_renewal_request_time_us,
|
||||
indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(
|
||||
oemcrypto_prep_and_sign_provisioning_request_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_license_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_renewal_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_provisioning_time_us, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_minor_api_version, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_maximum_usage_table_header_size, indent);
|
||||
|
||||
// OEMCrypto V17 metrics below.
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_watermarking_support, indent);
|
||||
}
|
||||
|
||||
void FormatSessionMetrics(const WvCdmMetrics_SessionMetrics& metrics,
|
||||
const string& indent, string& result) {
|
||||
FORMAT_OPTIONAL_VALUE(session_id, indent);
|
||||
FORMAT_OPTIONAL_CRYPTO_METRICS(crypto_metrics, indent);
|
||||
FORMAT_OPTIONAL_VALUE(cdm_session_life_span_ms, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(cdm_session_renew_key_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_session_restore_offline_session, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_session_restore_usage_session, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(cdm_session_license_request_latency_ms, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_build_info, indent);
|
||||
FORMAT_OPTIONAL_VALUE(license_sdk_version, indent);
|
||||
FORMAT_OPTIONAL_VALUE(license_service_version, indent);
|
||||
}
|
||||
|
||||
void FormatEngineMetrics(const WvCdmMetrics_EngineMetrics& metrics,
|
||||
const string& indent, string& result) {
|
||||
FORMAT_OPTIONAL_CRYPTO_METRICS(crypto_metrics, indent);
|
||||
|
||||
// OEMCrypto Initialize Metrics.
|
||||
FORMAT_OPTIONAL_INITIALIZATION_MODE(oemcrypto_initialization_mode, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_l1_api_version, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_l1_min_api_version, indent);
|
||||
FORMAT_OPTIONAL_VALUE(level3_oemcrypto_initialization_error, indent);
|
||||
FORMAT_OPTIONAL_VALUE(previous_oemcrypto_initialization_failure, indent);
|
||||
|
||||
// CdmEngine Metrics.
|
||||
FORMAT_OPTIONAL_VALUE(app_package_name, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(cdm_engine_add_key_time_us, indent);
|
||||
FORMAT_OPTIONAL_VALUE(cdm_engine_cdm_version, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_close_session, indent);
|
||||
FORMAT_OPTIONAL_VALUE(cdm_engine_creation_time_millis, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(cdm_engine_decrypt_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_find_session_for_key, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(cdm_engine_generate_key_request_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(cdm_engine_get_provisioning_request_time_us,
|
||||
indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_get_secure_stop_ids, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(cdm_engine_get_usage_info_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(cdm_engine_handle_provisioning_response_time_us,
|
||||
indent);
|
||||
FORMAT_OPTIONAL_VALUE(cdm_engine_life_span_ms, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_open_key_set_session, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_open_session, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(cdm_engine_query_key_status_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_release_all_usage_info, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_release_usage_info, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_remove_all_usage_info, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_remove_keys, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_remove_usage_info, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(cdm_engine_restore_key_time_us, indent);
|
||||
FORMAT_REPEATED_COUNTER(cdm_engine_unprovision, indent);
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
namespace wv_metrics {
|
||||
void FormatWvCdmMetrics(const WvCdmMetrics& metrics, string& result) {
|
||||
string indent = kIndentPerLine;
|
||||
string next_indent = indent + kIndentPerLine;
|
||||
|
||||
result.append("engine_metrics\n");
|
||||
if (metrics.has_engine_metrics()) {
|
||||
FormatEngineMetrics(metrics.engine_metrics(), indent, result);
|
||||
}
|
||||
result.append("session_metrics\n");
|
||||
for (int i = 0; i < metrics.session_metrics_size(); i++) {
|
||||
result.append(indent + "session[" + to_string(i) + "]\n");
|
||||
FormatSessionMetrics(metrics.session_metrics(i), next_indent, result);
|
||||
}
|
||||
}
|
||||
} // namespace wv_metrics
|
||||
Reference in New Issue
Block a user