Merge pull request #6275 from JosJuice/android-reliable-init
Android: Always run HandleInit logic on app start
This commit is contained in:
commit
257da9980e
|
@ -3,6 +3,8 @@ package org.dolphinemu.dolphinemu;
|
|||
import android.app.Application;
|
||||
|
||||
import org.dolphinemu.dolphinemu.model.GameDatabase;
|
||||
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
|
||||
import org.dolphinemu.dolphinemu.utils.PermissionsHandler;
|
||||
|
||||
public class DolphinApplication extends Application
|
||||
{
|
||||
|
@ -13,6 +15,11 @@ public class DolphinApplication extends Application
|
|||
{
|
||||
super.onCreate();
|
||||
|
||||
NativeLibrary.SetUserDirectory(""); // Empty string means use the default path
|
||||
|
||||
if (PermissionsHandler.hasWriteAccess(getApplicationContext()))
|
||||
DirectoryInitializationService.startService(getApplicationContext());
|
||||
|
||||
databaseHelper = new GameDatabase(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,6 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
|||
mPresenter.onCreate();
|
||||
|
||||
// Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
|
||||
// TODO Split some of this stuff into Application.onCreate()
|
||||
if (savedInstanceState == null)
|
||||
StartupHandler.HandleInit(this);
|
||||
|
||||
|
|
|
@ -5,28 +5,19 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.FragmentActivity;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
|
||||
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
|
||||
|
||||
public final class StartupHandler
|
||||
{
|
||||
public static boolean HandleInit(FragmentActivity parent)
|
||||
public static void HandleInit(FragmentActivity parent)
|
||||
{
|
||||
String user_dir = "";
|
||||
String start_file = "";
|
||||
// Ask the user to grant write permission if it's not already granted
|
||||
PermissionsHandler.checkWritePermission(parent);
|
||||
|
||||
String start_file = "";
|
||||
Bundle extras = parent.getIntent().getExtras();
|
||||
if (extras != null)
|
||||
{
|
||||
user_dir = extras.getString("UserDir");
|
||||
start_file = extras.getString("AutoStartFile");
|
||||
}
|
||||
|
||||
NativeLibrary.SetUserDirectory(user_dir); // Uses default path if user_dir equals ""
|
||||
|
||||
if (PermissionsHandler.checkWritePermission(parent))
|
||||
DirectoryInitializationService.startService(parent);
|
||||
|
||||
if (!TextUtils.isEmpty(start_file))
|
||||
{
|
||||
|
@ -35,9 +26,6 @@ public final class StartupHandler
|
|||
emulation_intent.putExtra("SelectedGame", start_file);
|
||||
parent.startActivity(emulation_intent);
|
||||
parent.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ JavaVM* g_java_vm;
|
|||
namespace
|
||||
{
|
||||
ANativeWindow* s_surf;
|
||||
std::string s_set_userpath;
|
||||
|
||||
jclass s_jni_class;
|
||||
jmethodID s_jni_method_alert;
|
||||
|
@ -677,9 +676,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirec
|
|||
JNIEnv* env, jobject obj, jstring jDirectory)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
std::string directory = GetJString(env, jDirectory);
|
||||
s_set_userpath = directory;
|
||||
UICommon::SetUserDirectory(directory);
|
||||
UICommon::SetUserDirectory(GetJString(env, jDirectory));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv* env,
|
||||
|
@ -778,7 +775,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv*
|
|||
RegisterMsgAlertHandler(&MsgAlert);
|
||||
|
||||
std::unique_lock<std::mutex> guard(s_host_identity_lock);
|
||||
UICommon::SetUserDirectory(s_set_userpath);
|
||||
UICommon::Init();
|
||||
|
||||
WiimoteReal::InitAdapterClass();
|
||||
|
|
Loading…
Reference in New Issue