Adding verbose setters and getters for diagnostics to make ResourceUtils
code able to print verbose message.
Bug: b/279977244
Test: Verified affected atests pass
Change-Id: Iafbf4cb8a63720c95748a339b1f48dd4213f0eac
diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp
index 91f4d60..d358df9 100644
--- a/tools/aapt2/ResourceUtils.cpp
+++ b/tools/aapt2/ResourceUtils.cpp
@@ -619,7 +619,7 @@
}
std::unique_ptr<Item> TryParseItemForAttribute(
- StringPiece value, uint32_t type_mask,
+ android::IDiagnostics* diag, StringPiece value, uint32_t type_mask,
const std::function<bool(const ResourceName&)>& on_create_reference) {
using android::ResTable_map;
@@ -685,6 +685,12 @@
// same string is smaller than 1, otherwise return as raw string.
if (fabs(f - d) < 1) {
return std::move(floating_point);
+ } else {
+ if (diag->IsVerbose()) {
+ diag->Note(android::DiagMessage()
+ << "precision lost greater than 1 while parsing float " << value
+ << ", return a raw string");
+ }
}
}
} else {
@@ -701,12 +707,12 @@
* allows.
*/
std::unique_ptr<Item> TryParseItemForAttribute(
- StringPiece str, const Attribute* attr,
+ android::IDiagnostics* diag, StringPiece str, const Attribute* attr,
const std::function<bool(const ResourceName&)>& on_create_reference) {
using android::ResTable_map;
const uint32_t type_mask = attr->type_mask;
- auto value = TryParseItemForAttribute(str, type_mask, on_create_reference);
+ auto value = TryParseItemForAttribute(diag, str, type_mask, on_create_reference);
if (value) {
return value;
}