Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1719210 authored by KhabarlakKonstantin's avatar KhabarlakKonstantin Committed by Michael W
Browse files

Fix gallery crash when trimming video

Fixes FileUriExposedException. Exposing files with Uri.fromFile is
forbidden in Nougat

Change-Id: Iab48e599f801459fa3db0c9c6f68f1cfd54460c6
parent 091a21f5
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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" />
+4 −0
Original line number Diff line number Diff line
<?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
+7 −1
Original line number Diff line number Diff line
/*
 * 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();