diff --git a/xwords4/android/app/build.gradle b/xwords4/android/app/build.gradle index 8dfcb27bb..92c526c22 100644 --- a/xwords4/android/app/build.gradle +++ b/xwords4/android/app/build.gradle @@ -69,6 +69,7 @@ android { buildConfigField "boolean", "IS_TAGGED_BUILD", "${CURTAG}" == '' ? "false" : "true" resValue "string", "invite_prefix", "/and/" buildConfigField "int[]", "SMS_BANNED_EXPL", "null" + buildConfigField "boolean", "UDP_ENABLED", "true" } xw4 { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/CommsTransport.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/CommsTransport.java index 06f63ac5b..ad479b99d 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/CommsTransport.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/CommsTransport.java @@ -80,7 +80,7 @@ public class CommsTransport implements TransportProcs, @Override public void run() { - if ( !XWApp.UDP_ENABLED ) { + if ( !BuildConfig.UDP_ENABLED ) { m_done = false; boolean failed = true; try { @@ -111,7 +111,7 @@ public class CommsTransport implements TransportProcs, private boolean loop() { boolean failed = false; - if ( !XWApp.UDP_ENABLED ) { + if ( !BuildConfig.UDP_ENABLED ) { outer_loop: while ( !m_done ) { try { @@ -237,7 +237,7 @@ public class CommsTransport implements TransportProcs, private synchronized void putOut( final byte[] buf ) { - if ( !XWApp.UDP_ENABLED ) { + if ( !BuildConfig.UDP_ENABLED ) { int len = buf.length; ByteBuffer netbuf = ByteBuffer.allocate( len + 2 ); netbuf.putShort( (short)len ); @@ -254,7 +254,7 @@ public class CommsTransport implements TransportProcs, private synchronized void closeSocket() { - if ( !XWApp.UDP_ENABLED && null != m_socketChannel ) { + if ( !BuildConfig.UDP_ENABLED && null != m_socketChannel ) { try { m_socketChannel.close(); } catch ( Exception e ) { @@ -294,7 +294,7 @@ public class CommsTransport implements TransportProcs, private void addIncoming( ) { - if ( !XWApp.UDP_ENABLED ) { + if ( !BuildConfig.UDP_ENABLED ) { m_bytesIn.flip(); for ( ; ; ) { @@ -330,7 +330,7 @@ public class CommsTransport implements TransportProcs, private void waitToStopImpl() { - if ( !XWApp.UDP_ENABLED ) { + if ( !BuildConfig.UDP_ENABLED ) { m_done = true; // this is in a race! if ( null != m_selector ) { m_selector.wakeup(); // getting NPE inside here -- see below @@ -363,13 +363,13 @@ public class CommsTransport implements TransportProcs, Assert.assertNotNull( addr ); Assert.assertTrue( addr.contains( conType ) ); - if ( !XWApp.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY + if ( !BuildConfig.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY && null == m_relayAddr ) { m_relayAddr = new CommsAddrRec( addr ); m_useHost = NetUtils.forceHost( m_relayAddr.ip_relay_hostName ); } - if ( !XWApp.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY ) { + if ( !BuildConfig.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY ) { if ( NetStateCache.netAvail( m_context ) ) { putOut( buf ); // add to queue if ( null == m_thread ) { @@ -422,7 +422,7 @@ public class CommsTransport implements TransportProcs, int nSent = -1; switch ( conType ) { case COMMS_CONN_RELAY: - Assert.assertTrue( XWApp.UDP_ENABLED ); + Assert.assertTrue( BuildConfig.UDP_ENABLED ); nSent = RelayService.sendPacket( context, rowID, buf ); break; case COMMS_CONN_SMS: diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiMsgSink.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiMsgSink.java index 17c78f387..8c420a79a 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiMsgSink.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiMsgSink.java @@ -58,7 +58,7 @@ public class MultiMsgSink implements TransportProcs { // can just insert a message into its queue public int sendViaRelay( byte[] buf, int gameID ) { - Assert.assertTrue( XWApp.UDP_ENABLED ); + Assert.assertTrue( BuildConfig.UDP_ENABLED ); return RelayService.sendPacket( m_context, getRowID(), buf ); } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java index c7fa3ddcf..517a14e7c 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java @@ -567,7 +567,7 @@ public class RelayService extends JobIntentService private boolean startFetchThreadIfNotUDP() { // DbgUtils.logf( "startFetchThreadIfNotUDP()" ); - boolean handled = relayEnabled( this ) && !XWApp.UDP_ENABLED; + boolean handled = relayEnabled( this ) && !BuildConfig.UDP_ENABLED; if ( handled && null == m_fetchThread ) { Assert.assertFalse( BuildConfig.DEBUG ); // NOT using this now! @@ -600,7 +600,7 @@ public class RelayService extends JobIntentService private UDPThreads startUDPThreadsOnce() { UDPThreads threads = null; - if ( XWApp.UDP_ENABLED && relayEnabled( this ) ) { + if ( BuildConfig.UDP_ENABLED && relayEnabled( this ) ) { synchronized ( sUDPThreadsRef ) { threads = sUDPThreadsRef.get(); if ( null == threads ) { @@ -1613,7 +1613,7 @@ public class RelayService extends JobIntentService Log.d( TAG, "startThreads()" ); if ( !relayEnabled( this ) || !NetStateCache.netAvail( this ) ) { stopThreads(); - } else if ( XWApp.UDP_ENABLED ) { + } else if ( BuildConfig.UDP_ENABLED ) { stopFetchThreadIf(); startUDPThreadsOnce(); registerWithRelay( -1 ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWApp.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWApp.java index 3bb5d2cfd..7b39e09d4 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWApp.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWApp.java @@ -45,7 +45,6 @@ public class XWApp extends Application implements LifecycleObserver { public static final boolean ATTACH_SUPPORTED = false; public static final boolean LOG_LIFECYLE = false; public static final boolean DEBUG_EXP_TIMERS = false; - public static final boolean UDP_ENABLED = true; public static final boolean SMS_INVITE_ENABLED = true; public static final boolean LOCUTILS_ENABLED = false; public static final boolean CONTEXT_MENUS_ENABLED = true;