mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Avoid Microsoft Teams notification burst during calls (#5525)
This commit is contained in:
+17
-1
@@ -703,7 +703,7 @@ public class NotificationListener extends NotificationListenerService {
|
||||
boolean callStarted = false;
|
||||
if (noti.actions != null && noti.actions.length > 0) {
|
||||
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 (mLastCallCommand == CallSpec.CALL_INCOMING) {
|
||||
@@ -723,6 +723,22 @@ public class NotificationListener extends NotificationListenerService {
|
||||
}*/
|
||||
}
|
||||
|
||||
if (app.equals("com.microsoft.teams")) {
|
||||
// #5525 - microsoft teams spams notifications with slightly increasing timestamps
|
||||
// we use a different key for the burst prevention to prevent suppressing notifications
|
||||
final String burstPreventionKey = "call:" + app;
|
||||
final Long notificationBurstPreventionValue = notificationBurstPrevention.get(burstPreventionKey);
|
||||
long curTime = System.nanoTime();
|
||||
if (notificationBurstPreventionValue != null) {
|
||||
long diff = curTime - notificationBurstPreventionValue;
|
||||
if (diff < TimeUnit.SECONDS.toNanos(1)) {
|
||||
LOG.info("Ignoring burst call notification from microsoft teams, last one was {} ms ago", TimeUnit.NANOSECONDS.toMillis(diff));
|
||||
return;
|
||||
}
|
||||
}
|
||||
notificationBurstPrevention.put(burstPreventionKey, curTime);
|
||||
}
|
||||
|
||||
// figure out sender
|
||||
String number = null;
|
||||
String notiTitle = null;
|
||||
|
||||
+2
@@ -49,6 +49,8 @@ public class PhoneCallReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
LOG.debug("Got phone call intent: {}", intent.getAction());
|
||||
|
||||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE);
|
||||
if ("android.intent.action.NEW_OUTGOING_CALL".equals(intent.getAction())) {
|
||||
mSavedNumber = intent.getExtras().getString("android.intent.extra.PHONE_NUMBER");
|
||||
|
||||
Reference in New Issue
Block a user