diff options
author | Anthony Lee <anthonylee@google.com> | 2014-05-11 00:43:55 -0700 |
---|---|---|
committer | Anthony Lee <anthonylee@google.com> | 2014-05-11 00:47:44 -0700 |
commit | bca4f9fcfb2301cd4bfdb9a4785f299f90e4263c (patch) | |
tree | 0f1f6bd561366527f142f403a86171c18374d75c /emailcommon | |
parent | d222c6b817a9979bd26070d22bac60ab56e8d67a (diff) | |
download | android_packages_apps_Email-bca4f9fcfb2301cd4bfdb9a4785f299f90e4263c.tar.gz android_packages_apps_Email-bca4f9fcfb2301cd4bfdb9a4785f299f90e4263c.tar.bz2 android_packages_apps_Email-bca4f9fcfb2301cd4bfdb9a4785f299f90e4263c.zip |
Service intent's package matches the content provider's.
b/14596165. When setting the package of the service intent,
query the app that implements the Email content authority since
that is the same app that should handle the intent.
Change-Id: I29a34a056516edda78acb83b9c89547ca0dc5ca1
Diffstat (limited to 'emailcommon')
-rw-r--r-- | emailcommon/src/com/android/emailcommon/service/ServiceProxy.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java b/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java index 354d70ef1..1c4f3b6bb 100644 --- a/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java +++ b/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java @@ -21,6 +21,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; +import android.content.pm.ProviderInfo; import android.os.AsyncTask; import android.os.Debug; import android.os.IBinder; @@ -60,8 +61,22 @@ public abstract class ServiceProxy { private boolean mTaskCompleted = false; public static Intent getIntentForEmailPackage(Context context, String actionName) { + /** + * We want to scope the intent so that only the Email app will handle it. Unfortunately + * we found that there are many instances where the package name of the Email app is + * not what we expect. The easiest way to find the package of the correct app is to + * see who is the EmailContent.AUTHORITY as there is only one app that can implement + * the content provider for this authority and this is the right app to handle this intent. + */ final Intent intent = new Intent(EmailContent.EMAIL_PACKAGE_NAME + "." + actionName); - intent.setPackage(EmailContent.EMAIL_PACKAGE_NAME); + final ProviderInfo info = context.getPackageManager().resolveContentProvider( + EmailContent.AUTHORITY, 0); + if (info != null) { + final String packageName = info.packageName; + intent.setPackage(packageName); + } else { + LogUtils.e(LogUtils.TAG, "Could not find the Email Content Provider"); + } return intent; } |