main-executable: extract native libs before instantiating the Application class

This commit is contained in:
Mis012
2025-08-01 13:40:29 +02:00
parent 53def20d4d
commit ebd16f01dc
5 changed files with 12 additions and 10 deletions

View File

@@ -612,14 +612,14 @@ public final class AssetManager {
private native final int addAssetPathNative(String path);
public static void extractFromAPK(String path, String target) throws IOException {
public static void extractFromAPK(String apk_path, String path, String target) throws IOException {
if (path.endsWith("/")) { // directory
try (JarFile apk = new JarFile(Context.this_application.getPackageCodePath())) {
try (JarFile apk = new JarFile(apk_path)) {
Enumeration<JarEntry> entries = apk.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (entry.getName().startsWith(path)) {
extractFromAPK(entry.getName(), entry.getName().replace(path, target));
extractFromAPK(apk_path, entry.getName(), entry.getName().replace(path, target));
}
}
}

View File

@@ -2,6 +2,7 @@ package android.media;
import java.io.IOException;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
@@ -25,7 +26,7 @@ public class SoundPool {
}
public int load(AssetFileDescriptor afd, int priority) throws IOException {
AssetManager.extractFromAPK(afd.fileName, afd.fileName);
AssetManager.extractFromAPK(Context.this_application.getPackageCodePath(), afd.fileName, afd.fileName);
return nativeLoad(nativePool, android.os.Environment.getExternalStorageDirectory().getPath() + "/" + afd.fileName);
}