create missed call notification when device is busy
This commit is contained in:
parent
89c59909b5
commit
68eb17d400
|
@ -773,6 +773,25 @@ public class NotificationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearMissedCall(final Message message) {
|
||||||
|
synchronized (mMissedCalls) {
|
||||||
|
final Iterator<Map.Entry<Conversational,MissedCallsInfo>> iterator = mMissedCalls.entrySet().iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
final Map.Entry<Conversational, MissedCallsInfo> entry = iterator.next();
|
||||||
|
final Conversational conversational = entry.getKey();
|
||||||
|
final MissedCallsInfo missedCallsInfo = entry.getValue();
|
||||||
|
if (conversational.getUuid().equals(message.getConversation().getUuid())) {
|
||||||
|
if (missedCallsInfo.removeMissedCall()) {
|
||||||
|
cancel(conversational.getUuid(), MISSED_CALL_NOTIFICATION_ID);
|
||||||
|
Log.d(Config.LOGTAG,conversational.getAccount().getJid().asBareJid()+": dismissed missed call because call was picked up on other device");
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateMissedCallNotifications(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void clearMissedCalls() {
|
public void clearMissedCalls() {
|
||||||
synchronized (mMissedCalls) {
|
synchronized (mMissedCalls) {
|
||||||
for (final Conversational conversation : mMissedCalls.keySet()) {
|
for (final Conversational conversation : mMissedCalls.keySet()) {
|
||||||
|
@ -1943,6 +1962,11 @@ public class NotificationService {
|
||||||
lastTime = time;
|
lastTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean removeMissedCall() {
|
||||||
|
--numberOfCalls;
|
||||||
|
return numberOfCalls <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
public int getNumberOfCalls() {
|
public int getNumberOfCalls() {
|
||||||
return numberOfCalls;
|
return numberOfCalls;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,8 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
this.terminatedSessions.asMap().containsKey(PersistableSessionId.of(id));
|
this.terminatedSessions.asMap().containsKey(PersistableSessionId.of(id));
|
||||||
final boolean stranger =
|
final boolean stranger =
|
||||||
isWithStrangerAndStrangerNotificationsAreOff(account, id.with);
|
isWithStrangerAndStrangerNotificationsAreOff(account, id.with);
|
||||||
if (isBusy() || sessionEnded || stranger) {
|
final boolean busy = isBusy();
|
||||||
|
if (busy || sessionEnded || stranger) {
|
||||||
Log.d(
|
Log.d(
|
||||||
Config.LOGTAG,
|
Config.LOGTAG,
|
||||||
id.account.getJid().asBareJid()
|
id.account.getJid().asBareJid()
|
||||||
|
@ -117,6 +118,15 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
sessionTermination.setTo(id.with);
|
sessionTermination.setTo(id.with);
|
||||||
sessionTermination.setReason(Reason.BUSY, null);
|
sessionTermination.setReason(Reason.BUSY, null);
|
||||||
mXmppConnectionService.sendIqPacket(account, sessionTermination, null);
|
mXmppConnectionService.sendIqPacket(account, sessionTermination, null);
|
||||||
|
if (busy || stranger) {
|
||||||
|
writeLogMissedIncoming(
|
||||||
|
account,
|
||||||
|
id.with,
|
||||||
|
id.sessionId,
|
||||||
|
null,
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
stranger);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connection = new JingleRtpConnection(this, id, from);
|
connection = new JingleRtpConnection(this, id, from);
|
||||||
|
@ -329,6 +339,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
Config.LOGTAG,
|
Config.LOGTAG,
|
||||||
id.account.getJid().asBareJid()
|
id.account.getJid().asBareJid()
|
||||||
+ ": updated previous busy because call got picked up by another device");
|
+ ": updated previous busy because call got picked up by another device");
|
||||||
|
mXmppConnectionService.getNotificationService().clearMissedCall(previousBusy);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,7 +411,12 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
isWithStrangerAndStrangerNotificationsAreOff(account, id.with);
|
isWithStrangerAndStrangerNotificationsAreOff(account, id.with);
|
||||||
if (isBusy() || stranger) {
|
if (isBusy() || stranger) {
|
||||||
writeLogMissedIncoming(
|
writeLogMissedIncoming(
|
||||||
account, id.with.asBareJid(), id.sessionId, serverMsgId, timestamp);
|
account,
|
||||||
|
id.with.asBareJid(),
|
||||||
|
id.sessionId,
|
||||||
|
serverMsgId,
|
||||||
|
timestamp,
|
||||||
|
stranger);
|
||||||
if (stranger) {
|
if (stranger) {
|
||||||
Log.d(
|
Log.d(
|
||||||
Config.LOGTAG,
|
Config.LOGTAG,
|
||||||
|
@ -544,10 +560,11 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
|
|
||||||
private void writeLogMissedIncoming(
|
private void writeLogMissedIncoming(
|
||||||
final Account account,
|
final Account account,
|
||||||
Jid with,
|
final Jid with,
|
||||||
final String sessionId,
|
final String sessionId,
|
||||||
String serverMsgId,
|
final String serverMsgId,
|
||||||
long timestamp) {
|
final long timestamp,
|
||||||
|
final boolean stranger) {
|
||||||
final Conversation conversation =
|
final Conversation conversation =
|
||||||
mXmppConnectionService.findOrCreateConversation(
|
mXmppConnectionService.findOrCreateConversation(
|
||||||
account, with.asBareJid(), false, false);
|
account, with.asBareJid(), false, false);
|
||||||
|
@ -557,7 +574,12 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
message.setBody(new RtpSessionStatus(false, 0).toString());
|
message.setBody(new RtpSessionStatus(false, 0).toString());
|
||||||
message.setServerMsgId(serverMsgId);
|
message.setServerMsgId(serverMsgId);
|
||||||
message.setTime(timestamp);
|
message.setTime(timestamp);
|
||||||
|
message.setCounterpart(with);
|
||||||
writeMessage(message);
|
writeMessage(message);
|
||||||
|
if (stranger) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mXmppConnectionService.getNotificationService().pushMissedCallNow(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeMessage(final Message message) {
|
private void writeMessage(final Message message) {
|
||||||
|
|
Loading…
Reference in a new issue