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); 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) JNIEXPORT void JNICALL Java_android_content_res_XmlBlock_nativeDestroyParseState(JNIEnv *env, jobject this, jlong parser_ptr)
{ {
struct ResXMLParser *parser = (struct ResXMLParser *)_PTR(parser_ptr); struct ResXMLParser *parser = (struct ResXMLParser *)_PTR(parser_ptr);

View file

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