am 11472650: Fix apk attachments

* commit '11472650d1fce7548939d311c4434128930c18ba':
  Fix apk attachments
This commit is contained in:
Paul Westbrook 2013-04-01 17:26:59 -07:00 committed by Android Git Automerger
commit 1522d89ed8

View File

@ -95,6 +95,7 @@ import com.android.mail.utils.AttachmentUtils;
import com.android.mail.utils.LogUtils; import com.android.mail.utils.LogUtils;
import com.android.mail.utils.MatrixCursorWithCachedColumns; import com.android.mail.utils.MatrixCursorWithCachedColumns;
import com.android.mail.utils.MatrixCursorWithExtra; import com.android.mail.utils.MatrixCursorWithExtra;
import com.android.mail.utils.MimeType;
import com.android.mail.utils.Utils; import com.android.mail.utils.Utils;
import com.android.mail.widget.BaseWidgetProvider; import com.android.mail.widget.BaseWidgetProvider;
import com.android.mail.widget.WidgetProvider; import com.android.mail.widget.WidgetProvider;
@ -3353,11 +3354,24 @@ outer:
@Override @Override
public String getString(int column) { public String getString(int column) {
if (column == mContentUriIndex) { if (column == mContentUriIndex) {
Uri uri = Uri.parse(getString(mUriIndex)); final Uri uri = Uri.parse(getString(mUriIndex));
long id = Long.parseLong(uri.getLastPathSegment()); final long id = Long.parseLong(uri.getLastPathSegment());
Attachment att = Attachment.restoreAttachmentWithId(mContext, id); final Attachment att = Attachment.restoreAttachmentWithId(mContext, id);
if (att == null) return ""; if (att == null) return "";
return AttachmentUtilities.getAttachmentUri(att.mAccountKey, id).toString();
final String contentUri;
// Until the package installer can handle opening apks from a content:// uri, for
// any apk that was successfully saved in external storage, return the
// content uri from the attachment
if (att.mUiDestination == UIProvider.AttachmentDestination.EXTERNAL &&
att.mUiState == UIProvider.AttachmentState.SAVED &&
TextUtils.equals(att.mMimeType, MimeType.ANDROID_ARCHIVE)) {
contentUri = att.getContentUri();
} else {
contentUri =
AttachmentUtilities.getAttachmentUri(att.mAccountKey, id).toString();
}
return contentUri;
} else { } else {
return super.getString(column); return super.getString(column);
} }