PushServiceHelper.java
6.75 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
package com.arellomobile.android.push;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import com.arellomobile.android.push.utils.GeneralUtils;
import com.arellomobile.android.push.utils.PreferenceUtils;
import com.arellomobile.android.push.utils.notification.BannerNotificationFactory;
import com.arellomobile.android.push.utils.notification.BaseNotificationFactory;
import com.arellomobile.android.push.utils.notification.SimpleNotificationFactory;
import java.util.Iterator;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class PushServiceHelper
{
public static void generateBroadcast(Context paramContext, Bundle paramBundle)
{
Intent localIntent = new Intent();
localIntent.setAction(paramContext.getPackageName() + ".action.PUSH_MESSAGE_RECEIVE");
localIntent.putExtras(paramBundle);
JSONObject localJSONObject2 = new JSONObject();
Iterator localIterator = paramBundle.keySet().iterator();
if (localIterator.hasNext())
{
String str = (String)localIterator.next();
if (str.equals("u")) {}
for (;;)
{
try
{
localObject2 = paramBundle.get("u");
if ((localObject2 != null) && ((localObject2 instanceof String)))
{
if (!((String)localObject2).startsWith("{")) {
continue;
}
JSONObject localJSONObject1 = new JSONObject((String)localObject2);
localJSONObject2.put("userdata", localJSONObject1);
}
}
catch (JSONException localJSONException2)
{
Object localObject2;
Object localObject1;
continue;
}
try
{
localJSONObject2.put(str, paramBundle.get(str));
}
catch (JSONException localJSONException1) {}
break;
localObject1 = localObject2;
if (((String)localObject2).startsWith("[")) {
localObject1 = new JSONArray((String)localObject2);
}
}
}
localIntent.putExtra("pw_data_json_string", localJSONObject2.toString());
if (GeneralUtils.isAmazonDevice())
{
paramContext.sendBroadcast(localIntent, paramContext.getPackageName() + ".permission.RECEIVE_ADM_MESSAGE");
return;
}
paramContext.sendBroadcast(localIntent, paramContext.getPackageName() + ".permission.C2D_MESSAGE");
}
public static void generateNotification(Context paramContext, Intent paramIntent)
{
Bundle localBundle = paramIntent.getExtras();
if (localBundle == null) {
return;
}
localBundle.putBoolean("foreground", GeneralUtils.isAppOnForeground(paramContext));
boolean bool;
label33:
String str1;
Object localObject1;
label102:
Object localObject2;
if (!GeneralUtils.isAppOnForeground(paramContext))
{
bool = true;
localBundle.putBoolean("onStart", bool);
str1 = (String)localBundle.get("title");
localObject1 = (String)localBundle.get("header");
paramIntent = (String)localBundle.get("l");
if (paramIntent == null) {
break label341;
}
paramIntent = new Intent("android.intent.action.VIEW", Uri.parse(paramIntent));
paramIntent.addFlags(268435456);
if (localObject1 != null) {
break label401;
}
localObject2 = paramContext.getPackageManager().getApplicationLabel(paramContext.getApplicationInfo());
localObject1 = localObject2;
if (localObject2 == null) {
localObject1 = "";
}
localObject1 = localObject1.toString();
}
label341:
label401:
for (;;)
{
localObject2 = (NotificationManager)paramContext.getSystemService("notification");
String str2 = (String)localBundle.get("b");
if ((paramContext.getResources().getIdentifier("notification", "layout", paramContext.getPackageName()) != 0) && (str2 != null)) {}
for (localObject1 = new BannerNotificationFactory(paramContext, localBundle, (String)localObject1, str1, PreferenceUtils.getSoundType(paramContext), PreferenceUtils.getVibrateType(paramContext));; localObject1 = new SimpleNotificationFactory(paramContext, localBundle, (String)localObject1, str1, PreferenceUtils.getSoundType(paramContext), PreferenceUtils.getVibrateType(paramContext)))
{
((BaseNotificationFactory)localObject1).generateNotification();
((BaseNotificationFactory)localObject1).addSoundAndVibrate();
((BaseNotificationFactory)localObject1).addCancel();
if (PreferenceUtils.getEnableLED(paramContext)) {
((BaseNotificationFactory)localObject1).addLED(true);
}
localObject1 = ((BaseNotificationFactory)localObject1).getNotification();
int j = PreferenceUtils.getMessageId(paramContext);
int i = j;
if (PreferenceUtils.getMultiMode(paramContext) == true)
{
i = j + 1;
PreferenceUtils.setMessageId(paramContext, i);
}
((Notification)localObject1).contentIntent = PendingIntent.getActivity(paramContext, i, paramIntent, 268435456);
if (!localBundle.getBoolean("silent", false)) {
((NotificationManager)localObject2).notify(i, (Notification)localObject1);
}
generateBroadcast(paramContext, localBundle);
if (localBundle.getBoolean("local", false)) {
break;
}
try
{
DeviceFeature2_5.sendMessageDeliveryEvent(paramContext, localBundle.getString("p"));
return;
}
catch (Exception paramContext)
{
return;
}
bool = false;
break label33;
paramIntent = new Intent(paramContext, PushHandlerActivity.class);
paramIntent.addFlags(603979776);
paramIntent.putExtra("pushBundle", localBundle);
break label102;
}
}
}
public static String getPushServiceClassName(Context paramContext)
{
try
{
paramContext = paramContext.getPackageManager().getApplicationInfo(paramContext.getApplicationContext().getPackageName(), 128);
if (paramContext.metaData != null)
{
paramContext = paramContext.metaData.getString("PW_PUSH_SERVICE");
if (paramContext != null) {
return paramContext;
}
}
}
catch (Exception paramContext) {}
return "com.arellomobile.android.push.PushGCMIntentService";
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/arellomobile/android/push/PushServiceHelper.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/