From f24b9a438d4246607d14eaa04d405c089cb758db Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Fri, 31 Mar 2023 22:37:42 +0000 Subject: Add additional check on float precision after parsing, only compile the value when precision is not lost. Bug: b/69347762 Test: Verified affected atests pass Change-Id: I8e4fcd420a924f0e949bfd3a8aae23d1e7d582b1 --- tools/aapt2/ResourceValues.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tools/aapt2/ResourceValues.cpp') diff --git a/tools/aapt2/ResourceValues.cpp b/tools/aapt2/ResourceValues.cpp index a5754e0d168f..728e35a266b7 100644 --- a/tools/aapt2/ResourceValues.cpp +++ b/tools/aapt2/ResourceValues.cpp @@ -22,12 +22,12 @@ #include #include -#include "android-base/stringprintf.h" -#include "androidfw/ResourceTypes.h" - #include "Resource.h" #include "ResourceUtils.h" #include "ValueVisitor.h" +#include "android-base/stringprintf.h" +#include "androidfw/ResourceTypes.h" +#include "io/StringStream.h" #include "util/Util.h" using ::aapt::text::Printer; @@ -487,6 +487,15 @@ void BinaryPrimitive::PrettyPrint(Printer* printer) const { } } +std::string BinaryPrimitive::toPrettyString() const { + std::string str; + io::StringOutputStream out(&str); + text::Printer printer(&out); + this->PrettyPrint(&printer); + out.Flush(); + return str; +} + Attribute::Attribute(uint32_t t) : type_mask(t), min_int(std::numeric_limits::min()), -- cgit v1.2.3-59-g8ed1b