Android: Fix IllegalStateException on startup

See https://github.com/dolphin-emu/dolphin/pull/9095#pullrequestreview-535576465
This commit is contained in:
JosJuice 2020-11-20 17:52:45 +01:00
parent 17da28ff07
commit 730f9cb7bd
1 changed files with 7 additions and 14 deletions

View File

@ -39,6 +39,7 @@ public final class DirectoryInitialization
private static final int WiimoteNewVersion = 5; // Last changed in PR 8907
private static volatile DirectoryInitializationState directoryState =
DirectoryInitializationState.NOT_YET_INITIALIZED;
private static volatile boolean areDirectoriesAvailable = false;
private static String userPath;
private static String internalPath;
private static AtomicBoolean isDolphinDirectoryInitializationRunning = new AtomicBoolean(false);
@ -74,6 +75,8 @@ public final class DirectoryInitialization
NativeLibrary.Initialize();
NativeLibrary.ReportStartToAnalytics();
areDirectoriesAvailable = true;
if (wiimoteIniWritten)
{
// This has to be done after calling NativeLibrary.Initialize(),
@ -229,32 +232,22 @@ public final class DirectoryInitialization
public static String getUserDirectory()
{
if (directoryState == DirectoryInitializationState.NOT_YET_INITIALIZED)
{
throw new IllegalStateException("DirectoryInitialization has to run at least once!");
}
else if (isDolphinDirectoryInitializationRunning.get())
if (!areDirectoriesAvailable)
{
throw new IllegalStateException(
"DirectoryInitialization has to finish running first!");
"DirectoryInitialization must run before accessing the user directory!");
}
return userPath;
}
public static String getDolphinInternalDirectory()
{
if (directoryState == DirectoryInitializationState.NOT_YET_INITIALIZED)
{
throw new IllegalStateException("DirectoryInitialization has to run at least once!");
}
else if (isDolphinDirectoryInitializationRunning.get())
if (!areDirectoriesAvailable)
{
throw new IllegalStateException(
"DirectoryInitialization has to finish running first!");
"DirectoryInitialization must run before accessing the internal directory!");
}
return internalPath;
}
private static void sendBroadcastState(DirectoryInitializationState state, Context context)