Relay.smali
12.7 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
.class final Lokhttp3/internal/cache2/Relay;
.super Ljava/lang/Object;
.source "Relay.java"
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lokhttp3/internal/cache2/Relay$RelaySource;
}
.end annotation
# static fields
.field private static final FILE_HEADER_SIZE:J = 0x20L
.field static final PREFIX_CLEAN:Lokio/ByteString;
.field static final PREFIX_DIRTY:Lokio/ByteString;
.field private static final SOURCE_FILE:I = 0x2
.field private static final SOURCE_UPSTREAM:I = 0x1
# instance fields
.field final buffer:Lokio/Buffer;
.field final bufferMaxSize:J
.field complete:Z
.field file:Ljava/io/RandomAccessFile;
.field private final metadata:Lokio/ByteString;
.field sourceCount:I
.field upstream:Lokio/Source;
.field final upstreamBuffer:Lokio/Buffer;
.field upstreamPos:J
.field upstreamReader:Ljava/lang/Thread;
# direct methods
.method static constructor <clinit>()V
.locals 1
const-string v0, "OkHttp cache v1\n"
.line 45
invoke-static {v0}, Lokio/ByteString;->encodeUtf8(Ljava/lang/String;)Lokio/ByteString;
move-result-object v0
sput-object v0, Lokhttp3/internal/cache2/Relay;->PREFIX_CLEAN:Lokio/ByteString;
const-string v0, "OkHttp DIRTY :(\n"
.line 46
invoke-static {v0}, Lokio/ByteString;->encodeUtf8(Ljava/lang/String;)Lokio/ByteString;
move-result-object v0
sput-object v0, Lokhttp3/internal/cache2/Relay;->PREFIX_DIRTY:Lokio/ByteString;
return-void
.end method
.method private constructor <init>(Ljava/io/RandomAccessFile;Lokio/Source;JLokio/ByteString;J)V
.locals 1
.line 107
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 79
new-instance v0, Lokio/Buffer;
invoke-direct {v0}, Lokio/Buffer;-><init>()V
iput-object v0, p0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
.line 94
new-instance v0, Lokio/Buffer;
invoke-direct {v0}, Lokio/Buffer;-><init>()V
iput-object v0, p0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
.line 108
iput-object p1, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
.line 109
iput-object p2, p0, Lokhttp3/internal/cache2/Relay;->upstream:Lokio/Source;
if-nez p2, :cond_0
const/4 p1, 0x1
goto :goto_0
:cond_0
const/4 p1, 0x0
.line 110
:goto_0
iput-boolean p1, p0, Lokhttp3/internal/cache2/Relay;->complete:Z
.line 111
iput-wide p3, p0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
.line 112
iput-object p5, p0, Lokhttp3/internal/cache2/Relay;->metadata:Lokio/ByteString;
.line 113
iput-wide p6, p0, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
return-void
.end method
.method public static edit(Ljava/io/File;Lokio/Source;Lokio/ByteString;J)Lokhttp3/internal/cache2/Relay;
.locals 9
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 126
new-instance v8, Ljava/io/RandomAccessFile;
const-string v0, "rw"
invoke-direct {v8, p0, v0}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V
.line 127
new-instance p0, Lokhttp3/internal/cache2/Relay;
const-wide/16 v3, 0x0
move-object v0, p0
move-object v1, v8
move-object v2, p1
move-object v5, p2
move-wide v6, p3
invoke-direct/range {v0 .. v7}, Lokhttp3/internal/cache2/Relay;-><init>(Ljava/io/RandomAccessFile;Lokio/Source;JLokio/ByteString;J)V
const-wide/16 p1, 0x0
.line 130
invoke-virtual {v8, p1, p2}, Ljava/io/RandomAccessFile;->setLength(J)V
.line 131
sget-object v2, Lokhttp3/internal/cache2/Relay;->PREFIX_DIRTY:Lokio/ByteString;
const-wide/16 v3, -0x1
const-wide/16 v5, -0x1
move-object v1, p0
invoke-direct/range {v1 .. v6}, Lokhttp3/internal/cache2/Relay;->writeHeader(Lokio/ByteString;JJ)V
return-object p0
.end method
.method public static read(Ljava/io/File;)Lokhttp3/internal/cache2/Relay;
.locals 10
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 144
new-instance v1, Ljava/io/RandomAccessFile;
const-string v0, "rw"
invoke-direct {v1, p0, v0}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V
.line 145
new-instance p0, Lokhttp3/internal/cache2/FileOperator;
invoke-virtual {v1}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object v0
invoke-direct {p0, v0}, Lokhttp3/internal/cache2/FileOperator;-><init>(Ljava/nio/channels/FileChannel;)V
.line 148
new-instance v0, Lokio/Buffer;
invoke-direct {v0}, Lokio/Buffer;-><init>()V
const-wide/16 v3, 0x0
const-wide/16 v6, 0x20
move-object v2, p0
move-object v5, v0
.line 149
invoke-virtual/range {v2 .. v7}, Lokhttp3/internal/cache2/FileOperator;->read(JLokio/Buffer;J)V
.line 150
sget-object v2, Lokhttp3/internal/cache2/Relay;->PREFIX_CLEAN:Lokio/ByteString;
invoke-virtual {v2}, Lokio/ByteString;->size()I
move-result v2
int-to-long v2, v2
invoke-virtual {v0, v2, v3}, Lokio/Buffer;->readByteString(J)Lokio/ByteString;
move-result-object v2
.line 151
sget-object v3, Lokhttp3/internal/cache2/Relay;->PREFIX_CLEAN:Lokio/ByteString;
invoke-virtual {v2, v3}, Lokio/ByteString;->equals(Ljava/lang/Object;)Z
move-result v2
if-eqz v2, :cond_0
.line 152
invoke-virtual {v0}, Lokio/Buffer;->readLong()J
move-result-wide v8
.line 153
invoke-virtual {v0}, Lokio/Buffer;->readLong()J
move-result-wide v6
.line 156
new-instance v0, Lokio/Buffer;
invoke-direct {v0}, Lokio/Buffer;-><init>()V
const-wide/16 v2, 0x20
add-long v3, v8, v2
move-object v2, p0
move-object v5, v0
.line 157
invoke-virtual/range {v2 .. v7}, Lokhttp3/internal/cache2/FileOperator;->read(JLokio/Buffer;J)V
.line 158
invoke-virtual {v0}, Lokio/Buffer;->readByteString()Lokio/ByteString;
move-result-object v5
.line 161
new-instance p0, Lokhttp3/internal/cache2/Relay;
const/4 v2, 0x0
const-wide/16 v6, 0x0
move-object v0, p0
move-wide v3, v8
invoke-direct/range {v0 .. v7}, Lokhttp3/internal/cache2/Relay;-><init>(Ljava/io/RandomAccessFile;Lokio/Source;JLokio/ByteString;J)V
return-object p0
.line 151
:cond_0
new-instance p0, Ljava/io/IOException;
const-string v0, "unreadable cache file"
invoke-direct {p0, v0}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
throw p0
.end method
.method private writeHeader(Lokio/ByteString;JJ)V
.locals 6
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 166
new-instance v3, Lokio/Buffer;
invoke-direct {v3}, Lokio/Buffer;-><init>()V
.line 167
invoke-virtual {v3, p1}, Lokio/Buffer;->write(Lokio/ByteString;)Lokio/Buffer;
.line 168
invoke-virtual {v3, p2, p3}, Lokio/Buffer;->writeLong(J)Lokio/Buffer;
.line 169
invoke-virtual {v3, p4, p5}, Lokio/Buffer;->writeLong(J)Lokio/Buffer;
.line 170
invoke-virtual {v3}, Lokio/Buffer;->size()J
move-result-wide p1
const-wide/16 p3, 0x20
cmp-long p1, p1, p3
if-nez p1, :cond_0
.line 172
new-instance v0, Lokhttp3/internal/cache2/FileOperator;
iget-object p1, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
invoke-virtual {p1}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object p1
invoke-direct {v0, p1}, Lokhttp3/internal/cache2/FileOperator;-><init>(Ljava/nio/channels/FileChannel;)V
const-wide/16 v1, 0x0
const-wide/16 v4, 0x20
.line 173
invoke-virtual/range {v0 .. v5}, Lokhttp3/internal/cache2/FileOperator;->write(JLokio/Buffer;J)V
return-void
.line 170
:cond_0
new-instance p1, Ljava/lang/IllegalArgumentException;
invoke-direct {p1}, Ljava/lang/IllegalArgumentException;-><init>()V
throw p1
.end method
.method private writeMetadata(J)V
.locals 6
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 177
new-instance v3, Lokio/Buffer;
invoke-direct {v3}, Lokio/Buffer;-><init>()V
.line 178
iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->metadata:Lokio/ByteString;
invoke-virtual {v3, v0}, Lokio/Buffer;->write(Lokio/ByteString;)Lokio/Buffer;
.line 180
new-instance v0, Lokhttp3/internal/cache2/FileOperator;
iget-object v1, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
invoke-virtual {v1}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object v1
invoke-direct {v0, v1}, Lokhttp3/internal/cache2/FileOperator;-><init>(Ljava/nio/channels/FileChannel;)V
const-wide/16 v1, 0x20
add-long/2addr v1, p1
.line 181
iget-object p1, p0, Lokhttp3/internal/cache2/Relay;->metadata:Lokio/ByteString;
invoke-virtual {p1}, Lokio/ByteString;->size()I
move-result p1
int-to-long v4, p1
invoke-virtual/range {v0 .. v5}, Lokhttp3/internal/cache2/FileOperator;->write(JLokio/Buffer;J)V
return-void
.end method
# virtual methods
.method commit(J)V
.locals 8
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 186
invoke-direct {p0, p1, p2}, Lokhttp3/internal/cache2/Relay;->writeMetadata(J)V
.line 187
iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
invoke-virtual {v0}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object v0
const/4 v1, 0x0
invoke-virtual {v0, v1}, Ljava/nio/channels/FileChannel;->force(Z)V
.line 190
sget-object v3, Lokhttp3/internal/cache2/Relay;->PREFIX_CLEAN:Lokio/ByteString;
iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->metadata:Lokio/ByteString;
invoke-virtual {v0}, Lokio/ByteString;->size()I
move-result v0
int-to-long v6, v0
move-object v2, p0
move-wide v4, p1
invoke-direct/range {v2 .. v7}, Lokhttp3/internal/cache2/Relay;->writeHeader(Lokio/ByteString;JJ)V
.line 191
iget-object p1, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
invoke-virtual {p1}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object p1
invoke-virtual {p1, v1}, Ljava/nio/channels/FileChannel;->force(Z)V
.line 194
monitor-enter p0
const/4 p1, 0x1
.line 195
:try_start_0
iput-boolean p1, p0, Lokhttp3/internal/cache2/Relay;->complete:Z
.line 196
monitor-exit p0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 198
iget-object p1, p0, Lokhttp3/internal/cache2/Relay;->upstream:Lokio/Source;
invoke-static {p1}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
const/4 p1, 0x0
.line 199
iput-object p1, p0, Lokhttp3/internal/cache2/Relay;->upstream:Lokio/Source;
return-void
:catchall_0
move-exception p1
.line 196
:try_start_1
monitor-exit p0
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
throw p1
.end method
.method isClosed()Z
.locals 1
.line 203
iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
if-nez v0, :cond_0
const/4 v0, 0x1
goto :goto_0
:cond_0
const/4 v0, 0x0
:goto_0
return v0
.end method
.method public metadata()Lokio/ByteString;
.locals 1
.line 207
iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->metadata:Lokio/ByteString;
return-object v0
.end method
.method public newSource()Lokio/Source;
.locals 1
.line 216
monitor-enter p0
.line 217
:try_start_0
iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
if-nez v0, :cond_0
const/4 v0, 0x0
monitor-exit p0
return-object v0
.line 218
:cond_0
iget v0, p0, Lokhttp3/internal/cache2/Relay;->sourceCount:I
add-int/lit8 v0, v0, 0x1
iput v0, p0, Lokhttp3/internal/cache2/Relay;->sourceCount:I
.line 219
monitor-exit p0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 221
new-instance v0, Lokhttp3/internal/cache2/Relay$RelaySource;
invoke-direct {v0, p0}, Lokhttp3/internal/cache2/Relay$RelaySource;-><init>(Lokhttp3/internal/cache2/Relay;)V
return-object v0
:catchall_0
move-exception v0
.line 219
:try_start_1
monitor-exit p0
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
throw v0
.end method