Skip to content

Commit

Permalink
Fix #217: track puzzlesgen version explicitly, not by timestamp.
Browse files Browse the repository at this point in the history
Bump version.
  • Loading branch information
chrisboyle committed Oct 26, 2014
1 parent ba99717 commit 7259a13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {

defaultConfig {
applicationId "name.boyle.chris.sgtpuzzles"
versionCode 88
versionName "10286.4"
versionCode 89
versionName "10286.5"

if (file(ndkDir.absolutePath + '/platforms/android-15').exists()) { // the last without PIE
minSdkVersion 7
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/name/boyle/chris/sgtpuzzles/GamePlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
Expand Down Expand Up @@ -98,6 +99,7 @@ public class GamePlay extends ActionBarActivity implements OnSharedPreferenceCha
public static final String SAVED_COMPLETED_PREFIX = "savedCompleted_";
public static final String SAVED_GAME_PREFIX = "savedGame_";
public static final String LAST_PARAMS_PREFIX = "last_params_";
private static final String PUZZLESGEN_LAST_UPDATE = "puzzlesgen_last_update";

private ProgressDialog progress;
private TextView statusBar;
Expand Down Expand Up @@ -564,6 +566,7 @@ private String generateGame(final List<String> args) throws IllegalArgumentExcep
return game;
}

@SuppressLint("CommitPrefEdits")
private void startGameGenProcess(final List<String> args) throws IOException {
final ApplicationInfo applicationInfo = getApplicationInfo();
final File dataDir = new File(applicationInfo.dataDir);
Expand All @@ -577,8 +580,13 @@ private void startGameGenProcess(final List<String> args) throws IOException {
final String suffix = canRunPIE ? "-with-pie" : "-no-pie";
File installablePath = new File(libDir, "libpuzzlesgen" + suffix + ".so");
File executablePath = new File(dataDir, "puzzlesgen" + suffix);
if (!executablePath.exists() ||
executablePath.lastModified() < installablePath.lastModified()) {
boolean needCopy = true;
try {
final int currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
needCopy = !executablePath.exists() || (prefs.getInt(PUZZLESGEN_LAST_UPDATE, 0) < currentVersion);
prefsSaver.save(prefs.edit().putInt(PUZZLESGEN_LAST_UPDATE, currentVersion));
} catch (PackageManager.NameNotFoundException ignored) {}
if (needCopy) {
copyFile(installablePath, executablePath);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
Expand Down

0 comments on commit 7259a13

Please sign in to comment.