api-impl/android/content/Context: make getObbDir consistent with apps' hardcoded assumptions about the obb dir location

This commit is contained in:
Mis012
2023-09-18 13:54:12 +02:00
parent 4628cfc66d
commit 210cda566a

View File

@@ -79,7 +79,6 @@ public class Context extends Object {
r = new Resources(assets, dm, config); r = new Resources(assets, dm, config);
theme = r.newTheme(); theme = r.newTheme();
application_info = new ApplicationInfo(); application_info = new ApplicationInfo();
InputStream inStream = ClassLoader.getSystemClassLoader().getResourceAsStream("AndroidManifest.xml"); InputStream inStream = ClassLoader.getSystemClassLoader().getResourceAsStream("AndroidManifest.xml");
try { try {
manifest = AndroidManifestBlock.load(inStream); manifest = AndroidManifestBlock.load(inStream);
@@ -260,7 +259,17 @@ public class Context extends Object {
public File getObbDir() { public File getObbDir() {
if (obb_dir == null) { if (obb_dir == null) {
obb_dir = new File(getDataDirFile(), "obb"); obb_dir = new File(getDataDirFile(), "Android/obb/" + getPackageName());
}
if (!obb_dir.exists()) {
if (!obb_dir.mkdirs()) {
if (obb_dir.exists()) {
// spurious failure; probably racing with another process for this app
return obb_dir;
}
Slog.w(TAG, "Unable to create obb directory >" + obb_dir.getPath() + "<");
return null;
}
} }
return obb_dir; return obb_dir;
} }