Relay$RelaySource.smali
16.1 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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
.class Lokhttp3/internal/cache2/Relay$RelaySource;
.super Ljava/lang/Object;
.source "Relay.java"
# interfaces
.implements Lokio/Source;
# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
value = Lokhttp3/internal/cache2/Relay;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x0
name = "RelaySource"
.end annotation
# instance fields
.field private fileOperator:Lokhttp3/internal/cache2/FileOperator;
.field private sourcePos:J
.field final synthetic this$0:Lokhttp3/internal/cache2/Relay;
.field private final timeout:Lokio/Timeout;
# direct methods
.method constructor <init>(Lokhttp3/internal/cache2/Relay;)V
.locals 1
.line 224
iput-object p1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 225
new-instance p1, Lokio/Timeout;
invoke-direct {p1}, Lokio/Timeout;-><init>()V
iput-object p1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/Timeout;
.line 228
new-instance p1, Lokhttp3/internal/cache2/FileOperator;
iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
invoke-virtual {v0}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object v0
invoke-direct {p1, v0}, Lokhttp3/internal/cache2/FileOperator;-><init>(Ljava/nio/channels/FileChannel;)V
iput-object p1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
return-void
.end method
# virtual methods
.method public close()V
.locals 4
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 344
iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
if-nez v0, :cond_0
return-void
:cond_0
const/4 v0, 0x0
.line 345
iput-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
.line 348
iget-object v1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v1
.line 349
:try_start_0
iget-object v2, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget v3, v2, Lokhttp3/internal/cache2/Relay;->sourceCount:I
add-int/lit8 v3, v3, -0x1
iput v3, v2, Lokhttp3/internal/cache2/Relay;->sourceCount:I
.line 350
iget-object v2, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget v2, v2, Lokhttp3/internal/cache2/Relay;->sourceCount:I
if-nez v2, :cond_1
.line 351
iget-object v2, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v2, v2, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
.line 352
iget-object v3, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v0, v3, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
move-object v0, v2
.line 354
:cond_1
monitor-exit v1
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
if-eqz v0, :cond_2
.line 357
invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
:cond_2
return-void
:catchall_0
move-exception v0
.line 354
:try_start_1
monitor-exit v1
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
throw v0
.end method
.method public read(Lokio/Buffer;J)J
.locals 21
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
move-object/from16 v1, p0
move-wide/from16 v2, p2
.line 252
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
if-eqz v0, :cond_7
.line 258
iget-object v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v4
.line 260
:goto_0
:try_start_0
iget-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v7, v0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
cmp-long v0, v5, v7
const/4 v5, 0x2
const-wide/16 v9, -0x1
if-nez v0, :cond_2
.line 262
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-boolean v0, v0, Lokhttp3/internal/cache2/Relay;->complete:Z
if-eqz v0, :cond_0
monitor-exit v4
return-wide v9
.line 265
:cond_0
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
if-eqz v0, :cond_1
.line 266
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/Timeout;
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-virtual {v0, v5}, Lokio/Timeout;->waitUntilNotified(Ljava/lang/Object;)V
goto :goto_0
.line 271
:cond_1
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
move-result-object v6
iput-object v6, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
const/4 v0, 0x1
.line 273
monitor-exit v4
goto :goto_1
.line 276
:cond_2
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
invoke-virtual {v0}, Lokio/Buffer;->size()J
move-result-wide v11
sub-long v11, v7, v11
.line 279
iget-wide v13, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
cmp-long v0, v13, v11
if-gez v0, :cond_6
.line 281
monitor-exit v4
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_5
move v0, v5
:goto_1
const-wide/16 v11, 0x20
if-ne v0, v5, :cond_3
.line 293
iget-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
sub-long/2addr v7, v4
invoke-static {v2, v3, v7, v8}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
.line 294
iget-object v13, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
iget-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
add-long v14, v4, v11
move-object/from16 v16, p1
move-wide/from16 v17, v2
invoke-virtual/range {v13 .. v18}, Lokhttp3/internal/cache2/FileOperator;->read(JLokio/Buffer;J)V
.line 295
iget-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
add-long/2addr v4, v2
iput-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
return-wide v2
:cond_3
const/4 v4, 0x0
.line 302
:try_start_1
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->upstream:Lokio/Source;
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v5, v5, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
iget-object v6, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v13, v6, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
invoke-interface {v0, v5, v13, v14}, Lokio/Source;->read(Lokio/Buffer;J)J
move-result-wide v5
cmp-long v0, v5, v9
if-nez v0, :cond_4
.line 306
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-virtual {v0, v7, v8}, Lokhttp3/internal/cache2/Relay;->commit(J)V
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_3
.line 332
iget-object v2, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v2
.line 333
:try_start_2
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v4, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
.line 334
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-virtual {v0}, Ljava/lang/Object;->notifyAll()V
.line 335
monitor-exit v2
return-wide v9
:catchall_0
move-exception v0
monitor-exit v2
:try_end_2
.catchall {:try_start_2 .. :try_end_2} :catchall_0
throw v0
.line 311
:cond_4
:try_start_3
invoke-static {v5, v6, v2, v3}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
.line 312
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v13, v0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
const-wide/16 v15, 0x0
move-object/from16 v14, p1
move-wide/from16 v17, v2
invoke-virtual/range {v13 .. v18}, Lokio/Buffer;->copyTo(Lokio/Buffer;JJ)Lokio/Buffer;
.line 313
iget-wide v9, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
add-long/2addr v9, v2
iput-wide v9, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
.line 316
iget-object v15, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
add-long v16, v7, v11
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
.line 317
invoke-virtual {v0}, Lokio/Buffer;->clone()Lokio/Buffer;
move-result-object v18
move-wide/from16 v19, v5
.line 316
invoke-virtual/range {v15 .. v20}, Lokhttp3/internal/cache2/FileOperator;->write(JLokio/Buffer;J)V
.line 319
iget-object v7, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v7
:try_end_3
.catchall {:try_start_3 .. :try_end_3} :catchall_3
.line 321
:try_start_4
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
iget-object v8, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v8, v8, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
invoke-virtual {v0, v8, v5, v6}, Lokio/Buffer;->write(Lokio/Buffer;J)V
.line 322
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
invoke-virtual {v0}, Lokio/Buffer;->size()J
move-result-wide v8
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v10, v0, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
cmp-long v0, v8, v10
if-lez v0, :cond_5
.line 323
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
iget-object v8, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v8, v8, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
invoke-virtual {v8}, Lokio/Buffer;->size()J
move-result-wide v8
iget-object v10, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v10, v10, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
sub-long/2addr v8, v10
invoke-virtual {v0, v8, v9}, Lokio/Buffer;->skip(J)V
.line 327
:cond_5
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v8, v0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
add-long/2addr v8, v5
iput-wide v8, v0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
.line 328
monitor-exit v7
:try_end_4
.catchall {:try_start_4 .. :try_end_4} :catchall_2
.line 332
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v5
.line 333
:try_start_5
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v4, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
.line 334
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-virtual {v0}, Ljava/lang/Object;->notifyAll()V
.line 335
monitor-exit v5
return-wide v2
:catchall_1
move-exception v0
monitor-exit v5
:try_end_5
.catchall {:try_start_5 .. :try_end_5} :catchall_1
throw v0
:catchall_2
move-exception v0
.line 328
:try_start_6
monitor-exit v7
:try_end_6
.catchall {:try_start_6 .. :try_end_6} :catchall_2
:try_start_7
throw v0
:try_end_7
.catchall {:try_start_7 .. :try_end_7} :catchall_3
:catchall_3
move-exception v0
.line 332
iget-object v2, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v2
.line 333
:try_start_8
iget-object v3, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v4, v3, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
.line 334
iget-object v3, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-virtual {v3}, Ljava/lang/Object;->notifyAll()V
.line 335
monitor-exit v2
:try_end_8
.catchall {:try_start_8 .. :try_end_8} :catchall_4
throw v0
:catchall_4
move-exception v0
:try_start_9
monitor-exit v2
:try_end_9
.catchall {:try_start_9 .. :try_end_9} :catchall_4
throw v0
.line 285
:cond_6
:try_start_a
iget-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
sub-long/2addr v7, v5
invoke-static {v2, v3, v7, v8}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
.line 286
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v13, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
iget-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
sub-long v15, v5, v11
move-object/from16 v14, p1
move-wide/from16 v17, v2
invoke-virtual/range {v13 .. v18}, Lokio/Buffer;->copyTo(Lokio/Buffer;JJ)Lokio/Buffer;
.line 287
iget-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
add-long/2addr v5, v2
iput-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
.line 288
monitor-exit v4
return-wide v2
:catchall_5
move-exception v0
.line 289
monitor-exit v4
:try_end_a
.catchall {:try_start_a .. :try_end_a} :catchall_5
throw v0
.line 252
:cond_7
new-instance v0, Ljava/lang/IllegalStateException;
const-string v2, "closed"
invoke-direct {v0, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method public timeout()Lokio/Timeout;
.locals 1
.line 340
iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/Timeout;
return-object v0
.end method