1 /* 2 * Copyright (C) 2012 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.google.android.vending.expansion.downloader; 18 19 import java.io.File; 20 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 /** Tag used for debugging/logging */ 28 public static final String TAG = "LVLDL"; 29 30 /** 31 * Expansion path where we store obb files 32 */ 33 public static final String EXP_PATH = File.separator + "Android" 34 + File.separator + "obb" + File.separator; 35 36 /** The intent that gets sent when the service must wake up for a retry */ 37 public static final String ACTION_RETRY = "android.intent.action.DOWNLOAD_WAKEUP"; 38 39 /** the intent that gets sent when clicking a successful download */ 40 public static final String ACTION_OPEN = "android.intent.action.DOWNLOAD_OPEN"; 41 42 /** the intent that gets sent when clicking an incomplete/failed download */ 43 public static final String ACTION_LIST = "android.intent.action.DOWNLOAD_LIST"; 44 45 /** the intent that gets sent when deleting the notification of a completed download */ 46 public static final String ACTION_HIDE = "android.intent.action.DOWNLOAD_HIDE"; 47 48 /** 49 * When a number has to be appended to the filename, this string is used to separate the 50 * base filename from the sequence number 51 */ 52 public static final String FILENAME_SEQUENCE_SEPARATOR = "-"; 53 54 /** The default user agent used for downloads */ 55 public static final String DEFAULT_USER_AGENT = "Android.LVLDM"; 56 57 /** The buffer size used to stream the data */ 58 public static final int BUFFER_SIZE = 4096; 59 60 /** The minimum amount of progress that has to be done before the progress bar gets updated */ 61 public static final int MIN_PROGRESS_STEP = 4096; 62 63 /** The minimum amount of time that has to elapse before the progress bar gets updated, in ms */ 64 public static final long MIN_PROGRESS_TIME = 1000; 65 66 /** The maximum number of rows in the database (FIFO) */ 67 public static final int MAX_DOWNLOADS = 1000; 68 69 /** 70 * The number of times that the download manager will retry its network 71 * operations when no progress is happening before it gives up. 72 */ 73 public static final int MAX_RETRIES = 5; 74 75 /** 76 * The minimum amount of time that the download manager accepts for 77 * a Retry-After response header with a parameter in delta-seconds. 78 */ 79 public static final int MIN_RETRY_AFTER = 30; // 30s 80 81 /** 82 * The maximum amount of time that the download manager accepts for 83 * a Retry-After response header with a parameter in delta-seconds. 84 */ 85 public static final int MAX_RETRY_AFTER = 24 * 60 * 60; // 24h 86 87 /** 88 * The maximum number of redirects. 89 */ 90 public static final int MAX_REDIRECTS = 5; // can't be more than 7. 91 92 /** 93 * The time between a failure and the first retry after an IOException. 94 * Each subsequent retry grows exponentially, doubling each time. 95 * The time is in seconds. 96 */ 97 public static final int RETRY_FIRST_DELAY = 30; 98 99 /** Enable separate connectivity logging */ 100 public static final boolean LOGX = true; 101 102 /** Enable verbose logging */ 103 public static final boolean LOGV = false; 104 105 /** Enable super-verbose logging */ 106 private static final boolean LOCAL_LOGVV = false; 107 public static final boolean LOGVV = LOCAL_LOGVV && LOGV; 108 109 /** 110 * This download has successfully completed. 111 * Warning: there might be other status values that indicate success 112 * in the future. 113 * Use isSucccess() to capture the entire category. 114 */ 115 public static final int STATUS_SUCCESS = 200; 116 117 /** 118 * This request couldn't be parsed. This is also used when processing 119 * requests with unknown/unsupported URI schemes. 120 */ 121 public static final int STATUS_BAD_REQUEST = 400; 122 123 /** 124 * This download can't be performed because the content type cannot be 125 * handled. 126 */ 127 public static final int STATUS_NOT_ACCEPTABLE = 406; 128 129 /** 130 * This download cannot be performed because the length cannot be 131 * determined accurately. This is the code for the HTTP error "Length 132 * Required", which is typically used when making requests that require 133 * a content length but don't have one, and it is also used in the 134 * client when a response is received whose length cannot be determined 135 * accurately (therefore making it impossible to know when a download 136 * completes). 137 */ 138 public static final int STATUS_LENGTH_REQUIRED = 411; 139 140 /** 141 * This download was interrupted and cannot be resumed. 142 * This is the code for the HTTP error "Precondition Failed", and it is 143 * also used in situations where the client doesn't have an ETag at all. 144 */ 145 public static final int STATUS_PRECONDITION_FAILED = 412; 146 147 /** 148 * The lowest-valued error status that is not an actual HTTP status code. 149 */ 150 public static final int MIN_ARTIFICIAL_ERROR_STATUS = 488; 151 152 /** 153 * The requested destination file already exists. 154 */ 155 public static final int STATUS_FILE_ALREADY_EXISTS_ERROR = 488; 156 157 /** 158 * Some possibly transient error occurred, but we can't resume the download. 159 */ 160 public static final int STATUS_CANNOT_RESUME = 489; 161 162 /** 163 * This download was canceled 164 */ 165 public static final int STATUS_CANCELED = 490; 166 167 /** 168 * This download has completed with an error. 169 * Warning: there will be other status values that indicate errors in 170 * the future. Use isStatusError() to capture the entire category. 171 */ 172 public static final int STATUS_UNKNOWN_ERROR = 491; 173 174 /** 175 * This download couldn't be completed because of a storage issue. 176 * Typically, that's because the filesystem is missing or full. 177 * Use the more specific {@link #STATUS_INSUFFICIENT_SPACE_ERROR} 178 * and {@link #STATUS_DEVICE_NOT_FOUND_ERROR} when appropriate. 179 */ 180 public static final int STATUS_FILE_ERROR = 492; 181 182 /** 183 * This download couldn't be completed because of an HTTP 184 * redirect response that the download manager couldn't 185 * handle. 186 */ 187 public static final int STATUS_UNHANDLED_REDIRECT = 493; 188 189 /** 190 * This download couldn't be completed because of an 191 * unspecified unhandled HTTP code. 192 */ 193 public static final int STATUS_UNHANDLED_HTTP_CODE = 494; 194 195 /** 196 * This download couldn't be completed because of an 197 * error receiving or processing data at the HTTP level. 198 */ 199 public static final int STATUS_HTTP_DATA_ERROR = 495; 200 201 /** 202 * This download couldn't be completed because of an 203 * HttpException while setting up the request. 204 */ 205 public static final int STATUS_HTTP_EXCEPTION = 496; 206 207 /** 208 * This download couldn't be completed because there were 209 * too many redirects. 210 */ 211 public static final int STATUS_TOO_MANY_REDIRECTS = 497; 212 213 /** 214 * This download couldn't be completed due to insufficient storage 215 * space. Typically, this is because the SD card is full. 216 */ 217 public static final int STATUS_INSUFFICIENT_SPACE_ERROR = 498; 218 219 /** 220 * This download couldn't be completed because no external storage 221 * device was found. Typically, this is because the SD card is not 222 * mounted. 223 */ 224 public static final int STATUS_DEVICE_NOT_FOUND_ERROR = 499; 225 226 /** 227 * The wake duration to check to see if a download is possible. 228 */ 229 public static final long WATCHDOG_WAKE_TIMER = 60*1000; 230 231 /** 232 * The wake duration to check to see if the process was killed. 233 */ 234 public static final long ACTIVE_THREAD_WATCHDOG = 5*1000; 235 236 }