Files
android/libwvdrmengine/src/WVCryptoFactory.cpp
John "Juce" Bruce 4b8dd050bf Downgrade Non-Critical Errors to Warnings
We are getting a lot of noise from Android bug-filers who are
concerned about several non-critical errors that show up when using
Widevine CDM on some devices or in some use cases. To mitigate this,
we are downgrading these errors to warnings.

Some of these errors pertained to our legacy support. To make sure
an error IS logged if problems with legacy support become critical,
a new error has been added to that code path.

Bug: 15136575
Change-Id: Id28bcf507f277a5d2f35a14da71bba2b118a54fe
2014-07-01 16:24:39 -07:00

93 lines
2.4 KiB
C++

//
// Copyright 2013 Google Inc. All Rights Reserved.
//
//#define LOG_NDEBUG 0
#define LOG_TAG "WVCdm"
#include <utils/Log.h>
#include "WVCryptoFactory.h"
#include <dlfcn.h>
#include "utils/Errors.h"
#include "WVCDMSingleton.h"
#include "WVCryptoPlugin.h"
#include "WVUUID.h"
namespace wvdrm {
using namespace android;
WVCryptoFactory::WVCryptoFactory()
: mLegacyLibraryHandle(NULL),
mLegacyFactory(NULL) {
mLegacyLibraryHandle = dlopen("libdrmdecrypt.so", RTLD_NOW);
if (mLegacyLibraryHandle == NULL) {
ALOGW("Unable to locate libdrmdecrypt.so");
} else {
typedef CryptoFactory* (*CreateCryptoFactoryFunc)();
CreateCryptoFactoryFunc legacyCreateCryptoFactory =
(CreateCryptoFactoryFunc)dlsym(mLegacyLibraryHandle,
"createCryptoFactory");
if (legacyCreateCryptoFactory == NULL) {
ALOGW("Unable to find legacy symbol 'createCryptoFactory'.");
dlclose(mLegacyLibraryHandle);
mLegacyLibraryHandle = NULL;
} else {
mLegacyFactory = legacyCreateCryptoFactory();
if (mLegacyFactory == NULL) {
ALOGW("Legacy createCryptoFactory() failed.");
dlclose(mLegacyLibraryHandle);
mLegacyLibraryHandle = NULL;
}
}
}
}
WVCryptoFactory::~WVCryptoFactory() {
if (mLegacyFactory != NULL) {
delete mLegacyFactory;
mLegacyFactory = NULL;
}
if (mLegacyLibraryHandle != NULL) {
dlclose(mLegacyLibraryHandle);
mLegacyLibraryHandle = NULL;
}
}
bool WVCryptoFactory::isCryptoSchemeSupported(const uint8_t uuid[16]) const {
return isWidevineUUID(uuid);
}
status_t WVCryptoFactory::createPlugin(const uint8_t uuid[16], const void* data,
size_t size, CryptoPlugin** plugin) {
if (!isCryptoSchemeSupported(uuid)) {
*plugin = NULL;
return BAD_VALUE;
}
// 0 size means they want an old-style Widevine plugin
if (size == 0) {
if (mLegacyFactory == NULL) {
ALOGE("Legacy crypto factory loading failed. Cannot create legacy "
"plugin. Look for warnings about this that were logged earlier, "
"during CryptoFactory instantiation.");
return -EINVAL;
}
return mLegacyFactory->createPlugin(uuid, data, size, plugin);
}
// We received a session ID, so create a CENC plugin.
*plugin = new WVCryptoPlugin(data, size, getCDM());
return OK;
}
} // namespace wvdrm