fix callbacks to old methods

This commit is contained in:
Connor Tumbleson 2012-08-08 15:14:08 -05:00
parent ca1e7a811e
commit 26362dac3b

View File

@ -17,15 +17,12 @@
package brut.androlib.res.decoder;
import brut.androlib.AndrolibException;
import brut.androlib.res.AndrolibResources;
import brut.androlib.res.data.ResTable;
import brut.androlib.res.util.ExtXmlSerializer;
import java.io.*;
import java.util.logging.Logger;
import org.xmlpull.v1.*;
import org.xmlpull.v1.wrapper.*;
import org.xmlpull.v1.wrapper.classic.StaticXmlSerializerWrapper;
/**
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
@ -42,75 +39,7 @@ public class XmlPullStreamDecoder implements ResStreamDecoder {
try {
XmlPullWrapperFactory factory = XmlPullWrapperFactory.newInstance();
XmlPullParserWrapper par = factory.newPullParserWrapper(mParser);
final ResTable resTable = ((AXmlResourceParser)mParser).getAttrDecoder().getCurrentPackage().getResTable();
final boolean optimizeForManifest = mOptimizeForManifest;
XmlSerializerWrapper ser = new StaticXmlSerializerWrapper(mSerial, factory){
boolean hideSdkInfo = false;
@Override
public void event(XmlPullParser pp) throws XmlPullParserException, IOException {
int type = pp.getEventType();
int newLine = pp.getLineNumber();
if ((!optimizeForManifest) || newLine != 0) {
((ExtXmlSerializer)xs).setLineNumber(newLine, type);
super.event(pp);
} else {
if (type == XmlPullParser.START_TAG) {
if ("uses-sdk".equalsIgnoreCase(pp.getName())) {
//TODO: parse uses-sdk( and some others?)
/*
* (--version-code)
* (--version-name)
* (debuggable)
* (...)
* --min-sdk-version
* --target-sdk-version
* --max-sdk-version
*/
try {
hideSdkInfo = parseAttr(pp);
if(hideSdkInfo) {
return;
}
} catch (AndrolibException e) {}
}
LOGGER.warning("Found generated line but parse failed, output it in xml.");
} else if (hideSdkInfo && type == XmlPullParser.END_TAG &&
"uses-sdk".equalsIgnoreCase(pp.getName())) {
return;
}
//((ExtXmlSerializer)xs).setLineNumber(newLine, type);
super.event(pp);
}
}
private boolean parseAttr(XmlPullParser pp) throws AndrolibException {
ResTable restable = resTable;
for (int i = 0; i < pp.getAttributeCount(); i++) {
final String a_ns = "http://schemas.android.com/apk/res/android";
String ns = pp.getAttributeNamespace (i);
if (a_ns.equalsIgnoreCase(ns)) {
String name = pp.getAttributeName (i);
String value = pp.getAttributeValue (i);
if (name != null && value != null) {
if (name.equalsIgnoreCase("minSdkVersion") ||
name.equalsIgnoreCase("targetSdkVersion") ||
name.equalsIgnoreCase("maxSdkVersion")) {
restable.addSdkInfo(name, value);
} else {
restable.clearSdkInfo();
return false;//Found unknown flags
}
}
} else {
resTable.clearSdkInfo();
return false;//Found unknown flags
}
}
return true;
}
};
//factory.newSerializerWrapper(mSerial);
XmlSerializerWrapper ser = factory.newSerializerWrapper(mSerial);
par.setInput(in, null);
ser.setOutput(out, null);