ad.java
11 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
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.ApplicationInfo;
import android.os.Build.VERSION;
import android.util.Log;
import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
public final class ad
{
private static Method a;
static
{
try
{
a = SharedPreferences.Editor.class.getMethod("apply", new Class[0]);
return;
}
catch (NoSuchMethodException localNoSuchMethodException)
{
a = null;
}
}
private static SharedPreferences a(Context paramContext)
{
if (Build.VERSION.SDK_INT < 11) {}
for (int i = 0;; i = 4) {
return paramContext.getSharedPreferences("multidex.version", i);
}
}
public static List<File> a(Context paramContext, ApplicationInfo paramApplicationInfo, File paramFile, boolean paramBoolean)
throws IOException
{
Log.i("MultiDex", "MultiDexExtractor.load(" + paramApplicationInfo.sourceDir + ", " + paramBoolean + ")");
File localFile = new File(paramApplicationInfo.sourceDir);
long l2 = ae.a(localFile);
long l1 = l2;
if (l2 == -1L) {
l1 = l2 - 1L;
}
int i;
if (!paramBoolean)
{
paramApplicationInfo = a(paramContext);
if ((paramApplicationInfo.getLong("timestamp", -1L) != b(localFile)) || (paramApplicationInfo.getLong("crc", -1L) != l1))
{
i = 1;
if (i != 0) {
break label223;
}
}
}
for (;;)
{
try
{
paramApplicationInfo = a(paramContext, localFile, paramFile);
paramContext = paramApplicationInfo;
}
catch (IOException paramApplicationInfo)
{
Log.w("MultiDex", "Failed to reload existing extracted secondary dex files, falling back to fresh extraction", paramApplicationInfo);
paramApplicationInfo = a(localFile, paramFile);
a(paramContext, b(localFile), l1, paramApplicationInfo.size() + 1);
paramContext = paramApplicationInfo;
continue;
}
Log.i("MultiDex", "load found " + paramContext.size() + " secondary dex files");
return paramContext;
i = 0;
break;
label223:
Log.i("MultiDex", "Detected that extraction must be performed.");
paramApplicationInfo = a(localFile, paramFile);
a(paramContext, b(localFile), l1, paramApplicationInfo.size() + 1);
paramContext = paramApplicationInfo;
}
}
private static List<File> a(Context paramContext, File paramFile1, File paramFile2)
throws IOException
{
Log.i("MultiDex", "loading existing secondary dex files");
paramFile1 = paramFile1.getName() + ".classes";
int j = a(paramContext).getInt("dex.number", 1);
paramContext = new ArrayList(j);
int i = 2;
while (i <= j)
{
File localFile = new File(paramFile2, paramFile1 + i + ".zip");
if (localFile.isFile())
{
paramContext.add(localFile);
if (!a(localFile))
{
Log.i("MultiDex", "Invalid zip file: " + localFile);
throw new IOException("Invalid ZIP file.");
}
}
else
{
throw new IOException("Missing extracted secondary dex file '" + localFile.getPath() + "'");
}
i += 1;
}
return paramContext;
}
private static List<File> a(File paramFile1, File paramFile2)
throws IOException
{
String str2 = paramFile1.getName() + ".classes";
a(paramFile2, str2);
localArrayList = new ArrayList();
localZipFile = new ZipFile(paramFile1);
try
{
paramFile1 = localZipFile.getEntry("classes2.dex");
j = 2;
}
finally
{
for (;;)
{
try
{
int j;
File localFile;
boolean bool;
int i;
localZipFile.close();
throw paramFile1;
j += 1;
paramFile1 = localZipFile.getEntry("classes" + j + ".dex");
continue;
try
{
localZipFile.close();
return localArrayList;
}
catch (IOException paramFile1)
{
Log.w("MultiDex", "Failed to close resource", paramFile1);
return localArrayList;
}
}
catch (IOException paramFile2)
{
Log.w("MultiDex", "Failed to close resource", paramFile2);
continue;
}
continue;
String str1 = "failed";
}
}
if (paramFile1 != null)
{
localFile = new File(paramFile2, str2 + j + ".zip");
localArrayList.add(localFile);
Log.i("MultiDex", "Extraction is needed for file " + localFile);
bool = false;
i = 0;
while ((i < 3) && (!bool))
{
i += 1;
a(localZipFile, paramFile1, localFile, str2);
bool = a(localFile);
StringBuilder localStringBuilder = new StringBuilder("Extraction ");
if (!bool) {
break label407;
}
str1 = "success";
Log.i("MultiDex", str1 + " - length " + localFile.getAbsolutePath() + ": " + localFile.length());
if (bool) {
break label404;
}
localFile.delete();
if (!localFile.exists()) {
break label404;
}
Log.w("MultiDex", "Failed to delete corrupted secondary dex '" + localFile.getPath() + "'");
}
if (!bool) {
throw new IOException("Could not create zip file " + localFile.getAbsolutePath() + " for secondary dex (" + j + ")");
}
}
}
private static void a(Context paramContext, long paramLong1, long paramLong2, int paramInt)
{
paramContext = a(paramContext).edit();
paramContext.putLong("timestamp", paramLong1);
paramContext.putLong("crc", paramLong2);
paramContext.putInt("dex.number", paramInt);
if (a != null) {}
try
{
a.invoke(paramContext, new Object[0]);
return;
}
catch (IllegalAccessException localIllegalAccessException)
{
paramContext.commit();
return;
}
catch (InvocationTargetException localInvocationTargetException)
{
for (;;) {}
}
}
private static void a(Closeable paramCloseable)
{
try
{
paramCloseable.close();
return;
}
catch (IOException paramCloseable)
{
Log.w("MultiDex", "Failed to close resource", paramCloseable);
}
}
private static void a(File paramFile, String paramString)
throws IOException
{
c(paramFile.getParentFile());
c(paramFile);
paramString = paramFile.listFiles(new FileFilter()
{
public final boolean accept(File paramAnonymousFile)
{
return !paramAnonymousFile.getName().startsWith(this.a);
}
});
if (paramString == null)
{
Log.w("MultiDex", "Failed to list secondary dex dir content (" + paramFile.getPath() + ").");
return;
}
int j = paramString.length;
int i = 0;
label66:
if (i < j)
{
paramFile = paramString[i];
Log.i("MultiDex", "Trying to delete old file " + paramFile.getPath() + " of size " + paramFile.length());
if (paramFile.delete()) {
break label154;
}
Log.w("MultiDex", "Failed to delete old file " + paramFile.getPath());
}
for (;;)
{
i += 1;
break label66;
break;
label154:
Log.i("MultiDex", "Deleted old file " + paramFile.getPath());
}
}
private static void a(ZipFile paramZipFile, ZipEntry paramZipEntry, File paramFile, String paramString)
throws IOException, FileNotFoundException
{
paramZipFile = paramZipFile.getInputStream(paramZipEntry);
paramString = File.createTempFile(paramString, ".zip", paramFile.getParentFile());
Log.i("MultiDex", "Extracting " + paramString.getPath());
try
{
ZipOutputStream localZipOutputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(paramString)));
ZipEntry localZipEntry;
int i;
a(paramZipFile);
}
finally
{
try
{
localZipEntry = new ZipEntry("classes.dex");
localZipEntry.setTime(paramZipEntry.getTime());
localZipOutputStream.putNextEntry(localZipEntry);
paramZipEntry = new byte['䀀'];
for (i = paramZipFile.read(paramZipEntry); i != -1; i = paramZipFile.read(paramZipEntry)) {
localZipOutputStream.write(paramZipEntry, 0, i);
}
localZipOutputStream.closeEntry();
localZipOutputStream.close();
Log.i("MultiDex", "Renaming to " + paramFile.getPath());
if (paramString.renameTo(paramFile)) {
break label244;
}
throw new IOException("Failed to rename \"" + paramString.getAbsolutePath() + "\" to \"" + paramFile.getAbsolutePath() + "\"");
}
finally
{
localZipOutputStream.close();
}
paramZipEntry = finally;
a(paramZipFile);
paramString.delete();
}
label244:
paramString.delete();
}
public static boolean a(File paramFile)
{
try
{
ZipFile localZipFile = new ZipFile(paramFile);
try
{
localZipFile.close();
return true;
}
catch (IOException localIOException1)
{
Log.w("MultiDex", "Failed to close zip file: " + paramFile.getAbsolutePath());
}
}
catch (ZipException localZipException)
{
for (;;)
{
Log.w("MultiDex", "File " + paramFile.getAbsolutePath() + " is not a valid zip file.", localZipException);
}
}
catch (IOException localIOException2)
{
for (;;)
{
Log.w("MultiDex", "Got an IOException trying to open zip file: " + paramFile.getAbsolutePath(), localIOException2);
}
}
return false;
}
private static long b(File paramFile)
{
long l2 = paramFile.lastModified();
long l1 = l2;
if (l2 == -1L) {
l1 = l2 - 1L;
}
return l1;
}
private static void c(File paramFile)
throws IOException
{
paramFile.mkdir();
if (!paramFile.isDirectory())
{
File localFile = paramFile.getParentFile();
if (localFile == null) {
Log.e("MultiDex", "Failed to create dir " + paramFile.getPath() + ". Parent file is null.");
}
for (;;)
{
throw new IOException("Failed to create cache directory " + paramFile.getPath());
Log.e("MultiDex", "Failed to create dir " + paramFile.getPath() + ". parent file is a dir " + localFile.isDirectory() + ", a file " + localFile.isFile() + ", exists " + localFile.exists() + ", readable " + localFile.canRead() + ", writable " + localFile.canWrite());
}
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/ad.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/