From 5949994557a695ec56575d13809623fde88d8693 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 12 Apr 2012 21:24:52 -0700 Subject: [PATCH] cleanup -- remove logging and simplify code a bit. --- .../org/eehouse/android/xw4/SMSService.java | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java index 9a3e3a836..040aabeae 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java @@ -393,12 +393,7 @@ public class SMSService extends Service { private void receiveBuffer( String as64, String senderPhone ) { - DbgUtils.logf( "receiveBuffer(%s)", as64 ); String[] parts = as64.split( ":" ); - DbgUtils.logf( "receiveBuffer: got %d parts", parts.length ); - for ( String part : parts ) { - DbgUtils.logf( "part: %s", part ); - } Assert.assertTrue( 5 == parts.length ); if ( 5 == parts.length ) { byte proto = Byte.valueOf( parts[0], 10 ); @@ -415,8 +410,9 @@ public class SMSService extends Service { if ( index == 0 && count == 1 ) { disAssemble( senderPhone, msg ); } else { - synchronized( s_partialMsgs ) { - HashMap perPhone = + // required? Should always be in main thread. + synchronized( s_partialMsgs ) { + HashMap perPhone = s_partialMsgs.get( senderPhone ); if ( null == perPhone ) { perPhone = new HashMap (); @@ -427,13 +423,10 @@ public class SMSService extends Service { store = new MsgStore( id, count ); perPhone.put( id, store ); } - store.add( index, msg ); - if ( store.isComplete() ) { - s_partialMsgs.remove( id ); - String fullMsg = store.message(); + if ( store.add( index, msg ).isComplete() ) { + disAssemble( senderPhone, store.message() ); perPhone.remove( id ); - disAssemble( senderPhone, fullMsg ); } } } @@ -486,7 +479,7 @@ public class SMSService extends Service { DbgUtils.logf( "Message \"%s\" of %d bytes sent to %s.", asPublic, asPublic.length(), phone ); } - DbgUtils.showf( this, "sent %dth msg", ++s_nSent ); + DbgUtils.showf( this, "sent %dth msg", s_nSent ); success = true; } catch ( IllegalArgumentException iae ) { DbgUtils.logf( "%s", iae.toString() ); @@ -587,13 +580,14 @@ public class SMSService extends Service { m_fullLength = 0; } - public void add( int index, String msg ) + public MsgStore add( int index, String msg ) { if ( null == m_msgs[index] ) { ++m_haveCount; m_fullLength += msg.length(); } m_msgs[index] = msg; + return this; } public boolean isComplete()