summaryrefslogtreecommitdiffstats
path: root/core/java/android/app
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2010-12-14 17:57:41 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-12-14 17:57:41 -0800
commita738671790503132a277880642ca746d7a1380e9 (patch)
treeab858baa2f1b0c9a898f5672a5773572784941a3 /core/java/android/app
parent59c8bce6644f9e9669c9d4b351bb0d030b4486c3 (diff)
parentf83e6e4b7a7fcbfcc8e3b6078f4655fa3e64bce3 (diff)
downloadframeworks_base-a738671790503132a277880642ca746d7a1380e9.zip
frameworks_base-a738671790503132a277880642ca746d7a1380e9.tar.gz
frameworks_base-a738671790503132a277880642ca746d7a1380e9.tar.bz2
Merge "bug:3264401 changes to support usage of new downloads dir in /data"
Diffstat (limited to 'core/java/android/app')
-rw-r--r--core/java/android/app/DownloadManager.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index ed4aed2..a24375e 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -24,6 +24,7 @@ import android.database.Cursor;
import android.database.CursorWrapper;
import android.net.ConnectivityManager;
import android.net.Uri;
+import android.os.Binder;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.provider.Downloads;
@@ -335,6 +336,7 @@ public class DownloadManager {
private int mAllowedNetworkTypes = ~0; // default to all network types allowed
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}.
*/
@@ -402,6 +404,24 @@ 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)}.
* <p>
@@ -596,7 +616,9 @@ public class DownloadManager {
values.put(Downloads.Impl.COLUMN_FILE_NAME_HINT, mDestinationUri.toString());
} else {
values.put(Downloads.Impl.COLUMN_DESTINATION,
- Downloads.Impl.DESTINATION_CACHE_PARTITION_PURGEABLE);
+ (this.mUseSystemCache) ?
+ Downloads.Impl.DESTINATION_SYSTEMCACHE_PARTITION :
+ 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 :
@@ -918,6 +940,7 @@ public class DownloadManager {
// non-external storage for a downloaded file, then the following code
// should also check for that destination.
if (destination == Downloads.Impl.DESTINATION_CACHE_PARTITION ||
+ destination == Downloads.Impl.DESTINATION_SYSTEMCACHE_PARTITION ||
destination == Downloads.Impl.DESTINATION_CACHE_PARTITION_NOROAMING ||
destination == Downloads.Impl.DESTINATION_CACHE_PARTITION_PURGEABLE) {
// return private uri