diff options
author | junjiez <junjiez@codeaurora.org> | 2018-06-01 16:15:21 +0800 |
---|---|---|
committer | junjiez <junjiez@codeaurora.org> | 2018-08-14 14:10:34 +0800 |
commit | 2db971aff32dbbee9562da217eb847531bda52ce (patch) | |
tree | 8f619e77e9d527d21a1288645a829f8cf2d520f3 /src/com/android/gallery3d/app | |
parent | 3c135f6e8086cc9117c7aebef671b0003401ebbb (diff) | |
download | android_packages_apps_Gallery2-2db971aff32dbbee9562da217eb847531bda52ce.tar.gz android_packages_apps_Gallery2-2db971aff32dbbee9562da217eb847531bda52ce.tar.bz2 android_packages_apps_Gallery2-2db971aff32dbbee9562da217eb847531bda52ce.zip |
SnapdragonGallery:Add FileProvider
Add a FileProvider to provide Uri of
files to avoid FileUriExposedException
when target sdk level is above 24.
Change-Id: I05f651c97733d27e5ba42065130dcc0ff963a073
CRs-Fixed: 2296203
Diffstat (limited to 'src/com/android/gallery3d/app')
-rwxr-xr-x | src/com/android/gallery3d/app/MuteVideo.java | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | src/com/android/gallery3d/app/TrimVideo.java | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/app/MuteVideo.java b/src/com/android/gallery3d/app/MuteVideo.java index bbb9fca7c..3b4226722 100755 --- a/src/com/android/gallery3d/app/MuteVideo.java +++ b/src/com/android/gallery3d/app/MuteVideo.java @@ -30,6 +30,7 @@ import org.codeaurora.gallery.R; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.util.SaveVideoFileInfo; import com.android.gallery3d.util.SaveVideoFileUtils; +import android.support.v4.content.FileProvider; import java.io.IOException; @@ -122,8 +123,12 @@ public class MuteVideo { // Show the result only when the activity not // stopped. Intent intent = new Intent(android.content.Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(mDstFileInfo.mFile), "video/*"); + intent.setDataAndType( + FileProvider.getUriForFile(mActivity, + "com.android.gallery3d.fileprovider", + mDstFileInfo.mFile), "video/*"); intent.putExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION, false); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); mActivity.startActivity(intent); } } diff --git a/src/com/android/gallery3d/app/TrimVideo.java b/src/com/android/gallery3d/app/TrimVideo.java index ec85de234..8daf39890 100644..100755 --- a/src/com/android/gallery3d/app/TrimVideo.java +++ b/src/com/android/gallery3d/app/TrimVideo.java @@ -35,6 +35,7 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import android.widget.VideoView; +import android.support.v4.content.FileProvider; import org.codeaurora.gallery.R; import com.android.gallery3d.util.SaveVideoFileInfo; @@ -42,6 +43,7 @@ import com.android.gallery3d.util.SaveVideoFileUtils; import java.io.File; import java.io.IOException; +import java.net.URI; public class TrimVideo extends Activity implements MediaPlayer.OnErrorListener, @@ -318,8 +320,12 @@ public class TrimVideo extends Activity implements mProgress = null; // Show the result only when the activity not stopped. Intent intent = new Intent(android.content.Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(mDstFileInfo.mFile), "video/*"); + intent.setDataAndType( + FileProvider.getUriForFile(mContext, + "com.android.gallery3d.fileprovider", + mDstFileInfo.mFile), "video/*"); intent.putExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION, false); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(intent); finish(); } |