From e707ddc188f4ee87de9f31bcd0915d7619cd1e3b Mon Sep 17 00:00:00 2001 From: Sudheer Shanka Date: Wed, 8 May 2019 18:59:45 -0700 Subject: [PATCH] Update behavior of setDestinationInExternalPublicDir(). Allow apps to use DownloadManager for downloading files into known public dirs other than "Download" but don't include them as part of Downloads collection. Bug: 132136431 Test: manual Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Test: atest cts/tests/app/DownloadManagerLegacyTest/src/android/app/cts/DownloadManagerLegacyTest.java Test: atest cts/tests/app/DownloadManagerApi28Test/src/android/app/cts/DownloadManagerApi28Test.java Change-Id: I059c0b19218e07c7813e23c6b2d414d0306434d5 --- core/java/android/app/DownloadManager.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java index be281c2a3efe2..584115adcd4ba 100644 --- a/core/java/android/app/DownloadManager.java +++ b/core/java/android/app/DownloadManager.java @@ -539,8 +539,9 @@ public class DownloadManager { * *

For applications targeting {@link android.os.Build.VERSION_CODES#Q} or above, * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE WRITE_EXTERNAL_STORAGE} - * permission is not needed and the {@code dirType} must - * be {@link Environment#DIRECTORY_DOWNLOADS}. + * permission is not needed and the {@code dirType} must be one of the known public + * directories like {@link Environment#DIRECTORY_DOWNLOADS}, + * {@link Environment#DIRECTORY_PICTURES}, {@link Environment#DIRECTORY_MOVIES}, etc. * * @param dirType the directory type to pass to {@link Environment#getExternalStoragePublicDirectory(String)} * @param subPath the path within the external directory, including the @@ -594,11 +595,8 @@ public class DownloadManager { * should be called before {@link DownloadManager#enqueue(Request)} is called. * * @deprecated Starting in Q, this value is ignored. Files downloaded to - * public Downloads directory (as returned by - * {@link Environment#getExternalStoragePublicDirectory(String)} with - * {@link Environment#DIRECTORY_DOWNLOADS}) will be scanned by MediaScanner - * and files downloaded to directories owned by applications - * (e.g. {@link Context#getExternalFilesDir(String)}) will not be scanned. + * directories owned by applications (e.g. {@link Context#getExternalFilesDir(String)}) + * will not be scanned by MediaScanner and the rest will be scanned. */ @Deprecated public void allowScanningByMediaScanner() { @@ -783,11 +781,11 @@ public class DownloadManager { * @param isVisible whether to display this download in the Downloads UI * @return this object * - * @deprecated Starting in Q, this value is ignored. Files downloaded to + * @deprecated Starting in Q, this value is ignored. Only files downloaded to * public Downloads directory (as returned by * {@link Environment#getExternalStoragePublicDirectory(String)} with * {@link Environment#DIRECTORY_DOWNLOADS}) will be visible in system's Downloads UI - * and files downloaded to directories owned by applications + * and the rest will not be visible. * (e.g. {@link Context#getExternalFilesDir(String)}) will not be visible. */ @Deprecated