[Droid Eris General] zanfur:
In case you missed the subject: ROOT REQUIRED.

Also, this issue only affects phones that are running Android 2.x *and* version 1.3 of the official Facebook app. Also, it only affects things synchronized by the Facebook app itself -- if you've used syncmypics, those pics are actually attached to your google account now, "manually".

As lots of you already know, android 2.x has a new contacts API, that allows sync providers (such as Facebook) restrict their information to just the system contacts app (and packages sharing the same uid). Facebook, in their infinite (lack of...) wisdom, has decided to mark their info as restricted, meaning that contact pics don't show up in, say, Dialer One, or any non-stock messaging or contacts widget. I'm reading in a bunch of places that this functionality was actually added at the behest of Facebook.

This. Is annoying.

Here's an incomplete list of common apps missing facebook pictures, that you would usually expect to have them:

Dialer One

SMS Popup

Google Voice

LauncherPro widgets

Pure Messenger Widget

This is particularly annoying, because there's not even a "permission" (so far as I'm aware) that you can grant apps to allow them access to "restricted" contacts. You just simply have to be running at uid 10000 (aka "app_0"). Individual apps can apparently get around this by ignoring the nice Android contact content provider API's and querying the database directly, but only a handful (such as Handcent and chompSMS) seem to do this.

There are a few ways around this globally (i.e. not on a per-app basis). Basically, you have three potential approaches:

Change the Facebook app to not mark it as restricted.

Change the API to ignore the silly "is_restricted" flag when enumerating contacts.

Change the restricted flag in the database itself.

Modifying the Facebook app ourselves is probably illegal, as it involves decompiling the facebook app, and I really don't want to tangle with their lawyers. We can hope that they release a new version without the stupid restriction, though.

We could change the API -- Android is, after all, open source. However, that means each ROM would have to include the modified library files to ignore the restriction. Also, there might be a time when you actually *do* want to keep some things restricted, so I'm not keen on simply removing the functionality. I just want to have the Facebook data unrestricted.

So, of course, I took option 3: Change it in the database. I now have face contact pics in Dialer One, as well as all of my 3rd-party applications, without needing to make any ROM changes, or even any application config changes. To make sure it *stays* that way when new content is added/updated, I added a couple triggers to the database to re-unrestrict it every time more facebook data is added or changed. In a single command, through adb. Here it is (MAKE BACKUPS FIRST):

adb shell sqlite3 /data/data/com.android.providers.contacts/databases/contacts2.db "CREATE TRIGGER unrestrict_new_data AFTER INSERT ON raw_contacts BEGIN UPDATE raw_contacts SET is_restricted=0 WHERE _id=NEW._id and NEW.is_restricted!=0 and NEW.account_type in ('com.facebook.auth.login'); END; CREATE TRIGGER unrestrict_updated_data AFTER UPDATE OF is_restricted ON raw_contacts BEGIN UPDATE raw_contacts SET is_restricted=0 WHERE _id=NEW._id and NEW.is_restricted!=0 and NEW.account_type in ('com.facebook.auth.login'); END; UPDATE raw_contacts SET is_restricted=0 WHERE is_restricted!=0 AND account_type in ('com.facebook.auth.login');"

Yeah, it's long. For the curious, I'll dissect the above command a little. Basically, it does three things: make an INSERT trigger, make an UPDATE trigger, and set everything that's already there to be unrestricted.

The INSERT trigger happens whenever a sync provider adds a new contact. This trigger will notice if it's a facebook contact trying to make a restricted contact (it leaves non-facebook ones alone), and overrides the is_restricted" flag, leaving it unrestricted.

The UPDATE trigger does the same thing, but it's triggered when a facebook contact has its is_restricted" flag changed back to restricted. It leaves all other changes alone.

The update itself takes all of your facebook contacts, and changes the "is_restricted" flag to unrestricted.

FYI, the "raw_contacts" table is where the sync providers actually store their data, including thumbnails. Yes, they're directly in the DB itself. There's a separate "contacts" table that's generated from the "raw_contacts" table, which is the list of things that are actually listed in your contacts application -- the "raw_contacts" table contains all the contacts you join together to create the ones in your normal list.

If, in the future, you want to override the "is_restricted" flag of other contact sync providers, just add it to the list in parens, comma-separated, that currently only says 'com.facebook.auth.login'.

Cheers!

Edited to add:

Handcent and chompSMS both seem to get the facebook pics just fine. Updated info above.