Merge pull request #9266 from JosJuice/android-startup-illegalstate
Android: Fix IllegalStateException on startup
This commit is contained in:
commit
33f15f22e2
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue