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,7 +286,9 @@ public class BTUtils {
public static void gameDied( Context context, String btAddr, int gameID )
{
getPA( btAddr ).addDied( gameID );
if ( !TextUtils.isEmpty( btAddr ) ) {
getPA( btAddr ).addDied( 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 ) ) {
CommsAddrRec[] addrs = XwJNI.comms_getAddrs( m_jniGamePtr );
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 );
}
}

View file

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