mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-05 17:45:52 +01:00
Added support for API13 resource qualifiers.
This commit is contained in:
parent
4c01265009
commit
8b285989d2
@ -43,6 +43,10 @@ public class ResConfigFlags {
|
||||
|
||||
public final byte screenLayout;
|
||||
public final byte uiMode;
|
||||
public final short smallestScreenWidthDp;
|
||||
|
||||
public final short screenWidthDp;
|
||||
public final short screenHeightDp;
|
||||
|
||||
public final boolean isInvalid;
|
||||
|
||||
@ -64,6 +68,9 @@ public class ResConfigFlags {
|
||||
sdkVersion = 0;
|
||||
screenLayout = SCREENLONG_ANY | SCREENSIZE_ANY;
|
||||
uiMode = UI_MODE_TYPE_ANY | UI_MODE_NIGHT_ANY;
|
||||
smallestScreenWidthDp = 0;
|
||||
screenWidthDp = 0;
|
||||
screenHeightDp = 0;
|
||||
isInvalid = false;
|
||||
mQualifiers = "";
|
||||
}
|
||||
@ -72,7 +79,8 @@ public class ResConfigFlags {
|
||||
byte orientation, byte touchscreen, short density, byte keyboard,
|
||||
byte navigation, byte inputFlags, short screenWidth,
|
||||
short screenHeight, short sdkVersion, byte screenLayout,
|
||||
byte uiMode, boolean isInvalid) {
|
||||
byte uiMode, short smallestScreenWidthDp, short screenWidthDp,
|
||||
short screenHeightDp, boolean isInvalid) {
|
||||
if (orientation < 0 || orientation > 3) {
|
||||
LOGGER.warning("Invalid orientation value: " + orientation);
|
||||
orientation = 0;
|
||||
@ -114,6 +122,9 @@ public class ResConfigFlags {
|
||||
this.sdkVersion = sdkVersion;
|
||||
this.screenLayout = screenLayout;
|
||||
this.uiMode = uiMode;
|
||||
this.smallestScreenWidthDp = smallestScreenWidthDp;
|
||||
this.screenWidthDp = screenWidthDp;
|
||||
this.screenHeightDp = screenHeightDp;
|
||||
this.isInvalid = isInvalid;
|
||||
mQualifiers = generateQualifiers();
|
||||
}
|
||||
@ -136,6 +147,15 @@ public class ResConfigFlags {
|
||||
ret.append("-r").append(country);
|
||||
}
|
||||
}
|
||||
if (smallestScreenWidthDp != 0) {
|
||||
ret.append("-sw").append(smallestScreenWidthDp).append("dp");
|
||||
}
|
||||
if (screenWidthDp != 0) {
|
||||
ret.append("-w").append(screenWidthDp).append("dp");
|
||||
}
|
||||
if (screenHeightDp != 0) {
|
||||
ret.append("-h").append(screenHeightDp).append("dp");
|
||||
}
|
||||
switch (screenLayout & MASK_SCREENSIZE) {
|
||||
case SCREENSIZE_SMALL:
|
||||
ret.append("-small");
|
||||
@ -279,6 +299,12 @@ public class ResConfigFlags {
|
||||
}
|
||||
|
||||
private short getNaturalSdkVersionRequirement() {
|
||||
if (
|
||||
smallestScreenWidthDp != 0 || screenWidthDp != 0
|
||||
|| screenHeightDp != 0
|
||||
) {
|
||||
return 13;
|
||||
}
|
||||
if (
|
||||
(uiMode & (MASK_UI_MODE_TYPE | MASK_UI_MODE_NIGHT)) != 0
|
||||
) {
|
||||
|
@ -257,10 +257,18 @@ public class ARSCDecoder {
|
||||
|
||||
byte screenLayout = 0;
|
||||
byte uiMode = 0;
|
||||
short smallestScreenWidthDp = 0;
|
||||
if (size >= 32) {
|
||||
screenLayout = mIn.readByte();
|
||||
uiMode = mIn.readByte();
|
||||
mIn.skipBytes(2);
|
||||
smallestScreenWidthDp = mIn.readShort();
|
||||
}
|
||||
|
||||
short screenWidthDp = 0;
|
||||
short screenHeightDp = 0;
|
||||
if (size >= 36) {
|
||||
screenWidthDp = mIn.readShort();
|
||||
screenHeightDp = mIn.readShort();
|
||||
}
|
||||
|
||||
int exceedingSize = size - KNOWN_CONFIG_BYTES;
|
||||
@ -284,7 +292,7 @@ public class ARSCDecoder {
|
||||
return new ResConfigFlags(mcc, mnc, language, country, orientation,
|
||||
touchscreen, density, keyboard, navigation, inputFlags,
|
||||
screenWidth, screenHeight, sdkVersion, screenLayout, uiMode,
|
||||
isInvalid);
|
||||
smallestScreenWidthDp, screenWidthDp, screenHeightDp, isInvalid);
|
||||
}
|
||||
|
||||
private void addMissingResSpecs() throws AndrolibException {
|
||||
@ -387,7 +395,7 @@ public class ARSCDecoder {
|
||||
|
||||
private static final Logger LOGGER =
|
||||
Logger.getLogger(ARSCDecoder.class.getName());
|
||||
private static final int KNOWN_CONFIG_BYTES = 32;
|
||||
private static final int KNOWN_CONFIG_BYTES = 36;
|
||||
|
||||
|
||||
public static class ARSCData {
|
||||
|
Loading…
Reference in New Issue
Block a user