diff options
author | 2023-05-04 23:54:03 +0000 | |
---|---|---|
committer | 2023-05-04 23:58:48 +0000 | |
commit | 48d229de10575efc0d7a636187ec41f5076b9be7 (patch) | |
tree | 0bea01112af70bc6670c70c75aaa5aaa90f98064 /tools/aapt2/ResourceUtils.cpp | |
parent | ad8af4dd2c7a1fc77f7aacc72566d939bde693e5 (diff) |
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
Diffstat (limited to 'tools/aapt2/ResourceUtils.cpp')
-rw-r--r-- | tools/aapt2/ResourceUtils.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp index 91f4d60317da..d358df98ada6 100644 --- a/tools/aapt2/ResourceUtils.cpp +++ b/tools/aapt2/ResourceUtils.cpp @@ -619,7 +619,7 @@ uint32_t AndroidTypeToAttributeTypeMask(uint16_t type) { } 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 @@ std::unique_ptr<Item> TryParseItemForAttribute( // 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 @@ std::unique_ptr<Item> TryParseItemForAttribute( * 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; } |