rename method: sendResult -> postEvent

This commit is contained in:
Eric House 2016-12-05 07:24:25 -08:00
parent aa420ce4d1
commit 9c14e0e858
6 changed files with 30 additions and 28 deletions

View file

@ -403,7 +403,7 @@ public class BTService extends XWService {
boolean cameOn = intent.getBooleanExtra( RADIO_KEY, false ); boolean cameOn = intent.getBooleanExtra( RADIO_KEY, false );
MultiEvent evt = cameOn? MultiEvent.BT_ENABLED MultiEvent evt = cameOn? MultiEvent.BT_ENABLED
: MultiEvent.BT_DISABLED; : MultiEvent.BT_DISABLED;
sendResult( evt ); postEvent( evt );
if ( cameOn ) { if ( cameOn ) {
GameUtils.resendAllIf( this, CommsConnType.COMMS_CONN_BT, GameUtils.resendAllIf( this, CommsConnType.COMMS_CONN_BT,
false ); false );
@ -594,7 +594,7 @@ public class BTService extends XWService {
} }
break; break;
case MESG_GAMEGONE: case MESG_GAMEGONE:
sendResult( MultiEvent.MESSAGE_NOGAME, gameID ); postEvent( MultiEvent.MESSAGE_NOGAME, gameID );
result = BTCmd.MESG_ACCPT; result = BTCmd.MESG_ACCPT;
break; break;
default: default:
@ -765,7 +765,7 @@ public class BTService extends XWService {
if ( sendPing( dev, 0 ) ) { // did we get a reply? if ( sendPing( dev, 0 ) ) { // did we get a reply?
addAddr( dev ); addAddr( dev );
if ( null != event ) { if ( null != event ) {
sendResult( event, dev.getName() ); postEvent( event, dev.getName() );
} }
} }
} }
@ -794,7 +794,7 @@ public class BTService extends XWService {
} else { } else {
gotReply = BTCmd.PONG == reply; gotReply = BTCmd.PONG == reply;
if ( gotReply && is.readBoolean() ) { if ( gotReply && is.readBoolean() ) {
sendResult( MultiEvent.MESSAGE_NOGAME, gameID ); postEvent( MultiEvent.MESSAGE_NOGAME, gameID );
} }
} }
@ -847,20 +847,20 @@ public class BTService extends XWService {
} }
if ( null == reply ) { if ( null == reply ) {
sendResult( MultiEvent.APP_NOT_FOUND_BT, dev.getName() ); postEvent( MultiEvent.APP_NOT_FOUND_BT, dev.getName() );
} else { } else {
switch ( reply ) { switch ( reply ) {
case BAD_PROTO: case BAD_PROTO:
sendBadProto( socket ); sendBadProto( socket );
break; break;
case INVITE_ACCPT: case INVITE_ACCPT:
sendResult( MultiEvent.NEWGAME_SUCCESS, elem.m_gameID ); postEvent( MultiEvent.NEWGAME_SUCCESS, elem.m_gameID );
break; break;
case INVITE_DUPID: case INVITE_DUPID:
sendResult( MultiEvent.NEWGAME_DUP_REJECTED, dev.getName() ); postEvent( MultiEvent.NEWGAME_DUP_REJECTED, dev.getName() );
break; break;
default: default:
sendResult( MultiEvent.NEWGAME_FAILURE, elem.m_gameID ); postEvent( MultiEvent.NEWGAME_FAILURE, elem.m_gameID );
break; break;
} }
} }
@ -943,10 +943,10 @@ public class BTService extends XWService {
if ( null != evt ) { if ( null != evt ) {
String btName = nameForAddr( m_adapter, elem.m_btAddr ); String btName = nameForAddr( m_adapter, elem.m_btAddr );
sendResult( evt, elem.m_gameID, 0, btName ); postEvent( evt, elem.m_gameID, 0, btName );
if ( ! success ) { if ( ! success ) {
int failCount = elem.incrFailCount(); int failCount = elem.incrFailCount();
sendResult( MultiEvent.MESSAGE_RESEND, btName, postEvent( MultiEvent.MESSAGE_RESEND, btName,
RESEND_TIMEOUT, failCount ); RESEND_TIMEOUT, failCount );
} }
} }
@ -966,7 +966,7 @@ public class BTService extends XWService {
iter.remove(); iter.remove();
} else if ( elem.failCountExceeded() ) { } else if ( elem.failCountExceeded() ) {
String btName = nameForAddr( m_adapter, elem.m_btAddr ); String btName = nameForAddr( m_adapter, elem.m_btAddr );
sendResult( MultiEvent.MESSAGE_FAILOUT, btName ); postEvent( MultiEvent.MESSAGE_FAILOUT, btName );
iter.remove(); iter.remove();
} }
} }
@ -1037,7 +1037,7 @@ public class BTService extends XWService {
for ( int ii = 0; ii < size; ++ii ) { for ( int ii = 0; ii < size; ++ii ) {
btNames[ii] = nameForAddr( m_adapter, btAddrs[ii] ); btNames[ii] = nameForAddr( m_adapter, btAddrs[ii] );
} }
sendResult( MultiEvent.SCAN_DONE, (Object)btAddrs, (Object)btNames ); postEvent( MultiEvent.SCAN_DONE, (Object)btAddrs, (Object)btNames );
} }
private void initAddrs() private void initAddrs()
@ -1147,7 +1147,7 @@ public class BTService extends XWService {
GameUtils.postInvitedNotification( this, nli.gameID(), body, GameUtils.postInvitedNotification( this, nli.gameID(), body,
rowid ); rowid );
sendResult( MultiEvent.BT_GAME_CREATED, rowid ); postEvent( MultiEvent.BT_GAME_CREATED, rowid );
} }
} else { } else {
result = BTCmd.INVITE_DUPID; result = BTCmd.INVITE_DUPID;
@ -1182,13 +1182,13 @@ public class BTService extends XWService {
DbgUtils.logex( ioe ); DbgUtils.logex( ioe );
++s_errCount; ++s_errCount;
// if ( 0 == s_errCount % 10 ) { // if ( 0 == s_errCount % 10 ) {
sendResult( MultiEvent.BT_ERR_COUNT, s_errCount ); postEvent( MultiEvent.BT_ERR_COUNT, s_errCount );
// } // }
} }
private void sendBadProto( BluetoothSocket socket ) private void sendBadProto( BluetoothSocket socket )
{ {
sendResult( MultiEvent.BAD_PROTO_BT, socket.getRemoteDevice().getName() ); postEvent( MultiEvent.BAD_PROTO_BT, socket.getRemoteDevice().getName() );
} }
private void updateStatusOut( boolean success ) private void updateStatusOut( boolean success )

View file

@ -59,6 +59,7 @@ public class MultiService {
private static final String ACTION_FETCH_DICT = "_afd"; private static final String ACTION_FETCH_DICT = "_afd";
private static final String FOR_MISSING_DICT = "_fmd"; private static final String FOR_MISSING_DICT = "_fmd";
// Shouldn't this be a Set?
private MultiEventListener m_li; private MultiEventListener m_li;
// these do not currently pass between devices so they can change. // these do not currently pass between devices so they can change.
@ -105,7 +106,7 @@ public class MultiService {
} }
} }
public void sendResult( MultiEvent event, Object ... args ) public void postEvent( MultiEvent event, Object ... args )
{ {
synchronized( this ) { synchronized( this ) {
if ( null != m_li ) { if ( null != m_li ) {

View file

@ -707,7 +707,7 @@ public class RelayService extends XWService
DbgUtils.logi( TAG, "relay unvailable for another %d seconds", DbgUtils.logi( TAG, "relay unvailable for another %d seconds",
unavail ); unavail );
String str = getVLIString( dis ); String str = getVLIString( dis );
sendResult( MultiEvent.RELAY_ALERT, str ); postEvent( MultiEvent.RELAY_ALERT, str );
break; break;
case XWPDEV_ALERT: case XWPDEV_ALERT:
str = getVLIString( dis ); str = getVLIString( dis );

View file

@ -521,11 +521,11 @@ public class SMSService extends XWService {
break; break;
case DEATH: case DEATH:
gameID = dis.readInt(); gameID = dis.readInt();
sendResult( MultiEvent.MESSAGE_NOGAME, gameID ); postEvent( MultiEvent.MESSAGE_NOGAME, gameID );
break; break;
case ACK: case ACK:
gameID = dis.readInt(); gameID = dis.readInt();
sendResult( MultiEvent.NEWGAME_SUCCESS, postEvent( MultiEvent.NEWGAME_SUCCESS,
gameID ); gameID );
break; break;
default: default:
@ -546,7 +546,7 @@ public class SMSService extends XWService {
byte[] rest = new byte[buffer.length - 4]; byte[] rest = new byte[buffer.length - 4];
System.arraycopy( buffer, 4, rest, 0, rest.length ); System.arraycopy( buffer, 4, rest, 0, rest.length );
if ( tryAssemble( senderPhone, id, index, count, rest ) ) { if ( tryAssemble( senderPhone, id, index, count, rest ) ) {
sendResult( MultiEvent.SMS_RECEIVE_OK ); postEvent( MultiEvent.SMS_RECEIVE_OK );
} else { } else {
DbgUtils.logw( TAG, "SMSService: receiveBuffer(): bogus message from" DbgUtils.logw( TAG, "SMSService: receiveBuffer(): bogus message from"
+ " phone %s", senderPhone ); + " phone %s", senderPhone );
@ -602,7 +602,7 @@ public class SMSService extends XWService {
if ( SMS_PROTO_VERSION < proto ) { if ( SMS_PROTO_VERSION < proto ) {
DbgUtils.logw( TAG, "SMSService.disAssemble: bad proto %d from %s;" DbgUtils.logw( TAG, "SMSService.disAssemble: bad proto %d from %s;"
+ " dropping", proto, senderPhone ); + " dropping", proto, senderPhone );
sendResult( MultiEvent.BAD_PROTO_SMS, senderPhone ); postEvent( MultiEvent.BAD_PROTO_SMS, senderPhone );
} else if ( gotPort != myPort ) { } else if ( gotPort != myPort ) {
DbgUtils.logd( TAG, "disAssemble(): received on port %d" DbgUtils.logd( TAG, "disAssemble(): received on port %d"
+ " but expected %d", gotPort, myPort ); + " but expected %d", gotPort, myPort );
@ -712,17 +712,17 @@ public class SMSService extends XWService {
{ {
switch ( getResultCode() ) { switch ( getResultCode() ) {
case Activity.RESULT_OK: case Activity.RESULT_OK:
sendResult( MultiEvent.SMS_SEND_OK ); postEvent( MultiEvent.SMS_SEND_OK );
break; break;
case SmsManager.RESULT_ERROR_RADIO_OFF: case SmsManager.RESULT_ERROR_RADIO_OFF:
DbgUtils.showf( SMSService.this, "NO RADIO!!!" ); DbgUtils.showf( SMSService.this, "NO RADIO!!!" );
sendResult( MultiEvent.SMS_SEND_FAILED_NORADIO ); postEvent( MultiEvent.SMS_SEND_FAILED_NORADIO );
break; break;
case SmsManager.RESULT_ERROR_NO_SERVICE: case SmsManager.RESULT_ERROR_NO_SERVICE:
DbgUtils.showf( SMSService.this, "NO SERVICE!!!" ); DbgUtils.showf( SMSService.this, "NO SERVICE!!!" );
default: default:
DbgUtils.logw( TAG, "FAILURE!!!" ); DbgUtils.logw( TAG, "FAILURE!!!" );
sendResult( MultiEvent.SMS_SEND_FAILED ); postEvent( MultiEvent.SMS_SEND_FAILED );
break; break;
} }
} }

View file

@ -709,7 +709,7 @@ public class WiDirService extends XWService {
private void handleGameGone( Intent intent ) private void handleGameGone( Intent intent )
{ {
int gameID = intent.getIntExtra( KEY_GAMEID, 0 ); int gameID = intent.getIntExtra( KEY_GAMEID, 0 );
sendResult( MultiEvent.MESSAGE_NOGAME, gameID ); postEvent( MultiEvent.MESSAGE_NOGAME, gameID );
} }
private void makeGame( NetLaunchInfo nli, String senderMac ) private void makeGame( NetLaunchInfo nli, String senderMac )

View file

@ -60,12 +60,13 @@ class XWService extends Service {
s_srcMgr.setListener( li ); s_srcMgr.setListener( li );
} }
protected void sendResult( MultiEvent event, Object ... args ) protected void postEvent( MultiEvent event, Object ... args )
{ {
if ( null != s_srcMgr ) { if ( null != s_srcMgr ) {
s_srcMgr.sendResult( event, args ); s_srcMgr.postEvent( event, args );
} else { } else {
DbgUtils.logd( TAG, "sendResult(): dropping %s event", event.toString() ); DbgUtils.logd( TAG, "postEvent(): dropping %s event",
event.toString() );
} }
} }