mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-07 20:46:17 +01:00
don't send sms messages in queue if sms support has been turned off
This commit is contained in:
parent
17307f910b
commit
fa856e1db0
1 changed files with 27 additions and 21 deletions
|
@ -620,25 +620,31 @@ public class SMSService extends XWService {
|
||||||
private boolean sendBuffers( byte[][] fragments, String phone, byte[] data )
|
private boolean sendBuffers( byte[][] fragments, String phone, byte[] data )
|
||||||
{
|
{
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
short nbsPort = (short)Integer.parseInt( getString( R.string.nbs_port ) );
|
if ( XWPrefs.getSMSEnabled( this ) ) {
|
||||||
try {
|
short nbsPort = (short)Integer.parseInt( getString( R.string.nbs_port ) );
|
||||||
SmsManager mgr = SmsManager.getDefault();
|
try {
|
||||||
PendingIntent sent = makeStatusIntent( MSG_SENT );
|
SmsManager mgr = SmsManager.getDefault();
|
||||||
PendingIntent delivery = makeStatusIntent( MSG_DELIVERED );
|
PendingIntent sent = makeStatusIntent( MSG_SENT );
|
||||||
for ( byte[] fragment : fragments ) {
|
PendingIntent delivery = makeStatusIntent( MSG_DELIVERED );
|
||||||
mgr.sendDataMessage( phone, null, nbsPort, fragment, sent,
|
for ( byte[] fragment : fragments ) {
|
||||||
delivery );
|
mgr.sendDataMessage( phone, null, nbsPort, fragment, sent,
|
||||||
|
delivery );
|
||||||
|
DbgUtils.logf( "SMSService.sendBuffers(): sent %d byte fragment",
|
||||||
|
fragment.length );
|
||||||
|
}
|
||||||
|
if ( s_showToasts ) {
|
||||||
|
DbgUtils.showf( this, "sent %dth msg", s_nSent );
|
||||||
|
}
|
||||||
|
success = true;
|
||||||
|
} catch ( IllegalArgumentException iae ) {
|
||||||
|
DbgUtils.logf( "sendBuffers(%s): %s", phone, iae.toString() );
|
||||||
|
} catch ( NullPointerException npe ) {
|
||||||
|
Assert.fail(); // shouldn't be trying to do this!!!
|
||||||
|
} catch ( Exception ee ) {
|
||||||
|
DbgUtils.loge( ee );
|
||||||
}
|
}
|
||||||
if ( s_showToasts ) {
|
} else {
|
||||||
DbgUtils.showf( this, "sent %dth msg", s_nSent );
|
DbgUtils.logf( "sendBuffers(): dropping because SMS disabled" );
|
||||||
}
|
|
||||||
success = true;
|
|
||||||
} catch ( IllegalArgumentException iae ) {
|
|
||||||
DbgUtils.logf( "sendBuffers(%s): %s", phone, iae.toString() );
|
|
||||||
} catch ( NullPointerException npe ) {
|
|
||||||
Assert.fail(); // shouldn't be trying to do this!!!
|
|
||||||
} catch ( Exception ee ) {
|
|
||||||
DbgUtils.loge( ee );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnStatusHandler.updateStatusOut( this, null,
|
ConnStatusHandler.updateStatusOut( this, null,
|
||||||
|
@ -697,9 +703,9 @@ public class SMSService extends XWService {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context arg0, Intent arg1)
|
public void onReceive(Context arg0, Intent arg1)
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "SMS delivery result: %s",
|
if ( Activity.RESULT_OK != getResultCode() ) {
|
||||||
Activity.RESULT_OK == getResultCode()
|
DbgUtils.logf( "SMS delivery result: FAILURE" );
|
||||||
? "SUCCESS" : "FAILURE" );
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
registerReceiver( m_receiveReceiver, new IntentFilter(MSG_DELIVERED) );
|
registerReceiver( m_receiveReceiver, new IntentFilter(MSG_DELIVERED) );
|
||||||
|
|
Loading…
Add table
Reference in a new issue