Merge "Ignore resources from unknown types" am: e0f44eb6e7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1430090 Change-Id: Ide8fdd4edb88574b046ed7302fb3e3e9415a8db3
This commit is contained in:
@@ -96,8 +96,6 @@ StringPiece to_string(ResourceType type) {
|
|||||||
return "styleable";
|
return "styleable";
|
||||||
case ResourceType::kTransition:
|
case ResourceType::kTransition:
|
||||||
return "transition";
|
return "transition";
|
||||||
case ResourceType::kUnknown:
|
|
||||||
return "unknown";
|
|
||||||
case ResourceType::kXml:
|
case ResourceType::kXml:
|
||||||
return "xml";
|
return "xml";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,11 +66,6 @@ enum class ResourceType {
|
|||||||
kStyle,
|
kStyle,
|
||||||
kStyleable,
|
kStyleable,
|
||||||
kTransition,
|
kTransition,
|
||||||
|
|
||||||
// Not a parsed type. It is only used when loading resource tables that may have modified type
|
|
||||||
// names
|
|
||||||
kUnknown,
|
|
||||||
|
|
||||||
kXml,
|
kXml,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -352,15 +352,15 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package,
|
|||||||
config.copyFromDtoH(type->config);
|
config.copyFromDtoH(type->config);
|
||||||
|
|
||||||
const std::string type_str = util::GetString(type_pool_, type->id - 1);
|
const std::string type_str = util::GetString(type_pool_, type->id - 1);
|
||||||
|
const ResourceType* parsed_type = ParseResourceType(type_str);
|
||||||
// Be lenient on the name of the type if the table is lenient on resource validation.
|
if (!parsed_type) {
|
||||||
auto parsed_type = ResourceType::kUnknown;
|
// Be lenient on the name of the type if the table is lenient on resource validation.
|
||||||
if (const ResourceType* parsed = ParseResourceType(type_str)) {
|
bool log_error = table_->GetValidateResources();
|
||||||
parsed_type = *parsed;
|
if (log_error) {
|
||||||
} else if (table_->GetValidateResources()) {
|
diag_->Error(DiagMessage(source_) << "invalid type name '" << type_str
|
||||||
diag_->Error(DiagMessage(source_) << "invalid type name '" << type_str << "' for type with ID "
|
<< "' for type with ID " << type->id);
|
||||||
<< (int) type->id);
|
}
|
||||||
return false;
|
return !log_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeVariant tv(type);
|
TypeVariant tv(type);
|
||||||
@@ -370,9 +370,8 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ResourceName name(package->name, parsed_type,
|
const ResourceName name(package->name, *parsed_type,
|
||||||
util::GetString(key_pool_, util::DeviceToHost32(entry->key.index)));
|
util::GetString(key_pool_, util::DeviceToHost32(entry->key.index)));
|
||||||
|
|
||||||
const ResourceId res_id(package->id.value(), type->id, static_cast<uint16_t>(it.index()));
|
const ResourceId res_id(package->id.value(), type->id, static_cast<uint16_t>(it.index()));
|
||||||
|
|
||||||
std::unique_ptr<Value> resource_value;
|
std::unique_ptr<Value> resource_value;
|
||||||
|
|||||||
Reference in New Issue
Block a user