Cherry pick 18.4 changes to udc-widevine-dev
Get the udc-widevine-dev Android branch and oemcrypto-v18 cdm branch in sync. The commit ID for 18.4 on oemcrypto-v18 is a2f23a2281e5e06dc2867585bdc516fa132b6396. Merged from go/wvgerrit/190151 Bug: 290252845 Test: WVTS tests are running and passing Change-Id: I457332e7ca70a5b5169345e1279b3eb9f18413b6
This commit is contained in:
64
libwvdrmengine/cdm/test/level3_file_system_ce_test.cpp
Normal file
64
libwvdrmengine/cdm/test/level3_file_system_ce_test.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
|
||||
/**
|
||||
The test file system for the Level 3 OEMCrypto sits on top of the host file
|
||||
system. A real production version may either use the host file system or it
|
||||
may write files directly to the file system.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "level3_file_system_ce_test.h"
|
||||
|
||||
#include "test_host.h"
|
||||
|
||||
namespace wvoec3 {
|
||||
|
||||
ssize_t OEMCrypto_Level3CETestFileSystem::Read(const char* filename,
|
||||
void* buffer, size_t size) {
|
||||
if (!g_host) return 0;
|
||||
const std::string name(filename);
|
||||
if (!g_host->global_storage().exists(name)) return 0;
|
||||
std::string data;
|
||||
if (!g_host->global_storage().read(name, &data)) return 0;
|
||||
size_t bytes_read = std::min(size, data.size());
|
||||
memcpy(buffer, data.data(), bytes_read);
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
ssize_t OEMCrypto_Level3CETestFileSystem::Write(const char* filename,
|
||||
const void* buffer,
|
||||
size_t size) {
|
||||
if (!g_host) return 0;
|
||||
std::string data(static_cast<const char*>(buffer), size);
|
||||
const std::string name(filename);
|
||||
if (!g_host->global_storage().write(name, data)) return 0;
|
||||
return size;
|
||||
}
|
||||
|
||||
bool OEMCrypto_Level3CETestFileSystem::Exists(const char* filename) {
|
||||
if (!g_host) return false;
|
||||
const std::string name(filename);
|
||||
return g_host->global_storage().exists(name);
|
||||
}
|
||||
|
||||
ssize_t OEMCrypto_Level3CETestFileSystem::FileSize(const char* filename) {
|
||||
if (!g_host) return 0;
|
||||
const std::string name(filename);
|
||||
if (!g_host->global_storage().exists(name)) return 0;
|
||||
return static_cast<ssize_t>(g_host->global_storage().size(name));
|
||||
}
|
||||
|
||||
bool OEMCrypto_Level3CETestFileSystem::Remove(const char* filename) {
|
||||
if (!g_host) return false;
|
||||
const std::string name(filename);
|
||||
if (!g_host->global_storage().exists(name)) return false;
|
||||
return g_host->global_storage().remove(name);
|
||||
}
|
||||
|
||||
} // namespace wvoec3
|
||||
Reference in New Issue
Block a user