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

Commit 0a20c77a authored by Flavio Lerda's avatar Flavio Lerda Committed by Android (Google) Code Review
Browse files

Merge "Fix clearing of voicemail notifications."

parents a4f6f104 0331d14d
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ import android.util.Log;
 * <p>
 * It handles the following actions:
 * <ul>
 * <li>{@link #ACTION_MARK_NEW_CALLS_AS_OLD}: marks all the new items in the call log as old; this
 * is called when a notification is dismissed.</li>
 * <li>{@link #ACTION_MARK_NEW_VOICEMAILS_AS_OLD}: marks all the new voicemails in the call log as
 * old; this is called when a notification is dismissed.</li>
 * <li>{@link #ACTION_UPDATE_NOTIFICATIONS}: updates the content of the new items notification; it
 * may include an optional extra {@link #EXTRA_NEW_VOICEMAIL_URI}, containing the URI of the new
 * voicemail that has triggered this update (if any).</li>
@@ -36,11 +36,9 @@ import android.util.Log;
public class CallLogNotificationsService extends IntentService {
    private static final String TAG = "CallLogNotificationsService";

    /**
     * Action to mark all the new calls as old.
     */
    public static final String ACTION_MARK_NEW_CALLS_AS_OLD =
            "com.android.contacts.calllog.MARK_NEW_CALLS_AS_OLD";
    /** Action to mark all the new voicemails as old. */
    public static final String ACTION_MARK_NEW_VOICEMAILS_AS_OLD =
            "com.android.contacts.calllog.ACTION_MARK_NEW_VOICEMAILS_AS_OLD";

    /**
     * Action to update the notifications.
@@ -72,8 +70,8 @@ public class CallLogNotificationsService extends IntentService {

    @Override
    protected void onHandleIntent(Intent intent) {
        if (ACTION_MARK_NEW_CALLS_AS_OLD.equals(intent.getAction())) {
            mCallLogQueryHandler.markNewCallsAsOld();
        if (ACTION_MARK_NEW_VOICEMAILS_AS_OLD.equals(intent.getAction())) {
            mCallLogQueryHandler.markNewVoicemailsAsOld();
        } else if (ACTION_UPDATE_NOTIFICATIONS.equals(intent.getAction())) {
            Uri voicemailUri = (Uri) intent.getParcelableExtra(EXTRA_NEW_VOICEMAIL_URI);
            DefaultVoicemailNotifier.getInstance(this).updateNotification(voicemailUri);
+20 −3
Original line number Diff line number Diff line
@@ -51,12 +51,13 @@ import javax.annotation.concurrent.GuardedBy;
    private static final int QUERY_OLD_CALLS_TOKEN = 54;
    /** The token for the query to mark all missed calls as old after seeing the call log. */
    private static final int UPDATE_MARK_AS_OLD_TOKEN = 55;
    /** The token for the query to mark all new voicemails as old. */
    private static final int UPDATE_MARK_VOICEMAILS_AS_OLD_TOKEN = 56;
    /** The token for the query to mark all missed calls as read after seeing the call log. */
    private static final int UPDATE_MARK_MISSED_CALL_AS_READ_TOKEN = 56;
    private static final int UPDATE_MARK_MISSED_CALL_AS_READ_TOKEN = 57;

    /** The token for the query to fetch voicemail status messages. */
    private static final int QUERY_VOICEMAIL_STATUS_TOKEN = 57;

    private static final int QUERY_VOICEMAIL_STATUS_TOKEN = 58;

    private final WeakReference<Listener> mListener;

@@ -192,6 +193,22 @@ import javax.annotation.concurrent.GuardedBy;
                values, where.toString(), null);
    }

    /** Updates all new voicemails to mark them as old. */
    public void markNewVoicemailsAsOld() {
        // Mark all "new" voicemails as not new anymore.
        StringBuilder where = new StringBuilder();
        where.append(Calls.NEW);
        where.append(" = 1 AND ");
        where.append(Calls.TYPE);
        where.append(" = ?");

        ContentValues values = new ContentValues(1);
        values.put(Calls.NEW, "0");

        startUpdate(UPDATE_MARK_VOICEMAILS_AS_OLD_TOKEN, null, Calls.CONTENT_URI_WITH_VOICEMAIL,
                values, where.toString(), new String[]{ Integer.toString(Calls.VOICEMAIL_TYPE) });
    }

    /** Updates all missed calls to mark them as read. */
    public void markMissedCallsAsRead() {
        // Mark all "new" calls as not new anymore.
+4 −4
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ public class DefaultVoicemailNotifier implements VoicemailNotifier {
                .setContentTitle(title)
                .setContentText(callers)
                .setDefaults(callToNotify != null ? Notification.DEFAULT_ALL : 0)
                .setDeleteIntent(createMarkNewCallsAsOld())
                .setDeleteIntent(createMarkNewVoicemailsAsOldIntent())
                .setAutoCancel(true)
                .getNotification();

@@ -182,10 +182,10 @@ public class DefaultVoicemailNotifier implements VoicemailNotifier {
        mNotificationManager.notify(NOTIFICATION_TAG, NOTIFICATION_ID, notification);
    }

    /** Creates a pending intent that marks all new calls as old. */
    private PendingIntent createMarkNewCallsAsOld() {
    /** Creates a pending intent that marks all new voicemails as old. */
    private PendingIntent createMarkNewVoicemailsAsOldIntent() {
        Intent intent = new Intent(mContext, CallLogNotificationsService.class);
        intent.setAction(CallLogNotificationsService.ACTION_MARK_NEW_CALLS_AS_OLD);
        intent.setAction(CallLogNotificationsService.ACTION_MARK_NEW_VOICEMAILS_AS_OLD);
        return PendingIntent.getService(mContext, 0, intent, 0);
    }