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
This commit is contained in:
parent
d222c6b817
commit
bca4f9fcfb
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue