From babdfe80cb5db510f0325820df06b5f47d2bf9fe Mon Sep 17 00:00:00 2001 From: canyie Date: Wed, 11 Jan 2023 15:42:23 +0800 Subject: [PATCH] Fix stub resources load on Android 5 --- .../java/com/topjohnwu/magisk/DownloadActivity.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/stub/src/main/java/com/topjohnwu/magisk/DownloadActivity.java b/stub/src/main/java/com/topjohnwu/magisk/DownloadActivity.java index 2efd98f19..6fb1e5fa0 100644 --- a/stub/src/main/java/com/topjohnwu/magisk/DownloadActivity.java +++ b/stub/src/main/java/com/topjohnwu/magisk/DownloadActivity.java @@ -35,6 +35,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.zip.InflaterInputStream; +import java.util.zip.ZipFile; import javax.crypto.Cipher; import javax.crypto.CipherInputStream; @@ -187,6 +188,16 @@ public class DownloadActivity extends Activity { } } else { File dir = new File(getCodeCacheDir(), "res"); + dir.mkdirs(); + + // addAssetPath requires a directory containing AndroidManifest.xml on Android 5 + try (var stubApk = new ZipFile(getPackageCodePath()); + var manifest = new FileOutputStream(new File(dir, "AndroidManifest.xml"))) { + var stubManifest = stubApk.getInputStream( + stubApk.getEntry("AndroidManifest.xml")); + APKInstall.transfer(stubManifest, manifest); + } + decryptResources(new FileOutputStream(new File(dir, "resources.arsc"))); StubApk.addAssetPath(getResources(), dir.getPath()); }