summaryrefslogtreecommitdiff
path: root/core/java/android/app/DownloadManager.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2017-07-15 12:58:38 -0600
committerJeff Sharkey <jsharkey@android.com>2017-07-15 21:08:56 -0600
commit4233f032fd41e82d1ce09b48860f8ae3f73fa5e0 (patch)
tree311d8c0b7136e473895491681062a11e8f7a7d96 /core/java/android/app/DownloadManager.java
parent53313d7e8153982f842910118371e1dc061248cd (diff)
Test if allocation supported; @removed clean up.
SM.allocateBytes() doesn't offer a clear way to detect if a failed request could ever succeed. (For example, we can never work with pipes, or files on an unsupported storage device.) So give developers a first-class API to test if allocation is supported. If the underlying filesystem doesn't support fallocate(), fall back to ftruncate() instead of failing completely. Clean up @removed APIs that were refactoring during API 26 review process. Remove support for storing downloads on the /cache partition, which doesn't exist on many devices. Bug: 63057877 Test: bit DownloadProviderTests:* Test: bit DocumentsUITests:com.android.documentsui.services.CopyJobTest Test: bit DocumentsUITests:com.android.documentsui.services.MoveJobTest Change-Id: I85d42a1a7240034b4f2a6f359011ac182bdce36e
Diffstat (limited to 'core/java/android/app/DownloadManager.java')
-rw-r--r--core/java/android/app/DownloadManager.java33
1 files changed, 7 insertions, 26 deletions
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index 5baaeb30e233..b444f17c0b69 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -18,9 +18,9 @@ package android.app;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.annotation.SystemService;
-import android.annotation.SdkConstant.SdkConstantType;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
@@ -36,8 +36,8 @@ import android.os.Environment;
import android.os.FileUtils;
import android.os.ParcelFileDescriptor;
import android.provider.Downloads;
-import android.provider.Settings;
import android.provider.MediaStore.Images;
+import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.text.TextUtils;
import android.util.Pair;
@@ -393,7 +393,6 @@ public class DownloadManager {
private int mFlags = 0;
private boolean mIsVisibleInDownloadsUi = true;
private boolean mScannable = false;
- private boolean mUseSystemCache = false;
/** if a file is designated as a MediaScanner scannable file, the following value is
* stored in the database column {@link Downloads.Impl#COLUMN_MEDIA_SCANNED}.
*/
@@ -474,24 +473,6 @@ public class DownloadManager {
}
/**
- * Set the local destination for the downloaded file to the system cache dir (/cache).
- * This is only available to System apps with the permission
- * {@link android.Manifest.permission#ACCESS_CACHE_FILESYSTEM}.
- * <p>
- * The downloaded file is not scanned by MediaScanner.
- * But it can be made scannable by calling {@link #allowScanningByMediaScanner()}.
- * <p>
- * Files downloaded to /cache may be deleted by the system at any time to reclaim space.
- *
- * @return this object
- * @hide
- */
- public Request setDestinationToSystemCache() {
- mUseSystemCache = true;
- return this;
- }
-
- /**
* Set the local destination for the downloaded file to a path within
* the application's external files directory (as returned by
* {@link Context#getExternalFilesDir(String)}.
@@ -772,13 +753,13 @@ public class DownloadManager {
values.put(Downloads.Impl.COLUMN_NOTIFICATION_PACKAGE, packageName);
if (mDestinationUri != null) {
- values.put(Downloads.Impl.COLUMN_DESTINATION, Downloads.Impl.DESTINATION_FILE_URI);
- values.put(Downloads.Impl.COLUMN_FILE_NAME_HINT, mDestinationUri.toString());
+ values.put(Downloads.Impl.COLUMN_DESTINATION,
+ Downloads.Impl.DESTINATION_FILE_URI);
+ values.put(Downloads.Impl.COLUMN_FILE_NAME_HINT,
+ mDestinationUri.toString());
} else {
values.put(Downloads.Impl.COLUMN_DESTINATION,
- (this.mUseSystemCache) ?
- Downloads.Impl.DESTINATION_SYSTEMCACHE_PARTITION :
- Downloads.Impl.DESTINATION_CACHE_PARTITION_PURGEABLE);
+ Downloads.Impl.DESTINATION_CACHE_PARTITION_PURGEABLE);
}
// is the file supposed to be media-scannable?
values.put(Downloads.Impl.COLUMN_MEDIA_SCANNED, (mScannable) ? SCANNABLE_VALUE_YES :