Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11935 from nitanmarcel/patch-1
Use getCacheDir if getExternalCacheDir returns null.
  • Loading branch information
JosJuice committed Jun 19, 2023
2 parents cff3e22 + cff7a4b commit 27db8d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Expand Up @@ -297,6 +297,8 @@ private NativeLibrary()

public static native void SetCacheDirectory(String directory);

public static native String GetCacheDirectory();

public static native int DefaultCPUCore();

public static native String GetDefaultGraphicsBackendName();
Expand Down
Expand Up @@ -122,7 +122,12 @@ private static boolean setDolphinUserDirectory(Context context)

File cacheDir = context.getExternalCacheDir();
if (cacheDir == null)
return false;
{
// In some custom ROMs getExternalCacheDir might return null for some reasons. If that is the case, fallback to getCacheDir which seems to work just fine.
cacheDir = context.getCacheDir();
if (cacheDir == null)
return false;
}

Log.debug("[DirectoryInitialization] Cache Dir: " + cacheDir.getPath());
NativeLibrary.SetCacheDirectory(cacheDir.getPath());
Expand Down Expand Up @@ -236,7 +241,7 @@ public static String getExtractedDriverDirectory()

public static File getGameListCache(Context context)
{
return new File(context.getExternalCacheDir(), "gamelist.cache");
return new File(NativeLibrary.GetCacheDirectory(), "gamelist.cache");
}

private static boolean copyAsset(String asset, File output, Context context)
Expand Down
6 changes: 6 additions & 0 deletions Source/Android/jni/MainAndroid.cpp
Expand Up @@ -382,6 +382,12 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetCacheDire
File::SetUserPath(D_CACHE_IDX, GetJString(env, jDirectory));
}

JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCacheDirectory(JNIEnv* env, jclass)
{
return ToJString(env, File::GetUserPath(D_CACHE_IDX));
}

JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv*, jclass)
{
return static_cast<jint>(PowerPC::DefaultCPUCore());
Expand Down

0 comments on commit 27db8d4

Please sign in to comment.