From 2642f4f15d4432a0798da4ef51746360f56ecc3d Mon Sep 17 00:00:00 2001 From: Christian Ascheberg Date: Fri, 12 Feb 2016 14:08:58 +0100 Subject: [PATCH] Make some missed call notifications alert user Closes #5220 // FREEBIE --- .../redphone/RedPhoneService.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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();