Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 200efcbc authored by Dheeraj Shetty's avatar Dheeraj Shetty Committed by Steve Kondik
Browse files

IMS: Fix vice notifications

Avoid duplicate vice notification by clearing them individually.
Remove usage of clearAll notifications - async call, does not handle back
to back vice indications/service status updates cleanly.

Change-Id: I764d0c6560c561b8a413dfe1b1a7731088e1604d
CRs-fixed: 949504 952824 953411
parent 4bc71aa6
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -176,11 +176,10 @@ public class ViceNotificationImpl extends CallsManagerListenerBase {
    // Clear the existing notifications on statusbar and
    // Hashmap whenever new Vice Notification is received
    private void resetBeforeProcess() {
        mNotificationManager.cancelAll();
        mNotification.clear();
        mBuilder = null;
        mPublicNotificationBuilder = null;
        mWasInCall = false;
        checkAndUpdateNotification();
    }

    /* Service connection bound to IQtiImsInterface */
@@ -323,7 +322,6 @@ public class ViceNotificationImpl extends CallsManagerListenerBase {
                        + ", notifId = " + notifId);

                resetBuilders();
                checkAndUpdateNotification(callInfo, false);
                Log.i(this, "processNotification isInCall = " + getTelecomManager().isInCall());
                isVt = isVtCall(callInfo[QtiViceInfo.INDEX_CALLTYPE]);

@@ -349,7 +347,6 @@ public class ViceNotificationImpl extends CallsManagerListenerBase {
            }
        } else {
            Log.i(this, "processNotification DEP null");
            resetBeforeProcess();
        }
    }

@@ -393,12 +390,12 @@ public class ViceNotificationImpl extends CallsManagerListenerBase {
    }

    /**
     * API updates the hashmap in following order :
     * - if new call : create new entry
     * - if existing call : cancel existing notification and remove it from hashmap
     *                      It will get added to hashmap in showNotification()
     * Retrieve all notifications from the map.
     * Cancel and remove all notifications from the map.
     * CancelAll not used as it is an asynchronous call and can cause issue with
     * back to back notifications.
     */
    private void checkAndUpdateNotification(String[] callInfo, boolean clear) {
    private void checkAndUpdateNotification() {
        Set<Map.Entry<String, Integer>> call = mNotification.entrySet();
        if ((call == null) || (mNotification.isEmpty())) {
            return;
@@ -409,10 +406,8 @@ public class ViceNotificationImpl extends CallsManagerListenerBase {
            Map.Entry<String, Integer> entry = iterator.next();
            String dialog = entry.getKey();
            Integer notifId = entry.getValue();
            if (dialog.equalsIgnoreCase(callInfo[QtiViceInfo.INDEX_DIALOG_ID])) {
            mNotificationManager.cancel(notifId);
                call.remove(dialog);
            }
            iterator.remove();
        }
    }