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

Commit 7eeec135 authored by Steve McKay's avatar Steve McKay Committed by android-build-merger
Browse files

Accurately emulate historic Downloads ACTION_VIEW behavior.

am: 8e5ac541

Change-Id: I9bbfffa96cf0d9594b22eb3e6d01d713e56d7a06
parents 10ef17ab 8e5ac541
Loading
Loading
Loading
Loading
+12 −2
Original line number Original line Diff line number Diff line
@@ -352,8 +352,18 @@ public class FilesActivity extends BaseActivity {


        // Fall back to traditional VIEW action...
        // Fall back to traditional VIEW action...
        intent = new Intent(Intent.ACTION_VIEW);
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        intent.setDataAndType(doc.derivedUri, doc.mimeType);
        intent.setData(doc.derivedUri);

        // Downloads has traditionally added the WRITE permission
        // in the TrampolineActivity. Since this behavior is long
        // established, we set the same permission for non-managed files
        // This ensures consistent behavior between the Downloads root
        // and other roots.
        int flags = Intent.FLAG_GRANT_READ_URI_PERMISSION;
        if (doc.isWriteSupported()) {
            flags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
        }
        intent.setFlags(flags);


        if (DEBUG && intent.getClipData() != null) {
        if (DEBUG && intent.getClipData() != null) {
            Log.d(TAG, "Starting intent w/ clip data: " + intent.getClipData());
            Log.d(TAG, "Starting intent w/ clip data: " + intent.getClipData());
+4 −0
Original line number Original line Diff line number Diff line
@@ -239,6 +239,10 @@ public class DocumentInfo implements Durable, Parcelable {
        return (flags & Document.FLAG_DIR_PREFERS_GRID) != 0;
        return (flags & Document.FLAG_DIR_PREFERS_GRID) != 0;
    }
    }


    public boolean isWriteSupported() {
        return (flags & Document.FLAG_SUPPORTS_WRITE) != 0;
    }

    public boolean isDeleteSupported() {
    public boolean isDeleteSupported() {
        return (flags & Document.FLAG_SUPPORTS_DELETE) != 0;
        return (flags & Document.FLAG_SUPPORTS_DELETE) != 0;
    }
    }