Merge pull request #9266 from JosJuice/android-startup-illegalstate

Android: Fix IllegalStateException on startup
This commit is contained in:
Léo Lam 2020-11-20 22:13:30 +01:00 committed by GitHub
commit 33f15f22e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)