AAPT2: Fix issue with styled string indices

Styled strings use spans to denote which part
is styled (<b>, <i>, etc). Spans are simply a range
of indices into the original string.

In Java, we use String and its internal representation, meaning
we must encode the indices using UTF16 lengths.

When the internal AAPT2 representation of strings switched to UTF8,
the indices also began to index into the UTF8 string.

This change reverts the indices to use UTF16 lengths.

Bug:31170115
Change-Id: I07b8b5b67d2542c7e0a855b601cdbd3ac4ebffb0
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 32e5cfd..c430c46 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -152,7 +152,7 @@
                 break;
             }
 
-            spanStack.back().lastChar = builder.str().size() - 1;
+            spanStack.back().lastChar = builder.utf16Len() - 1;
             outStyleString->spans.push_back(spanStack.back());
             spanStack.pop_back();
 
@@ -185,12 +185,12 @@
                 spanName += attrIter->value;
             }
 
-            if (builder.str().size() > std::numeric_limits<uint32_t>::max()) {
+            if (builder.utf16Len() > std::numeric_limits<uint32_t>::max()) {
                 mDiag->error(DiagMessage(mSource.withLine(parser->getLineNumber()))
                              << "style string '" << builder.str() << "' is too long");
                 error = true;
             } else {
-                spanStack.push_back(Span{ spanName, static_cast<uint32_t>(builder.str().size()) });
+                spanStack.push_back(Span{ spanName, static_cast<uint32_t>(builder.utf16Len()) });
             }
 
         } else if (event == xml::XmlPullParser::Event::kComment) {