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

Commit d848a815 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix behavior when receive ACTION_VIEW_DOWNLOADS intent"

parents 0afcb08c bb6d8f69
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.content.ContentResolver.wrap;

import static com.android.documentsui.base.SharedMinimal.DEBUG;

import android.app.DownloadManager;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ContentProviderClient;
@@ -57,6 +58,7 @@ import com.android.documentsui.base.DocumentStack;
import com.android.documentsui.base.Features;
import com.android.documentsui.base.Lookup;
import com.android.documentsui.base.MimeTypes;
import com.android.documentsui.base.Providers;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.Shared;
import com.android.documentsui.base.State;
@@ -429,6 +431,11 @@ public class ActionHandler<T extends FragmentActivity & Addons> extends Abstract
            return;
        }

        if (launchToDownloads(intent)) {
            if (DEBUG) Log.d(TAG, "Launched to a downloads.");
            return;
        }

        if (DEBUG) Log.d(TAG, "Launching directly into Home directory.");
        launchToDefaultLocation();
    }
@@ -500,6 +507,17 @@ public class ActionHandler<T extends FragmentActivity & Addons> extends Abstract
        return false;
    }

    private boolean launchToDownloads(Intent intent) {
        if (DownloadManager.ACTION_VIEW_DOWNLOADS.equals(intent.getAction())) {
            Uri uri = DocumentsContract.buildRootUri(Providers.AUTHORITY_DOWNLOADS,
                    Providers.ROOT_ID_DOWNLOADS);
            loadRoot(uri);
            return true;
        }

        return false;
    }

    @Override
    public void showChooserForDoc(DocumentInfo doc) {
        assert(!doc.isDirectory());
+10 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import android.app.Activity;
import android.app.DownloadManager;
import android.app.PendingIntent;
import android.content.ClipData;
import android.content.Intent;
@@ -501,6 +502,15 @@ public class ActionHandlerTest {
        mActivity.refreshCurrentRootAndDirectory.assertCalled();
    }

    @Test
    public void testInitLocation_LaunchToDownloads() throws Exception {
        Intent intent = mActivity.getIntent();
        intent.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS);

        mHandler.initLocation(intent);
        assertRootPicked(TestProvidersAccess.DOWNLOADS.getUri());
    }

    @Test
    public void testDragAndDrop_OnReadOnlyRoot() throws Exception {
        RootInfo root = new RootInfo(); // root by default has no SUPPORT_CREATE flag