wvcdm: filter logs by app uid
This commit is a combination of the following: * http://go/wvgerrit/117003 * http://go/wvgerrit/118303 Bug: 162255728 Test: MediaDrmTest#testGetLogMessages Change-Id: I5699b64d5c4bab463e5b587595fa7d324dc1d93f
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#define LOG_BUF_SIZE 1024
|
||||
|
||||
#include "log.h"
|
||||
#include <hwbinder/IPCThreadState.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
@@ -54,6 +55,27 @@ LogPriority g_cutoff = LOG_VERBOSE;
|
||||
|
||||
LogBuffer g_logbuf;
|
||||
|
||||
thread_local bool tl_logging_uid_set_ = false;
|
||||
|
||||
thread_local uint32_t tl_logging_uid_ = UNKNOWN_UID;
|
||||
|
||||
void SetLoggingUid(const uint32_t uid) {
|
||||
tl_logging_uid_set_ = true;
|
||||
tl_logging_uid_ = uid;
|
||||
}
|
||||
|
||||
void ClearLoggingUid() {
|
||||
tl_logging_uid_set_ = false;
|
||||
tl_logging_uid_ = UNKNOWN_UID;
|
||||
}
|
||||
|
||||
uint32_t GetLoggingUid() { return tl_logging_uid_; }
|
||||
|
||||
uint32_t GetIpcCallingUid() {
|
||||
const auto self = android::hardware::IPCThreadState::selfOrNull();
|
||||
return self ? self->getCallingUid() : UNKNOWN_UID;
|
||||
}
|
||||
|
||||
void InitLogging() {}
|
||||
|
||||
void Log(const char* file, const char* function, int line, LogPriority level,
|
||||
@@ -101,7 +123,8 @@ void Log(const char* file, const char* function, int line, LogPriority level,
|
||||
|
||||
__android_log_write(prio, LOG_TAG, buf);
|
||||
if (level <= LOG_INFO) {
|
||||
g_logbuf.addLog({GetCurrentTimeMs(), level, buf});
|
||||
uint32_t uid = tl_logging_uid_set_ ? tl_logging_uid_ : GetIpcCallingUid();
|
||||
g_logbuf.addLog({uid, GetCurrentTimeMs(), level, buf});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user