Base64OutputStream.smali
5.9 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
.class public Lcom/brplug/base64/Base64OutputStream;
.super Ljava/io/OutputStream;
# instance fields
.field private buffer:I
.field private bytecounter:I
.field private linecounter:I
.field private linelength:I
.field private outputStream:Ljava/io/OutputStream;
# direct methods
.method public constructor <init>(Ljava/io/OutputStream;)V
.locals 1
const/16 v0, 0x4c
invoke-direct {p0, p1, v0}, Lcom/brplug/base64/Base64OutputStream;-><init>(Ljava/io/OutputStream;I)V
return-void
.end method
.method public constructor <init>(Ljava/io/OutputStream;I)V
.locals 1
invoke-direct {p0}, Ljava/io/OutputStream;-><init>()V
const/4 v0, 0x0
iput-object v0, p0, Lcom/brplug/base64/Base64OutputStream;->outputStream:Ljava/io/OutputStream;
const/4 v0, 0x0
iput v0, p0, Lcom/brplug/base64/Base64OutputStream;->buffer:I
iput v0, p0, Lcom/brplug/base64/Base64OutputStream;->bytecounter:I
iput v0, p0, Lcom/brplug/base64/Base64OutputStream;->linecounter:I
iput v0, p0, Lcom/brplug/base64/Base64OutputStream;->linelength:I
iput-object p1, p0, Lcom/brplug/base64/Base64OutputStream;->outputStream:Ljava/io/OutputStream;
iput p2, p0, Lcom/brplug/base64/Base64OutputStream;->linelength:I
return-void
.end method
# virtual methods
.method public close()V
.locals 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
invoke-virtual {p0}, Lcom/brplug/base64/Base64OutputStream;->commit()V
iget-object v0, p0, Lcom/brplug/base64/Base64OutputStream;->outputStream:Ljava/io/OutputStream;
invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
return-void
.end method
.method protected commit()V
.locals 6
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
iget v0, p0, Lcom/brplug/base64/Base64OutputStream;->bytecounter:I
if-lez v0, :cond_3
iget v0, p0, Lcom/brplug/base64/Base64OutputStream;->linelength:I
const/4 v1, 0x0
if-lez v0, :cond_0
iget v2, p0, Lcom/brplug/base64/Base64OutputStream;->linecounter:I
if-ne v2, v0, :cond_0
iget-object v0, p0, Lcom/brplug/base64/Base64OutputStream;->outputStream:Ljava/io/OutputStream;
const-string v2, "\r\n"
invoke-virtual {v2}, Ljava/lang/String;->getBytes()[B
move-result-object v2
invoke-virtual {v0, v2}, Ljava/io/OutputStream;->write([B)V
iput v1, p0, Lcom/brplug/base64/Base64OutputStream;->linecounter:I
:cond_0
sget-object v0, Lcom/brplug/base64/Shared;->chars:Ljava/lang/String;
iget v2, p0, Lcom/brplug/base64/Base64OutputStream;->buffer:I
shl-int/lit8 v2, v2, 0x8
ushr-int/lit8 v2, v2, 0x1a
invoke-virtual {v0, v2}, Ljava/lang/String;->charAt(I)C
move-result v0
sget-object v2, Lcom/brplug/base64/Shared;->chars:Ljava/lang/String;
iget v3, p0, Lcom/brplug/base64/Base64OutputStream;->buffer:I
shl-int/lit8 v3, v3, 0xe
ushr-int/lit8 v3, v3, 0x1a
invoke-virtual {v2, v3}, Ljava/lang/String;->charAt(I)C
move-result v2
iget v3, p0, Lcom/brplug/base64/Base64OutputStream;->bytecounter:I
const/4 v4, 0x2
if-ge v3, v4, :cond_1
sget-char v3, Lcom/brplug/base64/Shared;->pad:C
goto :goto_0
:cond_1
sget-object v3, Lcom/brplug/base64/Shared;->chars:Ljava/lang/String;
iget v4, p0, Lcom/brplug/base64/Base64OutputStream;->buffer:I
shl-int/lit8 v4, v4, 0x14
ushr-int/lit8 v4, v4, 0x1a
invoke-virtual {v3, v4}, Ljava/lang/String;->charAt(I)C
move-result v3
:goto_0
iget v4, p0, Lcom/brplug/base64/Base64OutputStream;->bytecounter:I
const/4 v5, 0x3
if-ge v4, v5, :cond_2
sget-char v4, Lcom/brplug/base64/Shared;->pad:C
goto :goto_1
:cond_2
sget-object v4, Lcom/brplug/base64/Shared;->chars:Ljava/lang/String;
iget v5, p0, Lcom/brplug/base64/Base64OutputStream;->buffer:I
shl-int/lit8 v5, v5, 0x1a
ushr-int/lit8 v5, v5, 0x1a
invoke-virtual {v4, v5}, Ljava/lang/String;->charAt(I)C
move-result v4
:goto_1
iget-object v5, p0, Lcom/brplug/base64/Base64OutputStream;->outputStream:Ljava/io/OutputStream;
invoke-virtual {v5, v0}, Ljava/io/OutputStream;->write(I)V
iget-object v0, p0, Lcom/brplug/base64/Base64OutputStream;->outputStream:Ljava/io/OutputStream;
invoke-virtual {v0, v2}, Ljava/io/OutputStream;->write(I)V
iget-object v0, p0, Lcom/brplug/base64/Base64OutputStream;->outputStream:Ljava/io/OutputStream;
invoke-virtual {v0, v3}, Ljava/io/OutputStream;->write(I)V
iget-object v0, p0, Lcom/brplug/base64/Base64OutputStream;->outputStream:Ljava/io/OutputStream;
invoke-virtual {v0, v4}, Ljava/io/OutputStream;->write(I)V
iget v0, p0, Lcom/brplug/base64/Base64OutputStream;->linecounter:I
add-int/lit8 v0, v0, 0x4
iput v0, p0, Lcom/brplug/base64/Base64OutputStream;->linecounter:I
iput v1, p0, Lcom/brplug/base64/Base64OutputStream;->bytecounter:I
iput v1, p0, Lcom/brplug/base64/Base64OutputStream;->buffer:I
:cond_3
return-void
.end method
.method public write(I)V
.locals 2
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
and-int/lit16 p1, p1, 0xff
iget v0, p0, Lcom/brplug/base64/Base64OutputStream;->bytecounter:I
mul-int/lit8 v1, v0, 0x8
rsub-int/lit8 v1, v1, 0x10
shl-int/2addr p1, v1
iget v1, p0, Lcom/brplug/base64/Base64OutputStream;->buffer:I
or-int/2addr p1, v1
iput p1, p0, Lcom/brplug/base64/Base64OutputStream;->buffer:I
add-int/lit8 v0, v0, 0x1
iput v0, p0, Lcom/brplug/base64/Base64OutputStream;->bytecounter:I
iget p1, p0, Lcom/brplug/base64/Base64OutputStream;->bytecounter:I
const/4 v0, 0x3
if-ne p1, v0, :cond_0
invoke-virtual {p0}, Lcom/brplug/base64/Base64OutputStream;->commit()V
:cond_0
return-void
.end method