mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-17 14:28:28 +00:00
Fix stub resource loading on Android 9, 10
They can only load resources from zip files Co-authored-by: canyie <a1364259@163.com> Co-authored-by: 南宫雪珊 <vvb2060@gmail.com>
This commit is contained in:
parent
606d97ae4d
commit
75ba62d588
@ -35,7 +35,9 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.zip.InflaterInputStream;
|
import java.util.zip.InflaterInputStream;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.CipherInputStream;
|
import javax.crypto.CipherInputStream;
|
||||||
@ -183,19 +185,17 @@ public class DownloadActivity extends Activity {
|
|||||||
Os.close(fd);
|
Os.close(fd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
File dir = new File(getCodeCacheDir(), "res");
|
File res = new File(getCodeCacheDir(), "res.apk");
|
||||||
dir.mkdirs();
|
try (var out = new ZipOutputStream(new FileOutputStream(res))) {
|
||||||
|
// AndroidManifest.xml is reuqired on Android 6-, and directory support is broken on Android 9-10
|
||||||
// addAssetPath requires a directory containing AndroidManifest.xml on Android 6.0
|
out.putNextEntry(new ZipEntry("AndroidManifest.xml"));
|
||||||
try (var stubApk = new ZipFile(getPackageCodePath());
|
try (var stubApk = new ZipFile(getPackageCodePath())) {
|
||||||
var manifest = new FileOutputStream(new File(dir, "AndroidManifest.xml"))) {
|
APKInstall.transfer(stubApk.getInputStream(stubApk.getEntry("AndroidManifest.xml")), out);
|
||||||
var stubManifest = stubApk.getInputStream(
|
}
|
||||||
stubApk.getEntry("AndroidManifest.xml"));
|
out.putNextEntry(new ZipEntry("resources.arsc"));
|
||||||
APKInstall.transfer(stubManifest, manifest);
|
decryptResources(out);
|
||||||
}
|
}
|
||||||
|
StubApk.addAssetPath(getResources(), res.getPath());
|
||||||
decryptResources(new FileOutputStream(new File(dir, "resources.arsc")));
|
|
||||||
StubApk.addAssetPath(getResources(), dir.getPath());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user