VersionHelper.java
9.36 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
package net.hockeyapp.android.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.text.TextUtils;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.Scanner;
import java.util.regex.Pattern;
import net.hockeyapp.android.UpdateInfoListener;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class VersionHelper
{
public static final String VERSION_MAX = "99.0";
private ArrayList<JSONObject> a;
private JSONObject b;
private UpdateInfoListener c;
private int d;
public VersionHelper(Context paramContext, String paramString, UpdateInfoListener paramUpdateInfoListener)
{
this.c = paramUpdateInfoListener;
a(paramContext, paramString);
Collections.sort(this.a, new Comparator()
{
private static int a(JSONObject paramAnonymousJSONObject1, JSONObject paramAnonymousJSONObject2)
{
try
{
int i = paramAnonymousJSONObject1.getInt("version");
int j = paramAnonymousJSONObject2.getInt("version");
if (i > j) {}
return 0;
}
catch (NullPointerException paramAnonymousJSONObject1)
{
return 0;
}
catch (JSONException paramAnonymousJSONObject1) {}
return 0;
}
});
}
private static long a(JSONObject paramJSONObject, String paramString)
{
try
{
long l = paramJSONObject.getLong(paramString);
return l;
}
catch (JSONException paramJSONObject) {}
return 0L;
}
private static String a(JSONObject paramJSONObject)
{
try
{
paramJSONObject = paramJSONObject.getString("id");
return paramJSONObject;
}
catch (JSONException paramJSONObject) {}
return "";
}
private static String a(JSONObject paramJSONObject, String paramString1, String paramString2)
{
try
{
paramJSONObject = paramJSONObject.getString(paramString1);
return paramJSONObject;
}
catch (JSONException paramJSONObject) {}
return paramString2;
}
private void a(Context paramContext, String paramString)
{
this.b = new JSONObject();
this.a = new ArrayList();
this.d = this.c.getCurrentVersionCode();
for (;;)
{
int k;
int m;
try
{
paramString = new JSONArray(paramString);
int j = this.c.getCurrentVersionCode();
int i = 0;
if (i < paramString.length())
{
JSONObject localJSONObject = paramString.getJSONObject(i);
if (localJSONObject.getInt("version") > j)
{
k = 1;
if ((localJSONObject.getInt("version") == j) && (isNewerThanLastUpdateTime(paramContext, localJSONObject.getLong("timestamp"))))
{
m = 1;
break label167;
this.b = localJSONObject;
j = localJSONObject.getInt("version");
this.a.add(localJSONObject);
i += 1;
}
}
else
{
k = 0;
continue;
}
m = 0;
}
}
catch (NullPointerException paramContext)
{
return;
}
catch (JSONException paramContext)
{
return;
}
label167:
if (k == 0) {
if (m == 0) {}
}
}
}
private static int b(JSONObject paramJSONObject)
{
try
{
int i = paramJSONObject.getInt("version");
return i;
}
catch (JSONException paramJSONObject) {}
return 0;
}
private static String c(JSONObject paramJSONObject)
{
try
{
paramJSONObject = paramJSONObject.getString("shortversion");
return paramJSONObject;
}
catch (JSONException paramJSONObject) {}
return "";
}
public static int compareVersionStrings(String paramString1, String paramString2)
{
int j = -1;
int i;
if ((paramString1 == null) || (paramString2 == null)) {
i = 0;
}
for (;;)
{
return i;
try
{
paramString1 = new Scanner(paramString1.replaceAll("\\-.*", ""));
paramString2 = new Scanner(paramString2.replaceAll("\\-.*", ""));
paramString1.useDelimiter("\\.");
paramString2.useDelimiter("\\.");
for (;;)
{
if ((paramString1.hasNextInt()) && (paramString2.hasNextInt()))
{
int k = paramString1.nextInt();
int m = paramString2.nextInt();
i = j;
if (k < m) {
break;
}
if (k > m) {
return 1;
}
}
}
if (paramString1.hasNextInt()) {
return 1;
}
boolean bool = paramString2.hasNextInt();
i = j;
if (!bool) {
return 0;
}
}
catch (Exception paramString1) {}
}
return 0;
}
public static boolean isNewerThanLastUpdateTime(Context paramContext, long paramLong)
{
if (paramContext == null) {}
for (;;)
{
return false;
try
{
long l = new File(paramContext.getPackageManager().getApplicationInfo(paramContext.getPackageName(), 0).sourceDir).lastModified() / 1000L;
if (paramLong > l + 1800L) {
return true;
}
}
catch (PackageManager.NameNotFoundException paramContext)
{
paramContext.printStackTrace();
}
}
return false;
}
public static String mapGoogleVersion(String paramString)
{
String str;
if ((paramString == null) || (paramString.equalsIgnoreCase("L"))) {
str = "5.0";
}
do
{
return str;
if (paramString.equalsIgnoreCase("M")) {
return "6.0";
}
if (paramString.equalsIgnoreCase("N")) {
return "7.0";
}
str = paramString;
} while (!Pattern.matches("^[a-zA-Z]+", paramString));
return "99.0";
}
@SuppressLint({"SimpleDateFormat"})
public String getFileDateString()
{
Date localDate = new Date(a(this.b, "timestamp") * 1000L);
return new SimpleDateFormat("dd.MM.yyyy").format(localDate);
}
public long getFileSizeBytes()
{
boolean bool = Boolean.valueOf(a(this.b, "external", "false")).booleanValue();
long l2 = a(this.b, "appsize");
long l1 = l2;
if (bool)
{
l1 = l2;
if (l2 == 0L) {
l1 = -1L;
}
}
return l1;
}
public String getReleaseNotes(boolean paramBoolean)
{
StringBuilder localStringBuilder1 = new StringBuilder();
localStringBuilder1.append("<html>");
localStringBuilder1.append("<body style='padding: 0px 0px 20px 0px'>");
Iterator localIterator = this.a.iterator();
int i = 0;
if (localIterator.hasNext())
{
Object localObject = (JSONObject)localIterator.next();
if (i > 0)
{
localStringBuilder1.append("<hr style='border-top: 1px solid #c8c8c8; border-bottom: 0px; margin: 40px 10px 0px 10px;' />");
if (paramBoolean)
{
localStringBuilder2 = new StringBuilder();
str = a((JSONObject)localObject);
if (!TextUtils.isEmpty(str)) {
localStringBuilder2.append("<a href='restore:" + str + "' style='background: #c8c8c8; color: #000; display: block; float: right; padding: 7px; margin: 0px 10px 10px; text-decoration: none;'>Restore</a>");
}
localStringBuilder1.append(localStringBuilder2.toString());
}
}
StringBuilder localStringBuilder2 = new StringBuilder();
int j = b(this.b);
int k = b((JSONObject)localObject);
String str = c((JSONObject)localObject);
localStringBuilder2.append("<div style='padding: 20px 10px 10px;'><strong>");
if (i == 0)
{
localStringBuilder2.append("Newest version:");
label193:
localStringBuilder2.append("</strong></div>");
localStringBuilder1.append(localStringBuilder2.toString());
localStringBuilder2 = new StringBuilder();
localObject = a((JSONObject)localObject, "notes", "");
localStringBuilder2.append("<div style='padding: 0px 10px;'>");
if (((String)localObject).trim().length() != 0) {
break label363;
}
localStringBuilder2.append("<em>No information.</em>");
}
for (;;)
{
localStringBuilder2.append("</div>");
localStringBuilder1.append(localStringBuilder2.toString());
i += 1;
break;
localStringBuilder2.append("Version " + str + " (" + k + "): ");
if ((k == j) || (k != this.d)) {
break label193;
}
this.d = -1;
localStringBuilder2.append("[INSTALLED]");
break label193;
label363:
localStringBuilder2.append((String)localObject);
}
}
localStringBuilder1.append("</body>");
localStringBuilder1.append("</html>");
return localStringBuilder1.toString();
}
public String getVersionString()
{
return a(this.b, "shortversion", "") + " (" + a(this.b, "version", "") + ")";
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/net/hockeyapp/android/utils/VersionHelper.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/