Fix broadcast of CONTACTS_DATABASE_CREATED intent.

The intent needs to be fired after database creation in case the user does
a clear data.  This is needed in addition to the boot receiver to cover
all cases.

Bug: 11570016
Change-Id: Iaa3d952cc6db0a9c0e55e209f5fe41919ae7250a
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
index 4cd01eb..068e595 100644
--- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java
+++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
@@ -1358,6 +1358,14 @@
 
         ContentResolver.requestSync(null /* all accounts */,
                 ContactsContract.AUTHORITY, new Bundle());
+
+        // Only send broadcasts for regular contacts db.
+        if (dbForProfile() == 0) {
+            final Intent dbCreatedIntent = new Intent(
+                    ContactsContract.Intents.CONTACTS_DATABASE_CREATED);
+            dbCreatedIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+            mContext.sendBroadcast(dbCreatedIntent, android.Manifest.permission.READ_CONTACTS);
+        }
     }
 
     protected void initializeAutoIncrementSequences(SQLiteDatabase db) {