move constant from XWApp to build.gradle

This commit is contained in:
Eric House 2019-02-06 10:44:21 -08:00
parent f92b0d7ac0
commit 895b19a097
5 changed files with 14 additions and 14 deletions

View file

@ -69,6 +69,7 @@ android {
buildConfigField "boolean", "IS_TAGGED_BUILD", "${CURTAG}" == '' ? "false" : "true" buildConfigField "boolean", "IS_TAGGED_BUILD", "${CURTAG}" == '' ? "false" : "true"
resValue "string", "invite_prefix", "/and/" resValue "string", "invite_prefix", "/and/"
buildConfigField "int[]", "SMS_BANNED_EXPL", "null" buildConfigField "int[]", "SMS_BANNED_EXPL", "null"
buildConfigField "boolean", "UDP_ENABLED", "true"
} }
xw4 { xw4 {

View file

@ -80,7 +80,7 @@ public class CommsTransport implements TransportProcs,
@Override @Override
public void run() public void run()
{ {
if ( !XWApp.UDP_ENABLED ) { if ( !BuildConfig.UDP_ENABLED ) {
m_done = false; m_done = false;
boolean failed = true; boolean failed = true;
try { try {
@ -111,7 +111,7 @@ public class CommsTransport implements TransportProcs,
private boolean loop() private boolean loop()
{ {
boolean failed = false; boolean failed = false;
if ( !XWApp.UDP_ENABLED ) { if ( !BuildConfig.UDP_ENABLED ) {
outer_loop: outer_loop:
while ( !m_done ) { while ( !m_done ) {
try { try {
@ -237,7 +237,7 @@ public class CommsTransport implements TransportProcs,
private synchronized void putOut( final byte[] buf ) private synchronized void putOut( final byte[] buf )
{ {
if ( !XWApp.UDP_ENABLED ) { if ( !BuildConfig.UDP_ENABLED ) {
int len = buf.length; int len = buf.length;
ByteBuffer netbuf = ByteBuffer.allocate( len + 2 ); ByteBuffer netbuf = ByteBuffer.allocate( len + 2 );
netbuf.putShort( (short)len ); netbuf.putShort( (short)len );
@ -254,7 +254,7 @@ public class CommsTransport implements TransportProcs,
private synchronized void closeSocket() private synchronized void closeSocket()
{ {
if ( !XWApp.UDP_ENABLED && null != m_socketChannel ) { if ( !BuildConfig.UDP_ENABLED && null != m_socketChannel ) {
try { try {
m_socketChannel.close(); m_socketChannel.close();
} catch ( Exception e ) { } catch ( Exception e ) {
@ -294,7 +294,7 @@ public class CommsTransport implements TransportProcs,
private void addIncoming( ) private void addIncoming( )
{ {
if ( !XWApp.UDP_ENABLED ) { if ( !BuildConfig.UDP_ENABLED ) {
m_bytesIn.flip(); m_bytesIn.flip();
for ( ; ; ) { for ( ; ; ) {
@ -330,7 +330,7 @@ public class CommsTransport implements TransportProcs,
private void waitToStopImpl() private void waitToStopImpl()
{ {
if ( !XWApp.UDP_ENABLED ) { if ( !BuildConfig.UDP_ENABLED ) {
m_done = true; // this is in a race! m_done = true; // this is in a race!
if ( null != m_selector ) { if ( null != m_selector ) {
m_selector.wakeup(); // getting NPE inside here -- see below m_selector.wakeup(); // getting NPE inside here -- see below
@ -363,13 +363,13 @@ public class CommsTransport implements TransportProcs,
Assert.assertNotNull( addr ); Assert.assertNotNull( addr );
Assert.assertTrue( addr.contains( conType ) ); 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 ) { && null == m_relayAddr ) {
m_relayAddr = new CommsAddrRec( addr ); m_relayAddr = new CommsAddrRec( addr );
m_useHost = NetUtils.forceHost( m_relayAddr.ip_relay_hostName ); 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 ) ) { if ( NetStateCache.netAvail( m_context ) ) {
putOut( buf ); // add to queue putOut( buf ); // add to queue
if ( null == m_thread ) { if ( null == m_thread ) {
@ -422,7 +422,7 @@ public class CommsTransport implements TransportProcs,
int nSent = -1; int nSent = -1;
switch ( conType ) { switch ( conType ) {
case COMMS_CONN_RELAY: case COMMS_CONN_RELAY:
Assert.assertTrue( XWApp.UDP_ENABLED ); Assert.assertTrue( BuildConfig.UDP_ENABLED );
nSent = RelayService.sendPacket( context, rowID, buf ); nSent = RelayService.sendPacket( context, rowID, buf );
break; break;
case COMMS_CONN_SMS: case COMMS_CONN_SMS:

View file

@ -58,7 +58,7 @@ public class MultiMsgSink implements TransportProcs {
// can just insert a message into its queue // can just insert a message into its queue
public int sendViaRelay( byte[] buf, int gameID ) public int sendViaRelay( byte[] buf, int gameID )
{ {
Assert.assertTrue( XWApp.UDP_ENABLED ); Assert.assertTrue( BuildConfig.UDP_ENABLED );
return RelayService.sendPacket( m_context, getRowID(), buf ); return RelayService.sendPacket( m_context, getRowID(), buf );
} }

View file

@ -567,7 +567,7 @@ public class RelayService extends JobIntentService
private boolean startFetchThreadIfNotUDP() private boolean startFetchThreadIfNotUDP()
{ {
// DbgUtils.logf( "startFetchThreadIfNotUDP()" ); // DbgUtils.logf( "startFetchThreadIfNotUDP()" );
boolean handled = relayEnabled( this ) && !XWApp.UDP_ENABLED; boolean handled = relayEnabled( this ) && !BuildConfig.UDP_ENABLED;
if ( handled && null == m_fetchThread ) { if ( handled && null == m_fetchThread ) {
Assert.assertFalse( BuildConfig.DEBUG ); // NOT using this now! Assert.assertFalse( BuildConfig.DEBUG ); // NOT using this now!
@ -600,7 +600,7 @@ public class RelayService extends JobIntentService
private UDPThreads startUDPThreadsOnce() private UDPThreads startUDPThreadsOnce()
{ {
UDPThreads threads = null; UDPThreads threads = null;
if ( XWApp.UDP_ENABLED && relayEnabled( this ) ) { if ( BuildConfig.UDP_ENABLED && relayEnabled( this ) ) {
synchronized ( sUDPThreadsRef ) { synchronized ( sUDPThreadsRef ) {
threads = sUDPThreadsRef.get(); threads = sUDPThreadsRef.get();
if ( null == threads ) { if ( null == threads ) {
@ -1613,7 +1613,7 @@ public class RelayService extends JobIntentService
Log.d( TAG, "startThreads()" ); Log.d( TAG, "startThreads()" );
if ( !relayEnabled( this ) || !NetStateCache.netAvail( this ) ) { if ( !relayEnabled( this ) || !NetStateCache.netAvail( this ) ) {
stopThreads(); stopThreads();
} else if ( XWApp.UDP_ENABLED ) { } else if ( BuildConfig.UDP_ENABLED ) {
stopFetchThreadIf(); stopFetchThreadIf();
startUDPThreadsOnce(); startUDPThreadsOnce();
registerWithRelay( -1 ); registerWithRelay( -1 );

View file

@ -45,7 +45,6 @@ public class XWApp extends Application implements LifecycleObserver {
public static final boolean ATTACH_SUPPORTED = false; public static final boolean ATTACH_SUPPORTED = false;
public static final boolean LOG_LIFECYLE = false; public static final boolean LOG_LIFECYLE = false;
public static final boolean DEBUG_EXP_TIMERS = 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 SMS_INVITE_ENABLED = true;
public static final boolean LOCUTILS_ENABLED = false; public static final boolean LOCUTILS_ENABLED = false;
public static final boolean CONTEXT_MENUS_ENABLED = true; public static final boolean CONTEXT_MENUS_ENABLED = true;