diff options
author | Debashish Chatterjee <debashishc@google.com> | 2011-07-01 08:08:49 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-01 08:08:49 -0700 |
commit | b0664c37411783238fd92f8a027b5820992cf899 (patch) | |
tree | edf2519d907788f5bc66ea0dc623b0fb0e32c913 /src/com | |
parent | 224d8a1d4b65b706951e0e15dd1f31f2c7921516 (diff) | |
parent | 975d52af754e6f05089fcd9f7066df05c290c3b7 (diff) | |
download | packages_providers_ContactsProvider-b0664c37411783238fd92f8a027b5820992cf899.zip packages_providers_ContactsProvider-b0664c37411783238fd92f8a027b5820992cf899.tar.gz packages_providers_ContactsProvider-b0664c37411783238fd92f8a027b5820992cf899.tar.bz2 |
Merge "Fixed VoicemailProviderTest."
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/providers/contacts/VoicemailContentProvider.java | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/com/android/providers/contacts/VoicemailContentProvider.java b/src/com/android/providers/contacts/VoicemailContentProvider.java index 5e17a33..1ae4522 100644 --- a/src/com/android/providers/contacts/VoicemailContentProvider.java +++ b/src/com/android/providers/contacts/VoicemailContentProvider.java @@ -19,13 +19,16 @@ import static com.android.providers.contacts.util.DbQueryUtils.checkForSupported import static com.android.providers.contacts.util.DbQueryUtils.concatenateClauses; import static com.android.providers.contacts.util.DbQueryUtils.getEqualityClause; +import com.android.providers.contacts.ContactsDatabaseHelper.Tables; +import com.android.providers.contacts.util.CloseUtils; +import com.android.providers.contacts.util.TypedUriMatcherImpl; + import android.content.ContentProvider; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.content.Intent; -import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; @@ -38,18 +41,11 @@ import android.provider.VoicemailContract; import android.provider.VoicemailContract.Voicemails; import android.util.Log; -import com.android.providers.contacts.ContactsDatabaseHelper.Tables; -import com.android.providers.contacts.ContactsDatabaseHelper.Views; -import com.android.providers.contacts.util.CloseUtils; -import com.android.providers.contacts.util.DbQueryUtils; -import com.android.providers.contacts.util.TypedUriMatcherImpl; - import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; // TODO: Restrict access to only voicemail columns (i.e no access to call_log // specific fields) @@ -398,10 +394,7 @@ public class VoicemailContentProvider extends ContentProvider { // 1) Send it to all packages that have READ_WRITE_ALL_VOICEMAIL permission. // 2) Send it to only the owner package that has just READ_WRITE_OWN_VOICEMAIL, if not // already sent in (1). - List<ResolveInfo> resolveInfos = context().getPackageManager() - .queryBroadcastReceivers(new Intent(intentAction, notificationUri), 0); - for (ResolveInfo resolveInfo : resolveInfos) { - String packageName = resolveInfo.activityInfo.packageName; + for (String packageName : getBroadcastReceiverPackages(intentAction, notificationUri)) { Intent intent = new Intent(intentAction, notificationUri); intent.setPackage(packageName); intent.putExtra(VoicemailContract.EXTRA_SELF_CHANGE, @@ -411,6 +404,18 @@ public class VoicemailContentProvider extends ContentProvider { } } + /** Determines the packages that can possibly receive the specified intent. */ + protected List<String> getBroadcastReceiverPackages(String intentAction, Uri uri) { + Intent intent = new Intent(intentAction, uri); + List<String> receiverPackages = new ArrayList<String>(); + // For broadcast receivers ResolveInfo.activityInfo is the one that is populated. + for (ResolveInfo resolveInfo : + context().getPackageManager().queryBroadcastReceivers(intent, 0)) { + receiverPackages.add(resolveInfo.activityInfo.packageName); + } + return receiverPackages; + } + /** Generates a random file for storing audio data. */ private String generateDataFile() { try { |