1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17 package com.android.providers.downloads; 18 19 import android.util.Config; 20 import android.util.Log; 21 22 /** 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. 25 */ 26 public class Constants { 27 28 /** Tag used for debugging/logging */ 29 public static final String TAG = "DownloadManager"; 30 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"; 33 34 /** The column that used to be used for the magic OTA update filename */ 35 public static final String OTA_UPDATE = "otaupdate"; 36 37 /** The column that used to be used to reject system filetypes */ 38 public static final String NO_SYSTEM_FILES = "no_system"; 39 40 /** The column that is used for the downloads's ETag */ 41 public static final String ETAG = "etag"; 42 43 /** The column that is used for the initiating app's UID */ 44 public static final String UID = "uid"; 45 46 /** The column that is used to remember whether the media scanner was invoked */ 47 public static final String MEDIA_SCANNED = "scanned"; 48 49 /** The column that is used to count retries */ 50 public static final String FAILED_CONNECTIONS = "numfailed"; 51 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"; 54 55 /** the intent that gets sent when clicking a successful download */ 56 public static final String ACTION_OPEN = "android.intent.action.DOWNLOAD_OPEN"; 57 58 /** the intent that gets sent when clicking an incomplete/failed download */ 59 public static final String ACTION_LIST = "android.intent.action.DOWNLOAD_LIST"; 60 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"; 63 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"; 66 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"; 69 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"; 72 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"; 75 76 /** 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 79 */ 80 public static final String FILENAME_SEQUENCE_SEPARATOR = "-"; 81 82 /** Where we store downloaded files on the external storage */ 83 public static final String DEFAULT_DL_SUBDIR = "/download"; 84 85 /** A magic filename that is allowed to exist within the system cache */ 86 public static final String KNOWN_SPURIOUS_FILENAME = "lost+found"; 87 88 /** A magic filename that is allowed to exist within the system cache */ 89 public static final String RECOVERY_DIRECTORY = "recovery"; 90 91 /** The default user agent used for downloads */ 92 public static final String DEFAULT_USER_AGENT = "AndroidDownloadManager"; 93 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; 97 98 /** The MIME type of APKs */ 99 public static final String MIMETYPE_APK = "application/vnd.android.package"; 100 101 /** The buffer size used to stream the data */ 102 public static final int BUFFER_SIZE = 4096; 103 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; 106 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; 109 110 /** The maximum number of rows in the database (FIFO) */ 111 public static final int MAX_DOWNLOADS = 1000; 112 113 /** 114 * The number of times that the download manager will retry its network 115 * operations when no progress is happening before it gives up. 116 */ 117 public static final int MAX_RETRIES = 5; 118 119 /** 120 * The minimum amount of time that the download manager accepts for 121 * a Retry-After response header with a parameter in delta-seconds. 122 */ 123 public static final int MIN_RETRY_AFTER = 30; // 30s 124 125 /** 126 * The maximum amount of time that the download manager accepts for 127 * a Retry-After response header with a parameter in delta-seconds. 128 */ 129 public static final int MAX_RETRY_AFTER = 24 * 60 * 60; // 24h 130 131 /** 132 * The maximum number of redirects. 133 */ 134 public static final int MAX_REDIRECTS = 5; // can't be more than 7. 135 136 /** 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. 140 */ 141 public static final int RETRY_FIRST_DELAY = 30; 142 143 /** Enable separate connectivity logging */ 144 static final boolean LOGX = false; 145 146 /** Enable verbose logging - use with "setprop log.tag.DownloadManager VERBOSE" */ 147 private static final boolean LOCAL_LOGV = false; 148 public static final boolean LOGV = Config.LOGV 149 || (Config.LOGD && LOCAL_LOGV && Log.isLoggable(TAG, Log.VERBOSE)); 150 151 /** Enable super-verbose logging */ 152 private static final boolean LOCAL_LOGVV = false; 153 public static final boolean LOGVV = LOCAL_LOGVV && LOGV; 154 } 155