diff options
author | KhabarlakKonstantin <habarlack@gmail.com> | 2017-09-26 09:02:11 +0300 |
---|---|---|
committer | Michael W <baddaemon87@gmail.com> | 2017-10-07 14:46:12 +0200 |
commit | e17192105b61934ccb8b34d218e9a60075fc5a58 (patch) | |
tree | 31ac9e0fe39535772ce6e7d3d22530619d9b0475 | |
parent | 091a21f5ae2af42f273d5922a0eb42e17e89b788 (diff) | |
download | android_packages_apps_Gallery2-e17192105b61934ccb8b34d218e9a60075fc5a58.tar.gz android_packages_apps_Gallery2-e17192105b61934ccb8b34d218e9a60075fc5a58.tar.bz2 android_packages_apps_Gallery2-e17192105b61934ccb8b34d218e9a60075fc5a58.zip |
Fix gallery crash when trimming video
Fixes FileUriExposedException. Exposing files with Uri.fromFile is
forbidden in Nougat
Change-Id: Iab48e599f801459fa3db0c9c6f68f1cfd54460c6
-rwxr-xr-x | AndroidManifest.xml | 10 | ||||
-rw-r--r-- | res/xml/provider_paths.xml | 4 | ||||
-rw-r--r-- | src/com/android/gallery3d/app/TrimVideo.java | 8 |
3 files changed, 21 insertions, 1 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 7c58e84d5..8a26772e1 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -264,6 +264,16 @@ android:readPermission="org.codeaurora.gallery.filtershow.permission.READ" android:writePermission="org.codeaurora.gallery.filtershow.permission.WRITE" /> + <provider + android:name="android.support.v4.content.FileProvider" + android:authorities="com.android.gallery3d.fileprovider" + android:exported="false" + android:grantUriPermissions="true"> + <meta-data + android:name="android.support.FILE_PROVIDER_PATHS" + android:resource="@xml/provider_paths" /> + </provider> + <service android:name="com.android.gallery3d.filtershow.pipeline.ProcessingService" android:exported="false" /> diff --git a/res/xml/provider_paths.xml b/res/xml/provider_paths.xml new file mode 100644 index 000000000..ffa74ab56 --- /dev/null +++ b/res/xml/provider_paths.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<paths xmlns:android="http://schemas.android.com/apk/res/android"> + <external-path name="external_files" path="."/> +</paths>
\ No newline at end of file diff --git a/src/com/android/gallery3d/app/TrimVideo.java b/src/com/android/gallery3d/app/TrimVideo.java index ec85de234..ca3acd7ef 100644 --- a/src/com/android/gallery3d/app/TrimVideo.java +++ b/src/com/android/gallery3d/app/TrimVideo.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 The Android Open Source Project + * Copyright (C) 2017 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +29,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.provider.MediaStore; +import android.support.v4.content.FileProvider; import android.view.View; import android.view.ViewGroup; import android.view.Window; @@ -57,6 +59,7 @@ public class TrimVideo extends Activity implements private Uri mUri; private final Handler mHandler = new Handler(); public static final String TRIM_ACTION = "com.android.camera.action.TRIM"; + private static final String FILE_PROVIDER_AUTHORITY = "com.android.gallery3d.fileprovider"; public ProgressDialog mProgress; @@ -318,7 +321,10 @@ 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/*"); + Uri fileUri = FileProvider.getUriForFile(getApplicationContext(), + FILE_PROVIDER_AUTHORITY, mDstFileInfo.mFile); + intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setDataAndType(fileUri, "video/*"); intent.putExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION, false); startActivity(intent); finish(); |