offer to email when unable to lock game

Only on non-shipping builds. This is attempting to catch a non-repro
lock-forever I'm trying to fix.
This commit is contained in:
Eric House 2019-06-02 09:02:25 -07:00
parent 52d2694bc7
commit 3a4a8baf70
3 changed files with 17 additions and 2 deletions

View file

@ -51,7 +51,8 @@ import android.support.annotation.NonNull;
public class GameLock implements AutoCloseable, Serializable {
private static final String TAG = GameLock.class.getSimpleName();
private static final boolean GET_OWNER_STACK = BuildConfig.DEBUG;
private static final boolean GET_OWNER_STACK =
BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD;
private static final boolean DEBUG_LOCKS = false;
// private static final long ASSERT_TIME = 2000;

View file

@ -98,13 +98,19 @@ public class GameUtils {
public static byte[] savedGame( Context context, long rowid )
{
byte[] result = null;
try (GameLock lock = GameLock.tryLockRO( rowid ) ) {
try ( GameLock lock = GameLock.tryLockRO( rowid ) ) {
if ( null != lock ) {
result = savedGame( context, lock );
}
}
if ( null == result ) {
String msg = "savedGame(): unable to get lock; holder dump: "
+ GameLock.getHolderDump( rowid );
Log.d( TAG, msg );
if ( BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD ) {
Utils.emailAuthor( context, msg );
}
throw new NoSuchGameException( rowid );
}

View file

@ -185,6 +185,11 @@ public class Utils {
}
public static void emailAuthor( Context context )
{
emailAuthor( context, null );
}
public static void emailAuthor( Context context, String msg )
{
Intent intent = new Intent( Intent.ACTION_SEND );
intent.setType( "message/rfc822" ); // force email
@ -196,6 +201,9 @@ public class Utils {
intent.putExtra( Intent.EXTRA_EMAIL, addrs );
String body = LocUtils.getString( context, R.string.email_body_rev_fmt,
BuildConfig.GIT_REV );
if ( null != msg ) {
body += "\n\n" + msg;
}
intent.putExtra( Intent.EXTRA_TEXT, body );
String chooserMsg = LocUtils.getString( context,
R.string.email_author_chooser );