From 5d305f7df7f0098b44b4139ba2d08f350f541a78 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 13 Aug 2020 09:15:25 -0700 Subject: [PATCH] for debug builds, check for upgrades hourly --- xwords4/android/app/build.gradle | 1 + .../main/java/org/eehouse/android/xw4/Assert.java | 2 +- .../org/eehouse/android/xw4/GameListItem.java | 2 +- .../java/org/eehouse/android/xw4/GameLock.java | 3 +-- .../java/org/eehouse/android/xw4/GameUtils.java | 2 +- .../eehouse/android/xw4/InviteChoicesAlert.java | 2 +- .../main/java/org/eehouse/android/xw4/Log.java | 3 +-- .../eehouse/android/xw4/MQTTInviteDelegate.java | 3 +-- .../eehouse/android/xw4/RelayInviteDelegate.java | 3 +-- .../eehouse/android/xw4/UpdateCheckReceiver.java | 15 +++++++++++---- 10 files changed, 20 insertions(+), 16 deletions(-) diff --git a/xwords4/android/app/build.gradle b/xwords4/android/app/build.gradle index 1e6061245..fb5af35d8 100644 --- a/xwords4/android/app/build.gradle +++ b/xwords4/android/app/build.gradle @@ -89,6 +89,7 @@ android { buildConfigField "String", "KEY_FCMID", "\"FBMService_fcmid\"" buildConfigField "boolean", "ATTACH_SUPPORTED", "false" buildConfigField "boolean", "OFFER_MQTT", "true" + buildConfigField "boolean", "NON_RELEASE", "DEBUG || !IS_TAGGED_BUILD" } xw4NoSMS { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Assert.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Assert.java index 9fed16ba8..d23e53861 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Assert.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Assert.java @@ -45,7 +45,7 @@ public class Assert { // NR: non-release public static void assertTrueNR( boolean val ) { - if ( BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD ) { + if ( BuildConfig.NON_RELEASE ) { assertTrue( val ); } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListItem.java index 2cb36a142..bb9abc9f1 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListItem.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListItem.java @@ -334,7 +334,7 @@ public class GameListItem extends LinearLayout // temporarily after every game closes because an *already-open* // game always tests as not safe-to-open. boolean doShow = false; - boolean quarantined = (BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD) + boolean quarantined = BuildConfig.NON_RELEASE && !Quarantine.safeToOpen( m_rowid ); ImageView iv = (ImageView)findViewById( R.id.has_chat_marker ); if ( quarantined ) { 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 188f7e1c4..7bf52cf4a 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 @@ -52,8 +52,7 @@ import androidx.annotation.NonNull; public class GameLock implements AutoCloseable { private static final String TAG = GameLock.class.getSimpleName(); - private static final boolean GET_OWNER_STACK = - BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD; + private static final boolean GET_OWNER_STACK = BuildConfig.NON_RELEASE; 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 5d9a24c02..78d60f38c 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 @@ -108,7 +108,7 @@ public class GameUtils { String msg = "savedGame(): unable to get lock; holder dump: " + GameLock.getHolderDump( rowid ); Log.d( TAG, msg ); - if ( BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD ) { + if ( BuildConfig.NON_RELEASE ) { Utils.emailAuthor( context, msg ); } throw new NoSuchGameException( rowid ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteChoicesAlert.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteChoicesAlert.java index a1a72c9bb..41d14eb97 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteChoicesAlert.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteChoicesAlert.java @@ -65,7 +65,7 @@ public class InviteChoicesAlert extends DlgDelegateAlert { if ( Utils.deviceSupportsNBS(context) ) { add( items, means, R.string.invite_choice_data_sms, InviteMeans.SMS_DATA ); } - if ( BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD ) { + if ( BuildConfig.NON_RELEASE ) { add( items, means, R.string.invite_choice_relay, InviteMeans.RELAY ); } if ( BuildConfig.OFFER_MQTT ) { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Log.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Log.java index d6c17e707..4def086cc 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Log.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Log.java @@ -40,8 +40,7 @@ public class Log { private static final String TAG = Log.class.getSimpleName(); private static final String PRE_TAG = BuildConfig.FLAVOR + "-"; private static final String KEY_USE_DB = TAG + "/useDB"; - private static final boolean LOGGING_ENABLED - = BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD; + private static final boolean LOGGING_ENABLED = BuildConfig.NON_RELEASE; private static final boolean ERROR_LOGGING_ENABLED = true; private static final String LOGS_FILE_NAME = BuildConfig.FLAVOR + "_logsDB.txt"; private static final String LOGS_DB_NAME = "xwlogs_db"; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTInviteDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTInviteDelegate.java index 2c63b9f39..3a8836151 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTInviteDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTInviteDelegate.java @@ -30,8 +30,7 @@ import org.eehouse.android.xw4.jni.XwJNI; public class MQTTInviteDelegate extends DevIDInviteDelegate { private static final String TAG = MQTTInviteDelegate.class.getSimpleName(); private static final String RECS_KEY = TAG + "/recs"; - private static final boolean MQTTINVITE_SUPPORTED - = BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD; + private static final boolean MQTTINVITE_SUPPORTED = BuildConfig.NON_RELEASE; private String m_devIDStr; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayInviteDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayInviteDelegate.java index e98074161..5d69b41b1 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayInviteDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayInviteDelegate.java @@ -29,8 +29,7 @@ import org.eehouse.android.xw4.DBUtils.SentInvitesInfo; public class RelayInviteDelegate extends DevIDInviteDelegate { private static final String TAG = RelayInviteDelegate.class.getSimpleName(); private static final String RECS_KEY = TAG + "/recs"; - private static final boolean RELAYINVITE_SUPPORTED - = BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD; + private static final boolean RELAYINVITE_SUPPORTED = BuildConfig.NON_RELEASE; private boolean m_immobileConfirmed; private String mRelayDevIDStr; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java index 27951ff81..22fdc023a 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java @@ -46,8 +46,9 @@ public class UpdateCheckReceiver extends BroadcastReceiver { public static final String NEW_DICT_NAME = "NEW_DICT_NAME"; public static final String NEW_XLATION_CBK = "NEW_XLATION_CBK"; + private static final long INTERVAL_ONEHOUR = 1000 * 60 * 60; // weekly - private static final long INTERVAL_ONEDAY = 1000 * 60 * 60 * 24; + private static final long INTERVAL_ONEDAY = INTERVAL_ONEHOUR * 24; private static final long INTERVAL_NDAYS = 7; // constants that are also used in info.py @@ -93,10 +94,16 @@ public class UpdateCheckReceiver extends BroadcastReceiver { PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 ); am.cancel( pi ); - long interval_millis = INTERVAL_ONEDAY; - if ( !devOK( context ) ) { - interval_millis *= INTERVAL_NDAYS; + long interval_millis; + if ( BuildConfig.NON_RELEASE ) { + interval_millis = INTERVAL_ONEHOUR; + } else { + interval_millis = INTERVAL_ONEDAY; + if ( !devOK( context ) ) { + interval_millis *= INTERVAL_NDAYS; + } } + interval_millis = (interval_millis / 2) + Math.abs(Utils.nextRandomInt() % interval_millis); am.setInexactRepeating( AlarmManager.ELAPSED_REALTIME_WAKEUP,