Use aidl interface for Widevine service.

The interface is defined in
hardware/interfaces/drm/aidl(http://go/ag/15329852).

Test: build
  m android.hardware.drm-service.widevine -j128

Test: build_and_run_all_unit_tests.sh
  for hidl tests

Test: atest VtsAidlHalDrmTargetTest

Bug: 200055138
Bug: 170964303
Change-Id: If2f2a129914436ba5cef1c46f6cb9415e12c3d1c
This commit is contained in:
Edwin
2021-12-30 11:39:14 -08:00
parent 642965c678
commit 96a8ccd4a1
75 changed files with 7077 additions and 1479 deletions

View File

@@ -22,13 +22,13 @@ namespace wvutil {
typedef enum {
// This log level should only be used for |g_cutoff|, in order to silence all
// logging. It should never be passed to |Log()| as a log level.
LOG_SILENT = -1,
CDM_LOG_SILENT = -1,
LOG_ERROR = 0,
LOG_WARN = 1,
LOG_INFO = 2,
LOG_DEBUG = 3,
LOG_VERBOSE = 4,
CDM_LOG_ERROR = 0,
CDM_LOG_WARN = 1,
CDM_LOG_INFO = 2,
CDM_LOG_DEBUG = 3,
CDM_LOG_VERBOSE = 4,
} LogPriority;
extern LogPriority g_cutoff;
@@ -93,15 +93,15 @@ CORE_UTIL_EXPORT void Log(const char* file, const char* function, int line,
// Log APIs
#ifndef LOGE
# define LOGE(...) \
Log(__FILE__, __func__, __LINE__, wvutil::LOG_ERROR, __VA_ARGS__)
Log(__FILE__, __func__, __LINE__, wvutil::CDM_LOG_ERROR, __VA_ARGS__)
# define LOGW(...) \
Log(__FILE__, __func__, __LINE__, wvutil::LOG_WARN, __VA_ARGS__)
Log(__FILE__, __func__, __LINE__, wvutil::CDM_LOG_WARN, __VA_ARGS__)
# define LOGI(...) \
Log(__FILE__, __func__, __LINE__, wvutil::LOG_INFO, __VA_ARGS__)
Log(__FILE__, __func__, __LINE__, wvutil::CDM_LOG_INFO, __VA_ARGS__)
# define LOGD(...) \
Log(__FILE__, __func__, __LINE__, wvutil::LOG_DEBUG, __VA_ARGS__)
Log(__FILE__, __func__, __LINE__, wvutil::CDM_LOG_DEBUG, __VA_ARGS__)
# define LOGV(...) \
Log(__FILE__, __func__, __LINE__, wvutil::LOG_VERBOSE, __VA_ARGS__)
Log(__FILE__, __func__, __LINE__, wvutil::CDM_LOG_VERBOSE, __VA_ARGS__)
#endif
} // namespace wvutil

View File

@@ -11,23 +11,27 @@
* 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
#ifdef NDEBUG
#define LOG_NDEBUG 1
#else
#define LOG_NDEBUG 0
#endif
#endif
#define LOG_TAG "WVCdm"
#define LOG_BUF_SIZE 5120
#include "log.h"
#include <hwbinder/IPCThreadState.h>
#include <utils/Log.h>
#ifdef IS_HIDL
#include <hwbinder/IPCThreadState.h>
#else // AIDL is the default
#include <binder/IPCThreadState.h>
#endif
#include <stdarg.h>
#include <stdio.h>
#include <sys/time.h>
#include <utils/Log.h>
#include <mutex>
#include <string>
@@ -51,7 +55,7 @@ int64_t GetCurrentTimeMs() {
}
} // namespace
LogPriority g_cutoff = LOG_VERBOSE;
LogPriority g_cutoff = CDM_LOG_VERBOSE;
LogBuffer g_logbuf;
@@ -72,7 +76,11 @@ void ClearLoggingUid() {
uint32_t GetLoggingUid() { return tl_logging_uid_; }
uint32_t GetIpcCallingUid() {
#ifdef IS_HIDL
const auto self = android::hardware::IPCThreadState::selfOrNull();
#else // AIDL is the default
const auto self = android::IPCThreadState::selfOrNull();
#endif
return self ? self->getCallingUid() : UNKNOWN_UID;
}
@@ -97,32 +105,32 @@ void Log(const char* file, const char* function, int line, LogPriority level,
android_LogPriority prio = ANDROID_LOG_VERBOSE;
switch (level) {
case LOG_SILENT:
return; // It is nonsensical to pass LOG_SILENT.
case LOG_ERROR:
case CDM_LOG_SILENT:
return; // It is nonsensical to pass CDM_LOG_SILENT.
case CDM_LOG_ERROR:
prio = ANDROID_LOG_ERROR;
break;
case LOG_WARN:
case CDM_LOG_WARN:
prio = ANDROID_LOG_WARN;
break;
case LOG_INFO:
case CDM_LOG_INFO:
prio = ANDROID_LOG_INFO;
break;
case LOG_DEBUG:
case CDM_LOG_DEBUG:
prio = ANDROID_LOG_DEBUG;
break;
#if LOG_NDEBUG
case LOG_VERBOSE:
case CDM_LOG_VERBOSE:
return;
#else
case LOG_VERBOSE:
case CDM_LOG_VERBOSE:
prio = ANDROID_LOG_VERBOSE;
break;
#endif
}
__android_log_write(prio, LOG_TAG, buf);
if (level <= LOG_INFO) {
if (level <= CDM_LOG_INFO) {
uint32_t uid = tl_logging_uid_set_ ? tl_logging_uid_ : GetIpcCallingUid();
g_logbuf.addLog({uid, GetCurrentTimeMs(), level, buf});
}