Repository navigation
Expand file tree
/
Copy pathDownloadTaskParams.java
More file actions
63 lines (53 loc) Β· 1.98 KB
/
Copy pathDownloadTaskParams.java
File metadata and controls
63 lines (53 loc) Β· 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package cn.reactnative.modules.update;
import java.io.File;
/**
* Created by tdzl2003 on 3/31/16.
*/
class DownloadTaskParams {
static final int TASK_TYPE_CLEANUP = 0; //Keep hash & originHash
// <generated:archive-patch-types> (scripts/contract.ts; bun scripts/generate-contract.ts)
static final int TASK_TYPE_PATCH_FULL = 1;
static final int TASK_TYPE_PATCH_FROM_APK = 2;
static final int TASK_TYPE_PATCH_FROM_PPK = 3;
// </generated:archive-patch-types>
static final int TASK_TYPE_PLAIN_DOWNLOAD = 4;
static final int DEFAULT_MAX_AGE_DAYS = 3;
int type;
String url;
String hash;
String originHash;
// TASK_TYPE_CLEANUP only: entries younger than this survive; 0 = delete all
int maxAgeDays = DEFAULT_MAX_AGE_DAYS;
// Absolute System.nanoTime deadline for orchestrated cold-start downloads;
// 0 keeps the normal public API's 10-minute per-call timeout.
long deadlineNanos;
File targetFile;
File unzipDirectory;
File originDirectory;
UpdateContext.DownloadFileListener listener;
// Cooperative cancellation for orchestrated downloads (CODE_AUDIT 2.12):
// the native check cancels a task whose phase budget expired, so it
// neither starts late on the single download thread nor keeps
// transferring behind the next attempt. Guarded by this.
private boolean cancelled;
private okhttp3.Call activeCall;
synchronized void cancel() {
cancelled = true;
if (activeCall != null) {
activeCall.cancel();
}
}
synchronized boolean isCancelled() {
return cancelled;
}
/**
* Registers the transfer in flight (null clears it); a task cancelled
* before its transfer started cancels the call right here.
*/
synchronized void attachCall(okhttp3.Call call) {
activeCall = call;
if (cancelled && call != null) {
call.cancel();
}
}
}