MarkableInputStream.smali
10.6 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
.class final Lcom/squareup/picasso/MarkableInputStream;
.super Ljava/io/InputStream;
.source "MarkableInputStream.java"
# static fields
.field private static final DEFAULT_BUFFER_SIZE:I = 0x1000
# instance fields
.field private defaultMark:J
.field private final in:Ljava/io/InputStream;
.field private limit:J
.field private offset:J
.field private reset:J
# direct methods
.method public constructor <init>(Ljava/io/InputStream;)V
.locals 1
const/16 v0, 0x1000
.line 38
invoke-direct {p0, p1, v0}, Lcom/squareup/picasso/MarkableInputStream;-><init>(Ljava/io/InputStream;I)V
return-void
.end method
.method public constructor <init>(Ljava/io/InputStream;I)V
.locals 2
.line 41
invoke-direct {p0}, Ljava/io/InputStream;-><init>()V
const-wide/16 v0, -0x1
.line 35
iput-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->defaultMark:J
.line 42
invoke-virtual {p1}, Ljava/io/InputStream;->markSupported()Z
move-result v0
if-nez v0, :cond_0
.line 43
new-instance v0, Ljava/io/BufferedInputStream;
invoke-direct {v0, p1, p2}, Ljava/io/BufferedInputStream;-><init>(Ljava/io/InputStream;I)V
move-object p1, v0
.line 45
:cond_0
iput-object p1, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
return-void
.end method
.method private setLimit(J)V
.locals 4
.line 77
:try_start_0
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->reset:J
iget-wide v2, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
cmp-long v0, v0, v2
if-gez v0, :cond_0
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
iget-wide v2, p0, Lcom/squareup/picasso/MarkableInputStream;->limit:J
cmp-long v0, v0, v2
if-gtz v0, :cond_0
.line 78
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0}, Ljava/io/InputStream;->reset()V
.line 79
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
iget-wide v1, p0, Lcom/squareup/picasso/MarkableInputStream;->reset:J
sub-long v1, p1, v1
long-to-int v1, v1
invoke-virtual {v0, v1}, Ljava/io/InputStream;->mark(I)V
.line 80
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->reset:J
iget-wide v2, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
invoke-direct {p0, v0, v1, v2, v3}, Lcom/squareup/picasso/MarkableInputStream;->skip(JJ)V
goto :goto_0
.line 82
:cond_0
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
iput-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->reset:J
.line 83
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
iget-wide v1, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
sub-long v1, p1, v1
long-to-int v1, v1
invoke-virtual {v0, v1}, Ljava/io/InputStream;->mark(I)V
.line 85
:goto_0
iput-wide p1, p0, Lcom/squareup/picasso/MarkableInputStream;->limit:J
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
return-void
:catch_0
move-exception p1
.line 87
new-instance p2, Ljava/lang/IllegalStateException;
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
const-string v1, "Unable to mark: "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p2, p1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p2
.end method
.method private skip(JJ)V
.locals 4
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
:goto_0
cmp-long v0, p1, p3
if-gez v0, :cond_2
.line 109
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
sub-long v1, p3, p1
invoke-virtual {v0, v1, v2}, Ljava/io/InputStream;->skip(J)J
move-result-wide v0
const-wide/16 v2, 0x0
cmp-long v2, v0, v2
if-nez v2, :cond_1
.line 111
invoke-virtual {p0}, Lcom/squareup/picasso/MarkableInputStream;->read()I
move-result v0
const/4 v1, -0x1
if-ne v0, v1, :cond_0
goto :goto_1
:cond_0
const-wide/16 v0, 0x1
:cond_1
add-long/2addr p1, v0
goto :goto_0
:cond_2
:goto_1
return-void
.end method
# virtual methods
.method public available()I
.locals 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 152
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0}, Ljava/io/InputStream;->available()I
move-result v0
return v0
.end method
.method public close()V
.locals 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 156
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
return-void
.end method
.method public mark(I)V
.locals 2
.line 50
invoke-virtual {p0, p1}, Lcom/squareup/picasso/MarkableInputStream;->savePosition(I)J
move-result-wide v0
iput-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->defaultMark:J
return-void
.end method
.method public markSupported()Z
.locals 1
.line 160
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0}, Ljava/io/InputStream;->markSupported()Z
move-result v0
return v0
.end method
.method public read()I
.locals 5
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 122
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0}, Ljava/io/InputStream;->read()I
move-result v0
const/4 v1, -0x1
if-eq v0, v1, :cond_0
.line 124
iget-wide v1, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
const-wide/16 v3, 0x1
add-long/2addr v1, v3
iput-wide v1, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
:cond_0
return v0
.end method
.method public read([B)I
.locals 4
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 130
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0, p1}, Ljava/io/InputStream;->read([B)I
move-result p1
const/4 v0, -0x1
if-eq p1, v0, :cond_0
.line 132
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
int-to-long v2, p1
add-long/2addr v0, v2
iput-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
:cond_0
return p1
.end method
.method public read([BII)I
.locals 2
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 138
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0, p1, p2, p3}, Ljava/io/InputStream;->read([BII)I
move-result p1
const/4 p2, -0x1
if-eq p1, p2, :cond_0
.line 140
iget-wide p2, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
int-to-long v0, p1
add-long/2addr p2, v0
iput-wide p2, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
:cond_0
return p1
.end method
.method public reset()V
.locals 2
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 93
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->defaultMark:J
invoke-virtual {p0, v0, v1}, Lcom/squareup/picasso/MarkableInputStream;->reset(J)V
return-void
.end method
.method public reset(J)V
.locals 4
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 98
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
iget-wide v2, p0, Lcom/squareup/picasso/MarkableInputStream;->limit:J
cmp-long v0, v0, v2
if-gtz v0, :cond_0
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->reset:J
cmp-long v0, p1, v0
if-ltz v0, :cond_0
.line 101
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0}, Ljava/io/InputStream;->reset()V
.line 102
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->reset:J
invoke-direct {p0, v0, v1, p1, p2}, Lcom/squareup/picasso/MarkableInputStream;->skip(JJ)V
.line 103
iput-wide p1, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
return-void
.line 99
:cond_0
new-instance p1, Ljava/io/IOException;
const-string p2, "Cannot reset"
invoke-direct {p1, p2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
throw p1
.end method
.method public savePosition(I)J
.locals 4
.line 60
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
int-to-long v2, p1
add-long/2addr v0, v2
.line 61
iget-wide v2, p0, Lcom/squareup/picasso/MarkableInputStream;->limit:J
cmp-long p1, v2, v0
if-gez p1, :cond_0
.line 62
invoke-direct {p0, v0, v1}, Lcom/squareup/picasso/MarkableInputStream;->setLimit(J)V
.line 64
:cond_0
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
return-wide v0
.end method
.method public skip(J)J
.locals 2
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 146
iget-object v0, p0, Lcom/squareup/picasso/MarkableInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0, p1, p2}, Ljava/io/InputStream;->skip(J)J
move-result-wide p1
.line 147
iget-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
add-long/2addr v0, p1
iput-wide v0, p0, Lcom/squareup/picasso/MarkableInputStream;->offset:J
return-wide p1
.end method