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.os.Environment; 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 = "/" + Environment.DIRECTORY_DOWNLOADS; 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 APKs */ 95 public static final String MIMETYPE_APK = "application/vnd.android.package"; 96 97 /** The buffer size used to stream the data */ 98 public static final int BUFFER_SIZE = 4096; 99 100 /** The minimum amount of progress that has to be done before the progress bar gets updated */ 101 public static final int MIN_PROGRESS_STEP = 4096; 102 103 /** The minimum amount of time that has to elapse before the progress bar gets updated, in ms */ 104 public static final long MIN_PROGRESS_TIME = 1500; 105 106 /** The maximum number of rows in the database (FIFO) */ 107 public static final int MAX_DOWNLOADS = 1000; 108 109 /** 110 * The number of times that the download manager will retry its network 111 * operations when no progress is happening before it gives up. 112 */ 113 public static final int MAX_RETRIES = 5; 114 115 /** 116 * The minimum amount of time that the download manager accepts for 117 * a Retry-After response header with a parameter in delta-seconds. 118 */ 119 public static final int MIN_RETRY_AFTER = 30; // 30s 120 121 /** 122 * The maximum amount of time that the download manager accepts for 123 * a Retry-After response header with a parameter in delta-seconds. 124 */ 125 public static final int MAX_RETRY_AFTER = 24 * 60 * 60; // 24h 126 127 /** 128 * The maximum number of redirects. 129 */ 130 public static final int MAX_REDIRECTS = 5; // can't be more than 7. 131 132 /** 133 * The time between a failure and the first retry after an IOException. 134 * Each subsequent retry grows exponentially, doubling each time. 135 * The time is in seconds. 136 */ 137 public static final int RETRY_FIRST_DELAY = 30; 138 139 /** Enable separate connectivity logging */ 140 static final boolean LOGX = false; 141 142 /** Enable verbose logging - use with "setprop log.tag.DownloadManager VERBOSE" */ 143 private static final boolean LOCAL_LOGV = false; 144 public static final boolean LOGV = LOCAL_LOGV && Log.isLoggable(TAG, Log.VERBOSE); 145 146 /** Enable super-verbose logging */ 147 private static final boolean LOCAL_LOGVV = false; 148 public static final boolean LOGVV = LOCAL_LOGVV && LOGV; 149 } 150