mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-04 20:46:28 +01:00
cleanup -- remove logging and simplify code a bit.
This commit is contained in:
parent
5b5b969e71
commit
5949994557
1 changed files with 8 additions and 14 deletions
|
@ -393,12 +393,7 @@ public class SMSService extends Service {
|
||||||
|
|
||||||
private void receiveBuffer( String as64, String senderPhone )
|
private void receiveBuffer( String as64, String senderPhone )
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "receiveBuffer(%s)", as64 );
|
|
||||||
String[] parts = as64.split( ":" );
|
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 );
|
Assert.assertTrue( 5 == parts.length );
|
||||||
if ( 5 == parts.length ) {
|
if ( 5 == parts.length ) {
|
||||||
byte proto = Byte.valueOf( parts[0], 10 );
|
byte proto = Byte.valueOf( parts[0], 10 );
|
||||||
|
@ -415,8 +410,9 @@ public class SMSService extends Service {
|
||||||
if ( index == 0 && count == 1 ) {
|
if ( index == 0 && count == 1 ) {
|
||||||
disAssemble( senderPhone, msg );
|
disAssemble( senderPhone, msg );
|
||||||
} else {
|
} else {
|
||||||
|
// required? Should always be in main thread.
|
||||||
synchronized( s_partialMsgs ) {
|
synchronized( s_partialMsgs ) {
|
||||||
HashMap <Integer, MsgStore> perPhone =
|
HashMap<Integer, MsgStore> perPhone =
|
||||||
s_partialMsgs.get( senderPhone );
|
s_partialMsgs.get( senderPhone );
|
||||||
if ( null == perPhone ) {
|
if ( null == perPhone ) {
|
||||||
perPhone = new HashMap <Integer, MsgStore>();
|
perPhone = new HashMap <Integer, MsgStore>();
|
||||||
|
@ -427,13 +423,10 @@ public class SMSService extends Service {
|
||||||
store = new MsgStore( id, count );
|
store = new MsgStore( id, count );
|
||||||
perPhone.put( id, store );
|
perPhone.put( id, store );
|
||||||
}
|
}
|
||||||
store.add( index, msg );
|
|
||||||
|
|
||||||
if ( store.isComplete() ) {
|
if ( store.add( index, msg ).isComplete() ) {
|
||||||
s_partialMsgs.remove( id );
|
disAssemble( senderPhone, store.message() );
|
||||||
String fullMsg = store.message();
|
|
||||||
perPhone.remove( id );
|
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.",
|
DbgUtils.logf( "Message \"%s\" of %d bytes sent to %s.",
|
||||||
asPublic, asPublic.length(), phone );
|
asPublic, asPublic.length(), phone );
|
||||||
}
|
}
|
||||||
DbgUtils.showf( this, "sent %dth msg", ++s_nSent );
|
DbgUtils.showf( this, "sent %dth msg", s_nSent );
|
||||||
success = true;
|
success = true;
|
||||||
} catch ( IllegalArgumentException iae ) {
|
} catch ( IllegalArgumentException iae ) {
|
||||||
DbgUtils.logf( "%s", iae.toString() );
|
DbgUtils.logf( "%s", iae.toString() );
|
||||||
|
@ -587,13 +580,14 @@ public class SMSService extends Service {
|
||||||
m_fullLength = 0;
|
m_fullLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add( int index, String msg )
|
public MsgStore add( int index, String msg )
|
||||||
{
|
{
|
||||||
if ( null == m_msgs[index] ) {
|
if ( null == m_msgs[index] ) {
|
||||||
++m_haveCount;
|
++m_haveCount;
|
||||||
m_fullLength += msg.length();
|
m_fullLength += msg.length();
|
||||||
}
|
}
|
||||||
m_msgs[index] = msg;
|
m_msgs[index] = msg;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isComplete()
|
public boolean isComplete()
|
||||||
|
|
Loading…
Add table
Reference in a new issue