From 3a4a8baf70f680fe82c99910105d170ef6915020 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 2 Jun 2019 09:02:25 -0700 Subject: [PATCH] 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. --- .../src/main/java/org/eehouse/android/xw4/GameLock.java | 3 ++- .../src/main/java/org/eehouse/android/xw4/GameUtils.java | 8 +++++++- .../app/src/main/java/org/eehouse/android/xw4/Utils.java | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameLock.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameLock.java index df193de46..1bdefe4d7 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameLock.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameLock.java @@ -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; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java index 56cad2bea..ed166f79d 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java @@ -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 ); } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java index 74c76393c..73720ce41 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java @@ -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 );