mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 05:47:46 +01:00
Mac OS X home dir support. Added <uses-sdk> support, reverted SkipBytes(2) for com.htc.resources as just moved the problem elsewhere.
I matched raw AAPT source directly to configFlags. HTC is using something non-official or old.
This commit is contained in:
parent
2509e402e7
commit
ca0f7ec0bb
@ -112,7 +112,6 @@ final public class AndrolibResources {
|
||||
Duo<ResFileDecoder, AXmlResourceParser> duo = getManifestFileDecoder();
|
||||
ResFileDecoder fileDecoder = duo.m1;
|
||||
|
||||
|
||||
// Set ResAttrDecoder
|
||||
duo.m2.setAttrDecoder(new ResAttrDecoder());
|
||||
ResAttrDecoder attrDecoder = duo.m2.getAttrDecoder();
|
||||
@ -539,8 +538,17 @@ final public class AndrolibResources {
|
||||
}
|
||||
|
||||
private File getFrameworkDir() throws AndrolibException {
|
||||
File dir = new File(System.getProperty("user.home") +
|
||||
File.separatorChar + "apktool" + File.separatorChar + "framework");
|
||||
String path;
|
||||
|
||||
/* store in user-home, for Mac OS X */
|
||||
if (System.getProperty("os.name").equals("Mac OS X")) {
|
||||
path = System.getProperty("user.home") + File.separatorChar +
|
||||
"Library/Application Support/apktool/framework"; }
|
||||
else {
|
||||
path = System.getProperty("user.home") + File.separatorChar +
|
||||
"apktool" + File.separatorChar + "framework";
|
||||
}
|
||||
File dir = new File(path);
|
||||
if (! dir.exists()) {
|
||||
if (! dir.mkdirs()) {
|
||||
throw new AndrolibException("Can't create directory: " + dir);
|
||||
|
@ -21,6 +21,7 @@ import brut.androlib.AndrolibException;
|
||||
import brut.androlib.res.data.*;
|
||||
import brut.androlib.res.data.value.*;
|
||||
import brut.util.Duo;
|
||||
import brut.androlib.res.data.ResTable;
|
||||
import brut.util.ExtDataInput;
|
||||
import com.mindprod.ledatastream.LEDataInputStream;
|
||||
import java.io.*;
|
||||
@ -247,13 +248,13 @@ public class ARSCDecoder {
|
||||
byte keyboard = mIn.readByte();
|
||||
byte navigation = mIn.readByte();
|
||||
byte inputFlags = mIn.readByte();
|
||||
mIn.skipBytes(1);
|
||||
/*inputPad0*/ mIn.skipBytes(1);
|
||||
|
||||
short screenWidth = mIn.readShort();
|
||||
short screenHeight = mIn.readShort();
|
||||
|
||||
short sdkVersion = mIn.readShort();
|
||||
mIn.skipBytes(2);
|
||||
/*minorVersion, now must always be 0*/ mIn.skipBytes(2);
|
||||
|
||||
byte screenLayout = 0;
|
||||
byte uiMode = 0;
|
||||
@ -273,7 +274,7 @@ public class ARSCDecoder {
|
||||
}
|
||||
|
||||
if (size >= 40) {
|
||||
mIn.skipBytes(2);
|
||||
// mIn.skipBytes(2);
|
||||
}
|
||||
|
||||
int exceedingSize = size - KNOWN_CONFIG_BYTES;
|
||||
@ -400,7 +401,7 @@ public class ARSCDecoder {
|
||||
|
||||
private static final Logger LOGGER =
|
||||
Logger.getLogger(ARSCDecoder.class.getName());
|
||||
private static final int KNOWN_CONFIG_BYTES = 36; // 42 now. Just need to map them out.
|
||||
private static final int KNOWN_CONFIG_BYTES = 36;
|
||||
|
||||
|
||||
public static class ARSCData {
|
||||
|
@ -17,11 +17,13 @@
|
||||
package brut.androlib.res.decoder;
|
||||
|
||||
import brut.androlib.AndrolibException;
|
||||
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>
|
||||
@ -38,7 +40,56 @@ public class XmlPullStreamDecoder implements ResStreamDecoder {
|
||||
try {
|
||||
XmlPullWrapperFactory factory = XmlPullWrapperFactory.newInstance();
|
||||
XmlPullParserWrapper par = factory.newPullParserWrapper(mParser);
|
||||
XmlSerializerWrapper ser = factory.newSerializerWrapper(mSerial);
|
||||
final ResTable resTable = ((AXmlResourceParser)mParser).getAttrDecoder().getCurrentPackage().getResTable();
|
||||
|
||||
XmlSerializerWrapper ser = new StaticXmlSerializerWrapper(mSerial, factory){
|
||||
boolean hideSdkInfo = false;
|
||||
@Override
|
||||
public void event(XmlPullParser pp) throws XmlPullParserException, IOException {
|
||||
int type = pp.getEventType();
|
||||
|
||||
if (type == XmlPullParser.START_TAG) {
|
||||
if ("uses-sdk".equalsIgnoreCase(pp.getName())) {
|
||||
try {
|
||||
hideSdkInfo = parseAttr(pp);
|
||||
if(hideSdkInfo) {
|
||||
return;
|
||||
}
|
||||
} catch (AndrolibException e) {}
|
||||
}
|
||||
} else if (hideSdkInfo && type == XmlPullParser.END_TAG &&
|
||||
"uses-sdk".equalsIgnoreCase(pp.getName())) {
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
par.setInput(in, null);
|
||||
ser.setOutput(out, null);
|
||||
@ -46,7 +97,6 @@ public class XmlPullStreamDecoder implements ResStreamDecoder {
|
||||
while (par.nextToken() != XmlPullParser.END_DOCUMENT) {
|
||||
ser.event(par);
|
||||
}
|
||||
mSerial.newLine();
|
||||
ser.flush();
|
||||
} catch (XmlPullParserException ex) {
|
||||
throw new AndrolibException("Could not decode XML", ex);
|
||||
|
@ -75,4 +75,5 @@ public class ExtMXSerializer extends MXSerializer implements ExtXmlSerializer {
|
||||
|
||||
private String mDefaultEncoding;
|
||||
private boolean mIsDisabledAttrEscape = false;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user