Make some missed call notifications alert user

Closes #5220
// FREEBIE
This commit is contained in:
Christian Ascheberg 2016-02-12 14:08:58 +01:00 committed by Moxie Marlinspike
parent 432e229698
commit 2642f4f15d

View File

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