Merge latest oemcrypto-v17 change

No-Typo-Check: Not related to this change.

Bug: 161477208
Change-Id: I99e4780f6855b7045aa0cd5a49c13d2d0d51ed64
This commit is contained in:
Kyle Zhang
2022-01-21 05:58:12 +00:00
committed by Fred Gylys-Colwell
parent c924960962
commit 642965c678
176 changed files with 301013 additions and 296749 deletions

View File

@@ -13,7 +13,7 @@
// This type alias is for convenience.
using CdmRandomLock = std::unique_lock<std::mutex>;
namespace wvcdm {
namespace wvutil {
namespace {
// More information about C++11's random number generators can be found
@@ -77,10 +77,10 @@ std::string CdmRandomGenerator::RandomData(size_t length) {
return std::string();
}
CdmRandomLock lock(generator_lock_);
std::uniform_int_distribution<uint8_t> dist; // Range of [0, 255].
std::uniform_int_distribution<short> dist(0, 255); // Range of [0, 255].
std::string random_data(length, '\0');
std::generate(random_data.begin(), random_data.end(),
[&]() { return dist(generator_); });
[&]() { return static_cast<char>(dist(generator_)); });
return random_data;
}
@@ -104,4 +104,4 @@ CdmRandomGenerator* CdmRandom::GetInstance() {
return g_instance;
}
} // namespace wvcdm
} // namespace wvutil

View File

@@ -8,7 +8,7 @@
#include <sys/time.h>
namespace wvcdm {
namespace wvutil {
int64_t Clock::GetCurrentTime() {
struct timeval tv;
@@ -17,4 +17,4 @@ int64_t Clock::GetCurrentTime() {
return tv.tv_sec;
}
} // namespace wvcdm
} // namespace wvutil

View File

@@ -20,7 +20,6 @@
#include "file_utils.h"
#include "log.h"
#include "string_conversions.h"
#include "wv_cdm_constants.h"
#include <openssl/md5.h>
@@ -28,7 +27,7 @@
// to strerror_r(3).
#define ERRORSTR_BUF_SIZE 1024
namespace wvcdm {
namespace wvutil {
namespace {
// Maximum number of attempts to read or write on a file.
constexpr size_t kMaxIoAttempts = 5;
@@ -42,6 +41,8 @@ constexpr int kClosedFd = -1;
// handling code to enter a bad state.
constexpr int kNoError = 0;
constexpr char kEmptyOrigin[] = "";
// Reads from file specified by |fd| into the provided |buffer| up to
// the number of bytes specified by |count|.
// This is an internal function and assumes that all parameters are
@@ -282,7 +283,7 @@ std::string GetFileNameSafeHash(const std::string& input) {
std::vector<uint8_t> hash(MD5_DIGEST_LENGTH);
MD5(reinterpret_cast<const uint8_t*>(input.data()), input.size(),
hash.data());
return wvcdm::Base64SafeEncode(hash);
return wvutil::Base64SafeEncode(hash);
}
std::string GetFileNameForIdentifier(const std::string path,
@@ -425,7 +426,7 @@ class AndroidFile : public File {
class FileSystem::Impl {};
FileSystem::FileSystem() : FileSystem(EMPTY_ORIGIN, nullptr) {}
FileSystem::FileSystem() : FileSystem(kEmptyOrigin, nullptr) {}
FileSystem::FileSystem(const std::string& origin, void* /* extra_data */)
: origin_(origin) {}
@@ -528,4 +529,4 @@ void FileSystem::set_origin(const std::string& origin) { origin_ = origin; }
void FileSystem::set_identifier(const std::string& identifier) {
identifier_ = identifier;
}
} // namespace wvcdm
} // namespace wvutil

View File

@@ -15,11 +15,9 @@
#include <cstring>
#include "file_store.h"
#include "log.h"
#include "properties.h"
namespace wvcdm {
namespace wvutil {
bool IsCurrentOrParentDirectory(const char* dir) {
return strcmp(dir, kCurrentDirectory) == 0 ||
@@ -228,4 +226,4 @@ bool FileUtils::CreateDirectory(const std::string& path_in) {
return true;
}
} // namespace wvcdm
} // namespace wvutil

View File

@@ -39,7 +39,7 @@
// #define LOG_NDEBUG 0
namespace wvcdm {
namespace wvutil {
namespace {
int64_t GetCurrentTimeMs() {
@@ -141,4 +141,4 @@ std::vector<LogMessage> LogBuffer::getLogs() {
return {buffer_.begin(), buffer_.end()};
}
} // namespace wvcdm
} // namespace wvutil

View File

@@ -6,7 +6,7 @@
#include "log.h"
namespace wvcdm {
namespace wvutil {
shared_mutex::~shared_mutex() {
if (reader_count_ > 0) {
@@ -57,4 +57,4 @@ void shared_mutex::unlock() {
condition_variable_.notify_all();
}
} // namespace wvcdm
} // namespace wvutil

View File

@@ -14,7 +14,7 @@
#include "log.h"
#include "platform.h"
namespace wvcdm {
namespace wvutil {
namespace {
// Base64 character set, indexed for their 6-bit mapping, plus '='.
const char kBase64Codes[] =
@@ -326,4 +326,4 @@ std::string EncodeUint32(unsigned int u) {
return s;
}
} // namespace wvcdm
} // namespace wvutil