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.
Update [Aug 1] : Files Updated.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.
Based on MIUI 2.7.27 , CM9 2012-07-31 & AOKP MileStone 6
- 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.
- You should have ClockWorkMod ( CWM ) Recovery in your phone for doing it via Method#1.
- 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:
- Copy the appropriate ZIP file for your phone/ROM to your SD card.
- Reboot your phone to recovery mode . You will need ClockWorkMod Recovery 3+ for this tweak to work.
- Go to ‘Mounts and Storage’. Mount ‘data’ ( and ‘datadata’ if it is present ). This step is very important.
- Choose update from sdcard. Locate the ZIP file and update it.
- Add FB account ( FB accounts which you had added before wont sync properly, so delete it and add again).
- Sync it.
Method#2 – Using Windows+ADB .
Files : Download the corresponding file from below( Filenames have date and ROM mentioned)
- Download the ‘FBSync_ADB_xx’ zip file corresponding to your ROM.
- Extract it to a folder. For eg: to your desktop.
- Connect your phone in debug mode. ( You can enable debugging mode from your phone Under Development > Enable Debugging mode ) .
- 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’
- Reboot the phone.
- 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.
- 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.
- For this , You have to edit the ContactsProvider.apk and add the whitelisted permission.
- For editing the ContactsProvider.apk ( Which resides in the /system/app/ directory) ,You will need smali ( An assembler/disassembler for Android’s dex format ).
- 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>
- 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.
- Now , Since ICS , Android 4.0 , Google has disabled this provision of whitelisting applications natively , hence they have obfuscated certain fields from the database.
- Add the column named
to the raw_contacts table inside contacts2.db ( stored in /data/data/com.android.providers.contacts/database/ )
- 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';
- After adding the column, all the facebook accounts added will be provided with Sync Prompt and they will appear under contacts.
[ Refer to my XDA Post ]