Skip to content

Commit

Permalink
(Android) Only update retroarch.cfg on startup if version changed (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
neil4 authored Jul 31, 2023
1 parent 0739221 commit 0b9e597
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ else if (dataDir != null)

/**
* Updates the libretro configuration file
* with new values if settings have changed.
* with new values if version has changed.
*
* @param ctx the current {@link Context}.
*/
Expand All @@ -121,10 +121,10 @@ public static void updateConfigFile(Context ctx)
String path = getDefaultConfigPath(ctx);
ConfigFile config = new ConfigFile(path);

Log.i(TAG, "Writing config to: " + path);

final String dataDir = ctx.getApplicationInfo().dataDir;
final String coreDir = dataDir + "/cores/";
final String dstPath = dataDir;
final String dstPathSubdir = "assets";

final SharedPreferences prefs = getPreferences(ctx);

Expand All @@ -137,16 +137,16 @@ public static void updateConfigFile(Context ctx)

try
{
int version = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionCode;
final String dst_path = dataDir;
final String dst_path_subdir = "assets";
int version = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionCode;
int last_version = config.keyExists("bundle_assets_extract_last_version") ?
config.getInt("bundle_assets_extract_last_version") : 0;

Log.i(TAG, "dst dir is: " + dst_path);
Log.i(TAG, "dst subdir is: " + dst_path_subdir);
if (version == last_version)
return;

config.setString("bundle_assets_src_path", ctx.getApplicationInfo().sourceDir);
config.setString("bundle_assets_dst_path", dst_path);
config.setString("bundle_assets_dst_path_subdir", dst_path_subdir);
config.setString("bundle_assets_dst_path", dstPath);
config.setString("bundle_assets_dst_path_subdir", dstPathSubdir);
config.setInt("bundle_assets_extract_version_current", version);
}
catch (NameNotFoundException ignored)
Expand All @@ -164,6 +164,9 @@ public static void updateConfigFile(Context ctx)

try
{
Log.i(TAG, "Writing config to: " + path);
Log.i(TAG, "dst dir is: " + dstPath);
Log.i(TAG, "dst subdir is: " + dstPathSubdir);
config.write(path);
}
catch (IOException e)
Expand Down

0 comments on commit 0b9e597

Please sign in to comment.