Prevent logging about "attachment with null contentUri"

Bug: 3373982
Change-Id: I41b655041d5c244484435fe5bab7649d9ca569eb
This commit is contained in:
Marc Blank 2011-01-22 13:55:14 -08:00
parent f92dd2bf3e
commit 1264651c69

View File

@ -113,11 +113,10 @@ public class AttachmentInfo {
} }
} }
// Check to see if any activities can view this attachment // Check to see if any activities can view this attachment; if none, we can't view it
// If not, we can't view it
Intent intent = getAttachmentIntent(context, 0); Intent intent = getAttachmentIntent(context, 0);
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
List<ResolveInfo> activityList = pm.queryIntentActivities(intent, 0); List<ResolveInfo> activityList = pm.queryIntentActivities(intent, 0 /*no account*/);
if (activityList.isEmpty()) { if (activityList.isEmpty()) {
canView = false; canView = false;
canSave = false; canSave = false;
@ -129,11 +128,17 @@ public class AttachmentInfo {
/** /**
* Returns an <code>Intent</code> to load the given attachment. * Returns an <code>Intent</code> to load the given attachment.
* @param context the caller's context
* @param accountId the account associated with the attachment (or 0 if we don't need to
* resolve from attachmentUri to contentUri)
* @return an Intent suitable for loading the attachment
*/ */
public Intent getAttachmentIntent(Context context, long accountId) { public Intent getAttachmentIntent(Context context, long accountId) {
Uri attachmentUri = AttachmentProvider.getAttachmentUri(accountId, mId); Uri contentUri = AttachmentProvider.getAttachmentUri(accountId, mId);
Uri contentUri = AttachmentProvider.resolveAttachmentIdToContentUri( if (accountId > 0) {
context.getContentResolver(), attachmentUri); contentUri = AttachmentProvider.resolveAttachmentIdToContentUri(
context.getContentResolver(), contentUri);
}
Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(contentUri); intent.setData(contentUri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION