mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 13:57:46 +01:00
parent
212330e0c9
commit
3ec4f360ab
@ -287,7 +287,7 @@ public class Androlib {
|
||||
|
||||
if (meta.sdkInfo != null && meta.sdkInfo.get("minSdkVersion") != null) {
|
||||
String minSdkVersion = meta.sdkInfo.get("minSdkVersion");
|
||||
mMinSdkVersion = getMinSdkVersionFromAndroidCodename(meta, minSdkVersion);
|
||||
mMinSdkVersion = mAndRes.getMinSdkVersionFromAndroidCodename(meta, minSdkVersion);
|
||||
}
|
||||
|
||||
if (outFile == null) {
|
||||
@ -728,19 +728,6 @@ public class Androlib {
|
||||
return files;
|
||||
}
|
||||
|
||||
private int getMinSdkVersionFromAndroidCodename(MetaInfo meta, String sdkVersion) {
|
||||
switch (sdkVersion) {
|
||||
case "M":
|
||||
return ResConfigFlags.SDK_MNC;
|
||||
case "N":
|
||||
return ResConfigFlags.SDK_NOUGAT;
|
||||
case "O":
|
||||
return ResConfigFlags.SDK_OREO;
|
||||
default:
|
||||
return Integer.parseInt(meta.sdkInfo.get("minSdkVersion"));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isModified(File working, File stored) {
|
||||
return ! stored.exists() || BrutIO.recursiveModifiedTime(working) > BrutIO .recursiveModifiedTime(stored);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package brut.androlib.res;
|
||||
import brut.androlib.AndrolibException;
|
||||
import brut.androlib.ApkOptions;
|
||||
import brut.androlib.err.CantFindFrameworkResException;
|
||||
import brut.androlib.meta.MetaInfo;
|
||||
import brut.androlib.meta.PackageInfo;
|
||||
import brut.androlib.meta.VersionInfo;
|
||||
import brut.androlib.res.data.*;
|
||||
@ -308,9 +309,10 @@ final public class AndrolibResources {
|
||||
}
|
||||
|
||||
public String checkTargetSdkVersionBounds() {
|
||||
int target = Integer.parseInt(mTargetSdkVersion);
|
||||
int min = (mMinSdkVersion != null) ? Integer.parseInt(mMinSdkVersion) : 0;
|
||||
int max = (mMaxSdkVersion != null) ? Integer.parseInt(mMaxSdkVersion) : target;
|
||||
int target = mapSdkShorthandToVersion(mTargetSdkVersion);
|
||||
|
||||
int min = (mMinSdkVersion != null) ? mapSdkShorthandToVersion(mMinSdkVersion) : 0;
|
||||
int max = (mMaxSdkVersion != null) ? mapSdkShorthandToVersion(mMaxSdkVersion) : target;
|
||||
|
||||
target = Math.min(max, target);
|
||||
target = Math.max(min, target);
|
||||
@ -455,6 +457,28 @@ final public class AndrolibResources {
|
||||
}
|
||||
}
|
||||
|
||||
public int getMinSdkVersionFromAndroidCodename(MetaInfo meta, String sdkVersion) {
|
||||
int sdkNumber = mapSdkShorthandToVersion(sdkVersion);
|
||||
|
||||
if (sdkNumber == ResConfigFlags.SDK_BASE) {
|
||||
return Integer.parseInt(meta.sdkInfo.get("minSdkVersion"));
|
||||
}
|
||||
return sdkNumber;
|
||||
}
|
||||
|
||||
private int mapSdkShorthandToVersion(String sdkVersion) {
|
||||
switch (sdkVersion) {
|
||||
case "M":
|
||||
return ResConfigFlags.SDK_MNC;
|
||||
case "N":
|
||||
return ResConfigFlags.SDK_NOUGAT;
|
||||
case "O":
|
||||
return ResConfigFlags.SDK_OREO;
|
||||
default:
|
||||
return Integer.parseInt(sdkVersion);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean detectWhetherAppIsFramework(File appDir)
|
||||
throws AndrolibException {
|
||||
File publicXml = new File(appDir, "res/values/public.xml");
|
||||
|
@ -75,4 +75,16 @@ public class InvalidSdkBoundingTest {
|
||||
androlibResources.setSdkInfo(sdkInfo);
|
||||
assertEquals("25", androlibResources.checkTargetSdkVersionBounds());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkForShortHandSdkTag() throws BrutException, IOException {
|
||||
AndrolibResources androlibResources = new AndrolibResources();
|
||||
|
||||
Map<String, String> sdkInfo = new LinkedHashMap<>();
|
||||
sdkInfo.put("targetSdkVersion", "O");
|
||||
|
||||
androlibResources.setSdkInfo(sdkInfo);
|
||||
assertEquals("26", androlibResources.checkTargetSdkVersionBounds());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user