diff --git a/src/org/thoughtcrime/redphone/RedPhoneService.java b/src/org/thoughtcrime/redphone/RedPhoneService.java index 0bc88e0ef9..57d963ce65 100644 --- a/src/org/thoughtcrime/redphone/RedPhoneService.java +++ b/src/org/thoughtcrime/redphone/RedPhoneService.java @@ -30,6 +30,7 @@ import android.support.annotation.Nullable; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; +import android.util.Pair; import org.thoughtcrime.redphone.audio.IncomingRinger; import org.thoughtcrime.redphone.audio.OutgoingRinger; @@ -228,7 +229,7 @@ public class RedPhoneService extends Service implements CallStateListener, CallS return; } - handleMissedCall(intent.getStringExtra(EXTRA_REMOTE_NUMBER)); + handleMissedCall(intent.getStringExtra(EXTRA_REMOTE_NUMBER), false); try { SignalingSocket signalingSocket = new SignalingSocket(this, session.getFullServerName(), @@ -243,9 +244,10 @@ public class RedPhoneService extends Service implements CallStateListener, CallS } } - private void handleMissedCall(String remoteNumber) { - DatabaseFactory.getSmsDatabase(this).insertMissedCall(remoteNumber); - MessageNotifier.updateNotification(this, KeyCachingService.getMasterSecret(this)); + private void handleMissedCall(String remoteNumber, boolean signal) { + Pair messageAndThreadId = DatabaseFactory.getSmsDatabase(this).insertMissedCall(remoteNumber); + MessageNotifier.updateNotification(this, KeyCachingService.getMasterSecret(this), + false, messageAndThreadId.second, signal); } private void handleAnswerCall(Intent intent) { @@ -381,7 +383,7 @@ public class RedPhoneService extends Service implements CallStateListener, CallS public void notifyCallStale() { Log.w(TAG, "Got a stale call, probably an old SMS..."); - handleMissedCall(remoteNumber); + handleMissedCall(remoteNumber, true); this.terminate(); } @@ -431,7 +433,7 @@ public class RedPhoneService extends Service implements CallStateListener, CallS public void notifyCallDisconnected() { if (state == STATE_RINGING) - handleMissedCall(remoteNumber); + handleMissedCall(remoteNumber, false); sendMessage(Type.CALL_DISCONNECTED, getRecipient(), null); this.terminate(); @@ -458,7 +460,7 @@ public class RedPhoneService extends Service implements CallStateListener, CallS public void notifyServerFailure() { if (state == STATE_RINGING) - handleMissedCall(remoteNumber); + handleMissedCall(remoteNumber, true); state = STATE_IDLE; outgoingRinger.playFailure(); @@ -468,7 +470,7 @@ public class RedPhoneService extends Service implements CallStateListener, CallS public void notifyClientFailure() { if (state == STATE_RINGING) - handleMissedCall(remoteNumber); + handleMissedCall(remoteNumber, false); state = STATE_IDLE; outgoingRinger.playFailure(); @@ -478,7 +480,7 @@ public class RedPhoneService extends Service implements CallStateListener, CallS public void notifyLoginFailed() { if (state == STATE_RINGING) - handleMissedCall(remoteNumber); + handleMissedCall(remoteNumber, true); state = STATE_IDLE; outgoingRinger.playFailure();