Move json util code to common
So that it can be shared by CE CDM extraction tool later. Test: m wv_factory_extraction_tool Bug: 414642286 Change-Id: I6dba70227ce2789dd3686ebbf6ed3a0dbf68dc00
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "WidevineOemcryptoInterface.h"
|
||||
#include "json_utils.h"
|
||||
#include "log.h"
|
||||
#include "properties.h"
|
||||
#include "string_conversions.h"
|
||||
@@ -32,51 +33,6 @@ const std::vector<std::vector<uint8_t>> kAuthorizedEekRoots = {
|
||||
0x62, 0xDC, 0x3E, 0x61, 0xAB, 0x57, 0x48, 0x7D, 0x75, 0x37, 0x29,
|
||||
0xAD, 0x76, 0x80, 0x32, 0xD2, 0xB3, 0xCB, 0x63, 0x58, 0xD9},
|
||||
};
|
||||
|
||||
std::string EscapeJson(const std::string& input) {
|
||||
std::string result;
|
||||
for (std::string::const_iterator c = input.begin(); c != input.end(); ++c) {
|
||||
switch (*c) {
|
||||
case '\"':
|
||||
result += "\\\"";
|
||||
break;
|
||||
case '\\':
|
||||
result += "\\\\";
|
||||
break;
|
||||
case '\b':
|
||||
result += "\\b";
|
||||
break;
|
||||
case '\f':
|
||||
result += "\\f";
|
||||
break;
|
||||
case '\n':
|
||||
result += "\\n";
|
||||
break;
|
||||
case '\r':
|
||||
result += "\\r";
|
||||
break;
|
||||
case '\t':
|
||||
result += "\\t";
|
||||
break;
|
||||
default:
|
||||
result += *c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string StringMapToJson(
|
||||
const std::map<std::string, std::string>& string_map) {
|
||||
std::string json = "{";
|
||||
for (const auto& value_pair : string_map) {
|
||||
json.append("\"" + value_pair.first + "\": " + "\"" + value_pair.second +
|
||||
"\",");
|
||||
}
|
||||
json.resize(json.size() - 1); // Remove the last comma.
|
||||
json.append("}");
|
||||
return json;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
WidevineProvisioner::WidevineProvisioner() {
|
||||
|
||||
Reference in New Issue
Block a user