Merge "VintfObject: use toXml." am: e8456d8ded am: c3a768efaf

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1678425

Change-Id: I4010afc700a61f7221f8d6fac7109ec0ca51e932
This commit is contained in:
Yifan Hong
2021-04-21 19:04:05 +00:00
committed by Automerger Merge Worker

View File

@@ -40,12 +40,10 @@ namespace android {
using vintf::HalManifest; using vintf::HalManifest;
using vintf::Level; using vintf::Level;
using vintf::SchemaType; using vintf::SchemaType;
using vintf::VintfObject;
using vintf::XmlConverter;
using vintf::Vndk;
using vintf::gHalManifestConverter;
using vintf::gCompatibilityMatrixConverter;
using vintf::to_string; using vintf::to_string;
using vintf::toXml;
using vintf::VintfObject;
using vintf::Vndk;
template<typename V> template<typename V>
static inline jobjectArray toJavaStringArray(JNIEnv* env, const V& v) { static inline jobjectArray toJavaStringArray(JNIEnv* env, const V& v) {
@@ -59,13 +57,12 @@ static inline jobjectArray toJavaStringArray(JNIEnv* env, const V& v) {
} }
template <typename T> template <typename T>
static void tryAddSchema(const std::shared_ptr<const T>& object, const XmlConverter<T>& converter, static void tryAddSchema(const std::shared_ptr<const T>& object, const std::string& description,
const std::string& description,
std::vector<std::string>* cStrings) { std::vector<std::string>* cStrings) {
if (object == nullptr) { if (object == nullptr) {
LOG(WARNING) << __FUNCTION__ << "Cannot get " << description; LOG(WARNING) << __FUNCTION__ << "Cannot get " << description;
} else { } else {
cStrings->push_back(converter(*object)); cStrings->push_back(toXml(*object));
} }
} }
@@ -84,14 +81,12 @@ static jobjectArray android_os_VintfObject_report(JNIEnv* env, jclass)
{ {
std::vector<std::string> cStrings; std::vector<std::string> cStrings;
tryAddSchema(VintfObject::GetDeviceHalManifest(), gHalManifestConverter, tryAddSchema(VintfObject::GetDeviceHalManifest(), "device manifest", &cStrings);
"device manifest", &cStrings); tryAddSchema(VintfObject::GetFrameworkHalManifest(), "framework manifest", &cStrings);
tryAddSchema(VintfObject::GetFrameworkHalManifest(), gHalManifestConverter, tryAddSchema(VintfObject::GetDeviceCompatibilityMatrix(), "device compatibility matrix",
"framework manifest", &cStrings); &cStrings);
tryAddSchema(VintfObject::GetDeviceCompatibilityMatrix(), gCompatibilityMatrixConverter, tryAddSchema(VintfObject::GetFrameworkCompatibilityMatrix(), "framework compatibility matrix",
"device compatibility matrix", &cStrings); &cStrings);
tryAddSchema(VintfObject::GetFrameworkCompatibilityMatrix(), gCompatibilityMatrixConverter,
"framework compatibility matrix", &cStrings);
return toJavaStringArray(env, cStrings); return toJavaStringArray(env, cStrings);
} }