(Android) Sets default savedir/savestate/system directory paths now to internal sandboxed

app dir (Android 4.4.2 and so on no longer allow writing to SD card)
This commit is contained in:
twinaphex 2014-06-13 03:52:17 +02:00
parent b3ad2913a4
commit 94cd38f628
5 changed files with 43 additions and 9 deletions

View File

@ -128,6 +128,7 @@ public final class HistorySelection extends DialogFragment
retro.putExtra("LIBRETRO", corePath);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));
retro.putExtra("IME", current_ime);
retro.putExtra("DATADIR", getActivity().getApplicationInfo().dataDir);
startActivity(retro);
dismiss();
}

View File

@ -280,6 +280,7 @@ public final class DetectCoreDirectoryFragment extends DirectoryFragment
retro.putExtra("LIBRETRO", corePath);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(getActivity()));
retro.putExtra("IME", current_ime);
retro.putExtra("DATADIR", getActivity().getApplicationInfo().dataDir);
startActivity(retro);
dismiss();
}

View File

@ -217,6 +217,7 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
retro.putExtra("LIBRETRO", libretro_path);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));
retro.putExtra("IME", current_ime);
retro.putExtra("DATADIR", ctx.getApplicationInfo().dataDir);
startActivity(retro);
}
// Load Core Preference
@ -290,6 +291,7 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
retro.putExtra("LIBRETRO", libretro_path);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));
retro.putExtra("IME", current_ime);
retro.putExtra("DATADIR", ctx.getApplicationInfo().dataDir);
startActivity(retro);
}
}

View File

@ -220,12 +220,18 @@ public final class UserPreferences
config.setBoolean("input_overlay_enable", prefs.getBoolean("input_overlay_enable", false));
config.setString("input_overlay", prefs.getString("input_overlay", ""));
final boolean usingCustomSaveFileDir = prefs.getBoolean("savefile_directory_enable", false);
final boolean usingCustomSaveStateDir = prefs.getBoolean("savestate_directory_enable", false);
final boolean usingCustomSystemDir = prefs.getBoolean("system_directory_enable", false);
config.setString("savefile_directory", usingCustomSaveFileDir ? prefs.getString("savefile_directory", "") : "");
config.setString("savestate_directory", usingCustomSaveStateDir ? prefs.getString("savestate_directory", "") : "");
config.setString("system_directory", usingCustomSystemDir ? prefs.getString("system_directory", "") : "");
if (prefs.getBoolean("savefile_directory_enable", false))
{
config.setString("savefile_directory", prefs.getString("savefile_directory", ""));
}
if (prefs.getBoolean("savestate_directory_enable", false))
{
config.setString("savestate_directory", prefs.getString("savestate_directory", ""));
}
if (prefs.getBoolean("system_directory_enable", false))
{
config.setString("system_directory", prefs.getString("system_directory", ""));
}
config.setBoolean("video_font_enable", prefs.getBoolean("video_font_enable", true));
config.setString("game_history_path", dataDir + "/retroarch-history.txt");

View File

@ -460,7 +460,7 @@ static void frontend_android_get_environment_settings(int *argc, char *argv[],
RARCH_LOG("Config file: [%s].\n", config_path);
if (args && *config_path)
args->config_path = config_path;
args->config_path = strdup(config_path);
}
// Current IME
@ -497,7 +497,7 @@ static void frontend_android_get_environment_settings(int *argc, char *argv[],
RARCH_LOG("Libretro path: [%s].\n", core_path);
if (args && *core_path)
args->libretro_path = core_path;
args->libretro_path = strdup(core_path);
}
// Content
@ -516,7 +516,31 @@ static void frontend_android_get_environment_settings(int *argc, char *argv[],
{
RARCH_LOG("Auto-start game %s.\n", path);
if (args && *path)
args->rom_path = path;
args->rom_path = strdup(path);
}
}
// Content
CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra, (*env)->NewStringUTF(env, "DATADIR"));
*path = '\0';
if (android_app->getStringExtra && jstr)
{
const char *argv = (*env)->GetStringUTFChars(env, jstr, 0);
if (*argv && *argv)
strlcpy(path, argv, sizeof(path));
(*env)->ReleaseStringUTFChars(env, jstr, argv);
if (*path)
{
RARCH_LOG("Data path: [%s].\n", path);
if (args && *path)
{
fill_pathname_join(g_defaults.savestate_dir, path, "savestates", sizeof(g_defaults.savestate_dir));
fill_pathname_join(g_defaults.sram_dir, path, "savefiles", sizeof(g_defaults.sram_dir));
fill_pathname_join(g_defaults.system_dir, path, "system", sizeof(g_defaults.system_dir));
}
}
}