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:
Robert Shih
2021-03-01 08:53:15 -08:00
parent 1ffc6ab16a
commit 7cb52c1ccf
19 changed files with 127 additions and 16 deletions

View File

@@ -11,6 +11,7 @@
#include <string>
#include "log.h"
#include "wv_cdm_constants.h"
namespace wvcdm {
@@ -38,6 +39,10 @@ struct CdmIdentifier {
// with a CdmEngine instance. This is a simple way to implement that.
uint32_t unique_id;
// Operating system user id of the application. Used to filter log messages.
// Defaults to UNKNOWN_UID.
uint32_t user_id;
// This method is needed to check to see if the identifier is equivalent
// to the default cdm. E.g. no spoid, origin or app package name. Use this
// comparison in lieu of the == operator when checking to see if the
@@ -52,7 +57,7 @@ struct CdmIdentifier {
inline bool operator==(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
return lhs.spoid == rhs.spoid && lhs.origin == rhs.origin &&
lhs.app_package_name == rhs.app_package_name &&
lhs.unique_id == rhs.unique_id;
lhs.unique_id == rhs.unique_id && lhs.user_id == rhs.user_id;
}
inline bool operator!=(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
@@ -66,7 +71,9 @@ inline bool operator<(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
(lhs.origin == rhs.origin &&
(lhs.app_package_name < rhs.app_package_name ||
(lhs.app_package_name == rhs.app_package_name &&
lhs.unique_id < rhs.unique_id)))));
(lhs.unique_id < rhs.unique_id ||
(lhs.unique_id == rhs.unique_id &&
lhs.user_id < rhs.user_id)))))));
}
inline bool operator>(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
@@ -82,8 +89,8 @@ inline bool operator>=(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
}
// Provide default
static const CdmIdentifier kDefaultCdmIdentifier = {EMPTY_SPOID, EMPTY_ORIGIN,
EMPTY_APP_PACKAGE_NAME, 0};
static const CdmIdentifier kDefaultCdmIdentifier = {
EMPTY_SPOID, EMPTY_ORIGIN, EMPTY_APP_PACKAGE_NAME, 0, UNKNOWN_UID};
} // namespace wvcdm