From 302a3a502583a0d6ece0d29946b3bfcfca321b70 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 9 Jan 2019 09:51:15 -0800 Subject: [PATCH] accept invite even if same-gameID game open more dev-only code, likely: if the game that's sending the invitation is open when the invitation arrives, should still check if it's a dupe or should be accepted. --- .../eehouse/android/xw4/XWServiceHelper.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java index d9c6a8f2d..a624dc047 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java @@ -135,17 +135,26 @@ abstract class XWServiceHelper { // for duplicates! forceChannel's hard to dig up, but works for ( int ii = 0; success && ii < rowids.length; ++ii ) { long rowid = rowids[ii]; + CurGameInfo gi = null; try ( GameLock lock = GameLock.getFor( rowid ).tryLockRO() ) { // drop invite if can't open game; likely a dupe! - success = null != lock; - if ( success ) { - CurGameInfo gi = new CurGameInfo( mService ); + if ( null != lock ) { + gi = new CurGameInfo( mService ); GamePtr gamePtr = GameUtils .loadMakeGame( mService, gi, lock ); - success = gi.forceChannel != nli.forceChannel; gamePtr.release(); } } + + if ( null == gi ) { + // locked. Maybe it's open? + JNIThread thread = JNIThread.getRetained( mService, rowid ); + if ( null != thread ) { + gi = thread.getGI(); + thread.release( false ); + } + } + success = null != gi && gi.forceChannel != nli.forceChannel; } } else { success = false;