FaceBook Sync for Android ICS Devices [ Updated Aug 01 '12 ]

If you are one of the unlucky ones who can’t make the original Facebook Application to sync its contacts with your phone / Google contacts  on Custom ROMs such as AOKP , ( CyanogenMod ) CM9   or MIUI . This  solution is the solution for you. It ‘will make the original FB application Sync it’s contacts with the Contacts app. I’ve created a flashable zip method using CWM and another one using ADB+Windows as well.

This will enable Sync dialog on the original  Facebook application  , just like it used to do on Gingerbread.

Screenshot_2012-05-29-19-25-21                 Screenshot_2012-05-29-19-25-08

Update [Aug 1] : Files Updated.
Based on    MIUI 2.7.27   ,   CM9  2012-07-31  &    AOKP MileStone 6

Update ->I won’t be able to update the files weekly anymore. But i will try to update them whenever i can get them to be updated.

Files are available at the bottom of this post. Read the instructions if you don’t want to see a lot of FC’s popping up.

 

Note:

  • If  the Contact Pictures are not loading, give it some time and keep the contacts application on with internet connected. It is slow , and it is because of slow FB servers.
  • If  this whole thing leaves you into a bootloop ( very unlikely )  or lot of FC’s ( very much likely if you didn’t reboot / if you flashed the wrong zip )  , You can reflash your current ROM to fix it.  Eg: If you were on the CM9  2012-07-31  , flash the CM9  2012-07-31.zip  again over your phone. No need to wipe and no need to format to revert this -hack- back.

 

PreRequisites

  1. You should have ClockWorkMod ( CWM ) Recovery in your phone for doing it via Method#1.
  2. You should be having atleast one account or phone number in the phone book , This is to ensure that contacts database is intialized. So -DO NOT- flash this directly after wiping or installing a new ROM, do it after a boot.

Method#1 Using ClockWorkMod Recovery

Files :  Download the corresponding file from below( Filenames have date  and ROM mentioned)

Steps:

  1. Copy the appropriate ZIP file for your phone/ROM  to your SD card.
  2. Reboot your phone to recovery mode . You will need ClockWorkMod Recovery 3+ for this tweak to work.
  3. Go to ‘Mounts and Storage’.  Mount  ‘data’  (  and  ‘datadata’ if it is present ). This step is very important.
  4. Choose update from sdcard. Locate the ZIP file and update it.
  5. Reboot.
  6. Add FB account ( FB accounts which you had added before wont sync properly, so delete it and add again).
  7. Sync it.

Method#2  - Using Windows+ADB .


Files :  Download the corresponding file from below( Filenames have date  and ROM mentioned)

  1. Download the ‘FBSync_ADB_xx’ zip file  corresponding to your ROM.
  2. Extract it to a folder. For eg: to your desktop.
  3. Connect your phone in debug mode.  ( You can enable debugging mode from your phone Under Development > Enable Debugging mode ) .
  4. Run  patch_db.cmd with administrator privileges ( this is a must  if you have UAC enabled ). For this, Right click ‘patch_db.cmd’ and select ‘Run as Administrator’
  5. Reboot the phone.

Warning

  • If you wipe the phone/contacts, you will have to flash the zip again.
  • Flash it after booting it once onto your phone and adding an account other than FB, preferably. This is to ensure that the database has been created. If you already have accounts , clear them , leave one phone contact preferably.
  • I’m not responsible for any data loss. If you mismatch the ROM and ZIP then it’s bound to soft-crash the phone.

Detailed Explanation:

  1. Facebook application can sync its contacts with the Contacts ( Through ContactsProvider ) only when its whitelisted ( or, in other words , given an escalated permission set ) in the ROM.
  2. For this , You have to edit the ContactsProvider.apk  and add the whitelisted permission.
  3. For editing the ContactsProvider.apk ( Which resides in the /system/app/ directory) ,You will need smali ( An assembler/disassembler for Android’s dex format ).
  4. After disassembling the ContactsProvider.apk using smali , Go to the res/values/ folder ( in the disassembled source ) , and add the file ( arrays.xml ) containing the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <string-array name="unrestricted_packages">
            <item>com.facebook.katana</item>
        </string-array>
    </resources>
  5. The  com.facebook.katana is the application of facebook. So after adding the arrays.xml file to the /res/values/ folder, Assemble the ContactsProvider using the smali into an unsigned apk file.
  6. Now , Since ICS , Android 4.0 , Google has disabled this provision of whitelisting applications natively , hence they have obfuscated certain fields from the database.
  7. Add the column named
    is_restricted

    to the raw_contacts table inside contacts2.db ( stored in /data/data/com.android.providers.contacts/database/ )

  8. If you have sqlite enabled ( along with busybox ) in your kernel you can use this command for altering the database and adding the necessary field by running it under ADB Shell:
    sqlite3 /data/data/com.android.providers.contacts/databases/contacts2.db
     'ALTER TABLE raw_contacts ADD COLUMN is_restricted VARCHAR';
  9. After adding the column, all the facebook accounts added will be provided with Sync Prompt and they will appear under contacts.

 Compatibility Reports

[ Refer to my XDA Post ]

Files

Name Date
Name Date
ADB
FBSync ManualBuild ADB AOKP 2012-08-01 August 1, 2012
FBSync ManualBuild ADB CM9 2012-08-01 August 1, 2012
FBSync ManualBuild ADB MIUI 2012-08-01 August 1, 2012
FBSync ManualBuild ADB MIUI Galaxysmtd 2012-08-01 August 1, 2012
FBSync ADB AOKP 2012-06-28 0105 June 28, 2012
FBSync ADB AOKP 2012-08-01 0742 August 1, 2012
FBSync ADB CM9 2012-06-29 0510 June 29, 2012
FBSync ADB CM9 2012-08-01 0741 August 1, 2012
FBSync ADB Galaxysmtd MIUI 2012-08-01 0740 August 1, 2012
FBSync ADB MIUI 2012-06-28 0105 June 28, 2012
FBSync ADB MIUI 2012-08-01 0740 August 1, 2012
CWM
FBSync AOKP 2012-06-28 0105 June 28, 2012
FBSync AOKP 2012-08-01 0742 August 1, 2012
FBSync CM9 2012-06-29 0510 June 29, 2012
FBSync CM9 2012-08-01 0741 August 1, 2012
FBSync ManualBuild AOKP 2012-08-01 August 1, 2012
FBSync ManualBuild CM9 2012-08-01 August 1, 2012
FBSync ManualBuild MIUI 2012-08-01 August 1, 2012
FBSync ManualBuild MIUI Galaxysmtd 2012-08-01 August 1, 2012
FBSync MIUI 2012-06-28 0105 June 28, 2012
FBSync MIUI 2012-08-01 0740 August 1, 2012
FBSync MIUI Galaxysmtd 2012-08-01 0740 August 1, 2012

 

Tagged with: , ,
Posted in Android, Tweaks
92 comments on “FaceBook Sync for Android ICS Devices [ Updated Aug 01 '12 ]
  1. Nidhin Kakotil says:

    no luck!! din works on my ZTE Blade

  2. Francois says:

    Hi,

    Tried both automated and manual versions and not syncing even if the table is updated. Running AOKP M5.

    Thanks

  3. Lain says:

    Made my G2X slow as crap.

    • ContactsProvider alone cannot make your phone lag. Yes, it will lag , but only while it’s syncing for the first time. It’s dedicated for contacts storage. Why would it make the phone lag when you are not accessing contacts. Check your other apps. ;-) .

      • Lain says:

        It wasn’t just the contacts, it was the home screen and completely unrelated apps. I’ll try giving it a little time.

        • It shouldn’t lag the other apps at all, ideally. Did you check the activites for CPU usage. You can do it by ticking “Show CPU Usage” under “Development Tools” in settings. This can’t be in no way related to contacts database. Maybe it’s the FB app , since it’s working now, it might be running your CPU. Tell me if you found out what’s happening. :-) .

  4. Kyle says:

    Hey man, this is phenomenal. Should get the word out.

    Only one question, will this push the hi-res photos from Facebook to my contacts (picture)? I assumed it would since the actual sync worked, but I have been messing with my gnex for about 10 minutes and it doesn’t seem like the pics are coming over.

    • It should get the default res pics that the facebook used to pull from fb server in gingerbread. It’s 128px square ones i think on my SGS i9000 .

      However the image pull is buggy at times. just remove the fb account and sync again and it will start syncing. It didn’t sync for me in 1 out of 10 times.

  5. Josiah says:

    Works on a Galaxy S2 Telus/T-Mobile variant. Seemed a bit quirky at first with some FCing, but it sorted itself out. Pretty sure I just wasn’t being patient enough with it. Anyways, synced contacts, but I’m not seeing any pictures.

    • That is a bug, I do not know what’s happening with that. It is syncing pics with mine But not always. Can you try removing the FB account and try adding it again from “Accounts & Sync” . Also if that doesn’t work , try clearing FB app data.

      Also tell me which ROM you were using as well. :-) . Thanks.

  6. Charlie says:

    The latest zip files don’t seem to be uploaded correctly? Their file size is only about 50 kb.

  7. Frog says:

    All the download links give me page not available ?

  8. Michele says:

    Links for download leads to a 404.

  9. Frog says:

    Many Thanks Its Working!!! Cheers. Good Job!

  10. Pietro says:

    with cm9 on wildfire s method 1 don’t work.. error during zip update..

  11. ovi sirb says:

    Any way to remove this once installed?

  12. k4rtik says:

    Thanks a lot buddy. The mod works perfectly! I appreciate you shared details about why it works too, keep up the good work. :)

  13. yonny says:

    Great job! I was looking for something like that.
    Any Idea if it would work on Slim ICS? I think it is based on AOSP so I’m not sure which zip to download.

    Thank you for you effort!

  14. mikelav466 says:

    I can confirm that this is working for the Epic 4G Touch running the 6/17 cm9 nightly. Thank You!

    Question: how do I get my peoples app to look like yours(orange, menu changes, etc…)?

  15. Droidalicious says:

    The links are leading to a 404 page again!

  16. Zach Medhaug says:

    It works on us cellular Samsung galaxy s2 sch-r760 thanks

  17. Charles says:

    Dude, your brilliant! Worked on T-Mobile Galaxy SII running the latest AOKP nightly. I did have to clear Facebook data and remove and add the account under “Accounts and Sync” to get the pictures to finally sync.

  18. Janish Aggarwal says:

    I am using CM9 nightly dated 13-06-2012 on Galaxy S. Which of the two files should I use? And what’s the difference??

  19. Worked for me no problems on my Sensation running CM9

  20. lehi says:

    will it work on galaxy s plus?

  21. Tim says:

    Just tried it through CWM on my Galaxy SII Skyrocket running AOKP 40, works flawlessly.

  22. Eric says:

    Now I have my FB contacts sync’ed OK, but my Whatsapp contacts aren’t sync’ed anymore :( (

  23. User says:

    Patch don’t work, the phone power off after reboot… i have to format the phone and lose my files.. thanks

    • You could’ve reflashed your ROM like i mentioned in the post instead of formatting. Your comment doesn’t have any information on which ROM and which Phone. That’s a no thanks.

  24. raichlea says:

    Just tried this via CWM on a Nexus S running CM9-RC1 and as soon as I booted back into the OS I started getting repetitive messages about different critical system processes stopping. I can’t use my phone. Can I roll this back somehow? Help, please!

  25. Mohit says:

    Niranjan, MIUI v2.6.29 is out, could you please make a cwm flashable zip for the fix. Thanks a ton!

  26. Jorge Figueroa says:

    Wich one is compatible with this ROM?

    forum.xda-developers.com/showthread.php?t=1618757

  27. Ankur Verma says:

    Please compile a package for SlimICS ROM.

  28. GaryJohnSr says:

    Niranjan Thilak – YOU, my friend – are awesome!!

    CWM worked like a charm. EVO4G ROM=cm-9-20120706-UNOFFICIAL-supersonic.zip

    Thank you!!!

  29. Droidalicious says:

    Just tried the latest with AOKP M6 and it isn’t working

  30. Excellent! Cant thank you enough for this. Im using Resurrection Remix, and the only issue I had, was my contacts not syncing from facebook. It’s sorted now! Much appreciated!

  31. Nitemahre says:

    Thanks so much for the hard work!

    Device: HTC One S
    ROM: CM-9-20120708-unofficial-ville
    Method #1: FBSync CM9 2012-06-29 0510, apparently, also works with TWRP, as this is the recovery I have installed on my HTCOS.

  32. JiCiT says:

    Works on LGVM670 Running quattrimus CM9 beta1 using the FBSync ADB CM9 2012-06-29 0510 fix.

    • Rocky says:

      Thanks so much for the great writeup. Is the process the same for Jellybean? I understand that jellybean natively syncs phone number, but does not pictures. I tried the above process. Contacts2.db already has the is_restricted column. However, when I installed the altered ContactsProvider.apk – I lost all my contacts and gapps failed (backed up with Ti-backup though). I used apktool the assemble the directory after adding the array xml. I am using PureAOSP jellybean rom for the galaxynexus toro. (I have tried Haxsync – but some of the pictures are cropped unfavorably)

  33. Adam says:

    Seems to work on Galaxy S3 running AOKP M6 too! ;-)

  34. himanshu says:

    it works for lg p500 optimus one AOKP custom rom ???

  35. DigitalSpider says:

    Working on Motorola Atrix 4G CM9 / AOKP

  36. Amir says:

    Hey!! I wanna thank you for the great work! Do you think you can put up a version for CM10?? I am on i9300 International Version, and the only thing stopping me from going to CM10 is the Facebook Sync issue!

  37. Tobe says:

    Confirmed to work on the Galaxy S 4G (SGH T595V) on the Unofficial CM9 Port. Much thanks bro!

  38. Ashray says:

    Thanks! I used FBSync CM9 2012-06-29 0510 – June 29, 2012, on Maclaw Studio’s CM9 Beta 10 on Samsung Galaxy Ace. Worked great!

  39. ABHISHEK says:

    hey i m using AOKP Milestone 6 with Samsung Galaxy S GT-I9003
    i m unable to file for my rom

    • The AOKP file should work for all the phones. If it doesn’t like in some rare cases ( It was rare till the last time i updated. ) , i can’t do it for all the phones. No time mate. Sorry. :-( . Too many phones out there .

  40. Protogon says:

    I’m running an unofficial CM10 build for the S4 HTC One X (a ROM you don’t support), and am trying to modify the ContactProviders.apk myself. After disassembling its classes.dex with baksmali, I found no ‘res’ directory in the ‘out’ directory. I found that when I tried to do the same with the ContactProviders.apk found in the CM9 zip, there was also no ‘res’ dir.

    Is there some flag I have to use with baksmali? Am I not supposed to use baksmali to disassemble the dex file?

    • Simpler steps:

      1) Get AutoAPKTool ( Google for it. It will be there in xDA.
      2) Load the framework-res.apk ( Option 1)
      3) Decompile ContactsProvider.apk ( Option 6 )
      4) Recompile & Build ( Option 9 ) .
      5) Use the APK from Zipaligned folder.
      6) Replace the APK in the zip file with this new one ( one of the zip files from my site)
      7) Flash it.

  41. Froggy says:

    Thanx for a great job!!

  42. Skizz McNizz says:

    AT&T One X running aokp 6.2. I used the aokp manual build: FBSync ManualBuild AOKP 2012-08-01 and it’s working fine. Thanks!

  43. Leo says:

    Installed “FBSync AOKP 2012-08-01 0742 August 1, 2012″ on my Resurrection Remix ics v2.6.1 ROM, using CWM, removed and added the FB account – works great!
    Thanks!

  44. matias says:

    genious!

  45. androiddd says:

    Thank you it worked perfectly on my first try!!

  46. MR says:

    beautiful man! its working like a charm on SGS (GT i9000) with the CM9 stable.
    downloaded the CWM went through the install, added new FB account and EVERYTHING is as it used to be on Gingerbread!!!
    THANK YOU!!!!

5 Pings/Trackbacks for "FaceBook Sync for Android ICS Devices [ Updated Aug 01 '12 ]"
  1. [...] and makes a few changes to the database for the sync to work. Read it at my blog : http://niranjanthilak.com/facebook-s…d-ics-devices/ Patch should work for all devices. But i've managed to test it on SGS i9000 MIUI/AOKP/CM9 and [...]

  2. [...] X Today 06:47 PM #4 found a fix here …. FaceBook Sync for Android ICS Devices | Niranjan Thilak CM 7.1.0 Reply With Quote + Reply to Thread [...]

  3. [...] (update if these steps do not work for you) 1: updating FB contact, Steps can be found here: FaceBook Sync for Android ICS Devices | Niranjan Thilak it has worked for me without faults. 2: Merging contact steps for CM9 with current Nightly: open [...]

  4. [...] google (brak zdjęć znajomych i urodzin/wydarzeń w kalendarzu) Jakaś rada? A proszę bardzo FaceBook Sync for Android ICS Devices | Niranjan Thilak Bez żadnych dodatkowych aplikacji, synchronizuje tylko, że bez zdjęć. ( przynajmniej u mnie ) [...]

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 12 other subscribers