mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-06-05 21:49:48 +02:00
Stop an incoming VoIP call notification when the call is answered
This commit is contained in:
@@ -116,6 +116,7 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
public static ArrayList<String> notificationStack = new ArrayList<>();
|
public static ArrayList<String> notificationStack = new ArrayList<>();
|
||||||
|
|
||||||
private long activeCallPostTime;
|
private long activeCallPostTime;
|
||||||
|
private int mLastCallCommand = CallSpec.CALL_UNDEFINED;
|
||||||
|
|
||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
|
|
||||||
@@ -452,13 +453,20 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
}
|
}
|
||||||
Notification noti = sbn.getNotification();
|
Notification noti = sbn.getNotification();
|
||||||
dumpExtras(noti.extras);
|
dumpExtras(noti.extras);
|
||||||
|
boolean callStarted = false;
|
||||||
if(noti.actions != null && noti.actions.length > 0) {
|
if(noti.actions != null && noti.actions.length > 0) {
|
||||||
for (Notification.Action action : noti.actions) {
|
for (Notification.Action action : noti.actions) {
|
||||||
LOG.info("Found call action: " + action.title);
|
LOG.info("Found call action: " + action.title);
|
||||||
}
|
}
|
||||||
if (noti.actions.length == 1) {
|
if (noti.actions.length == 1) {
|
||||||
LOG.info("There is only one call action, assuming outgoing call and ignoring");
|
if (mLastCallCommand == CallSpec.CALL_INCOMING) {
|
||||||
return;
|
LOG.info("There is only one call action and previous state was CALL_INCOMING, assuming call started");
|
||||||
|
callStarted = true;
|
||||||
|
} else {
|
||||||
|
LOG.info("There is only one call action and previous state was not CALL_INCOMING, assuming outgoing call / duplicate notification and ignoring");
|
||||||
|
// FIXME: is there a way to detect transition CALL_OUTGOING -> CALL_START for more complete VoIP call state tracking?
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*try {
|
/*try {
|
||||||
LOG.info("Executing first action");
|
LOG.info("Executing first action");
|
||||||
@@ -481,7 +489,8 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
activeCallPostTime = sbn.getPostTime();
|
activeCallPostTime = sbn.getPostTime();
|
||||||
CallSpec callSpec = new CallSpec();
|
CallSpec callSpec = new CallSpec();
|
||||||
callSpec.number = number;
|
callSpec.number = number;
|
||||||
callSpec.command = CallSpec.CALL_INCOMING;
|
callSpec.command = callStarted ? CallSpec.CALL_START : CallSpec.CALL_INCOMING;
|
||||||
|
mLastCallCommand = callSpec.command;
|
||||||
GBApplication.deviceService().onSetCallState(callSpec);
|
GBApplication.deviceService().onSetCallState(callSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,6 +662,7 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
activeCallPostTime = 0;
|
activeCallPostTime = 0;
|
||||||
CallSpec callSpec = new CallSpec();
|
CallSpec callSpec = new CallSpec();
|
||||||
callSpec.command = CallSpec.CALL_END;
|
callSpec.command = CallSpec.CALL_END;
|
||||||
|
mLastCallCommand = callSpec.command;
|
||||||
GBApplication.deviceService().onSetCallState(callSpec);
|
GBApplication.deviceService().onSetCallState(callSpec);
|
||||||
}
|
}
|
||||||
// FIXME: DISABLED for now
|
// FIXME: DISABLED for now
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.model;
|
package nodomain.freeyourgadget.gadgetbridge.model;
|
||||||
|
|
||||||
public class CallSpec {
|
public class CallSpec {
|
||||||
public static final int CALL_UNDEFINED = 1;
|
public static final int CALL_UNDEFINED = 0;
|
||||||
public static final int CALL_ACCEPT = 1;
|
public static final int CALL_ACCEPT = 1;
|
||||||
public static final int CALL_INCOMING = 2;
|
public static final int CALL_INCOMING = 2;
|
||||||
public static final int CALL_OUTGOING = 3;
|
public static final int CALL_OUTGOING = 3;
|
||||||
|
Reference in New Issue
Block a user