Widvine remote provisioning HAL implementation
This HAL implementation should be included in the factory image only. BUG: 213415013 Test: manual Change-Id: Icc0cc7f767a647238ce319623e0408ec22531f58
This commit is contained in:
91
libwvdrmengine/factory_upload_tool/src/log.cpp
Normal file
91
libwvdrmengine/factory_upload_tool/src/log.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
//
|
||||
// Log - implemented using the standard Android logging mechanism
|
||||
|
||||
/*
|
||||
* Qutoing from system/core/include/log/log.h:
|
||||
* Normally we strip ALOGV (VERBOSE messages) from release builds.
|
||||
* You can modify this (for example with "#define LOG_NDEBUG 0"
|
||||
* at the top of your source file) to change that behavior.
|
||||
*/
|
||||
#ifndef LOG_NDEBUG
|
||||
# ifdef NDEBUG
|
||||
# define LOG_NDEBUG 1
|
||||
# else
|
||||
# define LOG_NDEBUG 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define LOG_TAG "Widevine"
|
||||
#define LOG_BUF_SIZE 1024
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
/*
|
||||
* Uncomment the line below if you want to have the LOGV messages to print
|
||||
* IMPORTANT : this will affect all of CDM
|
||||
*/
|
||||
|
||||
// #define LOG_NDEBUG 0
|
||||
|
||||
namespace wvutil {
|
||||
|
||||
LogPriority g_cutoff = CDM_LOG_INFO;
|
||||
|
||||
void InitLogging() {}
|
||||
|
||||
void Log(const char* file, const char* function, int line, LogPriority level,
|
||||
const char* format, ...) {
|
||||
if (level > g_cutoff) return;
|
||||
|
||||
const char* filename = strrchr(file, '/');
|
||||
filename = filename == nullptr ? file : filename + 1;
|
||||
|
||||
char buf[LOG_BUF_SIZE];
|
||||
int len =
|
||||
snprintf(buf, LOG_BUF_SIZE, "[%s(%d):%s] ", filename, line, function);
|
||||
if (len < 0) len = 0;
|
||||
if (static_cast<unsigned int>(len) < sizeof(buf)) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf(buf + len, LOG_BUF_SIZE - len, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
android_LogPriority prio = ANDROID_LOG_VERBOSE;
|
||||
|
||||
switch (level) {
|
||||
case CDM_LOG_ERROR:
|
||||
prio = ANDROID_LOG_ERROR;
|
||||
break;
|
||||
case CDM_LOG_WARN:
|
||||
prio = ANDROID_LOG_WARN;
|
||||
break;
|
||||
case CDM_LOG_INFO:
|
||||
prio = ANDROID_LOG_INFO;
|
||||
break;
|
||||
case CDM_LOG_DEBUG:
|
||||
prio = ANDROID_LOG_DEBUG;
|
||||
break;
|
||||
#if LOG_NDEBUG
|
||||
case CDM_LOG_VERBOSE:
|
||||
return;
|
||||
#else
|
||||
case CDM_LOG_VERBOSE:
|
||||
prio = ANDROID_LOG_VERBOSE;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
__android_log_write(prio, LOG_TAG, buf);
|
||||
}
|
||||
|
||||
} // namespace wvutil
|
||||
Reference in New Issue
Block a user