From b33df6b222161a96c15372b7f8156a0c594db4b9 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 20 Jun 2017 19:19:03 -0700 Subject: [PATCH] reset SMSResend timer on new data only Resetting it on every ACK etc meant it happened forever at the most frequent interval, at least on devices that have both sides of a game, which is my usual test setup. --- .../main/java/org/eehouse/android/xw4/SMSService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/SMSService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/SMSService.java index 8fe7f5add..84e7afd19 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/SMSService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/SMSService.java @@ -523,7 +523,9 @@ public class SMSService extends XWService { int gameID = dis.readInt(); byte[] rest = new byte[dis.available()]; dis.read( rest ); - feedMessage( gameID, rest, new CommsAddrRec( phone ) ); + if ( feedMessage( gameID, rest, new CommsAddrRec( phone ) ) ) { + SMSResendReceiver.resetTimer( this ); + } break; case DEATH: gameID = dis.readInt(); @@ -538,8 +540,6 @@ public class SMSService extends XWService { Log.w( TAG, "unexpected cmd %s", cmd.toString() ); break; } - - SMSResendReceiver.resetTimer( this ); } catch ( java.io.IOException ioe ) { Log.ex( TAG, ioe ); } @@ -708,12 +708,13 @@ public class SMSService extends XWService { return success; } - private void feedMessage( int gameID, byte[] msg, CommsAddrRec addr ) + private boolean feedMessage( int gameID, byte[] msg, CommsAddrRec addr ) { ReceiveResult rslt = receiveMessage( this, gameID, null, msg, addr ); if ( ReceiveResult.GAME_GONE == rslt ) { sendDiedPacket( addr.sms_phone, gameID ); } + return rslt == ReceiveResult.OK; } private void registerReceivers()