2 * Copyright (C) 2008 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.providers.downloads;
19 import android.util.Config;
20 import android.util.Log;
23 * Contains the internal constants that are used in the download manager.
24 * As a general rule, modifying these constants should be done with care.
26 public class Constants {
28 /** Tag used for debugging/logging */
29 public static final String TAG = "DownloadManager";
31 /** The column that used to be used for the HTTP method of the request */
32 public static final String RETRY_AFTER_X_REDIRECT_COUNT = "method";
34 /** The column that used to be used for the magic OTA update filename */
35 public static final String OTA_UPDATE = "otaupdate";
37 /** The column that used to be used to reject system filetypes */
38 public static final String NO_SYSTEM_FILES = "no_system";
40 /** The column that is used for the downloads's ETag */
41 public static final String ETAG = "etag";
43 /** The column that is used for the initiating app's UID */
44 public static final String UID = "uid";
46 /** The column that is used to remember whether the media scanner was invoked */
47 public static final String MEDIA_SCANNED = "scanned";
49 /** The column that is used to count retries */
50 public static final String FAILED_CONNECTIONS = "numfailed";
52 /** The intent that gets sent when the service must wake up for a retry */
53 public static final String ACTION_RETRY = "android.intent.action.DOWNLOAD_WAKEUP";
55 /** the intent that gets sent when clicking a successful download */
56 public static final String ACTION_OPEN = "android.intent.action.DOWNLOAD_OPEN";
58 /** the intent that gets sent when clicking an incomplete/failed download */
59 public static final String ACTION_LIST = "android.intent.action.DOWNLOAD_LIST";
61 /** the intent that gets sent when deleting the notification of a completed download */
62 public static final String ACTION_HIDE = "android.intent.action.DOWNLOAD_HIDE";
64 /** The default base name for downloaded files if we can't get one at the HTTP level */
65 public static final String DEFAULT_DL_FILENAME = "downloadfile";
67 /** The default extension for html files if we can't get one at the HTTP level */
68 public static final String DEFAULT_DL_HTML_EXTENSION = ".html";
70 /** The default extension for text files if we can't get one at the HTTP level */
71 public static final String DEFAULT_DL_TEXT_EXTENSION = ".txt";
73 /** The default extension for binary files if we can't get one at the HTTP level */
74 public static final String DEFAULT_DL_BINARY_EXTENSION = ".bin";
77 * When a number has to be appended to the filename, this string is used to separate the
78 * base filename from the sequence number
80 public static final String FILENAME_SEQUENCE_SEPARATOR = "-";
82 /** Where we store downloaded files on the external storage */
83 public static final String DEFAULT_DL_SUBDIR = "/download";
85 /** A magic filename that is allowed to exist within the system cache */
86 public static final String KNOWN_SPURIOUS_FILENAME = "lost+found";
88 /** A magic filename that is allowed to exist within the system cache */
89 public static final String RECOVERY_DIRECTORY = "recovery";
91 /** The default user agent used for downloads */
92 public static final String DEFAULT_USER_AGENT = "AndroidDownloadManager";
94 /** The MIME type of special DRM files */
95 public static final String MIMETYPE_DRM_MESSAGE =
96 android.drm.mobile1.DrmRawContent.DRM_MIMETYPE_MESSAGE_STRING;
98 /** The MIME type of APKs */
99 public static final String MIMETYPE_APK = "application/vnd.android.package";
101 /** The buffer size used to stream the data */
102 public static final int BUFFER_SIZE = 4096;
104 /** The minimum amount of progress that has to be done before the progress bar gets updated */
105 public static final int MIN_PROGRESS_STEP = 4096;
107 /** The minimum amount of time that has to elapse before the progress bar gets updated, in ms */
108 public static final long MIN_PROGRESS_TIME = 1500;
110 /** The maximum number of rows in the database (FIFO) */
111 public static final int MAX_DOWNLOADS = 1000;
114 * The number of times that the download manager will retry its network
115 * operations when no progress is happening before it gives up.
117 public static final int MAX_RETRIES = 5;
120 * The minimum amount of time that the download manager accepts for
121 * a Retry-After response header with a parameter in delta-seconds.
123 public static final int MIN_RETRY_AFTER = 30; // 30s
126 * The maximum amount of time that the download manager accepts for
127 * a Retry-After response header with a parameter in delta-seconds.
129 public static final int MAX_RETRY_AFTER = 24 * 60 * 60; // 24h
132 * The maximum number of redirects.
134 public static final int MAX_REDIRECTS = 5; // can't be more than 7.
137 * The time between a failure and the first retry after an IOException.
138 * Each subsequent retry grows exponentially, doubling each time.
139 * The time is in seconds.
141 public static final int RETRY_FIRST_DELAY = 30;
143 /** Enable verbose logging - use with "setprop log.tag.DownloadManager VERBOSE" */
144 private static final boolean LOCAL_LOGV = true;
145 public static final boolean LOGV = Config.LOGV
146 || (Config.LOGD && LOCAL_LOGV && Log.isLoggable(TAG, Log.VERBOSE));
148 /** Enable super-verbose logging */
149 private static final boolean LOCAL_LOGVV = false;
150 public static final boolean LOGVV = LOCAL_LOGVV && LOGV;