XmlBlock: implement nativeGetAttributeName, use getPooledString instead of mStrings.get

This commit is contained in:
Mis012 2025-03-26 19:42:49 +01:00
parent 15a6432d01
commit 6d73fd7a99
2 changed files with 11 additions and 5 deletions

View file

@ -114,6 +114,12 @@ JNIEXPORT jint JNICALL Java_android_content_res_XmlBlock_nativeGetAttributeData(
return ResXMLParser_getAttributeData(parser, index);
}
JNIEXPORT jint JNICALL Java_android_content_res_XmlBlock_nativeGetAttributeName(JNIEnv *env, jclass this, jlong parser_ptr, jint index)
{
struct ResXMLParser *parser = (struct ResXMLParser *)_PTR(parser_ptr);
return ResXMLParser_getAttributeNameID(parser, index);
}
JNIEXPORT void JNICALL Java_android_content_res_XmlBlock_nativeDestroyParseState(JNIEnv *env, jobject this, jlong parser_ptr)
{
struct ResXMLParser *parser = (struct ResXMLParser *)_PTR(parser_ptr);

View file

@ -137,7 +137,7 @@ final class XmlBlock {
}
public String getText() {
int id = nativeGetText(mParseState);
return id >= 0 ? mStrings.get(id).toString() : null;
return id >= 0 ? (String)getPooledString(id) : null;
}
public int getLineNumber() {
return nativeGetLineNumber(mParseState);
@ -165,7 +165,7 @@ final class XmlBlock {
}
public String getNamespace() {
int id = nativeGetNamespace(mParseState);
return id >= 0 ? mStrings.get(id).toString() : "";
return id >= 0 ? (String)getPooledString(id) : "";
}
public String getName() {
return nativeGetName(mParseState);
@ -175,7 +175,7 @@ final class XmlBlock {
if (DEBUG)
System.out.println("getAttributeNamespace of " + index + " = " + id);
if (id >= 0)
return mStrings.get(id).toString();
return (String)getPooledString(id);
else if (id == -1)
return "";
throw new IndexOutOfBoundsException(String.valueOf(index));
@ -185,7 +185,7 @@ final class XmlBlock {
if (DEBUG)
System.out.println("getAttributeName of " + index + " = " + id);
if (id >= 0)
return mStrings.get(id).toString();
return (String)getPooledString(id);
throw new IndexOutOfBoundsException(String.valueOf(index));
}
public String getAttributePrefix(int index) {
@ -417,7 +417,7 @@ final class XmlBlock {
public String getIdAttribute() {
int id = nativeGetIdAttribute(mParseState);
return id >= 0 ? mStrings.get(id).toString() : null;
return id >= 0 ? (String)getPooledString(id) : null;
}
public String getClassAttribute() {
return nativeGetClassAttribute(mParseState);