mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
fix BT and SMS game creation in response to invitations by passing a
UtilCtxt they can use to get the devices ID, allowing relay messages to reach the games when they're not open. Move into superclass while at it.
This commit is contained in:
parent
3bff4c070a
commit
16b558a566
4 changed files with 19 additions and 20 deletions
|
@ -1124,7 +1124,8 @@ public class BTService extends XWService {
|
|||
if ( null == rowids || 0 == rowids.length ) {
|
||||
CommsAddrRec addr = nli.makeAddrRec( BTService.this );
|
||||
long rowid = GameUtils.makeNewMultiGame( BTService.this, nli,
|
||||
m_btMsgSink, null );
|
||||
m_btMsgSink,
|
||||
getUtilCtxt() );
|
||||
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
|
||||
result = BTCmd.INVITE_FAILED;
|
||||
} else {
|
||||
|
|
|
@ -53,8 +53,6 @@ import org.eehouse.android.xw4.jni.CommsAddrRec;
|
|||
import org.eehouse.android.xw4.jni.GameSummary;
|
||||
import org.eehouse.android.xw4.jni.LastMoveInfo;
|
||||
import org.eehouse.android.xw4.jni.UtilCtxt.DevIDType;
|
||||
import org.eehouse.android.xw4.jni.UtilCtxt;
|
||||
import org.eehouse.android.xw4.jni.UtilCtxtImpl;
|
||||
import org.eehouse.android.xw4.jni.XwJNI;
|
||||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
|
||||
|
@ -256,8 +254,8 @@ public class RelayService extends XWService
|
|||
// make the initial connection -- needs access to util. That
|
||||
// should be fixable -- eventually.
|
||||
RelayMsgSink sink = new RelayMsgSink();
|
||||
UtilCtxt util = new UtilCtxtImpl( this );
|
||||
long rowid = GameUtils.makeNewMultiGame( this, nli, sink, util );
|
||||
long rowid = GameUtils.makeNewMultiGame( this, nli, sink,
|
||||
getUtilCtxt() );
|
||||
if ( DBUtils.ROWID_NOTFOUND != rowid ) {
|
||||
if ( null != nli.gameName && 0 < nli.gameName.length() ) {
|
||||
DBUtils.setName( this, rowid, nli.gameName );
|
||||
|
|
|
@ -637,24 +637,13 @@ public class SMSService extends XWService {
|
|||
|
||||
private void makeForInvite( String phone, NetLaunchInfo nli )
|
||||
{
|
||||
SMSMsgSink sink = new SMSMsgSink( this );
|
||||
long rowid = GameUtils.makeNewMultiGame( this, nli, sink, null );
|
||||
long rowid = GameUtils.makeNewMultiGame( this, nli,
|
||||
new SMSMsgSink( this ),
|
||||
getUtilCtxt() );
|
||||
postNotification( phone, nli.gameID(), rowid );
|
||||
ackInvite( phone, nli.gameID() );
|
||||
}
|
||||
|
||||
private void makeForInvite( String phone, int gameID, String gameName,
|
||||
int lang, String dict, int nPlayersT,
|
||||
int nPlayersH, int forceChannel )
|
||||
{
|
||||
long rowid =
|
||||
GameUtils.makeNewGame( this, gameID, new CommsAddrRec( phone ),
|
||||
lang, dict, nPlayersT, nPlayersH,
|
||||
forceChannel, gameName );
|
||||
postNotification( phone, gameID, rowid );
|
||||
ackInvite( phone, gameID );
|
||||
}
|
||||
|
||||
private PendingIntent makeStatusIntent( String msg )
|
||||
{
|
||||
Intent intent = new Intent( msg );
|
||||
|
|
|
@ -28,13 +28,16 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import org.eehouse.android.xw4.MultiService.MultiEvent;
|
||||
|
||||
import org.eehouse.android.xw4.jni.UtilCtxt;
|
||||
import org.eehouse.android.xw4.jni.UtilCtxtImpl;
|
||||
|
||||
public class XWService extends Service {
|
||||
|
||||
protected static MultiService s_srcMgr = null;
|
||||
private static Set<String> s_seen = new HashSet<String>();
|
||||
|
||||
private UtilCtxt m_utilCtxt;
|
||||
|
||||
@Override
|
||||
public IBinder onBind( Intent intent )
|
||||
{
|
||||
|
@ -74,4 +77,12 @@ public class XWService extends Service {
|
|||
DbgUtils.logf( "XWService.checkNotDupe(%s) => %b", inviteID, !isDupe );
|
||||
return !isDupe;
|
||||
}
|
||||
|
||||
protected UtilCtxt getUtilCtxt()
|
||||
{
|
||||
if ( null == m_utilCtxt ) {
|
||||
m_utilCtxt = new UtilCtxtImpl( this );
|
||||
}
|
||||
return m_utilCtxt;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue