SharedLibraryLoader: iterate through all apks for bundles

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2019-10-13 10:21:24 +02:00
parent 3af2420da9
commit 749efcde21

View File

@ -13,6 +13,9 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
@ -32,9 +35,16 @@ public final class SharedLibraryLoader {
noAbiException = e; noAbiException = e;
} }
final Collection<String> apks = new HashSet<>();
if (context.getApplicationInfo().sourceDir != null)
apks.add(context.getApplicationInfo().sourceDir);
if (context.getApplicationInfo().splitSourceDirs != null)
apks.addAll(Arrays.asList(context.getApplicationInfo().splitSourceDirs));
for (final String apk : apks) {
final ZipFile zipFile; final ZipFile zipFile;
try { try {
zipFile = new ZipFile(new File(context.getApplicationInfo().sourceDir), ZipFile.OPEN_READ); zipFile = new ZipFile(new File(apk), ZipFile.OPEN_READ);
} catch (final IOException e) { } catch (final IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -68,6 +78,7 @@ public final class SharedLibraryLoader {
f.delete(); f.delete();
} }
} }
}
if (noAbiException instanceof RuntimeException) if (noAbiException instanceof RuntimeException)
throw (RuntimeException) noAbiException; throw (RuntimeException) noAbiException;
throw new RuntimeException(noAbiException); throw new RuntimeException(noAbiException);