Quantcast
Channel: xda-developers - Android Software and Hacking General [Developers Only]
Viewing all articles
Browse latest Browse all 3614

[GUIDE] Fix CALL ID not matching to contacts [MT6577] [MT6516]

$
0
0
I've noticed that ROMs not matching incoming calls/messages to exsisting contacts, it is a reocurring problem. Many have struggled to get a grip on this, some have succeeded. I see apps like Prefixer and ExDialer can leviate the problem to a degree.

I have no experience with ExDialer - but I've heard good things about it. As I understand, it is a 3rd party dialer - so I would believe it can do alot on the contact processing side. What I do know about Prefixer, is that it can, with the right ruleset, be configured to match caller ID to contacts - but the product will be a popup, as no app (afaik) can direcly interfere with the call ID.

Now the point of this thread, is not to instruct in how to work around the issue with apps - but how to fix it. The problem resides within the framwork.

This will require your phone to be rooted!
THESE INSTRUCTIONS ARE FOR MT6577 AND MT6516 ! I STRONGLY ADVICE AGAINST APPLYING THEM TO OTHER SETS WITHOUT PROPER ADJUSTMENTS !

There are methods to do this straight off your phone - if you posess the skill to work with Java VM and baksmali/smali on Android, I guess the code strings are the only useful thing for you here.

---------------

I'm doing this off a Windows 7 platform, 4.1.2 ROM on MT6577, but I'm hoping anyone working on a (very) different platform, is capable of adapting the instructions - and hopefully append them to this thread.

There are a few things you will need.
  • Your phone - USB connection or SD card reader.
  • An android file explorer with root privileges (ES File Explorer is a worthy free alternative).
  • Java Runtime Environment or Java Developement Kit
  • Smali & baksmali (the .jar files)
  • 7zip or any other tool able to extract & replace contents of .jar files - they are basicly zip files]
  • A text editor. Notepad or similar will suffice, as long as it saves as text only (no processing).
  • Command prompt.
This guide is Step.... by... step... - if you managed to root your phone, I can't see you struggling with this.

For those of you quite competent with working with Android and console work, I did a highly shortened version :

 
  • Make sure Java RE or JDK is installed.
  • Download baksmali and smali (.jar) from the above locations (suggest renaming them to remove verison tag).
  • have a zip tool available.
  • mount /system in android and copy /system/framework/framework.jar to SD, and then copy to computer.
  • rename framework.jar on SD to framework.bak (^^,)
  • Put baksmali.jar, smali.jar and framework.jar in a directory.
  • Unzip framework.jar to current folder (.jar is basicly .zip, so temporary rename to .zip if it makes it simpler (just rename it back to .jar afterwards)
  • run in (in current folder) in console: java -jar baksmali.jar -o classes classes.dex
  • Delete classes.dex
  • Open /classes/android/telephony/PhoneNumberUtils.smali
  • Refer to Step 8 in the guide for code changes - save(!).
  • Back in directory with baksmali & smali and /classes, run command: java -Xmx512M -jar smali.jar classes -o classes.dex
  • Replace newly compiled classes.dex with old classes.dex inside framework.jar
  • For cleanliness, delete /classes
  • Copy new framework.jar to SD
  • Mount /system/framework as RW, replace old framewirk.jar with new.
  • Set permissions for new framework.jar : rw- r-- r-- (All read, user write)
  • Unmount /system/framework RW (RO)
  • Reboot.



Step 1.
MAKE A BACKUP! ALWAYS! Make a backup. I suggest a dup type backup with CWM, and copy it to your computer before proceeding. A recent edition of CWM or other custom recovery capable of mounting root and /system to USB, is highly recommended.


Step 2.
If you're uncertain if you already have Java RE/JDK installed, pull up a command prompt (Windows button, type CMD in the search field and hit enter. now type JAVA and hit enter. If you get a long list if command switches ( -xxxx etc), you already have Java RE or JDK installed. If not, download and install from the above source. Type exit and hit enter to close the command prompt window.

Install 7zip if needed.


Step 3.
Now make yourself a directory to work in - C:\WORK\ will do fine (short path). Download the the smali and baksmali .jar files to this directory. I suggest renaming them to just smali.jar and baksmali.jar - to make the following instructions fully compatible with future releases.


Step 4.
Open up a file explorer with root privileges (instructions here for ES File Explorer). Push the / button up top, to go to root. Next, go to 7system/framework. Find framework.jar, long-press it to mark it. Push your menu button and select Copy to. Select root on your SD card, and hit OK. Now exit the explorer.


Step 5.
Connect your phone to your computer, mount USB (or insert your SD card in reader) - and copy the framework.jar file, to the folder you placed the smali.jar and baksmali.jar files in (C:\WORK\).

Your folder should now contain smali.jar , baksmali.jar and framework.jar.

Open framework.jar in 7zip (or compatible software), and extract classes.dex to the same directory (C:\WORK\).


Step 6.
Open a command prompt (windows button, type CMD in search field, hit enter).
Now run the following commands (Only the bold, Enter after each command): CD\WORK - next, java -jar baksmali.jar -o classes classes.dex .

This could take a little time to process, just be patient and wait for the prompt to return.


Step 7.
Now leave the command prompt window open, go back to your (windows) explorer. You will find a new folder within your work folder (C:\WORK), called CLASSES. Here (in C:\WORK\) you should delete the classes.dex file, as its no longer needed. Now navigate to the folder CLASSES/ANDROID/TELEPHONY/. Therein you shall find a file called PhoneNumberUtils.smali. Open it in your preferred text editor (Notepad etc.)


Step 8.

FOR MT6577!

Search for the following lines (I suggest searching for .local v7, minMatchLen:I and .local v0, minMatchLen:I, as the const/4 part can vary between ROMs) :

Code:

.local v7, minMatchLen:I
const/4 v7, 0xb

and
Code:

.local v0, minMatchLen:I
const/4 v0, 0xb


Now change these sections to:

Code:

.local v7, minMatchLen:I
const/16 v7, 0x7

and
Code:

.local v0, minMatchLen:I
const/16 v0, 0x7



FOR MT6516!

Search for the following line :

Code:

.field static final MIN_MATCH:I = 0xB
Change this line to:

Code:

.field static final MIN_MATCH:I = 0x7
Now heres something to bare in mind; The 0x7 part is the minimum number of ciphers (in hexadecimal) in a Call ID number, before it attempts to do a lookup (I guess the exception might be exact match - don't quote me on this). As most of these phones originate from Asia - China and philippines etc, these countrys have seriously long phone numbers when including area codes - 10-11 ciphers +. I guess thats where the value 0xb originates from, as B is hexadecimal for 11. SO - if you should happen to live in a country (don't know if there is any really), where phone numbers (without prefixes) are less than 7 digits, OR you need to store a contact to identify a Call ID with less than 7 digits (some companies or public services use these) - then you might want to change this to a lower value than 7.

Now, save the file and exit the editor.



Step 9.
Now go back to the command prompt window, and run the following command: java -Xmx512M -jar smali.jar classes -o classes.dex
This too will take a little while, just be patient. When the operation is done and the prompt is back, you're done with the console. Type exit and hit enter, or just close the window. You now have a new classes.dex file in your work directory.


Step 10.
You now need to open the framework.jar file in 7zip again, assuming that you closed it. You can delete the old classes.dex (within the framework.jar file! Not in C:\WORK\ !) first, or just directly drag the new classes.dex file into the open 7zip window - it will replace the old file if you didn't delete it manually first. Then, close 7zip, save if prompted.


Step 11.
Time to get the new framework.jar into is place. Copy the file to the root of your SD card, and open up ES File Explorer again. Push the / button up top, to go to root. Now, press the menu button, and select Root Explorer, then Mount R/W. Now check RW for /system. Now go to /system/framework/. Now find framework.jar and long-press to mark it, select Rename at the bottom, and rename it to framework.bak. This is now your backup. Again, long-press to mark the file (now framework.bak), hit the menu button, select Copy to. It should already be showing the root of your SD card - if not, navigate there, and push OK.

Next, hit the / button up top again to go to root. Go to /sdcard, find your freshly modified framework.jar (make sure its the .JAR, not .BAK) - long-press to select. Select Cut at the bottom. Now, Push the / button up top, to go to root, then go to /system/framework/. Hit Paste at the bottom.

Now here's a VERY important part! Long-press to mark the newly pasted framework.jar. Hit the menu button, and select Properties. The bottom field where it says "Permissions", press Change. The following permissions should be set (checked): READ: All. WRITE: User. All other permissions unchecked. Hit OK, then Cancel. Next, hit the menu button, select Root Explorer, then Mount R/W. Set /system back to RO. Hit OK, and exit the application.


Step 12.
If you want, you can copy the Framework.bak file to your computer for safekeeping. Other than that, it is time to reboot the phone. As there has been changes to the framework, it needs to optimize your applications again during the first boot - this will take a a few moments - much depending on how many apps you've got installed.

Thats it! *pew*

---------

If for any reason you should be stuck in a bootloop - boot into CWM and either restore the backup you made - or mount /sdcard and /system, and then mount to USB. Replace the framework.jar with the framework.bak you made a copy of, go into "Advanced", do "Fix Permissions", and reboot.

Now, although I spent some hours compiling an easily understandable method of applying these modifications - I'm not gonna try to take credit for working out what was wrong here. I'm not absolute certain who did that work, but the earliest I could trace back the MT6516 code, was Bruno Martins, A mod and ROM cooker over at eten-users.eu. The MT6577 code traced back to gommers1978, a senior member here at xda-developers. I also want to thank zeppelinrox here at xda-developers for helping me understand the parameters better.

--------

If this HOWTO helped you in any way, or you just feel inclined to thumbs'up it - I would really appreciate it if you gave the "Thanks" button a hit - I'm still new here, and could use all the creds I can get :)

Viewing all articles
Browse latest Browse all 3614

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>