mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
quarantine: tolerate one crash but not two
I was really after the situation where a game could never be opened. There are lots of reasons a single failure can occur, not least of which is installing via adb while game's open. :-)
This commit is contained in:
parent
e8c18b74d0
commit
dbe48644c2
2 changed files with 14 additions and 2 deletions
|
@ -1992,7 +1992,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
// DEBUG only
|
// DEBUG only
|
||||||
case R.id.games_game_markbad:
|
case R.id.games_game_markbad:
|
||||||
Quarantine.recordOpened( selRowIDs[0] );
|
Quarantine.markBad( selRowIDs[0] );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.io.Serializable;
|
||||||
public class Quarantine {
|
public class Quarantine {
|
||||||
private static final String TAG = Quarantine.class.getSimpleName();
|
private static final String TAG = Quarantine.class.getSimpleName();
|
||||||
private static final String DATA_KEY = TAG + "/key";
|
private static final String DATA_KEY = TAG + "/key";
|
||||||
|
private static final int BAD_COUNT = 2;
|
||||||
|
|
||||||
public static boolean safeToOpen( long rowid )
|
public static boolean safeToOpen( long rowid )
|
||||||
{
|
{
|
||||||
|
@ -37,7 +38,7 @@ public class Quarantine {
|
||||||
synchronized ( sDataRef ) {
|
synchronized ( sDataRef ) {
|
||||||
count = get().getFor( rowid );
|
count = get().getFor( rowid );
|
||||||
}
|
}
|
||||||
boolean result = count == 0; // Not too strict?
|
boolean result = count < BAD_COUNT;
|
||||||
if ( !result ) {
|
if ( !result ) {
|
||||||
Log.d( TAG, "safeToOpen(%d) => %b (count=%d)", rowid, result, count );
|
Log.d( TAG, "safeToOpen(%d) => %b (count=%d)", rowid, result, count );
|
||||||
}
|
}
|
||||||
|
@ -70,6 +71,17 @@ public class Quarantine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void markBad( long rowid )
|
||||||
|
{
|
||||||
|
synchronized ( sDataRef ) {
|
||||||
|
for ( int ii = 0; ii < BAD_COUNT; ++ii ) {
|
||||||
|
get().increment( rowid );
|
||||||
|
}
|
||||||
|
store();
|
||||||
|
Log.d( TAG, "markBad(%d): %s", rowid, sDataRef[0].toString() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class Data implements Serializable {
|
private static class Data implements Serializable {
|
||||||
private HashMap<Long, Integer> mCounts = new HashMap<>();
|
private HashMap<Long, Integer> mCounts = new HashMap<>();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue