(Android) Only update retroarch.cfg on startup if version changed (#15536)

This commit is contained in:
neil4 2023-07-30 22:11:59 -05:00 committed by GitHub
parent 073922119b
commit 0b9e5975f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,7 +112,7 @@ public final class UserPreferences
/** /**
* Updates the libretro configuration file * 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}. * @param ctx the current {@link Context}.
*/ */
@ -121,10 +121,10 @@ public final class UserPreferences
String path = getDefaultConfigPath(ctx); String path = getDefaultConfigPath(ctx);
ConfigFile config = new ConfigFile(path); ConfigFile config = new ConfigFile(path);
Log.i(TAG, "Writing config to: " + path);
final String dataDir = ctx.getApplicationInfo().dataDir; final String dataDir = ctx.getApplicationInfo().dataDir;
final String coreDir = dataDir + "/cores/"; final String coreDir = dataDir + "/cores/";
final String dstPath = dataDir;
final String dstPathSubdir = "assets";
final SharedPreferences prefs = getPreferences(ctx); final SharedPreferences prefs = getPreferences(ctx);
@ -137,16 +137,16 @@ public final class UserPreferences
try try
{ {
int version = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionCode; int version = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionCode;
final String dst_path = dataDir; int last_version = config.keyExists("bundle_assets_extract_last_version") ?
final String dst_path_subdir = "assets"; config.getInt("bundle_assets_extract_last_version") : 0;
Log.i(TAG, "dst dir is: " + dst_path); if (version == last_version)
Log.i(TAG, "dst subdir is: " + dst_path_subdir); return;
config.setString("bundle_assets_src_path", ctx.getApplicationInfo().sourceDir); config.setString("bundle_assets_src_path", ctx.getApplicationInfo().sourceDir);
config.setString("bundle_assets_dst_path", dst_path); config.setString("bundle_assets_dst_path", dstPath);
config.setString("bundle_assets_dst_path_subdir", dst_path_subdir); config.setString("bundle_assets_dst_path_subdir", dstPathSubdir);
config.setInt("bundle_assets_extract_version_current", version); config.setInt("bundle_assets_extract_version_current", version);
} }
catch (NameNotFoundException ignored) catch (NameNotFoundException ignored)
@ -164,6 +164,9 @@ public final class UserPreferences
try 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); config.write(path);
} }
catch (IOException e) catch (IOException e)