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