I'll talk through the steps for enabling the sync for ROM devs and provide the bits and pieces needed to do so. I specifically decided to try and find a solution that doesn't involve hacking about with the Facebook APK itself. This is because I wanted end users to be able to continue receiving app updates.
<strong class='bbc'>Step 1 - ContactsProvider</strong>
In previous versions of Android, simply making a tweak to the ContactsProvider would allow sync to work. We still need to do this in ICS. If you're working on a disassembled ContactsProvider APK, the file in question is res/values/arrays.xml. In contrast to previous versions, this file doesn't actually exist in the ICS packages, you need to create it. When you do so, the content needs to be as follows:
<pre class='prettyprint'><?xml version="1.0" encoding="utf-8"?><resources> <string-array name="unrestricted_packages"> <item>com.facebook.katana</item> </string-array></resources></pre>
Simply, this adds the Facebook app (com.facebook.katana) to a group which has elevated access to contacts.
I've uploaded a ready-to-go ContactsProvider APK if you'd like to use / take a look at one - <a href='http://www.filefacto...ctsProvider.apk' class='bbc_url' title='External link' rel='nofollow external'>download ContactsProvider.apk</a>
<strong class='bbc'>Step 2 - contact database tweak</strong>
After adding this to ContactsProvider I hoped it would 'just work' but sadly, it didn't. No contacts. Upon digging deeper in logcat, I could see a bunch of errors when it tried to sync the Facebook contacts into the database. Nothing too tricky, just a missing column in the database. The column is_restricted was previously in the contacts database, but is no longer present. Simple enough... we can use a SQLite binary to put the column back in the database. So, I did just that, rebooted and hey presto - contacts syncing!
Now, obviously we don't want users to have to drop to a command line and run a SQLite command, so I built a custom script that is run from /system/etc/init.d on startup that adds the relevant column. This relies on a sqlite3 binary being present in /system/xbin. This is a good way of doing things because init.d is run before any process could be doing anything with the contacts DB. There is a minor issue in that if the contacts DB doesn't exist (e.g. on first boot) it can't work it's magic, and therefore Facebook sync won't work until the user's second boot.
I've uploaded my script for init.d and my sqlite binary (ensure you use one suitable for your device's architecture) if you'd like to use them - <a href='http://www.filefacto...0d/n/99complete' class='bbc_url' title='External link' rel='nofollow external'>download 99complete</a> / <a href='http://www.filefacto...dfd08/n/sqlite3' class='bbc_url' title='External link' rel='nofollow external'>download sqlite3</a>
<strong class='bbc'>And that's it!</strong>
If you have any thoughts / questions, feel free to post them. I'll be updating this post as I tweak / improve the process. Hope this info is useful! If so, and indeed if you use this info, please consider linking back to this page.
Cheers!
This item was promoted to the News page - click here to view.







Sign In
Create Account



Back to top










