diff options
author | Tavis Bohne <tbohne@google.com> | 2016-05-16 18:14:20 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-05-16 18:14:20 +0000 |
commit | ca5fc9fa7dbba6cbab625d4a80f812b7206f0676 (patch) | |
tree | a90eaae902abfe2e20c925fd5774e99430a8fd6d /src | |
parent | c4073ff4ce1a342daad01a99d3fce84c54bc4776 (diff) | |
parent | 30fb3385393aafd3463811f8e88e04a08b157f67 (diff) | |
download | packages_apps_Messaging-ca5fc9fa7dbba6cbab625d4a80f812b7206f0676.tar.gz packages_apps_Messaging-ca5fc9fa7dbba6cbab625d4a80f812b7206f0676.tar.bz2 packages_apps_Messaging-ca5fc9fa7dbba6cbab625d4a80f812b7206f0676.zip |
Merge "Messaging doesn't allow sharing of its own files" into nyc-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/messaging/ui/conversationlist/ShareIntentActivity.java | 9 | ||||
-rw-r--r-- | src/com/android/messaging/util/FileUtil.java | 17 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/com/android/messaging/ui/conversationlist/ShareIntentActivity.java b/src/com/android/messaging/ui/conversationlist/ShareIntentActivity.java index ef7fcef..396f1da 100644 --- a/src/com/android/messaging/ui/conversationlist/ShareIntentActivity.java +++ b/src/com/android/messaging/ui/conversationlist/ShareIntentActivity.java @@ -34,6 +34,7 @@ import com.android.messaging.util.Assert; import com.android.messaging.util.ContentType; import com.android.messaging.util.LogUtil; import com.android.messaging.util.MediaMetadataRetrieverWrapper; +import com.android.messaging.util.FileUtil; import java.io.IOException; import java.util.ArrayList; @@ -158,8 +159,12 @@ public class ShareIntentActivity extends BaseBugleActivity implements } private void addSharedImagePartToDraft(final String contentType, final Uri imageUri) { - mDraftMessage.addPart(PendingAttachmentData.createPendingAttachmentData(contentType, - imageUri)); + if (FileUtil.isInPrivateDir(getBaseContext(), imageUri)) { + Assert.fail("Cannot send private file " + imageUri.toString()); + } else { + mDraftMessage.addPart(PendingAttachmentData.createPendingAttachmentData(contentType, + imageUri)); + } } @Override diff --git a/src/com/android/messaging/util/FileUtil.java b/src/com/android/messaging/util/FileUtil.java index 7c47ae9..f8051ed 100644 --- a/src/com/android/messaging/util/FileUtil.java +++ b/src/com/android/messaging/util/FileUtil.java @@ -16,7 +16,10 @@ package com.android.messaging.util; +import android.content.ContentResolver; import android.content.Context; +import android.net.Uri; +import android.text.TextUtils; import android.webkit.MimeTypeMap; import com.android.messaging.Factory; @@ -116,6 +119,20 @@ public class FileUtil { } } + private static boolean isFileUri(final Uri uri) { + return TextUtils.equals(uri.getScheme(), ContentResolver.SCHEME_FILE); + } + + // Checks if the file is in /data/data/com.android.messaging + // The other app folders are either symlinks to this, or hold non-private data like binaries. + public static boolean isInPrivateDir(Context context, Uri uri) { + if (!isFileUri(uri)) { + return false; + } + final File file = new File(uri.getPath()); + return FileUtil.isSameOrSubDirectory(new File(context.getApplicationInfo().dataDir), file); + } + /** * Checks, whether the child directory is the same as, or a sub-directory of the base * directory. |