RequestManager.java
13.8 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
package com.arellomobile.android.push.request;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import com.arellomobile.android.push.utils.PreferenceUtils;
import java.util.Map;
import org.json.JSONObject;
public class RequestManager
{
public static final int MAX_TRIES = 1;
public static boolean useSSL = false;
/* Error */
private static NetworkResult a(Context paramContext, Map<String, Object> paramMap, String paramString)
throws Exception
{
// Byte code:
// 0: aconst_null
// 1: astore 6
// 3: new 6 com/arellomobile/android/push/request/RequestManager$NetworkResult
// 6: dup
// 7: sipush 500
// 10: iconst_0
// 11: aconst_null
// 12: invokespecial 27 com/arellomobile/android/push/request/RequestManager$NetworkResult:<init> (IILorg/json/JSONObject;)V
// 15: astore 7
// 17: aload_0
// 18: invokestatic 33 com/arellomobile/android/push/utils/PreferenceUtils:getBaseUrl (Landroid/content/Context;)Ljava/lang/String;
// 21: astore 5
// 23: aload 5
// 25: astore 4
// 27: aload 5
// 29: invokestatic 39 android/text/TextUtils:isEmpty (Ljava/lang/CharSequence;)Z
// 32: ifeq +9 -> 41
// 35: aload_0
// 36: invokestatic 41 com/arellomobile/android/push/request/RequestManager:a (Landroid/content/Context;)Ljava/lang/String;
// 39: astore 4
// 41: aload 4
// 43: astore 5
// 45: aload 4
// 47: ldc 43
// 49: invokevirtual 49 java/lang/String:endsWith (Ljava/lang/String;)Z
// 52: ifne +25 -> 77
// 55: new 51 java/lang/StringBuilder
// 58: dup
// 59: invokespecial 52 java/lang/StringBuilder:<init> ()V
// 62: aload 4
// 64: invokevirtual 56 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 67: ldc 43
// 69: invokevirtual 56 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 72: invokevirtual 60 java/lang/StringBuilder:toString ()Ljava/lang/String;
// 75: astore 5
// 77: aload_0
// 78: aload 5
// 80: invokestatic 64 com/arellomobile/android/push/utils/PreferenceUtils:setBaseUrl (Landroid/content/Context;Ljava/lang/String;)V
// 83: new 66 java/net/URL
// 86: dup
// 87: new 51 java/lang/StringBuilder
// 90: dup
// 91: invokespecial 52 java/lang/StringBuilder:<init> ()V
// 94: aload 5
// 96: invokevirtual 56 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 99: aload_2
// 100: invokevirtual 56 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 103: invokevirtual 60 java/lang/StringBuilder:toString ()Ljava/lang/String;
// 106: invokespecial 69 java/net/URL:<init> (Ljava/lang/String;)V
// 109: invokevirtual 73 java/net/URL:openConnection ()Ljava/net/URLConnection;
// 112: checkcast 75 java/net/HttpURLConnection
// 115: astore 4
// 117: aload 4
// 119: ldc 77
// 121: invokevirtual 80 java/net/HttpURLConnection:setRequestMethod (Ljava/lang/String;)V
// 124: aload 4
// 126: ldc 82
// 128: ldc 84
// 130: invokevirtual 88 java/net/HttpURLConnection:setRequestProperty (Ljava/lang/String;Ljava/lang/String;)V
// 133: aload 4
// 135: iconst_1
// 136: invokevirtual 92 java/net/HttpURLConnection:setDoOutput (Z)V
// 139: new 94 org/json/JSONObject
// 142: dup
// 143: invokespecial 95 org/json/JSONObject:<init> ()V
// 146: astore_2
// 147: aload_2
// 148: ldc 97
// 150: aload_1
// 151: invokestatic 103 com/arellomobile/android/push/utils/JsonUtils:mapToJson (Ljava/util/Map;)Lorg/json/JSONObject;
// 154: invokevirtual 107 org/json/JSONObject:put (Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
// 157: pop
// 158: aload 4
// 160: ldc 109
// 162: aload_2
// 163: invokevirtual 110 org/json/JSONObject:toString ()Ljava/lang/String;
// 166: invokevirtual 114 java/lang/String:getBytes ()[B
// 169: arraylength
// 170: invokestatic 118 java/lang/String:valueOf (I)Ljava/lang/String;
// 173: invokevirtual 88 java/net/HttpURLConnection:setRequestProperty (Ljava/lang/String;Ljava/lang/String;)V
// 176: aload 4
// 178: invokevirtual 122 java/net/HttpURLConnection:getOutputStream ()Ljava/io/OutputStream;
// 181: astore_1
// 182: aload_1
// 183: aload_2
// 184: invokevirtual 110 org/json/JSONObject:toString ()Ljava/lang/String;
// 187: invokevirtual 114 java/lang/String:getBytes ()[B
// 190: invokevirtual 128 java/io/OutputStream:write ([B)V
// 193: aload_1
// 194: invokevirtual 131 java/io/OutputStream:flush ()V
// 197: aload_1
// 198: invokevirtual 134 java/io/OutputStream:close ()V
// 201: new 136 java/io/BufferedInputStream
// 204: dup
// 205: aload 4
// 207: invokevirtual 140 java/net/HttpURLConnection:getInputStream ()Ljava/io/InputStream;
// 210: invokespecial 143 java/io/BufferedInputStream:<init> (Ljava/io/InputStream;)V
// 213: astore_2
// 214: new 145 java/io/ByteArrayOutputStream
// 217: dup
// 218: invokespecial 146 java/io/ByteArrayOutputStream:<init> ()V
// 221: astore 5
// 223: sipush 1024
// 226: newarray <illegal type>
// 228: astore 6
// 230: aload_2
// 231: aload 6
// 233: invokevirtual 152 java/io/InputStream:read ([B)I
// 236: istore_3
// 237: iload_3
// 238: iflt +34 -> 272
// 241: aload 5
// 243: aload 6
// 245: iconst_0
// 246: iload_3
// 247: invokevirtual 155 java/io/ByteArrayOutputStream:write ([BII)V
// 250: goto -20 -> 230
// 253: astore_0
// 254: aload_2
// 255: ifnull +7 -> 262
// 258: aload_2
// 259: invokevirtual 156 java/io/InputStream:close ()V
// 262: aload_1
// 263: ifnull +7 -> 270
// 266: aload_1
// 267: invokevirtual 134 java/io/OutputStream:close ()V
// 270: aload_0
// 271: athrow
// 272: aload 5
// 274: invokevirtual 157 java/io/ByteArrayOutputStream:close ()V
// 277: new 45 java/lang/String
// 280: dup
// 281: aload 5
// 283: invokevirtual 160 java/io/ByteArrayOutputStream:toByteArray ()[B
// 286: invokespecial 162 java/lang/String:<init> ([B)V
// 289: invokevirtual 165 java/lang/String:trim ()Ljava/lang/String;
// 292: astore 5
// 294: ldc -89
// 296: new 51 java/lang/StringBuilder
// 299: dup
// 300: ldc -87
// 302: invokespecial 170 java/lang/StringBuilder:<init> (Ljava/lang/String;)V
// 305: aload 5
// 307: invokevirtual 56 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 310: invokevirtual 60 java/lang/StringBuilder:toString ()Ljava/lang/String;
// 313: invokestatic 176 android/util/Log:w (Ljava/lang/String;Ljava/lang/String;)I
// 316: pop
// 317: new 94 org/json/JSONObject
// 320: dup
// 321: aload 5
// 323: invokespecial 177 org/json/JSONObject:<init> (Ljava/lang/String;)V
// 326: astore 5
// 328: aload 7
// 330: aload 5
// 332: invokevirtual 181 com/arellomobile/android/push/request/RequestManager$NetworkResult:setData (Lorg/json/JSONObject;)V
// 335: aload 7
// 337: aload 4
// 339: invokevirtual 185 java/net/HttpURLConnection:getResponseCode ()I
// 342: invokevirtual 189 com/arellomobile/android/push/request/RequestManager$NetworkResult:setCode (I)V
// 345: aload 7
// 347: aload 5
// 349: ldc -65
// 351: invokevirtual 195 org/json/JSONObject:getInt (Ljava/lang/String;)I
// 354: invokevirtual 198 com/arellomobile/android/push/request/RequestManager$NetworkResult:setPushwooshCode (I)V
// 357: aload_2
// 358: invokevirtual 156 java/io/InputStream:close ()V
// 361: aload_1
// 362: ifnull +7 -> 369
// 365: aload_1
// 366: invokevirtual 134 java/io/OutputStream:close ()V
// 369: aload 7
// 371: areturn
// 372: astore 4
// 374: aload_0
// 375: aload_0
// 376: invokestatic 41 com/arellomobile/android/push/request/RequestManager:a (Landroid/content/Context;)Ljava/lang/String;
// 379: invokestatic 64 com/arellomobile/android/push/utils/PreferenceUtils:setBaseUrl (Landroid/content/Context;Ljava/lang/String;)V
// 382: aload 4
// 384: athrow
// 385: astore_0
// 386: aconst_null
// 387: astore_1
// 388: aload 6
// 390: astore_2
// 391: goto -137 -> 254
// 394: astore_0
// 395: aload 6
// 397: astore_2
// 398: goto -144 -> 254
// Local variable table:
// start length slot name signature
// 0 401 0 paramContext Context
// 0 401 1 paramMap Map<String, Object>
// 0 401 2 paramString String
// 236 11 3 i int
// 25 313 4 localObject1 Object
// 372 11 4 localException Exception
// 21 327 5 localObject2 Object
// 1 395 6 arrayOfByte byte[]
// 15 355 7 localNetworkResult NetworkResult
// Exception table:
// from to target type
// 214 230 253 finally
// 230 237 253 finally
// 241 250 253 finally
// 272 317 253 finally
// 317 357 253 finally
// 374 385 253 finally
// 317 357 372 java/lang/Exception
// 17 23 385 finally
// 27 41 385 finally
// 45 77 385 finally
// 77 182 385 finally
// 182 214 394 finally
}
private static String a(Context paramContext)
{
localObject1 = null;
Object localObject2 = paramContext.getPackageManager();
try
{
localObject2 = ((PackageManager)localObject2).getApplicationInfo(paramContext.getPackageName(), 128).metaData;
paramContext = (Context)localObject1;
if (localObject2 != null) {
paramContext = ((Bundle)localObject2).getString("PushwooshUrl");
}
}
catch (PackageManager.NameNotFoundException paramContext)
{
for (;;)
{
paramContext = (Context)localObject1;
}
}
localObject1 = paramContext;
if (TextUtils.isEmpty(paramContext))
{
if (useSSL) {
localObject1 = "https://cp.pushwoosh.com/json/1.3/";
}
}
else {
return (String)localObject1;
}
return "http://cp.pushwoosh.com/json/1.3/";
}
public static void sendRequest(Context paramContext, PushRequest paramPushRequest)
throws Exception
{
Map localMap = paramPushRequest.getParams(paramContext);
Log.w("Pushwoosh: Request manager", "Try To sent: " + paramPushRequest.getMethod());
Object localObject = new NetworkResult(500, 0, null);
JSONObject localJSONObject = null;
int i = 0;
for (;;)
{
if (i <= 0) {}
for (;;)
{
try
{
NetworkResult localNetworkResult = a(paramContext, localMap, paramPushRequest.getMethod());
localObject = localNetworkResult;
if (200 != localNetworkResult.getResultCode())
{
localObject = localNetworkResult;
break;
}
localObject = localNetworkResult;
int j = localNetworkResult.getPushwooshCode();
if (200 != j)
{
paramContext = localNetworkResult;
paramPushRequest = localJSONObject;
if (localJSONObject == null)
{
paramPushRequest = "";
if (paramContext.getResultData() != null) {
paramPushRequest = paramContext.getResultData().toString();
}
paramPushRequest = new Exception(paramPushRequest);
}
Log.e("Pushwoosh: Request manager", "ERROR: " + paramPushRequest.getMessage() + ". Response = " + paramContext.getResultData(), paramPushRequest);
throw paramPushRequest;
}
localObject = localNetworkResult;
Log.w("Pushwoosh: Request manager", paramPushRequest.getMethod() + " response success");
localObject = localNetworkResult;
localJSONObject = localNetworkResult.getResultData();
if (localJSONObject != null)
{
localObject = localNetworkResult;
if (localJSONObject.has("base_url"))
{
localObject = localNetworkResult;
PreferenceUtils.setBaseUrl(paramContext, localJSONObject.optString("base_url"));
}
localObject = localNetworkResult;
paramPushRequest.parseResponse(localJSONObject);
}
return;
}
catch (Exception localException) {}
paramContext = (Context)localObject;
}
i += 1;
}
}
public static class NetworkResult
{
private int a;
private int b;
private JSONObject c;
public NetworkResult(int paramInt1, int paramInt2, JSONObject paramJSONObject)
{
this.b = paramInt1;
this.a = paramInt2;
this.c = paramJSONObject;
}
public int getPushwooshCode()
{
return this.a;
}
public int getResultCode()
{
return this.b;
}
public JSONObject getResultData()
{
return this.c;
}
public void setCode(int paramInt)
{
this.b = paramInt;
}
public void setData(JSONObject paramJSONObject)
{
this.c = paramJSONObject;
}
public void setPushwooshCode(int paramInt)
{
this.a = paramInt;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/arellomobile/android/push/request/RequestManager.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/