Send a broadcast when profile changes
Bug 7148705
Change-Id: I3df22b7fc18a106f221f022f222d8fee566a24af
diff --git a/src/com/android/providers/contacts/ProfileProvider.java b/src/com/android/providers/contacts/ProfileProvider.java
index ba10e8b..7fc0916 100644
--- a/src/com/android/providers/contacts/ProfileProvider.java
+++ b/src/com/android/providers/contacts/ProfileProvider.java
@@ -17,11 +17,13 @@
import android.content.ContentValues;
import android.content.Context;
+import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.CancellationSignal;
+import android.provider.ContactsContract.Intents;
import java.io.FileNotFoundException;
import java.util.Locale;
@@ -31,7 +33,6 @@
* database from the rest of contacts.
*/
public class ProfileProvider extends AbstractContactsProvider {
-
private static final String READ_PERMISSION = "android.permission.READ_PROFILE";
private static final String WRITE_PERMISSION = "android.permission.WRITE_PROFILE";
@@ -144,6 +145,7 @@
@Override
public void onCommit() {
mDelegate.onCommitTransactionInternal(true);
+ sendProfileChangedBroadcast();
}
@Override
@@ -166,4 +168,9 @@
public String toString() {
return "ProfileProvider";
}
+
+ private void sendProfileChangedBroadcast() {
+ final Intent intent = new Intent(Intents.ACTION_PROFILE_CHANGED);
+ getContext().sendBroadcast(intent, READ_PERMISSION);
+ }
}
diff --git a/tests/src/com/android/providers/contacts/ContactsActor.java b/tests/src/com/android/providers/contacts/ContactsActor.java
index e75c52e..7a30244 100644
--- a/tests/src/com/android/providers/contacts/ContactsActor.java
+++ b/tests/src/com/android/providers/contacts/ContactsActor.java
@@ -28,6 +28,7 @@
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -341,6 +342,16 @@
public void enforceCallingOrSelfPermission(String permission, String message) {
enforceCallingPermission(permission, message);
}
+
+ @Override
+ public void sendBroadcast(Intent intent) {
+ mOverallContext.sendBroadcast(intent);
+ }
+
+ @Override
+ public void sendBroadcast(Intent intent, String receiverPermission) {
+ mOverallContext.sendBroadcast(intent, receiverPermission);
+ }
}
static String sCallingPackage = null;