Search code examples
androidsamsung-mobilecalllog

Bad CallLog Grouping after updating a Call Log on Samsung devices


INTRO:

I am creating an application that redirects a call to another number and then tone dials the actual target number. For example: every time I call a foreign number lets say "+46 123 4567" it actually redirects to a local number "+1 555 1234" and dials the foreign number as tones after a 2 sec. pause.

After the call I update the call log using CallLog.Calls so that the call log shows the actual target number (not the local proxy).

Everything works fine, My Nexus 5 and all emulators behave the way I want them to.

PROBLEM:

However on some Samsung devices (Specifically 4.2.2 Galaxy S2+ (GT-I905P)), a problem occurs:

If I place a call to lets say a UK contact and after that I place a call to SE (Sweden) contact both of these get grouped together in the Samsung call log. So instead of seeing two separate call logs:

enter image description here

I only see

enter image description here

As if I called the Swedish number twice, but that isn't true. It is obvious that somehow Samsung is still grouping the calls using the proxy number and ignoring CallLog.Calls when grouping calls.

When I check the output of CallLog.Calls all is like it should be: (The last two lines of the CallLog.Calls when ordered by DATE Ascending:

id: 25261 name: Test Uk number: 00446342845 duration: 2 new: 1 date: 1409833561100

id: 25262 name: Test SE number: 004629564647 duration: 3 new: 1 date: 1409833582098

HOW I UPDATE THE CALL LOGS:

    // get Log ordered by date, so that the newest is the last entry:
    Cursor cursor = context.getContentResolver()
            .query(CallLog.Calls.CONTENT_URI, null, null, null, CallLog.Calls.DATE);
    cursor.moveToLast();

    // get a field unique value from the cursor so that I know which field to update:
    // (should probably use _ID instead of date)
    long date = cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DATE));

    ContentValues cv = new ContentValues();

    cv.put(CallLog.Calls.NUMBER, destinationNumber); // update the number

    context.getContentResolver().update(CallLog.Calls.CONTENT_URI, cv,
            CallLog.Calls.DATE + " = ?"
           , new String[]{String.valueOf(date)});

So the question is: How does Samsung group these calls? And what can I do to counter this?


Solution

  • With an advice from a colleague I've actually solved this issue by doing a delete and insert instead of an update. Now the Samsung dialer groups the calls right.