user preferred framework & prefer compileSdkVersion #39

This commit is contained in:
REAndroid 2023-05-04 21:35:53 +02:00
parent d1e5682d02
commit aa64e591ff

View File

@ -57,6 +57,7 @@ public class ApkModule implements ApkFile {
private Decoder mDecoder; private Decoder mDecoder;
private ApkType mApkType; private ApkType mApkType;
private ApkSignatureBlock apkSignatureBlock; private ApkSignatureBlock apkSignatureBlock;
private Integer preferredFramework;
public ApkModule(String moduleName, APKArchive apkArchive){ public ApkModule(String moduleName, APKArchive apkArchive){
this.moduleName=moduleName; this.moduleName=moduleName;
@ -209,17 +210,37 @@ public class ApkModule implements ApkFile {
} }
return null; return null;
} }
public void setPreferredFramework(Integer version) throws IOException {
if(version!=null && version.equals(preferredFramework)){
return;
}
this.preferredFramework = version;
if(version == null || mTableBlock==null){
return;
}
logMessage("Initializing preferred framework: " + version);
mTableBlock.clearFrameworks();
FrameworkApk frameworkApk = AndroidFrameworks.getBestMatch(version);
AndroidFrameworks.setCurrent(frameworkApk);
mTableBlock.addFramework(frameworkApk.getTableBlock());
logMessage("Initialized framework: " + frameworkApk.getVersionCode());
}
public Integer getAndroidFrameworkVersion(){ public Integer getAndroidFrameworkVersion(){
if(preferredFramework != null){
return preferredFramework;
}
if(!hasAndroidManifestBlock()){ if(!hasAndroidManifestBlock()){
return null; return null;
} }
AndroidManifestBlock manifestBlock = getAndroidManifestBlock(); AndroidManifestBlock manifestBlock = getAndroidManifestBlock();
Integer version = manifestBlock.getTargetSdkVersion(); Integer version = manifestBlock.getCompileSdkVersion();
if(version == null){ if(version == null){
version = manifestBlock.getPlatformBuildVersionCode(); version = manifestBlock.getPlatformBuildVersionCode();
} }
if(version == null){ if(version == null){
version = manifestBlock.getCompileSdkVersion(); version = manifestBlock.getTargetSdkVersion();
} }
return version; return version;
} }