remove RelayService and stuff that uses it

This commit is contained in:
Eric House 2022-05-07 18:21:51 -07:00
parent 3953ab19a4
commit 58cba766d3
13 changed files with 12 additions and 202 deletions

View file

@ -2666,7 +2666,7 @@ public class BoardDelegate extends DelegateBase
dev = null; // don't record send a second time dev = null; // don't record send a second time
break; break;
case RELAY: case RELAY:
RelayService.logGoneFail( TAG, 2 ); Assert.failDbg();
break; break;
case WIFIDIRECT: case WIFIDIRECT:
WiDirService.inviteRemote( m_activity, dev, nli ); WiDirService.inviteRemote( m_activity, dev, nli );
@ -2895,7 +2895,6 @@ public class BoardDelegate extends DelegateBase
boolean doIt = true; boolean doIt = true;
String phone = null; String phone = null;
String btAddr = null; String btAddr = null;
String relayID = null;
String p2pMacAddress = null; String p2pMacAddress = null;
String mqttDevID = null; String mqttDevID = null;
if ( DeviceRole.SERVER_STANDALONE == gi.serverRole ) { if ( DeviceRole.SERVER_STANDALONE == gi.serverRole ) {
@ -2922,8 +2921,6 @@ public class BoardDelegate extends DelegateBase
} }
if ( addr.contains( CommsConnType.COMMS_CONN_RELAY ) ) { if ( addr.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
Assert.failDbg(); Assert.failDbg();
Assert.assertNull( relayID );
relayID = XwJNI.comms_formatRelayID( jniGamePtr, ii );
} }
if ( addr.contains( CommsConnType.COMMS_CONN_P2P ) ) { if ( addr.contains( CommsConnType.COMMS_CONN_P2P ) ) {
Assert.assertNull( p2pMacAddress ); Assert.assertNull( p2pMacAddress );
@ -2941,8 +2938,7 @@ public class BoardDelegate extends DelegateBase
Intent intent = GamesListDelegate Intent intent = GamesListDelegate
.makeRematchIntent( activity, rowid, groupID, gi, .makeRematchIntent( activity, rowid, groupID, gi,
summary.conTypes, btAddr, phone, summary.conTypes, btAddr, phone,
relayID, p2pMacAddress, p2pMacAddress, mqttDevID, newName );
mqttDevID, newName );
if ( null != intent ) { if ( null != intent ) {
activity.startActivity( intent ); activity.startActivity( intent );
} }
@ -3052,10 +3048,6 @@ public class BoardDelegate extends DelegateBase
BTUtils.inviteRemote( m_activity, value, nli ); BTUtils.inviteRemote( m_activity, value, nli );
recordInviteSent( InviteMeans.BLUETOOTH, value ); recordInviteSent( InviteMeans.BLUETOOTH, value );
} }
value = m_summary.getStringExtra( GameSummary.EXTRA_REMATCH_RELAY );
if ( null != value ) {
RelayService.logGoneFail( TAG, 3 );
}
value = m_summary.getStringExtra( GameSummary.EXTRA_REMATCH_P2P ); value = m_summary.getStringExtra( GameSummary.EXTRA_REMATCH_P2P );
if ( null != value ) { if ( null != value ) {
WiDirService.inviteRemote( m_activity, value, nli ); WiDirService.inviteRemote( m_activity, value, nli );

View file

@ -404,7 +404,7 @@ public class CommsTransport implements TransportProcs,
int nSent = -1; int nSent = -1;
switch ( conType ) { switch ( conType ) {
case COMMS_CONN_RELAY: case COMMS_CONN_RELAY:
RelayService.logGoneFail( TAG, 2 ); Assert.failDbg();
break; break;
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
nSent = NBSProto.sendPacket( context, addr.sms_phone, nSent = NBSProto.sendPacket( context, addr.sms_phone,

View file

@ -715,7 +715,7 @@ public class ConnStatusHandler {
if ( BuildConfig.DEBUG ) { if ( BuildConfig.DEBUG ) {
switch ( typ ) { switch ( typ ) {
case COMMS_CONN_RELAY: case COMMS_CONN_RELAY:
RelayService.logGoneFail( TAG, 1 ); Assert.failDbg();
break; break;
case COMMS_CONN_MQTT: case COMMS_CONN_MQTT:
if ( null != addr ) { if ( null != addr ) {

View file

@ -388,15 +388,13 @@ public class DBUtils {
} }
public static void addRematchInfo( Context context, long rowid, String btAddr, public static void addRematchInfo( Context context, long rowid, String btAddr,
String phone, String relayID, String p2pAddr, String phone, String p2pAddr, String mqttDevID )
String mqttDevID )
{ {
try ( GameLock lock = GameLock.tryLock(rowid) ) { try ( GameLock lock = GameLock.tryLock(rowid) ) {
if ( null != lock ) { if ( null != lock ) {
GameSummary summary = getSummary( context, lock ) GameSummary summary = getSummary( context, lock )
.putStringExtra( GameSummary.EXTRA_REMATCH_BTADDR, btAddr ) .putStringExtra( GameSummary.EXTRA_REMATCH_BTADDR, btAddr )
.putStringExtra( GameSummary.EXTRA_REMATCH_PHONE, phone ) .putStringExtra( GameSummary.EXTRA_REMATCH_PHONE, phone )
.putStringExtra( GameSummary.EXTRA_REMATCH_RELAY, relayID )
.putStringExtra( GameSummary.EXTRA_REMATCH_P2P, p2pAddr ) .putStringExtra( GameSummary.EXTRA_REMATCH_P2P, p2pAddr )
.putStringExtra( GameSummary.EXTRA_REMATCH_MQTT, mqttDevID ) .putStringExtra( GameSummary.EXTRA_REMATCH_MQTT, mqttDevID )
; ;
@ -870,23 +868,6 @@ public class DBUtils {
return result; return result;
} }
public static long[] getRowIDsFor( Context context, String relayID )
{
long[] result = {};
String[] columns = { ROW_ID };
String selection = DBHelper.RELAYID + "='" + relayID + "'";
initDB( context );
synchronized( s_dbHelper ) {
Cursor cursor = query( TABLE_NAMES.SUM, columns, selection );
result = new long[cursor.getCount()];
for ( int ii = 0; cursor.moveToNext(); ++ii ) {
result[ii] = cursor.getLong( cursor.getColumnIndex(ROW_ID) );
}
cursor.close();
}
return result;
}
public static long[] getRowIDsFor( Context context, int gameID ) public static long[] getRowIDsFor( Context context, int gameID )
{ {
long[] result = {}; long[] result = {};

View file

@ -475,7 +475,7 @@ public abstract class DelegateBase implements DlgClickNotify,
public void onClick( DialogInterface dlg, int buttn ) { public void onClick( DialogInterface dlg, int buttn ) {
NetStateCache.reset( m_activity ); NetStateCache.reset( m_activity );
if ( conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) { if ( conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
RelayService.logGoneFail( TAG, 1 ); Assert.failDbg();
} }
if ( conTypes.contains( CommsConnType.COMMS_CONN_P2P ) ) { if ( conTypes.contains( CommsConnType.COMMS_CONN_P2P ) ) {
WiDirService.reset( getActivity() ); WiDirService.reset( getActivity() );

View file

@ -42,13 +42,6 @@ public class DevID {
private static String s_relayDevID; private static String s_relayDevID;
private static int s_asInt; private static int s_asInt;
// Called, likely on DEBUG builds only, when the relay hostname is
// changed. DevIDs are invalid at that point.
public static void hostChanged( Context context )
{
RelayService.logGone( TAG, 1 );
}
public static int getRelayDevIDInt( Context context ) public static int getRelayDevIDInt( Context context )
{ {
if ( 0 == s_asInt ) { if ( 0 == s_asInt ) {

View file

@ -86,7 +86,6 @@ public class GamesListDelegate extends ListDelegateBase
private static final String SAVE_REMATCHEXTRAS = "SAVE_REMATCHEXTRAS"; private static final String SAVE_REMATCHEXTRAS = "SAVE_REMATCHEXTRAS";
private static final String SAVE_MYSIS = TAG + "/MYSIS"; private static final String SAVE_MYSIS = TAG + "/MYSIS";
private static final String RELAYIDS_EXTRA = "relayids";
private static final String ROWID_EXTRA = "rowid"; private static final String ROWID_EXTRA = "rowid";
private static final String GAMEID_EXTRA = "gameid"; private static final String GAMEID_EXTRA = "gameid";
private static final String INVITEE_REC_EXTRA = "invitee_rec"; private static final String INVITEE_REC_EXTRA = "invitee_rec";
@ -100,7 +99,6 @@ public class GamesListDelegate extends ListDelegateBase
private static final String REMATCH_ADDRS_EXTRA = "rm_addrs"; private static final String REMATCH_ADDRS_EXTRA = "rm_addrs";
private static final String REMATCH_BTADDR_EXTRA = "rm_btaddr"; private static final String REMATCH_BTADDR_EXTRA = "rm_btaddr";
private static final String REMATCH_PHONE_EXTRA = "rm_phone"; private static final String REMATCH_PHONE_EXTRA = "rm_phone";
private static final String REMATCH_RELAYID_EXTRA = "rm_relayid";
private static final String REMATCH_P2PADDR_EXTRA = "rm_p2pma"; private static final String REMATCH_P2PADDR_EXTRA = "rm_p2pma";
private static final String INVITE_ACTION = "org.eehouse.action_invite"; private static final String INVITE_ACTION = "org.eehouse.action_invite";
@ -2330,39 +2328,6 @@ public class GamesListDelegate extends ListDelegateBase
return hasDicts; return hasDicts;
} }
private void invalRelayIDs( String[] relayIDs )
{
if ( null != relayIDs ) {
for ( String relayID : relayIDs ) {
long[] rowids = DBUtils.getRowIDsFor( m_activity, relayID );
for ( long rowid : rowids ) {
reloadGame( rowid );
}
}
}
}
// Launch the first of these for which there's a dictionary
// present.
private boolean startFirstHasDict( String[] relayIDs )
{
boolean launched = false;
if ( null != relayIDs ) {
outer:
for ( String relayID : relayIDs ) {
long[] rowids = DBUtils.getRowIDsFor( m_activity, relayID );
for ( long rowid : rowids ) {
if ( GameUtils.gameDictsHere( m_activity, rowid ) ) {
launchGame( rowid );
launched = true;
break outer;
}
}
}
}
return launched;
}
private boolean startFirstHasDict( final long rowid, final Bundle extras ) private boolean startFirstHasDict( final long rowid, final Bundle extras )
{ {
boolean handled = -1 != rowid && DBUtils.haveGame( m_activity, rowid ); boolean handled = -1 != rowid && DBUtils.haveGame( m_activity, rowid );
@ -2391,12 +2356,9 @@ public class GamesListDelegate extends ListDelegateBase
{ {
boolean result = false; boolean result = false;
if ( null != intent ) { if ( null != intent ) {
String[] relayIDs = intent.getStringArrayExtra( RELAYIDS_EXTRA );
if ( !startFirstHasDict( relayIDs ) ) {
long rowid = intent.getLongExtra( ROWID_EXTRA, -1 ); long rowid = intent.getLongExtra( ROWID_EXTRA, -1 );
result = startFirstHasDict( rowid, intent.getExtras() ); result = startFirstHasDict( rowid, intent.getExtras() );
} }
}
return result; return result;
} }
@ -2622,8 +2584,6 @@ public class GamesListDelegate extends ListDelegateBase
} else { } else {
String btAddr = extras.getString( REMATCH_BTADDR_EXTRA ); String btAddr = extras.getString( REMATCH_BTADDR_EXTRA );
String phone = extras.getString( REMATCH_PHONE_EXTRA ); String phone = extras.getString( REMATCH_PHONE_EXTRA );
String relayID = extras.getString( REMATCH_RELAYID_EXTRA );
Assert.assertTrueNR( null == relayID );
String p2pMacAddress = extras.getString( REMATCH_P2PADDR_EXTRA ); String p2pMacAddress = extras.getString( REMATCH_P2PADDR_EXTRA );
String dict = extras.getString( REMATCH_DICT_EXTRA ); String dict = extras.getString( REMATCH_DICT_EXTRA );
int lang = extras.getInt( REMATCH_LANG_EXTRA, -1 ); int lang = extras.getInt( REMATCH_LANG_EXTRA, -1 );
@ -2633,7 +2593,7 @@ public class GamesListDelegate extends ListDelegateBase
newid = GameUtils.makeNewMultiGame( m_activity, groupID, dict, newid = GameUtils.makeNewMultiGame( m_activity, groupID, dict,
lang, json, addrs, gameName ); lang, json, addrs, gameName );
DBUtils.addRematchInfo( m_activity, newid, btAddr, phone, DBUtils.addRematchInfo( m_activity, newid, btAddr, phone,
relayID, p2pMacAddress, mqttDevID ); p2pMacAddress, mqttDevID );
} }
launchGame( newid ); launchGame( newid );
} }
@ -3129,8 +3089,8 @@ public class GamesListDelegate extends ListDelegateBase
long groupID, CurGameInfo gi, long groupID, CurGameInfo gi,
CommsConnTypeSet addrTypes, CommsConnTypeSet addrTypes,
String btAddr, String phone, String btAddr, String phone,
String relayID, String p2pMacAddress, String p2pMacAddress, String mqttDevID,
String mqttDevID, String newName ) String newName )
{ {
Intent intent = null; Intent intent = null;
boolean isSolo = gi.serverRole == CurGameInfo.DeviceRole.SERVER_STANDALONE; boolean isSolo = gi.serverRole == CurGameInfo.DeviceRole.SERVER_STANDALONE;
@ -3153,11 +3113,6 @@ public class GamesListDelegate extends ListDelegateBase
Assert.assertTrue( addrTypes.contains( CommsConnType.COMMS_CONN_SMS ) ); Assert.assertTrue( addrTypes.contains( CommsConnType.COMMS_CONN_SMS ) );
intent.putExtra( REMATCH_PHONE_EXTRA, phone ); intent.putExtra( REMATCH_PHONE_EXTRA, phone );
} }
if ( null != relayID ) {
Assert.failDbg();
Assert.assertTrue( addrTypes.contains( CommsConnType.COMMS_CONN_RELAY ) );
intent.putExtra( REMATCH_RELAYID_EXTRA, relayID );
}
if ( null != p2pMacAddress ) { if ( null != p2pMacAddress ) {
Assert.assertTrue( addrTypes.contains( CommsConnType.COMMS_CONN_P2P ) ); Assert.assertTrue( addrTypes.contains( CommsConnType.COMMS_CONN_P2P ) );
intent.putExtra( REMATCH_P2PADDR_EXTRA, p2pMacAddress ); intent.putExtra( REMATCH_P2PADDR_EXTRA, p2pMacAddress );

View file

@ -56,7 +56,7 @@ public class MultiMsgSink implements TransportProcs {
int sendViaRelay( byte[] buf, String msgID, int gameID ) int sendViaRelay( byte[] buf, String msgID, int gameID )
{ {
RelayService.logGoneFail( TAG, 1 ); Assert.failDbg();
return -1; return -1;
} }

View file

@ -1,84 +0,0 @@
/* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */
/*
* Copyright 2010 - 2015 by Eric House (xwords@eehouse.org). All
* rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.eehouse.android.xw4;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import androidx.annotation.Nullable;
import android.text.TextUtils;
import org.eehouse.android.xw4.GameUtils.BackMoveResult;
import org.eehouse.android.xw4.MultiService.DictFetchOwner;
import org.eehouse.android.xw4.MultiService.MultiEvent;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.CommsAddrRec;
import org.eehouse.android.xw4.jni.DUtilCtxt.DevIDType;
import org.eehouse.android.xw4.jni.XwJNI;
import org.eehouse.android.xw4.loc.LocUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.HttpsURLConnection;
public class RelayService {
private static final String TAG = RelayService.class.getSimpleName();
public static void logGoneFail( String tag, int id )
{
logGoneImpl( tag, id, true );
}
public static void logGone( String tag, int id )
{
logGoneImpl( tag, id, false );
}
private static void logGoneImpl( String tag, int id, boolean isFail )
{
Log.d( TAG, "logGone(id=%d) called from %s", id, tag );
Assert.assertTrueNR( !isFail );
}
}

View file

@ -87,7 +87,6 @@ public class XWApp extends Application
} }
UpdateCheckReceiver.restartTimer( this ); UpdateCheckReceiver.restartTimer( this );
RelayService.logGone( TAG, 1 );
WiDirWrapper.init( this ); WiDirWrapper.init( this );
mPort = Short.valueOf( getString( R.string.nbs_port ) ); mPort = Short.valueOf( getString( R.string.nbs_port ) );

View file

@ -48,7 +48,6 @@ public class GameSummary implements Serializable {
private static final String TAG = GameSummary.class.getSimpleName(); private static final String TAG = GameSummary.class.getSimpleName();
public static final String EXTRA_REMATCH_BTADDR = "rm_btaddr"; public static final String EXTRA_REMATCH_BTADDR = "rm_btaddr";
public static final String EXTRA_REMATCH_PHONE = "rm_phone"; public static final String EXTRA_REMATCH_PHONE = "rm_phone";
public static final String EXTRA_REMATCH_RELAY = "rm_relay";
public static final String EXTRA_REMATCH_P2P = "rm_p2p"; public static final String EXTRA_REMATCH_P2P = "rm_p2p";
public static final String EXTRA_REMATCH_MQTT = "rm_mqtt"; public static final String EXTRA_REMATCH_MQTT = "rm_mqtt";
public static final String EXTRA_REMATCH_ADDR = "rm_addr"; public static final String EXTRA_REMATCH_ADDR = "rm_addr";
@ -534,7 +533,6 @@ public class GameSummary implements Serializable {
boolean found = false; boolean found = false;
String[] keys = { EXTRA_REMATCH_BTADDR, String[] keys = { EXTRA_REMATCH_BTADDR,
EXTRA_REMATCH_PHONE, EXTRA_REMATCH_PHONE,
EXTRA_REMATCH_RELAY,
EXTRA_REMATCH_P2P, EXTRA_REMATCH_P2P,
EXTRA_REMATCH_MQTT, EXTRA_REMATCH_MQTT,
}; };

View file

@ -502,7 +502,6 @@ public class XwJNI {
public static native void comms_transportFailed( GamePtr gamePtr, public static native void comms_transportFailed( GamePtr gamePtr,
CommsConnType failed ); CommsConnType failed );
public static native boolean comms_isConnected( GamePtr gamePtr ); public static native boolean comms_isConnected( GamePtr gamePtr );
public static native String comms_formatRelayID( GamePtr gamePtr, int indx );
public static native String comms_getStats( GamePtr gamePtr ); public static native String comms_getStats( GamePtr gamePtr );
public static native void comms_addMQTTDevID( GamePtr gamePtr, int channelNo, public static native void comms_addMQTTDevID( GamePtr gamePtr, int channelNo,
String devID ); String devID );

View file

@ -2567,29 +2567,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1isConnected
return result; return result;
} }
JNIEXPORT jstring JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_comms_1formatRelayID
( JNIEnv* env, jclass C, GamePtrType gamePtr, jint indx )
{
jstring result = NULL;
#ifdef XWFEATURE_RELAY
XWJNI_START();
XP_UCHAR buf[64];
XP_U16 len = sizeof(buf);
if ( comms_formatRelayID( state->game.comms, indx, buf, &len ) ) {
XP_ASSERT( len < sizeof(buf) );
LOG_RETURNF( "%s", buf );
result = (*env)->NewStringUTF( env, buf );
}
XWJNI_END();
#else
XP_ASSERT(0);
#endif
return result;
}
JNIEXPORT jstring JNICALL JNIEXPORT jstring JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getStats Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getStats
( JNIEnv* env, jclass C, GamePtrType gamePtr ) ( JNIEnv* env, jclass C, GamePtrType gamePtr )