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 7595c3f2e..e508544ee 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java @@ -324,7 +324,8 @@ public class BTService extends XWService { : MultiEvent.BT_DISABLED; sendResult( evt ); if ( cameOn ) { - GameUtils.resendAllIf( this, false ); + GameUtils.resendAllIf( this, CommsConnType.COMMS_CONN_BT, + false ); } else { ConnStatusHandler.updateStatus( this, null, CommsConnType.COMMS_CONN_BT, diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index a8d44ade1..c4521e384 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -374,7 +374,8 @@ public class GameUtils { return thumb; } - public static void resendAllIf( Context context, boolean force ) + public static void resendAllIf( Context context, CommsConnType filter, + boolean force ) { final boolean showUI = force; @@ -393,7 +394,7 @@ public class GameUtils { if ( force ) { HashMap games = DBUtils.getGamesWithSendsPending( context ); if ( 0 < games.size() ) { - new ResendTask( context, games, showUI ).execute(); + new ResendTask( context, games, filter, showUI ).execute(); } } } @@ -1075,13 +1076,15 @@ public class GameUtils { private Context m_context; private HashMap m_games; private boolean m_showUI; + private CommsConnType m_filter; private int m_nSent = 0; public ResendTask( Context context, HashMap games, - boolean showUI ) + CommsConnType filter, boolean showUI ) { m_context = context; m_games = games; + m_filter = filter; m_showUI = showUI; } @@ -1091,6 +1094,10 @@ public class GameUtils { Iterator iter = m_games.keySet().iterator(); while ( iter.hasNext() ) { long rowid = iter.next(); + if ( null != m_filter && m_filter != m_games.get( rowid ) ) { + continue; + } + GameLock lock = new GameLock( rowid, false ); if ( lock.tryLock() ) { CurGameInfo gi = new CurGameInfo( m_context ); @@ -1100,6 +1107,9 @@ public class GameUtils { XwJNI.comms_resendAll( gamePtr, true, false ); } lock.unlock(); + } else { + DbgUtils.logf( "ResendTask.doInBackground: unable to unlock %d", + rowid ); } } return null; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java index f4e8b03db..e9594e60e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -1156,7 +1156,7 @@ public class GamesListDelegate extends ListDelegateBase switch ( itemID ) { // There's no selection for these items, so nothing to clear case R.id.games_menu_resend: - GameUtils.resendAllIf( m_activity, true ); + GameUtils.resendAllIf( m_activity, null, true ); break; case R.id.games_menu_newgame: startNewGameActivity( groupID ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java index a4d978eb0..307259107 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java @@ -33,6 +33,8 @@ import java.util.Iterator; import junit.framework.Assert; +import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType; + public class NetStateCache { private static final long WAIT_STABLE_MILLIS = 2 * 1000; @@ -160,7 +162,10 @@ public class NetStateCache { } if ( s_netAvail ) { - GameUtils.resendAllIf( context, false ); + CommsConnType typ = CommsConnType + .COMMS_CONN_RELAY; + GameUtils.resendAllIf( context, typ, + false ); } } };