PushManager.java
20 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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
package com.arellomobile.android.push;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import com.arellomobile.android.push.exception.PushWooshException;
import com.arellomobile.android.push.preference.SoundType;
import com.arellomobile.android.push.preference.VibrateType;
import com.arellomobile.android.push.registrar.PushRegistrar;
import com.arellomobile.android.push.registrar.PushRegistrarADM;
import com.arellomobile.android.push.registrar.PushRegistrarGCM;
import com.arellomobile.android.push.utils.GeneralUtils;
import com.arellomobile.android.push.utils.PreferenceUtils;
import com.arellomobile.android.push.utils.WorkerTask;
import com.arellomobile.android.push.utils.executor.ExecutorHelper;
import com.google.android.gcm.GCMRegistrar;
import hf;
import java.io.PrintStream;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class PushManager
{
public static final String PUSH_RECEIVE_EVENT = "PUSH_RECEIVE_EVENT";
public static final String REGISTER_BROAD_CAST_ACTION = "com.arellomobile.android.push.REGISTER_BROAD_CAST_ACTION";
public static final String REGISTER_ERROR_EVENT = "REGISTER_ERROR_EVENT";
public static final String REGISTER_EVENT = "REGISTER_EVENT";
public static final String UNREGISTER_ERROR_EVENT = "UNREGISTER_ERROR_EVENT";
public static final String UNREGISTER_EVENT = "UNREGISTER_EVENT";
private static PushManager c = null;
private static final Object d = new Object();
private static AsyncTask<Void, Void, Void> e;
private Context a;
private PushRegistrar b;
private PushManager(Context paramContext)
{
GeneralUtils.checkNotNull(paramContext, "context");
this.a = paramContext;
if (GeneralUtils.isAmazonDevice())
{
this.b = new PushRegistrarADM(paramContext);
return;
}
this.b = new PushRegistrarGCM(paramContext);
}
static void a(Context paramContext, final String paramString)
{
new Handler(paramContext.getMainLooper()).post(new Runnable()
{
public final void run()
{
ExecutorHelper.executeAsyncTask(new WorkerTask(this.a)
{
protected final void doWork(Context paramAnonymous2Context)
{
try
{
DeviceFeature2_5.sendPushStat(paramAnonymous2Context, PushManager.9.this.b);
return;
}
catch (Exception paramAnonymous2Context) {}
}
});
}
});
}
static boolean a(Activity paramActivity)
{
Bundle localBundle = paramActivity.getIntent().getBundleExtra("pushBundle");
if (localBundle == null) {
return false;
}
JSONObject localJSONObject2 = new JSONObject();
Iterator localIterator = localBundle.keySet().iterator();
if (localIterator.hasNext())
{
String str = (String)localIterator.next();
if (str.equals("u")) {}
for (;;)
{
try
{
localObject3 = localBundle.get("u");
if ((localObject3 != null) && ((localObject3 instanceof String)))
{
if (!((String)localObject3).startsWith("{")) {
continue;
}
JSONObject localJSONObject1 = new JSONObject((String)localObject3);
localJSONObject2.put("userdata", localJSONObject1);
}
}
catch (JSONException localJSONException2)
{
Object localObject3;
Object localObject1;
Object localObject2;
continue;
}
try
{
localJSONObject2.put(str, localBundle.get(str));
}
catch (JSONException localJSONException1) {}
break;
localObject1 = localObject3;
if (((String)localObject3).startsWith("[")) {
localObject1 = new JSONArray((String)localObject3);
}
}
}
PushEventsTransmitter.a(paramActivity, localJSONObject2.toString(), localBundle);
localObject1 = (String)localBundle.get("h");
if (localObject1 != null)
{
localObject1 = String.format("https://cp.pushwoosh.com/content/%s", new Object[] { localObject1 });
localObject3 = new Intent(paramActivity, PushWebview.class);
((Intent)localObject3).putExtra("url", (String)localObject1);
paramActivity.startActivity((Intent)localObject3);
}
localObject1 = (String)localBundle.get("r");
if (localObject1 != null)
{
localObject3 = new Intent(paramActivity, PushWebview.class);
((Intent)localObject3).putExtra("url", (String)localObject1);
paramActivity.startActivity((Intent)localObject3);
}
localObject1 = (String)localBundle.get("launch");
if (localObject1 != null) {}
try
{
localObject1 = paramActivity.getPackageManager().getLaunchIntentForPackage((String)localObject1);
if (localObject1 != null) {
paramActivity.startActivity((Intent)localObject1);
}
a(paramActivity, localBundle.getString("p"));
return true;
}
catch (Exception localException)
{
for (;;)
{
localObject2 = null;
}
}
}
private static void b()
{
synchronized (d)
{
if (e != null) {
e.cancel(true);
}
e = null;
return;
}
}
private void b(final Context paramContext, final String paramString)
{
b();
new Handler(paramContext.getMainLooper()).post(new Runnable()
{
public final void run()
{
PushManager.a(PushManager.a(PushManager.this, paramContext, paramString));
ExecutorHelper.executeAsyncTask(PushManager.a());
}
});
}
public static void clearLocalNotifications(Context paramContext)
{
AlarmReceiver.clearAlarm(paramContext);
}
public static void getBeacons(Context paramContext, final GetBeaconsListener paramGetBeaconsListener)
{
new Handler(paramContext.getMainLooper()).post(new Runnable()
{
public final void run()
{
ExecutorHelper.executeAsyncTask(new WorkerTask(this.a)
{
protected final void doWork(Context paramAnonymous2Context)
{
try
{
paramAnonymous2Context = DeviceFeature2_5.getBeacons(paramAnonymous2Context);
PushManager.6.this.b.onBeaconsReceived(paramAnonymous2Context);
return;
}
catch (Exception paramAnonymous2Context)
{
PushManager.6.this.b.onBeaconsError(paramAnonymous2Context);
}
}
});
}
});
}
public static PushManager getInstance(Context paramContext)
{
if (c == null) {
for (;;)
{
try
{
localObject1 = paramContext.getPackageManager().getApplicationInfo(paramContext.getPackageName(), 128);
localObject4 = ((ApplicationInfo)localObject1).metaData.getString("PW_APPID");
}
catch (Exception localException2)
{
Object localObject1;
Object localObject5;
Object localObject2;
Object localObject3 = null;
Object localObject4 = null;
continue;
System.out.println("App ID: " + (String)localObject5);
System.out.println("Project ID: " + (String)localObject4);
if (PreferenceUtils.getApplicationId(paramContext).equals(localObject5)) {
continue;
}
PreferenceUtils.setForceRegister(paramContext, true);
PreferenceUtils.setApplicationId(paramContext, (String)localObject5);
PreferenceUtils.setProjectId(paramContext, (String)localObject4);
c = new PushManager(paramContext);
}
try
{
localObject1 = ((ApplicationInfo)localObject1).metaData.getString("PW_PROJECT_ID").substring(1);
localObject5 = localObject4;
if (TextUtils.isEmpty((CharSequence)localObject4)) {
localObject5 = PreferenceUtils.getApplicationId(paramContext);
}
localObject4 = localObject1;
if (TextUtils.isEmpty((CharSequence)localObject1)) {
localObject4 = PreferenceUtils.getProjectId(paramContext);
}
if (GeneralUtils.isAmazonDevice()) {
localObject4 = "AMAZON_DEVICE";
}
if ((TextUtils.isEmpty((CharSequence)localObject5)) || (TextUtils.isEmpty((CharSequence)localObject4)))
{
System.out.println("Tried to get instance of PushManager with no Pushwoosh App ID or Project Id set");
return null;
}
}
catch (Exception localException1)
{
localObject2 = null;
}
}
}
return c;
}
public static String getPushToken(Context paramContext)
{
return GCMRegistrar.getRegistrationId(paramContext);
}
public static String getPushwooshHWID(Context paramContext)
{
return GeneralUtils.getDeviceUUID(paramContext);
}
public static void getTagsAsync(Context paramContext, final GetTagsListener paramGetTagsListener)
{
if (!GCMRegistrar.isRegisteredOnServer(paramContext)) {
return;
}
new Handler(paramContext.getMainLooper()).post(new Runnable()
{
public final void run()
{
ExecutorHelper.executeAsyncTask(new WorkerTask(this.a)
{
protected final void doWork(Context paramAnonymous2Context)
{
try
{
paramAnonymous2Context = DeviceFeature2_5.getTags(paramAnonymous2Context);
PushManager.4.this.b.onTagsReceived(paramAnonymous2Context);
return;
}
catch (Exception paramAnonymous2Context)
{
PushManager.4.this.b.onError(paramAnonymous2Context);
}
}
});
}
});
}
public static Map<String, Object> getTagsSync(Context paramContext)
{
if (!GCMRegistrar.isRegisteredOnServer(paramContext)) {
return null;
}
try
{
paramContext = DeviceFeature2_5.getTags(paramContext);
return paramContext;
}
catch (Exception paramContext) {}
return new HashMap();
}
public static Map<String, Object> incrementalTag(Integer paramInteger)
{
HashMap localHashMap = new HashMap();
localHashMap.put("operation", "increment");
localHashMap.put("value", paramInteger);
return localHashMap;
}
public static void initializePushManager(Context paramContext, String paramString1, String paramString2)
{
PreferenceUtils.setApplicationId(paramContext, paramString1);
PreferenceUtils.setProjectId(paramContext, paramString2);
}
public static void processBeacon(Context paramContext, final String paramString1, final String paramString2, final String paramString3, final String paramString4)
{
new Handler(paramContext.getMainLooper()).post(new Runnable()
{
public final void run()
{
ExecutorHelper.executeAsyncTask(new WorkerTask(this.a)
{
protected final void doWork(Context paramAnonymous2Context)
{
try
{
DeviceFeature2_5.processBeacon(paramAnonymous2Context, PushManager.7.this.b, PushManager.7.this.c, PushManager.7.this.d, PushManager.7.this.e);
return;
}
catch (Exception paramAnonymous2Context)
{
paramAnonymous2Context.printStackTrace();
}
}
});
}
});
}
public static void scheduleLocalNotification(Context paramContext, String paramString, int paramInt)
{
scheduleLocalNotification(paramContext, paramString, null, paramInt);
}
public static void scheduleLocalNotification(Context paramContext, String paramString, Bundle paramBundle, int paramInt)
{
AlarmReceiver.setAlarm(paramContext, paramString, paramBundle, paramInt);
}
public static void sendGoalAchieved(Context paramContext, final String paramString, final Integer paramInteger)
{
new Handler(paramContext.getMainLooper()).post(new Runnable()
{
public final void run()
{
ExecutorHelper.executeAsyncTask(new WorkerTask(this.a)
{
protected final void doWork(Context paramAnonymous2Context)
{
try
{
DeviceFeature2_5.sendGoalAchieved(paramAnonymous2Context, PushManager.11.this.b, PushManager.11.this.c);
return;
}
catch (Exception paramAnonymous2Context) {}
}
});
}
});
}
public static void sendLocation(Context paramContext, final Location paramLocation)
{
if (!GCMRegistrar.isRegisteredOnServer(paramContext)) {
return;
}
new Handler(paramContext.getMainLooper()).post(new Runnable()
{
public final void run()
{
ExecutorHelper.executeAsyncTask(new WorkerTask(this.a)
{
protected final void doWork(Context paramAnonymous2Context)
{
try
{
DeviceFeature2_5.getNearestZone(paramAnonymous2Context, PushManager.5.this.b);
return;
}
catch (Exception paramAnonymous2Context) {}
}
});
}
});
}
public static void sendTags(Context paramContext, final Map<String, Object> paramMap, final SendPushTagsCallBack paramSendPushTagsCallBack)
{
new Handler(paramContext.getMainLooper()).post(new Runnable()
{
public final void run()
{
new hf(this.a, paramSendPushTagsCallBack).execute(new Map[] { paramMap });
}
});
}
public static Map<String, String> sendTagsFromBG(Context paramContext, Map<String, Object> paramMap)
throws PushWooshException
{
localHashMap = new HashMap();
try
{
paramContext = DeviceFeature2_5.sendTags(paramContext, paramMap);
int i = 0;
while (i < paramContext.length())
{
paramMap = paramContext.getJSONObject(i);
localHashMap.put(paramMap.getString("tag"), paramMap.getString("reason"));
i += 1;
}
return localHashMap;
}
catch (Exception paramContext)
{
throw new PushWooshException(paramContext);
}
}
public static void sendTagsFromUI(Context paramContext, Map<String, Object> paramMap, SendPushTagsCallBack paramSendPushTagsCallBack)
{
new hf(paramContext, paramSendPushTagsCallBack).execute(new Map[] { paramMap });
}
public static void setBeaconBackgroundMode(Context paramContext, boolean paramBoolean)
{
paramContext.startService(new Intent(paramContext, PushBeaconService.class).putExtra("backgroundMode", paramBoolean));
}
public static void setEnableLED(Context paramContext, boolean paramBoolean)
{
PreferenceUtils.setEnableLED(paramContext, paramBoolean);
}
public static void setLightScreenOnNotification(Context paramContext, boolean paramBoolean)
{
PreferenceUtils.setLightScreenOnNotification(paramContext, paramBoolean);
}
public static void setMultiNotificationMode(Context paramContext)
{
PreferenceUtils.setMultiMode(paramContext, true);
}
public static void setSimpleNotificationMode(Context paramContext)
{
PreferenceUtils.setMultiMode(paramContext, false);
}
public static void setSoundNotificationType(Context paramContext, SoundType paramSoundType)
{
PreferenceUtils.setSoundType(paramContext, paramSoundType);
}
public static void setVibrateNotificationType(Context paramContext, VibrateType paramVibrateType)
{
PreferenceUtils.setVibrateType(paramContext, paramVibrateType);
}
public static void startTrackingGeoPushes(Context paramContext)
{
paramContext.startService(new Intent(paramContext, GeoLocationService.class));
}
public static void stopTrackingGeoPushes(Context paramContext)
{
paramContext.stopService(new Intent(paramContext, GeoLocationService.class));
}
public static void trackInAppRequest(Context paramContext, final String paramString1, final String paramString2, final long paramLong)
{
new Handler(paramContext.getMainLooper()).post(new Runnable()
{
public final void run()
{
ExecutorHelper.executeAsyncTask(new WorkerTask(this.a)
{
protected final void doWork(Context paramAnonymous2Context)
{
try
{
DeviceFeature2_5.trackInAppRequest(paramAnonymous2Context, PushManager.2.this.b, PushManager.2.this.c, PushManager.2.this.d);
return;
}
catch (Exception paramAnonymous2Context) {}
}
});
}
});
}
public String getCustomData(Bundle paramBundle)
{
if (paramBundle == null) {
return null;
}
return paramBundle.getString("u");
}
public void onStartup(final Context paramContext)
throws Exception
{
this.b.checkDevice(paramContext);
new Handler(paramContext.getMainLooper()).post(new Runnable()
{
public final void run()
{
ExecutorHelper.executeAsyncTask(new WorkerTask(paramContext)
{
protected final void doWork(Context paramAnonymous2Context)
{
try
{
DeviceFeature2_5.sendAppOpen(paramAnonymous2Context);
return;
}
catch (Exception paramAnonymous2Context) {}
}
});
}
});
if (((paramContext instanceof Activity)) && (((Activity)paramContext).getIntent().hasExtra("PUSH_RECEIVE_EVENT"))) {}
for (;;)
{
return;
String str = GCMRegistrar.getRegistrationId(this.a);
if ((str != null) && (!str.equals("")))
{
boolean bool = PreferenceUtils.getForceRegister(paramContext);
PreferenceUtils.setForceRegister(paramContext, false);
if (bool)
{
b(paramContext, str);
return;
}
Calendar localCalendar1 = Calendar.getInstance();
Calendar localCalendar2 = Calendar.getInstance();
localCalendar2.add(12, -10);
Calendar localCalendar3 = Calendar.getInstance();
localCalendar3.setTime(new Date(PreferenceUtils.getLastRegistration(paramContext)));
if ((localCalendar2.before(localCalendar3)) && (localCalendar3.before(localCalendar1))) {}
for (int i = 0; i != 0; i = 1)
{
b(paramContext, str);
return;
}
}
}
}
public void registerForPushNotifications()
{
String str = GCMRegistrar.getRegistrationId(this.a);
if (str.equals("")) {
try
{
this.b.registerPW(this.a);
return;
}
catch (Exception localException)
{
localException.printStackTrace();
return;
}
}
PushEventsTransmitter.a(this.a, localException);
}
public void startTrackingBeaconPushes()
{
this.a.startService(new Intent(this.a, PushBeaconService.class));
}
public void startTrackingGeoPushes()
{
this.a.startService(new Intent(this.a, GeoLocationService.class));
}
public void stopTrackingBeaconPushes()
{
this.a.stopService(new Intent(this.a, PushBeaconService.class));
}
public void stopTrackingGeoPushes()
{
this.a.stopService(new Intent(this.a, GeoLocationService.class));
}
public void unregisterForPushNotifications()
{
b();
this.b.unregisterPW(this.a);
}
public static abstract interface GetBeaconsListener
{
public abstract void onBeaconsError(Exception paramException);
public abstract void onBeaconsReceived(JSONObject paramJSONObject);
}
public static abstract interface GetTagsListener
{
public abstract void onError(Exception paramException);
public abstract void onTagsReceived(Map<String, Object> paramMap);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/arellomobile/android/push/PushManager.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/