Change xposed_init -> java_init.list, add xposedtargetversion

This commit is contained in:
Nullptr 2023-01-15 21:45:54 +08:00 committed by LoveSy
parent 7d2c599e96
commit 295b0ee0ce
5 changed files with 17 additions and 6 deletions

View File

@ -550,9 +550,11 @@ public class ModulesFragment extends BaseFragment implements ModuleUtil.ModuleLi
if (item.minVersion == 0) {
warningText = getString(R.string.no_min_version_specified);
} else if (installXposedVersion > 0 && item.minVersion > installXposedVersion) {
warningText = String.format(getString(R.string.warning_xposed_min_version), item.minVersion);
warningText = getString(R.string.warning_xposed_min_version, item.minVersion);
} else if (item.targetVersion > installXposedVersion) {
warningText = getString(R.string.warning_target_version_higher, item.targetVersion);
} else if (item.minVersion < ModuleUtil.MIN_MODULE_VERSION) {
warningText = String.format(getString(R.string.warning_min_version_too_low), item.minVersion, ModuleUtil.MIN_MODULE_VERSION);
warningText = getString(R.string.warning_min_version_too_low, item.minVersion, ModuleUtil.MIN_MODULE_VERSION);
} else if (item.isInstalledOnExternalStorage()) {
warningText = getString(R.string.warning_installed_on_external_storage);
}

View File

@ -215,6 +215,7 @@ public final class ModuleUtil {
public final String versionName;
public final long versionCode;
public final int minVersion;
public final int targetVersion;
public final long installTime;
public final long updateTime;
public ApplicationInfo app;
@ -245,6 +246,14 @@ public final class ModuleUtil {
} else {
this.minVersion = 0;
}
Object targetVersionRaw = app.metaData.get("xposedtargetversion");
if (targetVersionRaw instanceof Integer) {
this.targetVersion = (Integer) targetVersionRaw;
} else if (targetVersionRaw instanceof String) {
this.targetVersion = extractIntPart((String) targetVersionRaw);
} else {
this.targetVersion = this.minVersion;
}
}
public boolean isInstalledOnExternalStorage() {

View File

@ -107,6 +107,7 @@
<!-- ModulesActivity -->
<string name="module_empty_description">(no description provided)</string>
<string name="warning_xposed_min_version">This module requires a newer Xposed version (%d) and thus cannot be activated</string>
<string name="warning_target_version_higher">This module is designed for a newer Xposed version (%d) and thus some functionalities may not work</string>
<string name="no_min_version_specified">This module does not specify the Xposed version it needs.</string>
<string name="warning_min_version_too_low">This module was created for Xposed version %1$d, but due to incompatible changes in version %2$d, it has been disabled</string>
<string name="warning_installed_on_external_storage">This module cannot be loaded because it\'s installed on the SD card, please move it to internal storage</string>

View File

@ -369,15 +369,14 @@ public class ConfigFileManager {
var moduleLibraryNames = new ArrayList<String>(1);
try (var apkFile = new ZipFile(toGlobalNamespace(path))) {
readDexes(apkFile, preLoadedDexes, obfuscate);
// TODO: we can store more info like api version, module description, etc. in META-INF
readName(apkFile, "META-INF/xposed/xposed_init", moduleClassNames);
readName(apkFile, "META-INF/xposed/java_init.list", moduleClassNames);
if (moduleClassNames.isEmpty()) {
file.legacy = true;
readName(apkFile, "assets/xposed_init", moduleClassNames);
readName(apkFile, "assets/native_init", moduleLibraryNames);
} else {
file.legacy = false;
readName(apkFile, "META-INF/xposed/native_init", moduleLibraryNames);
readName(apkFile, "META-INF/xposed/native_init.list", moduleLibraryNames);
}
} catch (IOException e) {
Log.e(TAG, "Can not open " + path, e);

View File

@ -769,7 +769,7 @@ public class ConfigManager {
return false;
}
try (var zip = new ZipFile(toGlobalNamespace(apk))) {
return zip.getEntry("META-INF/xposed/xposed_init") != null || zip.getEntry("assets/xposed_init") != null;
return zip.getEntry("META-INF/xposed/java_init.list") != null || zip.getEntry("assets/xposed_init") != null;
} catch (IOException e) {
return false;
}