AssetManager: use AndroidManifest.xml to identify apks

resources.arsc may be missing in rare cases
This commit is contained in:
Mis012
2024-12-20 00:12:01 +01:00
parent 58745f23ea
commit 060ea72f94

View File

@@ -110,7 +110,7 @@ public final class AssetManager {
Log.v(TAG, "New asset manager: " + this); Log.v(TAG, "New asset manager: " + this);
// ensureSystemAssets() // ensureSystemAssets()
try { try {
Enumeration<URL> resources = ClassLoader.getSystemClassLoader().getResources("resources.arsc"); Enumeration<URL> resources = ClassLoader.getSystemClassLoader().getResources("AndroidManifest.xml");
ArrayList<String> paths = new ArrayList<String>(); ArrayList<String> paths = new ArrayList<String>();
paths.add(null); // reserve first slot for framework-res.apk paths.add(null); // reserve first slot for framework-res.apk
while (resources.hasMoreElements()) { while (resources.hasMoreElements()) {
@@ -123,7 +123,7 @@ public final class AssetManager {
} }
for (String path : paths) { for (String path : paths) {
if (path != null) { if (path != null) {
path = path.substring(path.indexOf("file:") + 5, path.indexOf("!/resources.arsc")); path = path.substring(path.indexOf("file:") + 5, path.indexOf("!/AndroidManifest.xml"));
addAssetPath(path); addAssetPath(path);
} }
} }