mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
include hwAddr as well as device name in bt section of address
This commit is contained in:
parent
af2fcc76e0
commit
b4b7609894
3 changed files with 24 additions and 7 deletions
|
@ -341,6 +341,7 @@ setJAddrRec( JNIEnv* env, jobject jaddr, const CommsAddrRec* addr )
|
|||
break;
|
||||
case COMMS_CONN_BT:
|
||||
setString( env, jaddr, "bt_hostName", addr->u.bt.hostName );
|
||||
setString( env, jaddr, "bt_btAddr", addr->u.bt.btAddr.chars );
|
||||
break;
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
|
@ -378,6 +379,8 @@ getJAddrRec( JNIEnv* env, CommsAddrRec* addr, jobject jaddr )
|
|||
case COMMS_CONN_BT:
|
||||
getString( env, jaddr, "bt_hostName", addr->u.bt.hostName,
|
||||
VSIZE(addr->u.bt.hostName) );
|
||||
getString( env, jaddr, "bt_btAddr", addr->u.bt.btAddr.chars,
|
||||
VSIZE(addr->u.bt.btAddr.chars) );
|
||||
break;
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
|
|
|
@ -27,9 +27,10 @@ import android.os.Bundle;
|
|||
import android.os.IBinder;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothClass;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothServerSocket;
|
||||
import android.bluetooth.BluetoothSocket;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
||||
|
@ -186,6 +187,7 @@ public class BTService extends Service {
|
|||
new BTSenderThread().start();
|
||||
} else {
|
||||
DbgUtils.logf( "not starting threads: BT not available" );
|
||||
stopSelf();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,7 +547,8 @@ public class BTService extends Service {
|
|||
os.flush();
|
||||
socket.close();
|
||||
|
||||
CommsAddrRec addr = new CommsAddrRec( this, host.getName() );
|
||||
CommsAddrRec addr = new CommsAddrRec( this, host.getName(),
|
||||
host.getAddress() );
|
||||
|
||||
if ( BoardActivity.feedMessage( gameID, buffer, addr ) ) {
|
||||
DbgUtils.logf( "BoardActivity.feedMessage took it" );
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.net.InetAddress;
|
|||
import android.content.Context;
|
||||
|
||||
import org.eehouse.android.xw4.Utils;
|
||||
import org.eehouse.android.xw4.DbgUtils;
|
||||
|
||||
public class CommsAddrRec {
|
||||
|
||||
|
@ -50,7 +51,7 @@ public class CommsAddrRec {
|
|||
|
||||
// bt case
|
||||
public String bt_hostName;
|
||||
public byte[] bt_btAddr; // array of 6 bytes on the C side
|
||||
public String bt_btAddr;
|
||||
|
||||
// sms case
|
||||
// public String sms_phone;
|
||||
|
@ -72,10 +73,11 @@ public class CommsAddrRec {
|
|||
this( context, CommsConnType.COMMS_CONN_RELAY );
|
||||
}
|
||||
|
||||
public CommsAddrRec( Context context, String btHost )
|
||||
public CommsAddrRec( Context context, String btHost, String btAddr )
|
||||
{
|
||||
this( context, CommsConnType.COMMS_CONN_BT );
|
||||
bt_hostName = btHost;
|
||||
bt_btAddr = btAddr;
|
||||
}
|
||||
|
||||
public CommsAddrRec( final CommsAddrRec src )
|
||||
|
@ -87,9 +89,17 @@ public class CommsAddrRec {
|
|||
{
|
||||
boolean matter = conType != other.conType;
|
||||
if ( !matter ) {
|
||||
matter = ! ip_relay_invite.equals( other.ip_relay_invite )
|
||||
|| ! ip_relay_hostName.equals( other.ip_relay_hostName )
|
||||
|| ip_relay_port != other.ip_relay_port;
|
||||
switch( conType ) {
|
||||
case COMMS_CONN_RELAY:
|
||||
matter = ! ip_relay_invite.equals( other.ip_relay_invite )
|
||||
|| ! ip_relay_hostName.equals( other.ip_relay_hostName )
|
||||
|| ip_relay_port != other.ip_relay_port;
|
||||
break;
|
||||
default:
|
||||
DbgUtils.logf( "changesMatter: not handling case: %s",
|
||||
conType.toString() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return matter;
|
||||
}
|
||||
|
@ -104,5 +114,6 @@ public class CommsAddrRec {
|
|||
ip_relay_advertiseRoom = src.ip_relay_advertiseRoom;
|
||||
|
||||
bt_hostName = src.bt_hostName;
|
||||
bt_btAddr = src.bt_btAddr;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue