mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
remove RelayService and stuff that uses it
This commit is contained in:
parent
3953ab19a4
commit
58cba766d3
13 changed files with 12 additions and 202 deletions
|
@ -2666,7 +2666,7 @@ public class BoardDelegate extends DelegateBase
|
|||
dev = null; // don't record send a second time
|
||||
break;
|
||||
case RELAY:
|
||||
RelayService.logGoneFail( TAG, 2 );
|
||||
Assert.failDbg();
|
||||
break;
|
||||
case WIFIDIRECT:
|
||||
WiDirService.inviteRemote( m_activity, dev, nli );
|
||||
|
@ -2895,7 +2895,6 @@ public class BoardDelegate extends DelegateBase
|
|||
boolean doIt = true;
|
||||
String phone = null;
|
||||
String btAddr = null;
|
||||
String relayID = null;
|
||||
String p2pMacAddress = null;
|
||||
String mqttDevID = null;
|
||||
if ( DeviceRole.SERVER_STANDALONE == gi.serverRole ) {
|
||||
|
@ -2922,8 +2921,6 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
if ( addr.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
|
||||
Assert.failDbg();
|
||||
Assert.assertNull( relayID );
|
||||
relayID = XwJNI.comms_formatRelayID( jniGamePtr, ii );
|
||||
}
|
||||
if ( addr.contains( CommsConnType.COMMS_CONN_P2P ) ) {
|
||||
Assert.assertNull( p2pMacAddress );
|
||||
|
@ -2941,8 +2938,7 @@ public class BoardDelegate extends DelegateBase
|
|||
Intent intent = GamesListDelegate
|
||||
.makeRematchIntent( activity, rowid, groupID, gi,
|
||||
summary.conTypes, btAddr, phone,
|
||||
relayID, p2pMacAddress,
|
||||
mqttDevID, newName );
|
||||
p2pMacAddress, mqttDevID, newName );
|
||||
if ( null != intent ) {
|
||||
activity.startActivity( intent );
|
||||
}
|
||||
|
@ -3052,10 +3048,6 @@ public class BoardDelegate extends DelegateBase
|
|||
BTUtils.inviteRemote( m_activity, value, nli );
|
||||
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 );
|
||||
if ( null != value ) {
|
||||
WiDirService.inviteRemote( m_activity, value, nli );
|
||||
|
|
|
@ -404,7 +404,7 @@ public class CommsTransport implements TransportProcs,
|
|||
int nSent = -1;
|
||||
switch ( conType ) {
|
||||
case COMMS_CONN_RELAY:
|
||||
RelayService.logGoneFail( TAG, 2 );
|
||||
Assert.failDbg();
|
||||
break;
|
||||
case COMMS_CONN_SMS:
|
||||
nSent = NBSProto.sendPacket( context, addr.sms_phone,
|
||||
|
|
|
@ -715,7 +715,7 @@ public class ConnStatusHandler {
|
|||
if ( BuildConfig.DEBUG ) {
|
||||
switch ( typ ) {
|
||||
case COMMS_CONN_RELAY:
|
||||
RelayService.logGoneFail( TAG, 1 );
|
||||
Assert.failDbg();
|
||||
break;
|
||||
case COMMS_CONN_MQTT:
|
||||
if ( null != addr ) {
|
||||
|
|
|
@ -388,15 +388,13 @@ public class DBUtils {
|
|||
}
|
||||
|
||||
public static void addRematchInfo( Context context, long rowid, String btAddr,
|
||||
String phone, String relayID, String p2pAddr,
|
||||
String mqttDevID )
|
||||
String phone, String p2pAddr, String mqttDevID )
|
||||
{
|
||||
try ( GameLock lock = GameLock.tryLock(rowid) ) {
|
||||
if ( null != lock ) {
|
||||
GameSummary summary = getSummary( context, lock )
|
||||
.putStringExtra( GameSummary.EXTRA_REMATCH_BTADDR, btAddr )
|
||||
.putStringExtra( GameSummary.EXTRA_REMATCH_PHONE, phone )
|
||||
.putStringExtra( GameSummary.EXTRA_REMATCH_RELAY, relayID )
|
||||
.putStringExtra( GameSummary.EXTRA_REMATCH_P2P, p2pAddr )
|
||||
.putStringExtra( GameSummary.EXTRA_REMATCH_MQTT, mqttDevID )
|
||||
;
|
||||
|
@ -870,23 +868,6 @@ public class DBUtils {
|
|||
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 )
|
||||
{
|
||||
long[] result = {};
|
||||
|
|
|
@ -475,7 +475,7 @@ public abstract class DelegateBase implements DlgClickNotify,
|
|||
public void onClick( DialogInterface dlg, int buttn ) {
|
||||
NetStateCache.reset( m_activity );
|
||||
if ( conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
|
||||
RelayService.logGoneFail( TAG, 1 );
|
||||
Assert.failDbg();
|
||||
}
|
||||
if ( conTypes.contains( CommsConnType.COMMS_CONN_P2P ) ) {
|
||||
WiDirService.reset( getActivity() );
|
||||
|
|
|
@ -42,13 +42,6 @@ public class DevID {
|
|||
private static String s_relayDevID;
|
||||
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 )
|
||||
{
|
||||
if ( 0 == s_asInt ) {
|
||||
|
|
|
@ -86,7 +86,6 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
private static final String SAVE_REMATCHEXTRAS = "SAVE_REMATCHEXTRAS";
|
||||
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 GAMEID_EXTRA = "gameid";
|
||||
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_BTADDR_EXTRA = "rm_btaddr";
|
||||
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 INVITE_ACTION = "org.eehouse.action_invite";
|
||||
|
@ -2330,39 +2328,6 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
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 )
|
||||
{
|
||||
boolean handled = -1 != rowid && DBUtils.haveGame( m_activity, rowid );
|
||||
|
@ -2391,11 +2356,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
{
|
||||
boolean result = false;
|
||||
if ( null != intent ) {
|
||||
String[] relayIDs = intent.getStringArrayExtra( RELAYIDS_EXTRA );
|
||||
if ( !startFirstHasDict( relayIDs ) ) {
|
||||
long rowid = intent.getLongExtra( ROWID_EXTRA, -1 );
|
||||
result = startFirstHasDict( rowid, intent.getExtras() );
|
||||
}
|
||||
long rowid = intent.getLongExtra( ROWID_EXTRA, -1 );
|
||||
result = startFirstHasDict( rowid, intent.getExtras() );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -2622,8 +2584,6 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
} else {
|
||||
String btAddr = extras.getString( REMATCH_BTADDR_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 dict = extras.getString( REMATCH_DICT_EXTRA );
|
||||
int lang = extras.getInt( REMATCH_LANG_EXTRA, -1 );
|
||||
|
@ -2633,7 +2593,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
newid = GameUtils.makeNewMultiGame( m_activity, groupID, dict,
|
||||
lang, json, addrs, gameName );
|
||||
DBUtils.addRematchInfo( m_activity, newid, btAddr, phone,
|
||||
relayID, p2pMacAddress, mqttDevID );
|
||||
p2pMacAddress, mqttDevID );
|
||||
}
|
||||
launchGame( newid );
|
||||
}
|
||||
|
@ -3129,8 +3089,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
long groupID, CurGameInfo gi,
|
||||
CommsConnTypeSet addrTypes,
|
||||
String btAddr, String phone,
|
||||
String relayID, String p2pMacAddress,
|
||||
String mqttDevID, String newName )
|
||||
String p2pMacAddress, String mqttDevID,
|
||||
String newName )
|
||||
{
|
||||
Intent intent = null;
|
||||
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 ) );
|
||||
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 ) {
|
||||
Assert.assertTrue( addrTypes.contains( CommsConnType.COMMS_CONN_P2P ) );
|
||||
intent.putExtra( REMATCH_P2PADDR_EXTRA, p2pMacAddress );
|
||||
|
|
|
@ -56,7 +56,7 @@ public class MultiMsgSink implements TransportProcs {
|
|||
|
||||
int sendViaRelay( byte[] buf, String msgID, int gameID )
|
||||
{
|
||||
RelayService.logGoneFail( TAG, 1 );
|
||||
Assert.failDbg();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
|
@ -87,7 +87,6 @@ public class XWApp extends Application
|
|||
}
|
||||
UpdateCheckReceiver.restartTimer( this );
|
||||
|
||||
RelayService.logGone( TAG, 1 );
|
||||
WiDirWrapper.init( this );
|
||||
|
||||
mPort = Short.valueOf( getString( R.string.nbs_port ) );
|
||||
|
|
|
@ -48,7 +48,6 @@ public class GameSummary implements Serializable {
|
|||
private static final String TAG = GameSummary.class.getSimpleName();
|
||||
public static final String EXTRA_REMATCH_BTADDR = "rm_btaddr";
|
||||
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_MQTT = "rm_mqtt";
|
||||
public static final String EXTRA_REMATCH_ADDR = "rm_addr";
|
||||
|
@ -534,7 +533,6 @@ public class GameSummary implements Serializable {
|
|||
boolean found = false;
|
||||
String[] keys = { EXTRA_REMATCH_BTADDR,
|
||||
EXTRA_REMATCH_PHONE,
|
||||
EXTRA_REMATCH_RELAY,
|
||||
EXTRA_REMATCH_P2P,
|
||||
EXTRA_REMATCH_MQTT,
|
||||
};
|
||||
|
|
|
@ -502,7 +502,6 @@ public class XwJNI {
|
|||
public static native void comms_transportFailed( GamePtr gamePtr,
|
||||
CommsConnType failed );
|
||||
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 void comms_addMQTTDevID( GamePtr gamePtr, int channelNo,
|
||||
String devID );
|
||||
|
|
|
@ -2567,29 +2567,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1isConnected
|
|||
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
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getStats
|
||||
( JNIEnv* env, jclass C, GamePtrType gamePtr )
|
||||
|
|
Loading…
Reference in a new issue