[Sony Xperia T, TL, TX, V] pollob666:
For Developers: If you are planning to compile your ROM, and want to use this mod, then read This Post

Background Story:

I was missing the CyberShot Camera too much and found Google Camera has been ported to JB :D And I also wanted to try the Moded LifeLog app, which somehow was not working on my Pacman Rom.

These were the reasons I Decided to come back to JB Stock Base. I had a previous Nandroid Backup of Lovin's Z2 ROM for XV. I took all my Call-Log and SMS Backups and also took backup of some apps that I used. Then I restored the NAND Backup today.

after that I started restoring the apps+data. Everything was fine.

After few hours of using, As I always do, I took the periodic backup of my Call Logs again. That's when I noticed, the previous Logs were 700+ and now after making some calls, it came down to 500. after Some test, I found out, this is not problem of Backup software.

A little Google search revealed Android has a default call log limit set to 500 Calls.

I searched for Xposed Mod for this, found TrimNot. But it showed error. Most probably, it is only for KK. Then I thought why not MOD it myself?

That's how it all started...

The research & work procedure:

I first thought, OK, I need to find where the Calls are stored. After passing some time with Google, I found, the Logs are stored in a SQlite3 Database, in

/data/data/com.android.providers.contacts/databases/contacts2.db

There is no limit in this database storage. So, the limit must be in the code.

After another couple of hours, I found that Android checks if the contacts has reached 500 then removes the older. Searching with

in android API reference, where I found some leads on my research.

"public class CallLog" which is under "android.provider.CallLog"

Something told me, to look for this class, in the actual source code. But that's almost 30 GB and I don't have time. from some prior Java knowledge I knew, all class have their own source file, with the same name, So the name would be "CallLog.java"

Now I searched Google, with it and found exactly what I was looking for. The search took me to a Git page android/platform_frameworks_base

And here I found this code.

private static void removeExpiredEntries(Context context) {
final ContentResolver resolver = context.getContentResolver();
resolver.delete(CONTENT_URI, "_id IN " +
"(SELECT _id FROM calls ORDER BY " + DEFAULT_SORT_ORDER
+ " LIMIT -1 OFFSET 500)", null);
}

The file is located in

platform_frameworks_base/core/java/android/provider/CallLog.java

and from the name I guessed, this should be inside framework files. Then I went into action. I first tried to de-compile the framework-res.apk file. I used Advanced APKTool by BDFreak

Using the windows search tool, I searched for "call log". I found nothing. Then I tried to de-compile "framework.jar". For this, I followed guide by Rizal Lovins - [Share Latest Apktool 4.2.2/Guide/Tutorial/] How to Decompile/Compile/Sign Apk/Jar

after the de-compiling was Done, I found there is a "android/provider" folder. Yes, it look similar to "platform_frameworks_base/core/java/android/provider/CallLog.java"

So, here should be the files. And I found Two files

CallLog$Calls.smali
CallLog.smali

I opened both with Notepad++,

CallLog.smali gave me noting. :(

But after a careful search, I found the exact query inside the ]CallLog$Calls.smali file.

I found this line -

const-string v2, "_id IN (SELECT _id FROM calls ORDER BY date DESC LIMIT -1 OFFSET 500)"

I just changed 500 to 100000 and I knew my task was done.

I then recompiled the framework.jar and took backup of my original framework.jar (took Nandroid backup ;) ), replaced the original with my modified JAR file. Set the permission rw-r-r or 644. Then rebooted my phone.

Testing:

After the phone started, I made a call, then took backup of the Call Log with Call Log Backup Restore it showed 501. :D :D :D

This means my task is done.

Then I thought, why not share the whole experience today in XDA. So I started Writing this Guide. :D:D:D

F.A.Q.

Why I need more than 500 Call Log ?

- Well I work in Billing Department of a GSM Phone Exchange/Gateway. I periodically cross check my phone Call Logs with the Exchange SoftSwitch Data. Except for that, It's just fun to try something new.

Why this guide has no steps or required steps?

- Because, if anything I missed, those will be added later in the FAQ, from the comments.

Is this tested on any device?

-Yes,

My # Xperia V with LOVINS X™ Z2 ROM 9.2.A.2.5

# Xperia V NeoWave™ ROM

# Xperia TX OmniRom

# Xperia TX (unknown ROM :( )

# Xperia Z2 (unknown ROM :( )

# Xperia P Stock ROM

#Xperia P JB based Enigma v7.2 ROM

#CyanogenMod 11 M11 and M12

Can this work on my T/TX/TL/Z/Z1 etc. etc.

- Theoretically it should work on any Device and any ROM. But, practically, I don't know, why don't you try yourself and let me know ;)

I'm newbie, can you provide me more simple guide?

- Well I'm a Newbie myself :) Just take a Nandroid Backup and start the process. What can go wrong? At most you'll have to restore the backup.

Go to every link and read those too. And Don't forget to Thank those people who provided the Tools and Guides.

Still If you don't understand my guide, read it twice, if it doesn't work read again.

Ha Ha Ha kidding. :D:D:D:D Here you go A Simple guide

Update:

If you are planning to compile your ROM, and want to use this mod, then read This Post

I switched to NeoWave™ ROM and just as usual applied my MOD. Restored 800+ Call Log from Backup. Now I find another limitation. It's in the Dialer. In the KitKat Call History, there is a Statistics option. Here it always shows

So Now I'm digging the sources again to make the stats go higher. :D

Update: The issue was caused because, after sometimes (any call), the call history automatically turned to 500. Because the framework.jar was odexed and i guess, odex file had the old value set again. And for the NeoWave I used android MultiTool, it showed one error while compiling, Unsigned Short value exceeds, I didn't notice that. My bad. :o Now I have done the Mod again with Apktool (Lovins shared one) and removed the odex file and then Everything seems fine. Even the Statistics Shows, TOATAL: 1203 Calls, .... :D