diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index bc8763f99..7c46895cd 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -1856,8 +1856,11 @@
From a player on the device %1$s wants to start a game
- Crosswords on %1$s wrong version for
- Bluetooth play.
+ The version of Crosswords on
+ \"%1$s\" is incompatible with this one for play using
+ Bluetooth. One of you may need to upgrade before you can
+ continue.
+
Invitation via Bluetooth
diff --git a/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml b/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
index bbb009cee..e130ac678 100644
--- a/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
+++ b/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
@@ -1593,8 +1593,10 @@
Morf a reyalp no eht ecived %1$s stnaw ot trats a emag
- Sdrowssorc no %1$s gnorw noisrev rof
- Htooteulb yalp.
+ Eht noisrev fo Sdrowssorc no
+ \"%1$s\" si elbitapmocni htiw siht eno rof yalp gnisu
+ Htooteulb. Eno fo uoy yam deen ot edargpu erofeb uoy nac
+ eunitnoc.
Noitativni aiv Htooteulb
diff --git a/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml b/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml
index ebdb8a839..2fea4595c 100644
--- a/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml
+++ b/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml
@@ -1593,8 +1593,10 @@
FROM A PLAYER ON THE DEVICE %1$s WANTS TO START A GAME
- CROSSWORDS ON %1$s WRONG VERSION FOR
- BLUETOOTH PLAY.
+ THE VERSION OF CROSSWORDS ON
+ \"%1$s\" IS INCOMPATIBLE WITH THIS ONE FOR PLAY USING
+ BLUETOOTH. ONE OF YOU MAY NEED TO UPGRADE BEFORE YOU CAN
+ CONTINUE.
INVITATION VIA BLUETOOTH
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java
index 622e6399a..48507336a 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java
@@ -86,20 +86,21 @@ public class BTService extends XWService {
private static final String BT_ADDRESS_STR = "BT_ADDRESS_STR";
private enum BTCmd {
- PING,
- PONG,
- SCAN,
- INVITE,
- INVITE_ACCPT,
- INVITE_DECL,
- INVITE_DUPID,
- INVITE_FAILED, // generic error
- MESG_SEND,
- MESG_ACCPT,
- MESG_DECL,
- MESG_GAMEGONE,
- REMOVE_FOR,
- };
+ BAD_PROTO,
+ PING,
+ PONG,
+ SCAN,
+ INVITE,
+ INVITE_ACCPT,
+ INVITE_DECL,
+ INVITE_DUPID,
+ INVITE_FAILED, // generic error
+ MESG_SEND,
+ MESG_ACCPT,
+ MESG_DECL,
+ MESG_GAMEGONE,
+ REMOVE_FOR,
+ };
private class BTQueueElem {
int m_failCount;
@@ -409,9 +410,12 @@ public class BTService extends XWService {
byte proto = inStream.readByte();
if ( proto != BT_PROTO ) {
+ DataOutputStream os = new DataOutputStream( socket.getOutputStream() );
+ os.writeByte( BTCmd.BAD_PROTO.ordinal() );
+ os.flush();
socket.close();
- sendResult( MultiEvent.BAD_PROTO,
- socket.getRemoteDevice().getName() );
+
+ sendBadProto( socket );
} else {
byte msg = inStream.readByte();
BTCmd cmd = BTCmd.values()[msg];
@@ -464,7 +468,6 @@ public class BTService extends XWService {
private void receivePing( BluetoothSocket socket ) throws IOException
{
- DbgUtils.logf( "got PING!!!" );
DataInputStream inStream = new DataInputStream( socket.getInputStream() );
int gameID = inStream.readInt();
boolean deleted = 0 != gameID && !DBUtils.haveGame( BTService.this, gameID );
@@ -716,9 +719,14 @@ public class BTService extends XWService {
DataInputStream is =
new DataInputStream( socket.getInputStream() );
- gotReply = BTCmd.PONG == BTCmd.values()[is.readByte()];
- if ( gotReply && is.readBoolean() ) {
- sendResult( MultiEvent.MESSAGE_NOGAME, gameID );
+ BTCmd reply = BTCmd.values()[is.readByte()];
+ if ( BTCmd.BAD_PROTO == reply ) {
+ sendBadProto( socket );
+ } else {
+ gotReply = BTCmd.PONG == reply;
+ if ( gotReply && is.readBoolean() ) {
+ sendResult( MultiEvent.MESSAGE_NOGAME, gameID );
+ }
}
receiveWorking = true;
@@ -751,7 +759,7 @@ public class BTService extends XWService {
BluetoothSocket socket =
dev.createRfcommSocketToServiceRecord( XWApp.getAppUUID() );
if ( null != socket ) {
- boolean success = false;
+ BTCmd reply = null;
DataOutputStream outStream = connect( socket, BTCmd.INVITE );
if ( null != outStream ) {
outStream.writeInt( elem.m_gameID );
@@ -764,16 +772,23 @@ public class BTService extends XWService {
DataInputStream inStream =
new DataInputStream( socket.getInputStream() );
- success = BTCmd.INVITE_ACCPT
- == BTCmd.values()[inStream.readByte()];
- DbgUtils.logf( "sendInvite(): invite done: success=%b",
- success );
+ reply = BTCmd.values()[inStream.readByte()];
}
socket.close();
- MultiEvent evt = success ? MultiEvent.NEWGAME_SUCCESS
- : MultiEvent.NEWGAME_FAILURE;
- sendResult( evt, elem.m_gameID );
+ if ( BTCmd.BAD_PROTO == reply ) {
+ sendBadProto( socket );
+ } else {
+ MultiEvent evt = null;
+ switch( reply ) {
+ case INVITE_ACCPT:
+ evt = MultiEvent.NEWGAME_SUCCESS;
+ break;
+ default:
+ evt = MultiEvent.NEWGAME_FAILURE;
+ }
+ sendResult( evt, elem.m_gameID );
+ }
}
} catch ( IOException ioe ) {
logIOE( ioe );
@@ -820,6 +835,10 @@ public class BTService extends XWService {
success = true;
switch ( reply ) {
+ case BAD_PROTO:
+ sendBadProto( socket );
+ evt = null;
+ break;
case MESG_ACCPT:
evt = MultiEvent.MESSAGE_ACCEPTED;
break;
@@ -836,12 +855,14 @@ public class BTService extends XWService {
}
}
- String btName = nameForAddr( elem.m_btAddr );
- sendResult( evt, elem.m_gameID, 0, btName );
- if ( ! success ) {
- int failCount = elem.incrFailCount();
- sendResult( MultiEvent.MESSAGE_RESEND, btName,
- RESEND_TIMEOUT, failCount );
+ if ( null != evt ) {
+ String btName = nameForAddr( elem.m_btAddr );
+ sendResult( evt, elem.m_gameID, 0, btName );
+ if ( ! success ) {
+ int failCount = elem.incrFailCount();
+ sendResult( MultiEvent.MESSAGE_RESEND, btName,
+ RESEND_TIMEOUT, failCount );
+ }
}
return success;
} // sendMsg
@@ -1058,6 +1079,11 @@ public class BTService extends XWService {
// }
}
+ private void sendBadProto( BluetoothSocket socket )
+ {
+ sendResult( MultiEvent.BAD_PROTO, socket.getRemoteDevice().getName() );
+ }
+
private void postNotification( int gameID, int title, String body,
long rowid )
{
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java
index beda31547..eead8e977 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java
@@ -456,6 +456,14 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify,
} catch ( java.lang.RuntimeException re ) {}
DbgUtils.logf( "Bluetooth error count: %d", count );
break;
+ case BAD_PROTO:
+ final String msg = getString( R.string.bt_bad_proto_fmt, (String)args[0] );
+ runOnUiThread( new Runnable() {
+ public void run() {
+ showOKOnlyDialog( msg );
+ }
+ });
+ break;
default:
DbgUtils.logf( "DelegateBase.eventOccurred(event=%s) (DROPPED)", event.toString() );
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
index 40bc762a1..7d2098821 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -394,9 +394,6 @@ public class DlgDelegate {
String msg = null;
boolean asToast = true;
switch( event ) {
- case BAD_PROTO:
- msg = getString( R.string.bt_bad_proto_fmt, (String)args[0] );
- break;
case MESSAGE_RESEND:
msg = getString( R.string.bt_resend_fmt, (String)args[0],
(Long)args[1], (Integer)args[2] );