don't send sms messages in queue if sms support has been turned off

This commit is contained in:
Eric House 2015-02-07 13:37:14 -08:00
parent 17307f910b
commit fa856e1db0

View file

@ -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) );