fix crashes when emulator decides it supports Bluetooth

This commit is contained in:
Eric House 2022-11-03 19:51:39 -07:00
parent 86303475af
commit e7861dca48
3 changed files with 7 additions and 5 deletions

View file

@ -286,8 +286,10 @@ public class BTUtils {
public static void gameDied( Context context, String btAddr, int gameID ) public static void gameDied( Context context, String btAddr, int gameID )
{ {
if ( !TextUtils.isEmpty( btAddr ) ) {
getPA( btAddr ).addDied( gameID ); getPA( btAddr ).addDied( gameID );
} }
}
public static void pingHost( Context context, String btAddr, int gameID ) public static void pingHost( Context context, String btAddr, int gameID )
{ {

View file

@ -2477,7 +2477,8 @@ public class BoardDelegate extends DelegateBase
&& !XWPrefs.getBTDisabled( m_activity ) ) { && !XWPrefs.getBTDisabled( m_activity ) ) {
CommsAddrRec[] addrs = XwJNI.comms_getAddrs( m_jniGamePtr ); CommsAddrRec[] addrs = XwJNI.comms_getAddrs( m_jniGamePtr );
for ( CommsAddrRec addr : addrs ) { for ( CommsAddrRec addr : addrs ) {
if ( addr.contains( CommsConnType.COMMS_CONN_BT ) ) { if ( addr.contains( CommsConnType.COMMS_CONN_BT )
&& !TextUtils.isEmpty(addr.bt_btAddr) ) {
BTUtils.pingHost( m_activity, addr.bt_btAddr, m_gi.gameID ); BTUtils.pingHost( m_activity, addr.bt_btAddr, m_gi.gameID );
} }
} }

View file

@ -1275,9 +1275,8 @@ public class GameUtils {
} }
if ( forceNew || !madeGame ) { if ( forceNew || !madeGame ) {
Assert.failDbg(); // Is this happening? selfAddr is sometimes final CommsAddrRec hostAddr = null;
// hostAddr so it can't work. try ( GamePtr gamePtr = XwJNI.initNew( gi, selfAddr, hostAddr,
try ( GamePtr gamePtr = XwJNI.initNew( gi, selfAddr, (CommsAddrRec)null,
util, (DrawCtx)null, cp, sink ) ) { util, (DrawCtx)null, cp, sink ) ) {
if ( null != gamePtr ) { if ( null != gamePtr ) {
applyChangesImpl( context, sink, gi, disab, lock, gamePtr ); applyChangesImpl( context, sink, gi, disab, lock, gamePtr );