mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-01 19:57:11 +01:00
add debug-only option for invitee players to be robots
It's useful when testing to have the remote device play without human interaction. So add an option, and UI to trigger it, for the players created remotely in response to an invitation to be robots. There are guards in place to catch the feature slipping into a release build.
This commit is contained in:
parent
136fa6ac7d
commit
438e134870
18 changed files with 151 additions and 68 deletions
|
@ -114,8 +114,9 @@ public class BTInviteDelegate extends InviteDelegate {
|
||||||
RequestCode requestCode )
|
RequestCode requestCode )
|
||||||
{
|
{
|
||||||
Assert.assertTrue( 0 < nMissing ); // don't call if nMissing == 0
|
Assert.assertTrue( 0 < nMissing ); // don't call if nMissing == 0
|
||||||
Intent intent = new Intent( activity, BTInviteActivity.class );
|
Intent intent = InviteDelegate
|
||||||
intent.putExtra( INTENT_KEY_NMISSING, nMissing );
|
.makeIntent( activity, BTInviteActivity.class,
|
||||||
|
nMissing, info );
|
||||||
if ( null != info ) {
|
if ( null != info ) {
|
||||||
String lastDev = info.getLastDev( InviteMeans.BLUETOOTH );
|
String lastDev = info.getLastDev( InviteMeans.BLUETOOTH );
|
||||||
if ( null != lastDev ) {
|
if ( null != lastDev ) {
|
||||||
|
|
|
@ -107,6 +107,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
private CommsConnTypeSet m_connTypes = null;
|
private CommsConnTypeSet m_connTypes = null;
|
||||||
private String[] m_missingDevs;
|
private String[] m_missingDevs;
|
||||||
private int[] m_missingCounts;
|
private int[] m_missingCounts;
|
||||||
|
private boolean m_remotesAreRobots;
|
||||||
private InviteMeans m_missingMeans = null;
|
private InviteMeans m_missingMeans = null;
|
||||||
private boolean m_progressShown = false;
|
private boolean m_progressShown = false;
|
||||||
private boolean m_isFirstLaunch;
|
private boolean m_isFirstLaunch;
|
||||||
|
@ -696,6 +697,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
// meaning m_gi etc are still null.
|
// meaning m_gi etc are still null.
|
||||||
m_missingDevs = data.getStringArrayExtra( InviteDelegate.DEVS );
|
m_missingDevs = data.getStringArrayExtra( InviteDelegate.DEVS );
|
||||||
m_missingCounts = data.getIntArrayExtra( InviteDelegate.COUNTS );
|
m_missingCounts = data.getIntArrayExtra( InviteDelegate.COUNTS );
|
||||||
|
m_remotesAreRobots = data.getBooleanExtra( InviteDelegate.RAR, false );
|
||||||
m_missingMeans = missingMeans;
|
m_missingMeans = missingMeans;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1230,12 +1232,12 @@ public class BoardDelegate extends DelegateBase
|
||||||
Action.INVITE_SMS, m_mySIS.nMissing, info );
|
Action.INVITE_SMS, m_mySIS.nMissing, info );
|
||||||
break;
|
break;
|
||||||
case RELAY:
|
case RELAY:
|
||||||
RelayInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing,
|
RelayInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing, info,
|
||||||
RequestCode.RELAY_INVITE_RESULT );
|
RequestCode.RELAY_INVITE_RESULT );
|
||||||
break;
|
break;
|
||||||
case WIFIDIRECT:
|
case WIFIDIRECT:
|
||||||
WiDirInviteDelegate.launchForResult( m_activity,
|
WiDirInviteDelegate.launchForResult( m_activity,
|
||||||
m_mySIS.nMissing,
|
m_mySIS.nMissing, info,
|
||||||
RequestCode.P2P_INVITE_RESULT );
|
RequestCode.P2P_INVITE_RESULT );
|
||||||
break;
|
break;
|
||||||
case EMAIL:
|
case EMAIL:
|
||||||
|
@ -1254,7 +1256,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.assertFalse( BuildConfig.DEBUG );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1348,7 +1350,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// TransportProcs.TPMsgHandler interface
|
// TransportProcs.TPMsgHandler interface
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
@Override
|
||||||
public void tpmRelayConnd( final String room, final int devOrder,
|
public void tpmRelayConnd( final String room, final int devOrder,
|
||||||
final boolean allHere, final int nMissing )
|
final boolean allHere, final int nMissing )
|
||||||
{
|
{
|
||||||
|
@ -1360,6 +1362,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void tpmRelayErrorProc( TransportProcs.XWRELAY_ERROR relayErr )
|
public void tpmRelayErrorProc( TransportProcs.XWRELAY_ERROR relayErr )
|
||||||
{
|
{
|
||||||
int strID = -1;
|
int strID = -1;
|
||||||
|
@ -1419,6 +1422,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// DwnldActivity.DownloadFinishedListener interface
|
// DwnldActivity.DownloadFinishedListener interface
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
@Override
|
||||||
public void downloadFinished( String lang, final String name,
|
public void downloadFinished( String lang, final String name,
|
||||||
boolean success )
|
boolean success )
|
||||||
{
|
{
|
||||||
|
@ -1435,6 +1439,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// NFCUtils.NFCActor
|
// NFCUtils.NFCActor
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
@Override
|
||||||
public String makeNFCMessage()
|
public String makeNFCMessage()
|
||||||
{
|
{
|
||||||
String data = null;
|
String data = null;
|
||||||
|
@ -2474,7 +2479,9 @@ public class BoardDelegate extends DelegateBase
|
||||||
Assert.assertTrue( 0 <= m_nGuestDevs );
|
Assert.assertTrue( 0 <= m_nGuestDevs );
|
||||||
int forceChannel = ii + m_nGuestDevs + 1;
|
int forceChannel = ii + m_nGuestDevs + 1;
|
||||||
NetLaunchInfo nli = new NetLaunchInfo( m_activity, m_summary, m_gi,
|
NetLaunchInfo nli = new NetLaunchInfo( m_activity, m_summary, m_gi,
|
||||||
nPlayers, forceChannel );
|
nPlayers, forceChannel )
|
||||||
|
.setRemotesAreRobots( m_remotesAreRobots );
|
||||||
|
|
||||||
if ( m_relayMissing ) {
|
if ( m_relayMissing ) {
|
||||||
nli.removeAddress( CommsConnType.COMMS_CONN_RELAY );
|
nli.removeAddress( CommsConnType.COMMS_CONN_RELAY );
|
||||||
}
|
}
|
||||||
|
|
|
@ -465,6 +465,7 @@ public class DBUtils {
|
||||||
private ArrayList<String> m_targets;
|
private ArrayList<String> m_targets;
|
||||||
private ArrayList<Date> m_timestamps;
|
private ArrayList<Date> m_timestamps;
|
||||||
private int m_cachedCount = 0;
|
private int m_cachedCount = 0;
|
||||||
|
private boolean m_remotesRobots = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals( Object other )
|
public boolean equals( Object other )
|
||||||
|
@ -590,6 +591,8 @@ public class DBUtils {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setRemotesRobots() { m_remotesRobots = true; }
|
||||||
|
boolean getRemotesRobots() { return m_remotesRobots; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SentInvitesInfo getInvitesFor( Context context, long rowid )
|
public static SentInvitesInfo getInvitesFor( Context context, long rowid )
|
||||||
|
|
|
@ -574,7 +574,7 @@ public class GameUtils {
|
||||||
new String[] { nli.dict }, null, nli.nPlayersT,
|
new String[] { nli.dict }, null, nli.nPlayersT,
|
||||||
nli.nPlayersH, nli.forceChannel,
|
nli.nPlayersH, nli.forceChannel,
|
||||||
nli.inviteID(), nli.gameID(),
|
nli.inviteID(), nli.gameID(),
|
||||||
nli.gameName, false );
|
nli.gameName, false, nli.remotesAreRobots );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long makeNewMultiGame( Context context, long groupID,
|
public static long makeNewMultiGame( Context context, long groupID,
|
||||||
|
@ -611,7 +611,7 @@ public class GameUtils {
|
||||||
return makeNewMultiGame( context, (MultiMsgSink)null, (UtilCtxt)null,
|
return makeNewMultiGame( context, (MultiMsgSink)null, (UtilCtxt)null,
|
||||||
groupID, addr, langArray, dictArray, jsonData,
|
groupID, addr, langArray, dictArray, jsonData,
|
||||||
2, 1, forceChannel, inviteID, 0, gameName,
|
2, 1, forceChannel, inviteID, 0, gameName,
|
||||||
true );
|
true, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long makeNewMultiGame( Context context, MultiMsgSink sink,
|
private static long makeNewMultiGame( Context context, MultiMsgSink sink,
|
||||||
|
@ -622,7 +622,7 @@ public class GameUtils {
|
||||||
int nPlayersT, int nPlayersH,
|
int nPlayersT, int nPlayersH,
|
||||||
int forceChannel, String inviteID,
|
int forceChannel, String inviteID,
|
||||||
int gameID, String gameName,
|
int gameID, String gameName,
|
||||||
boolean isHost )
|
boolean isHost, boolean localsRobots )
|
||||||
{
|
{
|
||||||
long rowid = DBUtils.ROWID_NOTFOUND;
|
long rowid = DBUtils.ROWID_NOTFOUND;
|
||||||
|
|
||||||
|
@ -633,7 +633,7 @@ public class GameUtils {
|
||||||
gi.forceChannel = forceChannel;
|
gi.forceChannel = forceChannel;
|
||||||
lang[0] = gi.dictLang;
|
lang[0] = gi.dictLang;
|
||||||
dict[0] = gi.dictName;
|
dict[0] = gi.dictName;
|
||||||
gi.setNPlayers( nPlayersT, nPlayersH );
|
gi.setNPlayers( nPlayersT, nPlayersH, localsRobots );
|
||||||
gi.juggle();
|
gi.juggle();
|
||||||
if ( 0 != gameID ) {
|
if ( 0 != gameID ) {
|
||||||
gi.gameID = gameID;
|
gi.gameID = gameID;
|
||||||
|
|
|
@ -132,7 +132,9 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
|
||||||
button.setEnabled( true );
|
button.setEnabled( true );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
OnClickListener okClicked = new OnClickListener() {
|
|
||||||
|
final OnClickListener okClicked = new OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick( DialogInterface dlg, int view ) {
|
public void onClick( DialogInterface dlg, int view ) {
|
||||||
Assert.assertTrue( Action.SKIP_CALLBACK != state.m_action );
|
Assert.assertTrue( Action.SKIP_CALLBACK != state.m_action );
|
||||||
int indx = sel[0];
|
int indx = sel[0];
|
||||||
|
@ -151,6 +153,21 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
|
||||||
sel[0], selChanged )
|
sel[0], selChanged )
|
||||||
.setPositiveButton( android.R.string.ok, okClicked )
|
.setPositiveButton( android.R.string.ok, okClicked )
|
||||||
.setNegativeButton( android.R.string.cancel, null );
|
.setNegativeButton( android.R.string.cancel, null );
|
||||||
|
if ( BuildConfig.DEBUG ) {
|
||||||
|
builder.setNeutralButton( R.string.ok_with_robots,
|
||||||
|
new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( DialogInterface dlg,
|
||||||
|
int view ) {
|
||||||
|
|
||||||
|
if ( state.m_params[0] instanceof SentInvitesInfo ) {
|
||||||
|
SentInvitesInfo sii = (SentInvitesInfo)state.m_params[0];
|
||||||
|
sii.setRemotesRobots();
|
||||||
|
}
|
||||||
|
okClicked.onClick( dlg, view );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.DBUtils.SentInvitesInfo;
|
||||||
|
|
||||||
abstract class InviteDelegate extends ListDelegateBase
|
abstract class InviteDelegate extends ListDelegateBase
|
||||||
implements View.OnClickListener,
|
implements View.OnClickListener,
|
||||||
ViewGroup.OnHierarchyChangeListener {
|
ViewGroup.OnHierarchyChangeListener {
|
||||||
|
@ -83,7 +85,8 @@ abstract class InviteDelegate extends ListDelegateBase
|
||||||
|
|
||||||
public static final String DEVS = "DEVS";
|
public static final String DEVS = "DEVS";
|
||||||
public static final String COUNTS = "COUNTS";
|
public static final String COUNTS = "COUNTS";
|
||||||
protected static final String INTENT_KEY_NMISSING = "NMISSING";
|
public static final String RAR = "RAR";
|
||||||
|
private static final String INTENT_KEY_NMISSING = "NMISSING";
|
||||||
protected static final String INTENT_KEY_LASTDEV = "LDEV";
|
protected static final String INTENT_KEY_LASTDEV = "LDEV";
|
||||||
|
|
||||||
protected int m_nMissing;
|
protected int m_nMissing;
|
||||||
|
@ -96,6 +99,18 @@ abstract class InviteDelegate extends ListDelegateBase
|
||||||
protected Map<InviterItem, Integer> m_counts;
|
protected Map<InviterItem, Integer> m_counts;
|
||||||
protected Set<InviterItem> m_checked;
|
protected Set<InviterItem> m_checked;
|
||||||
private boolean m_setChecked;
|
private boolean m_setChecked;
|
||||||
|
private boolean m_remotesAreRobots;
|
||||||
|
|
||||||
|
public static Intent makeIntent( Activity activity, Class target,
|
||||||
|
int nMissing, SentInvitesInfo info )
|
||||||
|
{
|
||||||
|
Intent intent = new Intent( activity, target )
|
||||||
|
.putExtra( INTENT_KEY_NMISSING, nMissing );
|
||||||
|
if ( null != info ) {
|
||||||
|
intent.putExtra( RAR, info.getRemotesRobots() );
|
||||||
|
}
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
public InviteDelegate( Delegator delegator, Bundle savedInstanceState )
|
public InviteDelegate( Delegator delegator, Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
|
@ -104,6 +119,7 @@ abstract class InviteDelegate extends ListDelegateBase
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
m_nMissing = intent.getIntExtra( INTENT_KEY_NMISSING, -1 );
|
m_nMissing = intent.getIntExtra( INTENT_KEY_NMISSING, -1 );
|
||||||
m_lastDev = intent.getStringExtra( INTENT_KEY_LASTDEV );
|
m_lastDev = intent.getStringExtra( INTENT_KEY_LASTDEV );
|
||||||
|
m_remotesAreRobots = intent.getBooleanExtra( RAR, false );
|
||||||
m_counts = new HashMap<InviterItem, Integer>();
|
m_counts = new HashMap<InviterItem, Integer>();
|
||||||
m_checked = new HashSet<InviterItem>();
|
m_checked = new HashSet<InviterItem>();
|
||||||
}
|
}
|
||||||
|
@ -193,6 +209,7 @@ abstract class InviteDelegate extends ListDelegateBase
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra( DEVS, devs );
|
intent.putExtra( DEVS, devs );
|
||||||
intent.putExtra( COUNTS, counts );
|
intent.putExtra( COUNTS, counts );
|
||||||
|
intent.putExtra( RAR, m_remotesAreRobots );
|
||||||
setResult( Activity.RESULT_OK, intent );
|
setResult( Activity.RESULT_OK, intent );
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class MultiService {
|
||||||
public static final String GAMENAME = "GAMENAME";
|
public static final String GAMENAME = "GAMENAME";
|
||||||
public static final String NPLAYERST = "NPLAYERST";
|
public static final String NPLAYERST = "NPLAYERST";
|
||||||
public static final String NPLAYERSH = "NPLAYERSH";
|
public static final String NPLAYERSH = "NPLAYERSH";
|
||||||
|
public static final String REMOTES_ROBOTS = "RR";
|
||||||
public static final String INVITER = "INVITER";
|
public static final String INVITER = "INVITER";
|
||||||
private static final String OWNER = "OWNER";
|
private static final String OWNER = "OWNER";
|
||||||
public static final String BT_NAME = "BT_NAME";
|
public static final String BT_NAME = "BT_NAME";
|
||||||
|
|
|
@ -72,6 +72,7 @@ public class NetLaunchInfo implements Serializable {
|
||||||
protected int forceChannel;
|
protected int forceChannel;
|
||||||
protected int nPlayersT;
|
protected int nPlayersT;
|
||||||
protected int nPlayersH;
|
protected int nPlayersH;
|
||||||
|
protected boolean remotesAreRobots;
|
||||||
protected String room; // relay
|
protected String room; // relay
|
||||||
protected String btName;
|
protected String btName;
|
||||||
protected String btAddress;
|
protected String btAddress;
|
||||||
|
@ -109,6 +110,7 @@ public class NetLaunchInfo implements Serializable {
|
||||||
gameName = bundle.getString( MultiService.GAMENAME );
|
gameName = bundle.getString( MultiService.GAMENAME );
|
||||||
nPlayersT = bundle.getInt( MultiService.NPLAYERST );
|
nPlayersT = bundle.getInt( MultiService.NPLAYERST );
|
||||||
nPlayersH = bundle.getInt( MultiService.NPLAYERSH );
|
nPlayersH = bundle.getInt( MultiService.NPLAYERSH );
|
||||||
|
remotesAreRobots = bundle.getBoolean( MultiService.REMOTES_ROBOTS );
|
||||||
gameID = bundle.getInt( MultiService.GAMEID );
|
gameID = bundle.getInt( MultiService.GAMEID );
|
||||||
btName = bundle.getString( MultiService.BT_NAME );
|
btName = bundle.getString( MultiService.BT_NAME );
|
||||||
btAddress = bundle.getString( MultiService.BT_ADDRESS );
|
btAddress = bundle.getString( MultiService.BT_ADDRESS );
|
||||||
|
@ -341,6 +343,7 @@ public class NetLaunchInfo implements Serializable {
|
||||||
bundle.putString( MultiService.GAMENAME, gameName );
|
bundle.putString( MultiService.GAMENAME, gameName );
|
||||||
bundle.putInt( MultiService.NPLAYERST, nPlayersT );
|
bundle.putInt( MultiService.NPLAYERST, nPlayersT );
|
||||||
bundle.putInt( MultiService.NPLAYERSH, nPlayersH );
|
bundle.putInt( MultiService.NPLAYERSH, nPlayersH );
|
||||||
|
bundle.putBoolean( MultiService.REMOTES_ROBOTS, remotesAreRobots );
|
||||||
bundle.putInt( MultiService.GAMEID, gameID() );
|
bundle.putInt( MultiService.GAMEID, gameID() );
|
||||||
bundle.putString( MultiService.BT_NAME, btName );
|
bundle.putString( MultiService.BT_NAME, btName );
|
||||||
bundle.putString( MultiService.BT_ADDRESS, btAddress );
|
bundle.putString( MultiService.BT_ADDRESS, btAddress );
|
||||||
|
@ -364,6 +367,7 @@ public class NetLaunchInfo implements Serializable {
|
||||||
&& forceChannel == other.forceChannel
|
&& forceChannel == other.forceChannel
|
||||||
&& nPlayersT == other.nPlayersT
|
&& nPlayersT == other.nPlayersT
|
||||||
&& nPlayersH == other.nPlayersH
|
&& nPlayersH == other.nPlayersH
|
||||||
|
&& remotesAreRobots == other.remotesAreRobots
|
||||||
&& TextUtils.equals( room, other.room )
|
&& TextUtils.equals( room, other.room )
|
||||||
&& TextUtils.equals( btName, other.btName )
|
&& TextUtils.equals( btName, other.btName )
|
||||||
&& TextUtils.equals( btAddress, other.btAddress )
|
&& TextUtils.equals( btAddress, other.btAddress )
|
||||||
|
@ -393,6 +397,7 @@ public class NetLaunchInfo implements Serializable {
|
||||||
.put( MultiService.GAMENAME, gameName )
|
.put( MultiService.GAMENAME, gameName )
|
||||||
.put( MultiService.NPLAYERST, nPlayersT )
|
.put( MultiService.NPLAYERST, nPlayersT )
|
||||||
.put( MultiService.NPLAYERSH, nPlayersH )
|
.put( MultiService.NPLAYERSH, nPlayersH )
|
||||||
|
.put( MultiService.REMOTES_ROBOTS, remotesAreRobots )
|
||||||
.put( MultiService.GAMEID, gameID() )
|
.put( MultiService.GAMEID, gameID() )
|
||||||
.put( MultiService.FORCECHANNEL, forceChannel );
|
.put( MultiService.FORCECHANNEL, forceChannel );
|
||||||
|
|
||||||
|
@ -467,6 +472,7 @@ public class NetLaunchInfo implements Serializable {
|
||||||
gameName = json.optString( MultiService.GAMENAME );
|
gameName = json.optString( MultiService.GAMENAME );
|
||||||
nPlayersT = json.optInt( MultiService.NPLAYERST, -1 );
|
nPlayersT = json.optInt( MultiService.NPLAYERST, -1 );
|
||||||
nPlayersH = json.optInt( MultiService.NPLAYERSH, 1 ); // absent ok
|
nPlayersH = json.optInt( MultiService.NPLAYERSH, 1 ); // absent ok
|
||||||
|
remotesAreRobots = json.optBoolean( MultiService.REMOTES_ROBOTS, false );
|
||||||
gameID = json.optInt( MultiService.GAMEID, 0 );
|
gameID = json.optInt( MultiService.GAMEID, 0 );
|
||||||
|
|
||||||
// Try each type
|
// Try each type
|
||||||
|
@ -607,6 +613,13 @@ public class NetLaunchInfo implements Serializable {
|
||||||
return m_valid;
|
return m_valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NetLaunchInfo setRemotesAreRobots( boolean val )
|
||||||
|
{
|
||||||
|
Assert.assertTrue( val == false || BuildConfig.DEBUG );
|
||||||
|
remotesAreRobots = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,7 @@ import java.util.Set;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.DBUtils.SentInvitesInfo;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
|
|
||||||
public class RelayInviteDelegate extends InviteDelegate {
|
public class RelayInviteDelegate extends InviteDelegate {
|
||||||
|
@ -64,22 +65,22 @@ public class RelayInviteDelegate extends InviteDelegate {
|
||||||
R.id.button_edit,
|
R.id.button_edit,
|
||||||
};
|
};
|
||||||
|
|
||||||
// private static final int GET_CONTACT = 1;
|
|
||||||
private static final String SAVE_NAME = "SAVE_NAME";
|
private static final String SAVE_NAME = "SAVE_NAME";
|
||||||
private static final String SAVE_NUMBER = "SAVE_NUMBER";
|
private static final String SAVE_NUMBER = "SAVE_NUMBER";
|
||||||
|
|
||||||
private ArrayList<DevIDRec> m_devIDRecs;
|
private ArrayList<DevIDRec> m_devIDRecs;
|
||||||
// private RelayDevsAdapter m_adapter;
|
|
||||||
private boolean m_immobileConfirmed;
|
private boolean m_immobileConfirmed;
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
private String m_devIDStr;
|
private String m_devIDStr;
|
||||||
|
|
||||||
public static void launchForResult( Activity activity, int nMissing,
|
public static void launchForResult( Activity activity, int nMissing,
|
||||||
|
SentInvitesInfo info,
|
||||||
RequestCode requestCode )
|
RequestCode requestCode )
|
||||||
{
|
{
|
||||||
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||||
Intent intent = new Intent( activity, RelayInviteActivity.class );
|
Intent intent =
|
||||||
intent.putExtra( INTENT_KEY_NMISSING, nMissing );
|
InviteDelegate.makeIntent( activity, RelayInviteActivity.class,
|
||||||
|
nMissing, info );
|
||||||
activity.startActivityForResult( intent, requestCode.ordinal() );
|
activity.startActivityForResult( intent, requestCode.ordinal() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,8 +66,10 @@ public class SMSInviteDelegate extends InviteDelegate {
|
||||||
SentInvitesInfo info,
|
SentInvitesInfo info,
|
||||||
RequestCode requestCode )
|
RequestCode requestCode )
|
||||||
{
|
{
|
||||||
Intent intent = new Intent( activity, SMSInviteActivity.class );
|
|
||||||
intent.putExtra( INTENT_KEY_NMISSING, nMissing );
|
Intent intent = InviteDelegate
|
||||||
|
.makeIntent( activity, SMSInviteActivity.class,
|
||||||
|
nMissing, info );
|
||||||
if ( null != info ) {
|
if ( null != info ) {
|
||||||
String lastDev = info.getLastDev( InviteMeans.SMS );
|
String lastDev = info.getLastDev( InviteMeans.SMS );
|
||||||
intent.putExtra( INTENT_KEY_LASTDEV, lastDev );
|
intent.putExtra( INTENT_KEY_LASTDEV, lastDev );
|
||||||
|
|
|
@ -33,6 +33,8 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.DBUtils.SentInvitesInfo;
|
||||||
|
|
||||||
public class WiDirInviteDelegate extends InviteDelegate
|
public class WiDirInviteDelegate extends InviteDelegate
|
||||||
implements WiDirService.DevSetListener {
|
implements WiDirService.DevSetListener {
|
||||||
private static final String SAVE_NAME = "SAVE_NAME";
|
private static final String SAVE_NAME = "SAVE_NAME";
|
||||||
|
@ -40,10 +42,12 @@ public class WiDirInviteDelegate extends InviteDelegate
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
|
|
||||||
public static void launchForResult( Activity activity, int nMissing,
|
public static void launchForResult( Activity activity, int nMissing,
|
||||||
|
SentInvitesInfo info,
|
||||||
RequestCode requestCode )
|
RequestCode requestCode )
|
||||||
{
|
{
|
||||||
Intent intent = new Intent( activity, WiDirInviteActivity.class );
|
Intent intent =
|
||||||
intent.putExtra( INTENT_KEY_NMISSING, nMissing );
|
InviteDelegate.makeIntent( activity, WiDirInviteActivity.class,
|
||||||
|
nMissing, info );
|
||||||
activity.startActivityForResult( intent, requestCode.ordinal() );
|
activity.startActivityForResult( intent, requestCode.ordinal() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,8 @@ public class CurGameInfo implements Serializable {
|
||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNPlayers( int nPlayersTotal, int nPlayersHere )
|
public void setNPlayers( int nPlayersTotal, int nPlayersHere,
|
||||||
|
boolean localsAreRobots )
|
||||||
{
|
{
|
||||||
assert( nPlayersTotal < MAX_NUM_PLAYERS );
|
assert( nPlayersTotal < MAX_NUM_PLAYERS );
|
||||||
assert( nPlayersHere < nPlayersTotal );
|
assert( nPlayersHere < nPlayersTotal );
|
||||||
|
@ -463,8 +464,14 @@ public class CurGameInfo implements Serializable {
|
||||||
nPlayers = nPlayersTotal;
|
nPlayers = nPlayersTotal;
|
||||||
|
|
||||||
for ( int ii = 0; ii < nPlayersTotal; ++ii ) {
|
for ( int ii = 0; ii < nPlayersTotal; ++ii ) {
|
||||||
players[ii].isLocal = ii < nPlayersHere;
|
boolean isLocal = ii < nPlayersHere;
|
||||||
assert( !players[ii].isRobot() );
|
LocalPlayer player = players[ii];
|
||||||
|
player.isLocal = isLocal;
|
||||||
|
if ( isLocal && localsAreRobots ) {
|
||||||
|
player.setIsRobot( true );
|
||||||
|
} else {
|
||||||
|
assert( !player.isRobot() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1169,6 +1169,9 @@
|
||||||
<string name="invite_choice_relay">Internet/Relay</string>
|
<string name="invite_choice_relay">Internet/Relay</string>
|
||||||
<string name="invite_choice_p2p">Wifi Direct</string>
|
<string name="invite_choice_p2p">Wifi Direct</string>
|
||||||
<string name="invite_choice_title">Inviting players: How?</string>
|
<string name="invite_choice_title">Inviting players: How?</string>
|
||||||
|
|
||||||
|
<!-- Button, on DEBUG builds only, causes invitee players to be robots -->
|
||||||
|
<string name="ok_with_robots">OK (robots)</string>
|
||||||
<!-- <string name="sms_or_email">Send invitation using SMS (texting) or -->
|
<!-- <string name="sms_or_email">Send invitation using SMS (texting) or -->
|
||||||
<!-- via email?</string> -->
|
<!-- via email?</string> -->
|
||||||
<!-- <string name="nfc_or_email">Send invitation using NFC (Android -->
|
<!-- <string name="nfc_or_email">Send invitation using NFC (Android -->
|
||||||
|
|
|
@ -11,7 +11,7 @@ LOCAL_C_INCLUDES+= \
|
||||||
LOCAL_LDLIBS += -llog
|
LOCAL_LDLIBS += -llog
|
||||||
|
|
||||||
ifeq ($(BUILD_TARGET),debug)
|
ifeq ($(BUILD_TARGET),debug)
|
||||||
LOCAL_DEBUG = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING -DCOMMS_CHECKSUM -Wno-unused-variable
|
LOCAL_DEBUG = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING -DCOMMS_CHECKSUM -DNLI_VERSION=1 -Wno-unused-variable
|
||||||
endif
|
endif
|
||||||
LOCAL_DEFINES += \
|
LOCAL_DEFINES += \
|
||||||
$(LOCAL_DEBUG) \
|
$(LOCAL_DEBUG) \
|
||||||
|
|
|
@ -425,7 +425,8 @@ static const SetInfo nli_ints[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SetInfo nli_bools[] = {
|
static const SetInfo nli_bools[] = {
|
||||||
ARR_MEMBER( NetLaunchInfo, isGSM )
|
ARR_MEMBER( NetLaunchInfo, isGSM ),
|
||||||
|
ARR_MEMBER( NetLaunchInfo, remotesAreRobots ),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SetInfo nli_strs[] = {
|
static const SetInfo nli_strs[] = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE -j3"; -*- */
|
/* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE -j3"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2001 - 2015 by Eric House (xwords@eehouse.org). All rights
|
* Copyright 2001 - 2019 by Eric House (xwords@eehouse.org). All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -25,6 +25,11 @@
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
#include "dbgutil.h"
|
#include "dbgutil.h"
|
||||||
|
|
||||||
|
/* Don't check in other than 0 for a few releases!!! */
|
||||||
|
#ifndef NLI_VERSION
|
||||||
|
# define NLI_VERSION 0
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
nli_init( NetLaunchInfo* nli, const CurGameInfo* gi, const CommsAddrRec* addr,
|
nli_init( NetLaunchInfo* nli, const CurGameInfo* gi, const CommsAddrRec* addr,
|
||||||
XP_U16 nPlayers, XP_U16 forceChannel )
|
XP_U16 nPlayers, XP_U16 forceChannel )
|
||||||
|
@ -41,7 +46,6 @@ nli_init( NetLaunchInfo* nli, const CurGameInfo* gi, const CommsAddrRec* addr,
|
||||||
types_addType( &nli->_conTypes, COMMS_CONN_RELAY );
|
types_addType( &nli->_conTypes, COMMS_CONN_RELAY );
|
||||||
XP_STRCAT( nli->room, addr->u.ip_relay.invite );
|
XP_STRCAT( nli->room, addr->u.ip_relay.invite );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static XP_U32
|
static XP_U32
|
||||||
|
@ -71,10 +75,9 @@ nli_setInviteID( NetLaunchInfo* nli, const XP_UCHAR* inviteID )
|
||||||
void
|
void
|
||||||
nli_saveToStream( const NetLaunchInfo* nli, XWStreamCtxt* stream )
|
nli_saveToStream( const NetLaunchInfo* nli, XWStreamCtxt* stream )
|
||||||
{
|
{
|
||||||
LOG_FUNC();
|
stream_putU8( stream, NLI_VERSION );
|
||||||
stream_putU8( stream, nli->version );
|
|
||||||
stream_putU16( stream, nli->_conTypes );
|
stream_putU16( stream, nli->_conTypes );
|
||||||
XP_LOGF( "%s: wrote _conTypes: %x", __func__, nli->_conTypes );
|
|
||||||
stream_putU16( stream, nli->lang );
|
stream_putU16( stream, nli->lang );
|
||||||
stringToStream( stream, nli->dict );
|
stringToStream( stream, nli->dict );
|
||||||
stringToStream( stream, nli->gameName );
|
stringToStream( stream, nli->gameName );
|
||||||
|
@ -84,65 +87,67 @@ nli_saveToStream( const NetLaunchInfo* nli, XWStreamCtxt* stream )
|
||||||
stream_putU8( stream, nli->forceChannel );
|
stream_putU8( stream, nli->forceChannel );
|
||||||
|
|
||||||
if ( types_hasType( nli->_conTypes, COMMS_CONN_RELAY ) ) {
|
if ( types_hasType( nli->_conTypes, COMMS_CONN_RELAY ) ) {
|
||||||
XP_LOGF( "%s: writing relay stuff", __func__ );
|
|
||||||
stringToStream( stream, nli->room );
|
stringToStream( stream, nli->room );
|
||||||
XP_LOGF( "%s: writing room: %s", __func__, nli->room );
|
|
||||||
stringToStream( stream, nli->inviteID );
|
stringToStream( stream, nli->inviteID );
|
||||||
stream_putU32( stream, nli->devID );
|
stream_putU32( stream, nli->devID );
|
||||||
}
|
}
|
||||||
if ( types_hasType( nli->_conTypes, COMMS_CONN_BT ) ) {
|
if ( types_hasType( nli->_conTypes, COMMS_CONN_BT ) ) {
|
||||||
XP_LOGF( "%s: writing bt stuff", __func__ );
|
|
||||||
stringToStream( stream, nli->btName );
|
stringToStream( stream, nli->btName );
|
||||||
stringToStream( stream, nli->btAddress );
|
stringToStream( stream, nli->btAddress );
|
||||||
}
|
}
|
||||||
if ( types_hasType( nli->_conTypes, COMMS_CONN_SMS ) ) {
|
if ( types_hasType( nli->_conTypes, COMMS_CONN_SMS ) ) {
|
||||||
XP_LOGF( "%s: writing sms stuff", __func__ );
|
|
||||||
stringToStream( stream, nli->phone );
|
stringToStream( stream, nli->phone );
|
||||||
stream_putU8( stream, nli->isGSM );
|
stream_putU8( stream, nli->isGSM );
|
||||||
stream_putU8( stream, nli->osType );
|
stream_putU8( stream, nli->osType );
|
||||||
stream_putU32( stream, nli->osVers );
|
stream_putU32( stream, nli->osVers );
|
||||||
}
|
}
|
||||||
LOG_RETURN_VOID();
|
|
||||||
|
if ( NLI_VERSION > 0 ) {
|
||||||
|
stream_putBits( stream, 1, nli->remotesAreRobots ? 1 : 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XP_Bool
|
XP_Bool
|
||||||
nli_makeFromStream( NetLaunchInfo* nli, XWStreamCtxt* stream )
|
nli_makeFromStream( NetLaunchInfo* nli, XWStreamCtxt* stream )
|
||||||
{
|
{
|
||||||
|
XP_Bool success = XP_TRUE;
|
||||||
LOG_FUNC();
|
LOG_FUNC();
|
||||||
XP_MEMSET( nli, 0, sizeof(*nli) );
|
XP_MEMSET( nli, 0, sizeof(*nli) );
|
||||||
nli->version = stream_getU8( stream );
|
XP_U16 version = stream_getU8( stream );
|
||||||
XP_Bool success = 0 == nli->version;
|
XP_LOGF( "%s(): read version: %d", __func__, version );
|
||||||
if ( success ) {
|
|
||||||
nli->_conTypes = stream_getU16( stream );
|
|
||||||
XP_LOGF( "%s: read _conTypes: %x", __func__, nli->_conTypes );
|
|
||||||
nli->lang = stream_getU16( stream );
|
|
||||||
stringFromStreamHere( stream, nli->dict, sizeof(nli->dict) );
|
|
||||||
stringFromStreamHere( stream, nli->gameName, sizeof(nli->gameName) );
|
|
||||||
nli->nPlayersT = stream_getU8( stream );
|
|
||||||
nli->nPlayersH = stream_getU8( stream );
|
|
||||||
nli->gameID = stream_getU32( stream );
|
|
||||||
nli->forceChannel = stream_getU8( stream );
|
|
||||||
|
|
||||||
if ( types_hasType( nli->_conTypes, COMMS_CONN_RELAY ) ) {
|
nli->_conTypes = stream_getU16( stream );
|
||||||
XP_LOGF( "%s: reading relay stuff", __func__ );
|
nli->lang = stream_getU16( stream );
|
||||||
stringFromStreamHere( stream, nli->room, sizeof(nli->room) );
|
stringFromStreamHere( stream, nli->dict, sizeof(nli->dict) );
|
||||||
XP_LOGF( "%s: read room: %s", __func__, nli->room );
|
stringFromStreamHere( stream, nli->gameName, sizeof(nli->gameName) );
|
||||||
stringFromStreamHere( stream, nli->inviteID, sizeof(nli->inviteID) );
|
nli->nPlayersT = stream_getU8( stream );
|
||||||
nli->devID = stream_getU32( stream );
|
nli->nPlayersH = stream_getU8( stream );
|
||||||
}
|
nli->gameID = stream_getU32( stream );
|
||||||
if ( types_hasType( nli->_conTypes, COMMS_CONN_BT ) ) {
|
nli->forceChannel = stream_getU8( stream );
|
||||||
XP_LOGF( "%s: reading bt stuff", __func__ );
|
|
||||||
stringFromStreamHere( stream, nli->btName, sizeof(nli->btName) );
|
if ( types_hasType( nli->_conTypes, COMMS_CONN_RELAY ) ) {
|
||||||
stringFromStreamHere( stream, nli->btAddress, sizeof(nli->btAddress) );
|
stringFromStreamHere( stream, nli->room, sizeof(nli->room) );
|
||||||
}
|
stringFromStreamHere( stream, nli->inviteID, sizeof(nli->inviteID) );
|
||||||
if ( types_hasType( nli->_conTypes, COMMS_CONN_SMS ) ) {
|
nli->devID = stream_getU32( stream );
|
||||||
XP_LOGF( "%s: reading sms stuff", __func__ );
|
|
||||||
stringFromStreamHere( stream, nli->phone, sizeof(nli->phone) );
|
|
||||||
nli->isGSM = stream_getU8( stream );
|
|
||||||
nli->osType= stream_getU8( stream );
|
|
||||||
nli->osVers = stream_getU32( stream );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if ( types_hasType( nli->_conTypes, COMMS_CONN_BT ) ) {
|
||||||
|
stringFromStreamHere( stream, nli->btName, sizeof(nli->btName) );
|
||||||
|
stringFromStreamHere( stream, nli->btAddress, sizeof(nli->btAddress) );
|
||||||
|
}
|
||||||
|
if ( types_hasType( nli->_conTypes, COMMS_CONN_SMS ) ) {
|
||||||
|
stringFromStreamHere( stream, nli->phone, sizeof(nli->phone) );
|
||||||
|
nli->isGSM = stream_getU8( stream );
|
||||||
|
nli->osType= stream_getU8( stream );
|
||||||
|
nli->osVers = stream_getU32( stream );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version > 0 ) {
|
||||||
|
nli->remotesAreRobots = 0 != stream_getBits( stream, 1 );
|
||||||
|
XP_LOGF( "%s(): remotesAreRobots: %d", __func__, nli->remotesAreRobots );
|
||||||
|
}
|
||||||
|
|
||||||
|
XP_ASSERT( 0 == stream_getSize( stream ) );
|
||||||
|
|
||||||
LOG_RETURNF( "%s", boolToStr(success) );
|
LOG_RETURNF( "%s", boolToStr(success) );
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ typedef enum {OSType_NONE, OSType_LINUX, OSType_ANDROID, } XP_OSType;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct _InviteInfo {
|
typedef struct _InviteInfo {
|
||||||
XP_U8 version; /* struct version for backward compatibility */
|
|
||||||
XP_U16 _conTypes;
|
XP_U16 _conTypes;
|
||||||
|
|
||||||
XP_UCHAR gameName[MAX_GAME_NAME_LEN];
|
XP_UCHAR gameName[MAX_GAME_NAME_LEN];
|
||||||
|
@ -46,6 +45,7 @@ typedef struct _InviteInfo {
|
||||||
XP_U8 forceChannel;
|
XP_U8 forceChannel;
|
||||||
XP_U8 nPlayersT;
|
XP_U8 nPlayersT;
|
||||||
XP_U8 nPlayersH;
|
XP_U8 nPlayersH;
|
||||||
|
XP_Bool remotesAreRobots;
|
||||||
|
|
||||||
/* Relay */
|
/* Relay */
|
||||||
XP_UCHAR room[MAX_INVITE_LEN + 1];
|
XP_UCHAR room[MAX_INVITE_LEN + 1];
|
||||||
|
|
|
@ -130,6 +130,7 @@ DEFINES += -DCOMMS_XPORT_FLAGSPROC
|
||||||
DEFINES += -DINITIAL_CLIENT_VERS=3
|
DEFINES += -DINITIAL_CLIENT_VERS=3
|
||||||
DEFINES += -DCOMMON_LAYOUT
|
DEFINES += -DCOMMON_LAYOUT
|
||||||
DEFINES += -DNATIVE_NLI
|
DEFINES += -DNATIVE_NLI
|
||||||
|
DEFINES += -DNLI_VERSION=1
|
||||||
# DEFINES += -DRELAY_VIA_HTTP
|
# DEFINES += -DRELAY_VIA_HTTP
|
||||||
|
|
||||||
# MAX_ROWS controls STREAM_VERS_BIGBOARD and with it move hashing
|
# MAX_ROWS controls STREAM_VERS_BIGBOARD and with it move hashing
|
||||||
|
|
Loading…
Add table
Reference in a new issue