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
AssetManager: re-extract native libs if APK file was updated
This commit is contained in:
@@ -33,6 +33,7 @@ import java.net.URLDecoder;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -625,11 +626,11 @@ public final class AssetManager {
|
|||||||
}
|
}
|
||||||
} else { // single file
|
} else { // single file
|
||||||
Path file = Paths.get(android.os.Environment.getExternalStorageDirectory().getPath(), target);
|
Path file = Paths.get(android.os.Environment.getExternalStorageDirectory().getPath(), target);
|
||||||
if (!Files.exists(file)) {
|
if (!Files.exists(file) || Files.getLastModifiedTime(file).toMillis() < Files.getLastModifiedTime(Paths.get(apk_path)).toMillis()) {
|
||||||
try (InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream(path)) {
|
try (InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream(path)) {
|
||||||
if (inputStream != null) {
|
if (inputStream != null) {
|
||||||
Files.createDirectories(file.getParent());
|
Files.createDirectories(file.getParent());
|
||||||
Files.copy(inputStream, file);
|
Files.copy(inputStream, file, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user