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:
Eric House 2020-07-19 21:30:22 -07:00
parent e8c18b74d0
commit dbe48644c2
2 changed files with 14 additions and 2 deletions

View file

@ -1992,7 +1992,7 @@ public class GamesListDelegate extends ListDelegateBase
// DEBUG only
case R.id.games_game_markbad:
Quarantine.recordOpened( selRowIDs[0] );
Quarantine.markBad( selRowIDs[0] );
break;
default:

View file

@ -30,6 +30,7 @@ import java.io.Serializable;
public class Quarantine {
private static final String TAG = Quarantine.class.getSimpleName();
private static final String DATA_KEY = TAG + "/key";
private static final int BAD_COUNT = 2;
public static boolean safeToOpen( long rowid )
{
@ -37,7 +38,7 @@ public class Quarantine {
synchronized ( sDataRef ) {
count = get().getFor( rowid );
}
boolean result = count == 0; // Not too strict?
boolean result = count < BAD_COUNT;
if ( !result ) {
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 HashMap<Long, Integer> mCounts = new HashMap<>();