You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
main-executable: extract native libs before instantiating the Application class
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user