Fix incoming call notifications not being removed on some devices

This commit is contained in:
xynngh 2020-05-16 17:26:48 +04:00
parent 930372f488
commit 29e43fec3c
2 changed files with 5 additions and 6 deletions

View File

@ -73,7 +73,7 @@ public class CallReceiver extends BroadcastReceiver {
} }
} else if(TelephonyManager.EXTRA_STATE_IDLE.equals(telephonyExtraState)) { } else if(TelephonyManager.EXTRA_STATE_IDLE.equals(telephonyExtraState)) {
isOnCall = false; isOnCall = false;
NotificationHelper.hideIncomingCallNotification(context, incomingNumber); NotificationHelper.hideIncomingCallNotification(context);
postEvent(new CallEndedEvent()); postEvent(new CallEndedEvent());
} }
} }

View File

@ -54,13 +54,12 @@ public class NotificationHelper {
public static void showIncomingCallNotification(Context context, NumberInfo numberInfo) { public static void showIncomingCallNotification(Context context, NumberInfo numberInfo) {
Notification notification = createIncomingCallNotification(context, numberInfo); Notification notification = createIncomingCallNotification(context, numberInfo);
String tag = numberInfo.number != null ? NOTIFICATION_TAG_INCOMING_CALL + numberInfo.number : null; notify(context, NOTIFICATION_TAG_INCOMING_CALL, NOTIFICATION_ID_INCOMING_CALL, notification);
notify(context, tag, NOTIFICATION_ID_INCOMING_CALL, notification);
} }
public static void hideIncomingCallNotification(Context context, String number) { public static void hideIncomingCallNotification(Context context) {
String tag = number != null ? NOTIFICATION_TAG_INCOMING_CALL + number : null; NotificationManagerCompat.from(context)
NotificationManagerCompat.from(context).cancel(tag, NOTIFICATION_ID_INCOMING_CALL); .cancel(NOTIFICATION_TAG_INCOMING_CALL, NOTIFICATION_ID_INCOMING_CALL);
} }
public static void showBlockedCallNotification(Context context, NumberInfo numberInfo) { public static void showBlockedCallNotification(Context context, NumberInfo numberInfo) {