Util.java
10 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
package com.squareup.okhttp.internal;
import com.squareup.okhttp.HttpUrl;
import java.io.Closeable;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import okio.Buffer;
import okio.ByteString;
import okio.Source;
import okio.Timeout;
public final class Util
{
public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
public static final String[] EMPTY_STRING_ARRAY = new String[0];
public static final Charset UTF_8 = Charset.forName("UTF-8");
public static void checkOffsetAndCount(long paramLong1, long paramLong2, long paramLong3)
{
if (((paramLong2 | paramLong3) < 0L) || (paramLong2 > paramLong1) || (paramLong1 - paramLong2 < paramLong3)) {
throw new ArrayIndexOutOfBoundsException();
}
}
public static void closeAll(Closeable paramCloseable1, Closeable paramCloseable2)
throws IOException
{
Object localObject = null;
for (;;)
{
try
{
paramCloseable1.close();
paramCloseable1 = (Closeable)localObject;
}
catch (Throwable paramCloseable1)
{
continue;
}
try
{
paramCloseable2.close();
paramCloseable2 = paramCloseable1;
}
catch (Throwable localThrowable)
{
paramCloseable2 = paramCloseable1;
if (paramCloseable1 != null) {
continue;
}
paramCloseable2 = localThrowable;
continue;
if (!(paramCloseable2 instanceof IOException)) {
continue;
}
throw ((IOException)paramCloseable2);
if (!(paramCloseable2 instanceof RuntimeException)) {
continue;
}
throw ((RuntimeException)paramCloseable2);
if (!(paramCloseable2 instanceof Error)) {
continue;
}
throw ((Error)paramCloseable2);
throw new AssertionError(paramCloseable2);
}
}
if (paramCloseable2 == null) {
return;
}
}
public static void closeQuietly(Closeable paramCloseable)
{
if (paramCloseable != null) {}
try
{
paramCloseable.close();
return;
}
catch (RuntimeException paramCloseable)
{
throw paramCloseable;
}
catch (Exception paramCloseable) {}
}
public static void closeQuietly(ServerSocket paramServerSocket)
{
if (paramServerSocket != null) {}
try
{
paramServerSocket.close();
return;
}
catch (RuntimeException paramServerSocket)
{
throw paramServerSocket;
}
catch (Exception paramServerSocket) {}
}
public static void closeQuietly(Socket paramSocket)
{
if (paramSocket != null) {}
try
{
paramSocket.close();
return;
}
catch (AssertionError paramSocket)
{
while (isAndroidGetsocknameError(paramSocket)) {}
throw paramSocket;
}
catch (RuntimeException paramSocket)
{
throw paramSocket;
}
catch (Exception paramSocket) {}
}
public static String[] concat(String[] paramArrayOfString, String paramString)
{
String[] arrayOfString = new String[paramArrayOfString.length + 1];
System.arraycopy(paramArrayOfString, 0, arrayOfString, 0, paramArrayOfString.length);
arrayOfString[(arrayOfString.length - 1)] = paramString;
return arrayOfString;
}
public static boolean contains(String[] paramArrayOfString, String paramString)
{
return Arrays.asList(paramArrayOfString).contains(paramString);
}
public static boolean discard(Source paramSource, int paramInt, TimeUnit paramTimeUnit)
{
try
{
boolean bool = skipAll(paramSource, paramInt, paramTimeUnit);
return bool;
}
catch (IOException paramSource) {}
return false;
}
public static boolean equal(Object paramObject1, Object paramObject2)
{
return (paramObject1 == paramObject2) || ((paramObject1 != null) && (paramObject1.equals(paramObject2)));
}
public static String hostHeader(HttpUrl paramHttpUrl)
{
if (paramHttpUrl.port() != HttpUrl.defaultPort(paramHttpUrl.scheme())) {
return paramHttpUrl.host() + ":" + paramHttpUrl.port();
}
return paramHttpUrl.host();
}
public static <T> List<T> immutableList(List<T> paramList)
{
return Collections.unmodifiableList(new ArrayList(paramList));
}
public static <T> List<T> immutableList(T... paramVarArgs)
{
return Collections.unmodifiableList(Arrays.asList((Object[])paramVarArgs.clone()));
}
public static <K, V> Map<K, V> immutableMap(Map<K, V> paramMap)
{
return Collections.unmodifiableMap(new LinkedHashMap(paramMap));
}
private static <T> List<T> intersect(T[] paramArrayOfT1, T[] paramArrayOfT2)
{
ArrayList localArrayList = new ArrayList();
int k = paramArrayOfT1.length;
int i = 0;
if (i < k)
{
T ? = paramArrayOfT1[i];
int m = paramArrayOfT2.length;
int j = 0;
for (;;)
{
if (j < m)
{
T ? = paramArrayOfT2[j];
if (?.equals(?)) {
localArrayList.add(?);
}
}
else
{
i += 1;
break;
}
j += 1;
}
}
return localArrayList;
}
public static <T> T[] intersect(Class<T> paramClass, T[] paramArrayOfT1, T[] paramArrayOfT2)
{
paramArrayOfT1 = intersect(paramArrayOfT1, paramArrayOfT2);
return paramArrayOfT1.toArray((Object[])Array.newInstance(paramClass, paramArrayOfT1.size()));
}
public static boolean isAndroidGetsocknameError(AssertionError paramAssertionError)
{
return (paramAssertionError.getCause() != null) && (paramAssertionError.getMessage() != null) && (paramAssertionError.getMessage().contains("getsockname failed"));
}
public static String md5Hex(String paramString)
{
try
{
paramString = ByteString.of(MessageDigest.getInstance("MD5").digest(paramString.getBytes("UTF-8"))).hex();
return paramString;
}
catch (NoSuchAlgorithmException paramString)
{
throw new AssertionError(paramString);
}
catch (UnsupportedEncodingException paramString)
{
for (;;) {}
}
}
public static ByteString sha1(ByteString paramByteString)
{
try
{
paramByteString = ByteString.of(MessageDigest.getInstance("SHA-1").digest(paramByteString.toByteArray()));
return paramByteString;
}
catch (NoSuchAlgorithmException paramByteString)
{
throw new AssertionError(paramByteString);
}
}
public static String shaBase64(String paramString)
{
try
{
paramString = ByteString.of(MessageDigest.getInstance("SHA-1").digest(paramString.getBytes("UTF-8"))).base64();
return paramString;
}
catch (NoSuchAlgorithmException paramString)
{
throw new AssertionError(paramString);
}
catch (UnsupportedEncodingException paramString)
{
for (;;) {}
}
}
public static boolean skipAll(Source paramSource, int paramInt, TimeUnit paramTimeUnit)
throws IOException
{
long l2 = System.nanoTime();
long l1;
if (paramSource.timeout().hasDeadline()) {
l1 = paramSource.timeout().deadlineNanoTime() - l2;
}
for (;;)
{
paramSource.timeout().deadlineNanoTime(Math.min(l1, paramTimeUnit.toNanos(paramInt)) + l2);
try
{
paramTimeUnit = new Buffer();
while (paramSource.read(paramTimeUnit, 2048L) != -1L) {
paramTimeUnit.clear();
}
}
catch (InterruptedIOException paramTimeUnit)
{
if (l1 == Long.MAX_VALUE) {
paramSource.timeout().clearDeadline();
}
for (;;)
{
return false;
l1 = Long.MAX_VALUE;
break;
if (l1 == Long.MAX_VALUE) {
paramSource.timeout().clearDeadline();
}
for (;;)
{
return true;
paramSource.timeout().deadlineNanoTime(l1 + l2);
}
paramSource.timeout().deadlineNanoTime(l1 + l2);
}
}
finally
{
if (l1 != Long.MAX_VALUE) {
break label188;
}
}
}
paramSource.timeout().clearDeadline();
for (;;)
{
throw paramTimeUnit;
label188:
paramSource.timeout().deadlineNanoTime(l1 + l2);
}
}
public static ThreadFactory threadFactory(String paramString, final boolean paramBoolean)
{
new ThreadFactory()
{
public final Thread newThread(Runnable paramAnonymousRunnable)
{
paramAnonymousRunnable = new Thread(paramAnonymousRunnable, this.val$name);
paramAnonymousRunnable.setDaemon(paramBoolean);
return paramAnonymousRunnable;
}
};
}
public static String toHumanReadableAscii(String paramString)
{
int m = paramString.length();
int i = 0;
for (;;)
{
Object localObject = paramString;
int j;
if (i < m)
{
j = paramString.codePointAt(i);
if ((j <= 31) || (j >= 127))
{
localObject = new Buffer();
((Buffer)localObject).writeUtf8(paramString, 0, i);
if (i < m)
{
int k = paramString.codePointAt(i);
if ((k > 31) && (k < 127)) {}
for (j = k;; j = 63)
{
((Buffer)localObject).writeUtf8CodePoint(j);
i = Character.charCount(k) + i;
break;
}
}
localObject = ((Buffer)localObject).readUtf8();
}
}
else
{
return (String)localObject;
}
i += Character.charCount(j);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/internal/Util.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/