mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-24 07:58:34 +01:00
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:
parent
52d2694bc7
commit
3a4a8baf70
3 changed files with 17 additions and 2 deletions
|
@ -51,7 +51,8 @@ import android.support.annotation.NonNull;
|
||||||
public class GameLock implements AutoCloseable, Serializable {
|
public class GameLock implements AutoCloseable, Serializable {
|
||||||
private static final String TAG = GameLock.class.getSimpleName();
|
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 boolean DEBUG_LOCKS = false;
|
||||||
|
|
||||||
// private static final long ASSERT_TIME = 2000;
|
// private static final long ASSERT_TIME = 2000;
|
||||||
|
|
|
@ -98,13 +98,19 @@ public class GameUtils {
|
||||||
public static byte[] savedGame( Context context, long rowid )
|
public static byte[] savedGame( Context context, long rowid )
|
||||||
{
|
{
|
||||||
byte[] result = null;
|
byte[] result = null;
|
||||||
try (GameLock lock = GameLock.tryLockRO( rowid ) ) {
|
try ( GameLock lock = GameLock.tryLockRO( rowid ) ) {
|
||||||
if ( null != lock ) {
|
if ( null != lock ) {
|
||||||
result = savedGame( context, lock );
|
result = savedGame( context, lock );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( null == result ) {
|
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 );
|
throw new NoSuchGameException( rowid );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,11 @@ public class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void emailAuthor( Context context )
|
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 intent = new Intent( Intent.ACTION_SEND );
|
||||||
intent.setType( "message/rfc822" ); // force email
|
intent.setType( "message/rfc822" ); // force email
|
||||||
|
@ -196,6 +201,9 @@ public class Utils {
|
||||||
intent.putExtra( Intent.EXTRA_EMAIL, addrs );
|
intent.putExtra( Intent.EXTRA_EMAIL, addrs );
|
||||||
String body = LocUtils.getString( context, R.string.email_body_rev_fmt,
|
String body = LocUtils.getString( context, R.string.email_body_rev_fmt,
|
||||||
BuildConfig.GIT_REV );
|
BuildConfig.GIT_REV );
|
||||||
|
if ( null != msg ) {
|
||||||
|
body += "\n\n" + msg;
|
||||||
|
}
|
||||||
intent.putExtra( Intent.EXTRA_TEXT, body );
|
intent.putExtra( Intent.EXTRA_TEXT, body );
|
||||||
String chooserMsg = LocUtils.getString( context,
|
String chooserMsg = LocUtils.getString( context,
|
||||||
R.string.email_author_chooser );
|
R.string.email_author_chooser );
|
||||||
|
|
Loading…
Add table
Reference in a new issue