Panagiotis Triantafyllou

update sdk to version 4.5.4.4

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.4.3' 5 + PUBLISH_VERSION = '4.5.4.4'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
...@@ -58,9 +58,9 @@ dependencies { ...@@ -58,9 +58,9 @@ dependencies {
58 annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' 58 annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
59 59
60 //------------------------------ Huawei -----------------------------// 60 //------------------------------ Huawei -----------------------------//
61 - api 'com.huawei.agconnect:agconnect-core:1.6.2.300' 61 + api 'com.huawei.agconnect:agconnect-core:1.6.5.300'
62 - api 'com.huawei.hms:base:6.2.0.300' 62 + api 'com.huawei.hms:base:6.4.0.302'
63 - api 'com.huawei.hms:push:6.1.0.300' 63 + api 'com.huawei.hms:push:6.3.0.304'
64 api 'com.huawei.hms:ads-identifier:3.4.39.302' 64 api 'com.huawei.hms:ads-identifier:3.4.39.302'
65 65
66 //------------------------------ SQLCipher -----------------------------// 66 //------------------------------ SQLCipher -----------------------------//
......
...@@ -5,11 +5,8 @@ ...@@ -5,11 +5,8 @@
5 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 5 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
6 <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 6 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
7 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 7 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
8 - <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
9 - <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
10 <uses-permission android:name="android.permission.BLUETOOTH" /> 8 <uses-permission android:name="android.permission.BLUETOOTH" />
11 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 9 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
12 - <uses-permission android:name="com.google.android.c2dm.permission.SEND" />
13 10
14 <application> 11 <application>
15 <!-- For Huawei Push --> 12 <!-- For Huawei Push -->
......
...@@ -203,62 +203,6 @@ public enum Warply { ...@@ -203,62 +203,6 @@ public enum Warply {
203 return isInitialized(false); 203 return isInitialized(false);
204 } 204 }
205 205
206 - /* GCM Related methods */
207 -
208 - public static void registerGCM(String senderId) {
209 - INSTANCE.isInitializedOrThrow();
210 - INSTANCE.registerGCMInternal(senderId, false);
211 - }
212 -
213 - /**
214 - * Method used to register with the GCM service, this will automatically
215 - * check if a registration is present and if not start the process.
216 - *
217 - * @param senderId The project ID, got from Google API Console
218 - */
219 - private void registerGCMInternal(String senderId, boolean force) {
220 - if (WarpUtils.isWaitingGCM(mContext.get())) {
221 - WarpUtils
222 - .log("************* WARPLY GCM Registration ********************");
223 - WarpUtils
224 - .log("[WARP TRace] Waiting to finish registration to GCM service.");
225 - WarpUtils
226 - .log("**********************************************************");
227 - } else if ((WarpUtils.isRegisteredGCM(mContext.get()) && (WarpUtils
228 - .getLastGCMSenderId(mContext.get()).equalsIgnoreCase(senderId)))
229 - && (!force)) {
230 - WarpUtils
231 - .log("************* WARPLY GCM Registration ********************");
232 - WarpUtils.log("[WARP TRace] Already registered to GCM service.");
233 - WarpUtils
234 - .log("**********************************************************");
235 - } else {
236 - WarpUtils
237 - .log("************* WARPLY GCM Registration ********************");
238 - WarpUtils
239 - .log("[WARP TRace] Try to register to GCM service with ID: "
240 - + senderId);
241 - WarpUtils
242 - .log("**********************************************************");
243 - WarpConstants.GCM_SENDER_ID = senderId;
244 - WarpUtils.setLastGCMSenderId(mContext.get(), senderId);
245 - GCMRegistrar.register(mContext.get(), senderId);
246 - }
247 - }
248 -
249 - /**
250 - * Method used to unregister from the GCM service.
251 - */
252 - public static void unregisterGCM() {
253 - INSTANCE.isInitializedOrThrow();
254 - GCMRegistrar.unregister(INSTANCE.mContext.get());
255 - WarpUtils
256 - .log("************* WARPLY GCM Registration ********************");
257 - WarpUtils.log("[WARP TRace] Unregistered from GCM");
258 - WarpUtils
259 - .log("**********************************************************");
260 - }
261 -
262 /* Locking methods */ 206 /* Locking methods */
263 207
264 private boolean acquirePostLockInternal() { 208 private boolean acquirePostLockInternal() {
...@@ -883,6 +827,10 @@ public enum Warply { ...@@ -883,6 +827,10 @@ public enum Warply {
883 } 827 }
884 828
885 private boolean hasDeviceInfoDifference(JSONObject savedDeviceInfo, JSONObject toSendDeviceInfo) { 829 private boolean hasDeviceInfoDifference(JSONObject savedDeviceInfo, JSONObject toSendDeviceInfo) {
830 + if (savedDeviceInfo.length() != toSendDeviceInfo.length()) {
831 + return true;
832 + }
833 +
886 for (Iterator<String> iterToSend = toSendDeviceInfo.keys(); iterToSend.hasNext(); ) { 834 for (Iterator<String> iterToSend = toSendDeviceInfo.keys(); iterToSend.hasNext(); ) {
887 String keyToSend = iterToSend.next(); 835 String keyToSend = iterToSend.next();
888 for (Iterator<String> iterSaved = savedDeviceInfo.keys(); iterSaved.hasNext(); ) { 836 for (Iterator<String> iterSaved = savedDeviceInfo.keys(); iterSaved.hasNext(); ) {
...@@ -998,7 +946,6 @@ public enum Warply { ...@@ -998,7 +946,6 @@ public enum Warply {
998 return; 946 return;
999 if (lastGCMSenderId.equals("")) 947 if (lastGCMSenderId.equals(""))
1000 return; 948 return;
1001 - registerGCMInternal(lastGCMSenderId, true);
1002 } 949 }
1003 950
1004 public void onGCMRegistrationSuccess() { 951 public void onGCMRegistrationSuccess() {
......
...@@ -189,14 +189,14 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -189,14 +189,14 @@ public class WarpViewActivity extends WarpBaseActivity {
189 private void setUpPushEvents(String sessionUUID) { 189 private void setUpPushEvents(String sessionUUID) {
190 WarplyAnalyticsManager.logUserEngagedPush(WarpJSONParser.createJSONObjectFromString("session_uuid", sessionUUID)); 190 WarplyAnalyticsManager.logUserEngagedPush(WarpJSONParser.createJSONObjectFromString("session_uuid", sessionUUID));
191 191
192 -// if (WorkManager.getInstance().getWorkInfosByTag(PushEventsWorkerService.TAG).isDone() || WorkManager.getInstance().getWorkInfosByTag(PushEventsWorkerService.TAG).isCancelled()) { 192 +// if (WorkManager.getInstance(this).getWorkInfosByTag(PushEventsWorkerService.TAG).isDone() || WorkManager.getInstance(this).getWorkInfosByTag(PushEventsWorkerService.TAG).isCancelled()) {
193 Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build(); 193 Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();
194 OneTimeWorkRequest sendEvent = new OneTimeWorkRequest.Builder(PushEventsClickedWorkerService.class) 194 OneTimeWorkRequest sendEvent = new OneTimeWorkRequest.Builder(PushEventsClickedWorkerService.class)
195 .setConstraints(constraints) 195 .setConstraints(constraints)
196 .setInitialDelay(defineRandomStart(), TimeUnit.MINUTES) 196 .setInitialDelay(defineRandomStart(), TimeUnit.MINUTES)
197 .build(); 197 .build();
198 198
199 - WorkManager.getInstance().enqueue(sendEvent); 199 + WorkManager.getInstance(this).enqueue(sendEvent);
200 // } 200 // }
201 } 201 }
202 202
......
1 -/*
2 - * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 - *
4 - * Redistribution and use in source and binary forms, without modification, are
5 - * permitted provided that the following conditions are met:
6 - *
7 - * 1. Redistributions of source code must retain the above copyright notice,
8 - * this list of conditions and the following disclaimer.
9 - *
10 - * 2. Redistributions in binary form must reproduce the above copyright notice,
11 - * this list of conditions and the following disclaimer in the documentation
12 - * and/or other materials provided with the distribution.
13 - *
14 - * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20 - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -package ly.warp.sdk.receivers;
27 -
28 -import android.app.Activity;
29 -import android.content.BroadcastReceiver;
30 -import android.content.Context;
31 -import android.content.Intent;
32 -import android.text.TextUtils;
33 -import android.util.Log;
34 -
35 -import ly.warp.sdk.services.GCMBaseIntentService;
36 -import ly.warp.sdk.services.WarpIntentService;
37 -import ly.warp.sdk.utils.WarpUtils;
38 -import ly.warp.sdk.utils.WarplyProperty;
39 -
40 -/**
41 - * {@link BroadcastReceiver} that receives GCM messages and delivers them to an
42 - * application-specific {@link ly.warp.sdk.services.GCMBaseIntentService} subclass.
43 - * <p/>
44 - * By default, the {@link ly.warp.sdk.services.GCMBaseIntentService} class belongs to the application
45 - * main package and is named
46 - * {@link ly.warp.sdk.utils.constants.GCMConstants#DEFAULT_INTENT_SERVICE_CLASS_NAME}. To use a new class,
47 - * the {@link #getGCMIntentServiceClassName(Context)} must be overridden.
48 - */
49 -public class GCMBroadcastReceiver extends BroadcastReceiver {
50 -
51 - private static final String TAG = "GCMBroadcastReceiver";
52 -
53 - @Override
54 - public final void onReceive(Context context, Intent intent) {
55 - Log.v(TAG, "onReceive: " + intent.getAction());
56 - String className = getGCMIntentServiceClassName(context);
57 - Log.v(TAG, "GCM IntentService class: " + className);
58 - // Delegates to the application-specific intent service.
59 - GCMBaseIntentService.runIntentInService(context, intent, className);
60 - if (isOrderedBroadcast()) {
61 - setResult(Activity.RESULT_OK, null /* data */, null /* extra */);
62 - }
63 - }
64 -
65 - /**
66 - * Gets the class name of the intent service that will handle GCM messages.
67 - */
68 - protected String getGCMIntentServiceClassName(Context context) {
69 - try {
70 - String customName = WarplyProperty.getCustomPushServiceClassName(context);
71 - if (!TextUtils.isEmpty(customName)) {
72 - Class.forName(customName);
73 - return customName;
74 - }
75 - } catch (ClassNotFoundException e) {
76 - WarpUtils.log("No custom push service class is implemented, using the default one");
77 - }
78 -
79 - return WarpIntentService.class.getCanonicalName();
80 - }
81 -}
1 package ly.warp.sdk.services; 1 package ly.warp.sdk.services;
2 2
3 +import static ly.warp.sdk.utils.constants.WarpConstants.CHANNEL_ID;
4 +import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MAX;
5 +import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MIN;
6 +
3 import android.app.Notification; 7 import android.app.Notification;
4 import android.app.NotificationChannel; 8 import android.app.NotificationChannel;
5 import android.app.NotificationManager; 9 import android.app.NotificationManager;
...@@ -13,12 +17,18 @@ import android.graphics.Color; ...@@ -13,12 +17,18 @@ import android.graphics.Color;
13 import android.media.RingtoneManager; 17 import android.media.RingtoneManager;
14 import android.os.Build; 18 import android.os.Build;
15 import android.os.Bundle; 19 import android.os.Bundle;
20 +import android.text.TextUtils;
21 +import android.widget.RemoteViews;
16 22
17 import androidx.annotation.NonNull; 23 import androidx.annotation.NonNull;
18 import androidx.core.app.NotificationCompat; 24 import androidx.core.app.NotificationCompat;
25 +import androidx.work.Constraints;
26 +import androidx.work.NetworkType;
27 +import androidx.work.OneTimeWorkRequest;
28 +import androidx.work.WorkManager;
19 29
20 -import android.text.TextUtils; 30 +import com.google.firebase.messaging.FirebaseMessagingService;
21 -import android.widget.RemoteViews; 31 +import com.google.firebase.messaging.RemoteMessage;
22 32
23 import org.apache.http.HttpStatus; 33 import org.apache.http.HttpStatus;
24 import org.json.JSONException; 34 import org.json.JSONException;
...@@ -33,26 +43,13 @@ import java.util.List; ...@@ -33,26 +43,13 @@ import java.util.List;
33 import java.util.concurrent.ThreadLocalRandom; 43 import java.util.concurrent.ThreadLocalRandom;
34 import java.util.concurrent.TimeUnit; 44 import java.util.concurrent.TimeUnit;
35 45
36 -import androidx.work.Constraints;
37 -import androidx.work.NetworkType;
38 -import androidx.work.OneTimeWorkRequest;
39 -import androidx.work.WorkManager;
40 -
41 import ly.warp.sdk.Warply; 46 import ly.warp.sdk.Warply;
42 import ly.warp.sdk.activities.WarpViewActivity; 47 import ly.warp.sdk.activities.WarpViewActivity;
43 import ly.warp.sdk.io.models.PushCampaign; 48 import ly.warp.sdk.io.models.PushCampaign;
44 -import ly.warp.sdk.utils.GCMRegistrar;
45 import ly.warp.sdk.utils.WarpUtils; 49 import ly.warp.sdk.utils.WarpUtils;
46 import ly.warp.sdk.utils.WarplyProperty; 50 import ly.warp.sdk.utils.WarplyProperty;
47 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; 51 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
48 52
49 -import static ly.warp.sdk.utils.constants.WarpConstants.CHANNEL_ID;
50 -import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MAX;
51 -import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MIN;
52 -
53 -import com.google.firebase.messaging.FirebaseMessagingService;
54 -import com.google.firebase.messaging.RemoteMessage;
55 -
56 /** 53 /**
57 * Created by Panagiotis Triantafyllou on 14-Feb-19. 54 * Created by Panagiotis Triantafyllou on 14-Feb-19.
58 */ 55 */
...@@ -97,7 +94,6 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -97,7 +94,6 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
97 @Override 94 @Override
98 public void onNewToken(@NonNull String s) { 95 public void onNewToken(@NonNull String s) {
99 super.onNewToken(s); 96 super.onNewToken(s);
100 - GCMRegistrar.setRegistrationId(this, s);
101 WarpUtils.setDeviceToken(this, s); 97 WarpUtils.setDeviceToken(this, s);
102 } 98 }
103 99
...@@ -132,14 +128,14 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -132,14 +128,14 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
132 Warply.getInitializer(this).init(); 128 Warply.getInitializer(this).init();
133 WarplyAnalyticsManager.logUserReceivedPush(pc); 129 WarplyAnalyticsManager.logUserReceivedPush(pc);
134 130
135 -// if (WorkManager.getInstance().getWorkInfosByTag(PushEventsWorkerService.TAG).isDone() || WorkManager.getInstance().getWorkInfosByTag(PushEventsWorkerService.TAG).isCancelled()) { 131 +// if (WorkManager.getInstance(this).getWorkInfosByTag(PushEventsWorkerService.TAG).isDone() || WorkManager.getInstance(this).getWorkInfosByTag(PushEventsWorkerService.TAG).isCancelled()) {
136 Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build(); 132 Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();
137 OneTimeWorkRequest sendEvent = new OneTimeWorkRequest.Builder(PushEventsWorkerService.class) 133 OneTimeWorkRequest sendEvent = new OneTimeWorkRequest.Builder(PushEventsWorkerService.class)
138 .setConstraints(constraints) 134 .setConstraints(constraints)
139 .setInitialDelay(defineRandomStart(), TimeUnit.MINUTES) 135 .setInitialDelay(defineRandomStart(), TimeUnit.MINUTES)
140 .build(); 136 .build();
141 137
142 - WorkManager.getInstance().enqueue(sendEvent); 138 + WorkManager.getInstance(this).enqueue(sendEvent);
143 // } 139 // }
144 } 140 }
145 141
......
1 package ly.warp.sdk.services; 1 package ly.warp.sdk.services;
2 2
3 +import static ly.warp.sdk.utils.constants.WarpConstants.CHANNEL_ID;
4 +import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MAX;
5 +import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MIN;
6 +
3 import android.app.Notification; 7 import android.app.Notification;
4 import android.app.NotificationChannel; 8 import android.app.NotificationChannel;
5 import android.app.NotificationManager; 9 import android.app.NotificationManager;
...@@ -41,15 +45,10 @@ import java.util.concurrent.TimeUnit; ...@@ -41,15 +45,10 @@ import java.util.concurrent.TimeUnit;
41 import ly.warp.sdk.Warply; 45 import ly.warp.sdk.Warply;
42 import ly.warp.sdk.activities.WarpViewActivity; 46 import ly.warp.sdk.activities.WarpViewActivity;
43 import ly.warp.sdk.io.models.PushCampaign; 47 import ly.warp.sdk.io.models.PushCampaign;
44 -import ly.warp.sdk.utils.GCMRegistrar;
45 import ly.warp.sdk.utils.WarpUtils; 48 import ly.warp.sdk.utils.WarpUtils;
46 import ly.warp.sdk.utils.WarplyProperty; 49 import ly.warp.sdk.utils.WarplyProperty;
47 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; 50 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
48 51
49 -import static ly.warp.sdk.utils.constants.WarpConstants.CHANNEL_ID;
50 -import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MAX;
51 -import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MIN;
52 -
53 /** 52 /**
54 * Created by Panagiotis Triantafyllou on 17-June-21. 53 * Created by Panagiotis Triantafyllou on 17-June-21.
55 */ 54 */
...@@ -133,7 +132,6 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -133,7 +132,6 @@ public class HMSBaseMessagingService extends HmsMessageService {
133 @Override 132 @Override
134 public void onNewToken(String s, Bundle bundle) { 133 public void onNewToken(String s, Bundle bundle) {
135 super.onNewToken(s, bundle); 134 super.onNewToken(s, bundle);
136 - GCMRegistrar.setRegistrationId(this, s);
137 WarpUtils.setDeviceToken(this, s); 135 WarpUtils.setDeviceToken(this, s);
138 } 136 }
139 137
...@@ -177,14 +175,14 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -177,14 +175,14 @@ public class HMSBaseMessagingService extends HmsMessageService {
177 Warply.getInitializer(this).init(); 175 Warply.getInitializer(this).init();
178 WarplyAnalyticsManager.logUserReceivedPush(pc); 176 WarplyAnalyticsManager.logUserReceivedPush(pc);
179 177
180 -// if (WorkManager.getInstance().getWorkInfosByTag(PushEventsWorkerService.TAG).isDone() || WorkManager.getInstance().getWorkInfosByTag(PushEventsWorkerService.TAG).isCancelled()) { 178 +// if (WorkManager.getInstance(this).getWorkInfosByTag(PushEventsWorkerService.TAG).isDone() || WorkManager.getInstance(this).getWorkInfosByTag(PushEventsWorkerService.TAG).isCancelled()) {
181 Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build(); 179 Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();
182 OneTimeWorkRequest sendEvent = new OneTimeWorkRequest.Builder(PushEventsWorkerService.class) 180 OneTimeWorkRequest sendEvent = new OneTimeWorkRequest.Builder(PushEventsWorkerService.class)
183 .setConstraints(constraints) 181 .setConstraints(constraints)
184 .setInitialDelay(defineRandomStart(), TimeUnit.MINUTES) 182 .setInitialDelay(defineRandomStart(), TimeUnit.MINUTES)
185 .build(); 183 .build();
186 184
187 - WorkManager.getInstance().enqueue(sendEvent); 185 + WorkManager.getInstance(this).enqueue(sendEvent);
188 // } 186 // }
189 } 187 }
190 188
......
1 /* 1 /*
2 * Copyright 2010-2013 Warply Ltd. All rights reserved. 2 * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 - * 3 + *
4 * Redistribution and use in source and binary forms, without modification, are 4 * Redistribution and use in source and binary forms, without modification, are
5 * permitted provided that the following conditions are met: 5 * permitted provided that the following conditions are met:
6 - * 6 + *
7 * 1. Redistributions of source code must retain the above copyright notice, 7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 - * 9 + *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 - * 13 + *
14 * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR 14 * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
25 25
26 package ly.warp.sdk.services; 26 package ly.warp.sdk.services;
27 27
28 +import static ly.warp.sdk.utils.constants.WarpConstants.CHANNEL_ID;
29 +
30 +import android.app.IntentService;
28 import android.app.Notification; 31 import android.app.Notification;
29 import android.app.NotificationChannel; 32 import android.app.NotificationChannel;
30 import android.app.NotificationManager; 33 import android.app.NotificationManager;
...@@ -38,10 +41,11 @@ import android.graphics.Color; ...@@ -38,10 +41,11 @@ import android.graphics.Color;
38 import android.media.RingtoneManager; 41 import android.media.RingtoneManager;
39 import android.os.Build; 42 import android.os.Build;
40 import android.os.Bundle; 43 import android.os.Bundle;
41 -import androidx.core.app.NotificationCompat;
42 import android.text.TextUtils; 44 import android.text.TextUtils;
43 import android.widget.RemoteViews; 45 import android.widget.RemoteViews;
44 46
47 +import androidx.core.app.NotificationCompat;
48 +
45 import org.apache.http.HttpEntity; 49 import org.apache.http.HttpEntity;
46 import org.apache.http.HttpResponse; 50 import org.apache.http.HttpResponse;
47 import org.apache.http.HttpStatus; 51 import org.apache.http.HttpStatus;
...@@ -55,16 +59,12 @@ import java.io.InputStream; ...@@ -55,16 +59,12 @@ import java.io.InputStream;
55 import java.security.SecureRandom; 59 import java.security.SecureRandom;
56 import java.util.List; 60 import java.util.List;
57 61
58 -import ly.warp.sdk.Warply;
59 import ly.warp.sdk.activities.WarpViewActivity; 62 import ly.warp.sdk.activities.WarpViewActivity;
60 import ly.warp.sdk.io.models.PushCampaign; 63 import ly.warp.sdk.io.models.PushCampaign;
61 import ly.warp.sdk.utils.WarpUtils; 64 import ly.warp.sdk.utils.WarpUtils;
62 import ly.warp.sdk.utils.WarplyProperty; 65 import ly.warp.sdk.utils.WarplyProperty;
63 -import ly.warp.sdk.utils.constants.WarpConstants;
64 -
65 -import static ly.warp.sdk.utils.constants.WarpConstants.CHANNEL_ID;
66 66
67 -public abstract class WarpBaseIntentService extends GCMBaseIntentService { 67 +public abstract class WarpBaseIntentService extends IntentService {
68 68
69 private static final String KEY_TITLE = "alert"; 69 private static final String KEY_TITLE = "alert";
70 private static final String KEY_SUBTITLE = "subtitle"; 70 private static final String KEY_SUBTITLE = "subtitle";
...@@ -72,65 +72,8 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService { ...@@ -72,65 +72,8 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService {
72 private static final String KEY_MESSAGE = "message"; 72 private static final String KEY_MESSAGE = "message";
73 private static final String KEY_PAYLOAD = "payload"; 73 private static final String KEY_PAYLOAD = "payload";
74 74
75 -
76 public WarpBaseIntentService() { 75 public WarpBaseIntentService() {
77 - 76 + super("WarpBaseIntentService");
78 - super(WarpConstants.GCM_SENDER_ID);
79 - }
80 -
81 - protected WarpBaseIntentService(String senderId) {
82 - super(senderId);
83 - }
84 -
85 - public abstract void onPushReceived(Context context, int action, Bundle data);
86 -
87 - @Override
88 - protected void onMessage(Context context, Intent intent) {
89 - Bundle data = intent.getExtras();
90 - if (data == null || !data.containsKey("loyalty-action"))
91 - return;
92 - PushCampaign pc = new PushCampaign(data);
93 - Warply.getInitializer(context).init();
94 -// WarplyAnalyticsManager.logUserReceivedPush(pc.getSessionUUID());
95 - WarpUtils.log("Received push with action: " + pc.getAction());
96 - if (pc.getAction() == 0 && !pc.hasActions())
97 - showCampaignNotification(context, pc);
98 - else
99 - onPushReceived(context, pc.getAction(), data);
100 - }
101 -
102 - @Override
103 - protected void onError(Context context, String errorId) {
104 - int errorCode = -1;
105 - try {
106 - errorCode = Integer.valueOf(errorId);
107 - } catch (NumberFormatException e) {
108 - WarpUtils.warn("[Warp Trace] Error id is not a number", e);
109 - }
110 - Warply.getInitializer(context).init();
111 - Warply.INSTANCE.onGCMRegistrationFail(errorCode);
112 - }
113 -
114 - @Override
115 - protected void onRegistered(Context context, String registrationId) {
116 - WarpUtils.log("Registration to GCM successful");
117 - /*
118 - * Initialize Warply only if it is not initialized. This is to make sure
119 - * device info are not sent in check (called in init) and then resent
120 - * using the reset (called in onGCMRegistrationSuccess)
121 - */
122 - if (!Warply.isInitialized())
123 - Warply.getInitializer(context).init();
124 - Warply.INSTANCE.onGCMRegistrationSuccess();
125 - }
126 -
127 - @Override
128 - protected void onUnregistered(Context context, String registrationId) {
129 - WarpUtils.log("Unregistration from GCM successful");
130 - Warply.getInitializer(context).init();
131 - if (WarpUtils.getIsDEVICEINFOENABLED(context))
132 - Warply.INSTANCE.postDeviceInfoData();
133 - Warply.INSTANCE.onGCMUnregistrationSuccess();
134 } 77 }
135 78
136 public static void showCampaignNotification(Context context, PushCampaign pc) { 79 public static void showCampaignNotification(Context context, PushCampaign pc) {
......
1 /* 1 /*
2 * Copyright 2010-2013 Warply Ltd. All rights reserved. 2 * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 - * 3 + *
4 * Redistribution and use in source and binary forms, without modification, are 4 * Redistribution and use in source and binary forms, without modification, are
5 * permitted provided that the following conditions are met: 5 * permitted provided that the following conditions are met:
6 - * 6 + *
7 * 1. Redistributions of source code must retain the above copyright notice, 7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 - * 9 + *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 - * 13 + *
14 * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR 14 * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
...@@ -33,7 +33,7 @@ import android.content.Context; ...@@ -33,7 +33,7 @@ import android.content.Context;
33 import android.content.Intent; 33 import android.content.Intent;
34 import android.content.pm.PackageManager; 34 import android.content.pm.PackageManager;
35 import android.os.Build; 35 import android.os.Build;
36 -import android.os.Bundle; 36 +
37 import androidx.annotation.NonNull; 37 import androidx.annotation.NonNull;
38 import androidx.core.app.NotificationCompat; 38 import androidx.core.app.NotificationCompat;
39 39
...@@ -54,12 +54,7 @@ public class WarpInAppNotificationService extends WarpBaseIntentService { ...@@ -54,12 +54,7 @@ public class WarpInAppNotificationService extends WarpBaseIntentService {
54 54
55 55
56 public WarpInAppNotificationService() { 56 public WarpInAppNotificationService() {
57 - super("WarpInAppNotificationService"); 57 + super();
58 - }
59 -
60 - @Override
61 - public void onPushReceived(Context context, int action, Bundle data) {
62 -
63 } 58 }
64 59
65 @Override 60 @Override
......
1 -/*
2 - * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 - *
4 - * Redistribution and use in source and binary forms, without modification, are
5 - * permitted provided that the following conditions are met:
6 - *
7 - * 1. Redistributions of source code must retain the above copyright notice,
8 - * this list of conditions and the following disclaimer.
9 - *
10 - * 2. Redistributions in binary form must reproduce the above copyright notice,
11 - * this list of conditions and the following disclaimer in the documentation
12 - * and/or other materials provided with the distribution.
13 - *
14 - * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20 - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -package ly.warp.sdk.services;
27 -
28 -import android.content.Context;
29 -import android.os.Bundle;
30 -
31 -public class WarpIntentService extends WarpBaseIntentService {
32 -
33 - @Override
34 - public void onPushReceived(Context context, int action, Bundle data) {
35 - showDefaultNotification(context, data);
36 - }
37 -}
1 /* 1 /*
2 * Copyright 2010-2013 Warply Ltd. All rights reserved. 2 * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 - * 3 + *
4 * Redistribution and use in source and binary forms, without modification, are 4 * Redistribution and use in source and binary forms, without modification, are
5 * permitted provided that the following conditions are met: 5 * permitted provided that the following conditions are met:
6 - * 6 + *
7 * 1. Redistributions of source code must retain the above copyright notice, 7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 - * 9 + *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 - * 13 + *
14 * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR 14 * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
25 25
26 package ly.warp.sdk.utils; 26 package ly.warp.sdk.utils;
27 27
28 -import android.app.PendingIntent;
29 import android.content.BroadcastReceiver; 28 import android.content.BroadcastReceiver;
30 import android.content.Context; 29 import android.content.Context;
31 import android.content.Intent; 30 import android.content.Intent;
...@@ -44,7 +43,6 @@ import java.util.HashSet; ...@@ -44,7 +43,6 @@ import java.util.HashSet;
44 import java.util.List; 43 import java.util.List;
45 import java.util.Set; 44 import java.util.Set;
46 45
47 -import ly.warp.sdk.receivers.GCMBroadcastReceiver;
48 import ly.warp.sdk.utils.constants.GCMConstants; 46 import ly.warp.sdk.utils.constants.GCMConstants;
49 47
50 48
...@@ -66,15 +64,6 @@ public final class GCMRegistrar { ...@@ -66,15 +64,6 @@ public final class GCMRegistrar {
66 private static final String PROPERTY_ON_SERVER = "onServer"; 64 private static final String PROPERTY_ON_SERVER = "onServer";
67 65
68 /** 66 /**
69 - * {@link GCMBroadcastReceiver} instance used to handle the retry intent.
70 - * <p/>
71 - * <p/>
72 - * This instance cannot be the same as the one defined in the manifest
73 - * because it needs a different permission.
74 - */
75 - private static GCMBroadcastReceiver sRetryReceiver;
76 -
77 - /**
78 * Checks if the device has the proper dependencies installed. 67 * Checks if the device has the proper dependencies installed.
79 * <p/> 68 * <p/>
80 * This method should be called when the application starts to verify that 69 * This method should be called when the application starts to verify that
...@@ -214,29 +203,6 @@ public final class GCMRegistrar { ...@@ -214,29 +203,6 @@ public final class GCMRegistrar {
214 // internalRegister(context, senderIds); 203 // internalRegister(context, senderIds);
215 } 204 }
216 205
217 - public static void internalRegister(Context context, String... senderIds) {
218 - if (senderIds == null || senderIds.length == 0) {
219 - throw new IllegalArgumentException("No senderIds");
220 - }
221 - StringBuilder builder = new StringBuilder(senderIds[0]);
222 - for (int i = 1; i < senderIds.length; i++) {
223 - builder.append(',').append(senderIds[i]);
224 - }
225 - String senders = builder.toString();
226 - Log.v(TAG, "Registering app " + context.getPackageName()
227 - + " of senders " + senders);
228 - Intent intent = new Intent(GCMConstants.INTENT_TO_GCM_REGISTRATION);
229 - intent.setPackage(GSF_PACKAGE);
230 - intent.putExtra(GCMConstants.EXTRA_APPLICATION_PENDING_INTENT,
231 - PendingIntent.getBroadcast(context, 0, new Intent(), 0));
232 - intent.putExtra(GCMConstants.EXTRA_SENDER, senders);
233 -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
234 -// context.startForegroundService(intent);
235 -// } else {
236 - context.startService(intent);
237 -// }
238 - }
239 -
240 /** 206 /**
241 * Unregister the application. 207 * Unregister the application.
242 * <p/> 208 * <p/>
...@@ -245,60 +211,7 @@ public final class GCMRegistrar { ...@@ -245,60 +211,7 @@ public final class GCMRegistrar {
245 * {@link GCMConstants#EXTRA_UNREGISTERED} extra. 211 * {@link GCMConstants#EXTRA_UNREGISTERED} extra.
246 */ 212 */
247 public static void unregister(Context context) { 213 public static void unregister(Context context) {
248 - setRetryBroadcastReceiver(context);
249 GCMRegistrar.resetBackoff(context); 214 GCMRegistrar.resetBackoff(context);
250 - internalUnregister(context);
251 - }
252 -
253 - /**
254 - * Clear internal resources.
255 - * <p/>
256 - * <p/>
257 - * This method should be called by the main activity's {@code onDestroy()}
258 - * method.
259 - */
260 - public static synchronized void onDestroy(Context context) {
261 - if (sRetryReceiver != null) {
262 - Log.v(TAG, "Unregistering receiver");
263 - context.unregisterReceiver(sRetryReceiver);
264 - sRetryReceiver = null;
265 - }
266 - }
267 -
268 - public static void internalUnregister(Context context) {
269 - Log.v(TAG, "Unregistering app " + context.getPackageName());
270 - Intent intent = new Intent(GCMConstants.INTENT_TO_GCM_UNREGISTRATION);
271 - intent.setPackage(GSF_PACKAGE);
272 - intent.putExtra(GCMConstants.EXTRA_APPLICATION_PENDING_INTENT,
273 - PendingIntent.getBroadcast(context, 0, new Intent(), 0));
274 -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
275 -// context.startForegroundService(intent);
276 -// } else {
277 - context.startService(intent);
278 -// }
279 - }
280 -
281 - /**
282 - * Lazy initializes the {@link GCMBroadcastReceiver} instance.
283 - */
284 - private static synchronized void setRetryBroadcastReceiver(Context context) {
285 - if (sRetryReceiver == null) {
286 - sRetryReceiver = new GCMBroadcastReceiver();
287 - String category = context.getPackageName();
288 - IntentFilter filter = new IntentFilter(
289 - GCMConstants.INTENT_FROM_GCM_LIBRARY_RETRY);
290 - filter.addCategory(category);
291 - // must use a permission that is defined on manifest for sure
292 - String permission = category + ".permission.C2D_MESSAGE";
293 - Log.v(TAG, "Registering receiver");
294 -// context.registerReceiver(sRetryReceiver, filter, permission, null);
295 - if (Build.VERSION.SDK_INT >= 27) {
296 - context.sendBroadcast(new Intent(context, GCMBroadcastReceiver.class)
297 - .setAction(GCMConstants.INTENT_FROM_GCM_REGISTRATION_CALLBACK));
298 - } else {
299 - context.registerReceiver(sRetryReceiver, filter, permission, null);
300 - }
301 - }
302 } 215 }
303 216
304 /** 217 /**
......
...@@ -141,16 +141,6 @@ public class WarpUtils { ...@@ -141,16 +141,6 @@ public class WarpUtils {
141 return GCMRegistrar.getRegistrationId(context); 141 return GCMRegistrar.getRegistrationId(context);
142 } 142 }
143 143
144 - /**
145 - * Method used return whether this device is registered with GCM or not
146 - *
147 - * @return True or False
148 - */
149 - public static boolean isRegisteredGCM(Context context) {
150 -
151 - return GCMRegistrar.isRegistered(context);
152 - }
153 -
154 public static void setRegistrationGCM(Context context, String registrationGCM) { 144 public static void setRegistrationGCM(Context context, String registrationGCM) {
155 145
156 SharedPreferences.Editor editor = getPreferences(context).edit(); 146 SharedPreferences.Editor editor = getPreferences(context).edit();
...@@ -180,11 +170,6 @@ public class WarpUtils { ...@@ -180,11 +170,6 @@ public class WarpUtils {
180 editor.apply(); 170 editor.apply();
181 } 171 }
182 172
183 - static boolean isRegisteredGCMOrWaiting(Context context) {
184 -
185 - return isRegisteredGCM(context) || isWaitingGCM(context);
186 - }
187 -
188 public static boolean isRegisteredWarply(Context context) { 173 public static boolean isRegisteredWarply(Context context) {
189 return !("".equalsIgnoreCase(getWebId(context))); 174 return !("".equalsIgnoreCase(getWebId(context)));
190 } 175 }
......
...@@ -80,6 +80,7 @@ public class WarplyDeviceInfoCollector { ...@@ -80,6 +80,7 @@ public class WarplyDeviceInfoCollector {
80 adInfo.isLimitAdTrackingEnabled() : ""); 80 adInfo.isLimitAdTrackingEnabled() : "");
81 jObj.putOpt("unique_device_id", getUniqueDeviceId()); 81 jObj.putOpt("unique_device_id", getUniqueDeviceId());
82 jObj.putOpt("os_version", getOsVersion()); 82 jObj.putOpt("os_version", getOsVersion());
83 + jObj.putOpt("app_version", getAppVersion());
83 } catch (JSONException e) { 84 } catch (JSONException e) {
84 WarpUtils.log("************* WARPLY Warning ********************"); 85 WarpUtils.log("************* WARPLY Warning ********************");
85 WarpUtils.log("Problem when creating Device Info JSON", e); 86 WarpUtils.log("Problem when creating Device Info JSON", e);
...@@ -106,6 +107,7 @@ public class WarplyDeviceInfoCollector { ...@@ -106,6 +107,7 @@ public class WarplyDeviceInfoCollector {
106 jObj.putOpt("advertising_id", info != null ? info.getId() : ""); 107 jObj.putOpt("advertising_id", info != null ? info.getId() : "");
107 jObj.putOpt("unique_device_id", getUniqueDeviceId()); 108 jObj.putOpt("unique_device_id", getUniqueDeviceId());
108 jObj.putOpt("os_version", getOsVersion()); 109 jObj.putOpt("os_version", getOsVersion());
110 + jObj.putOpt("app_version", getAppVersion());
109 //jObj.putOpt("opt_out_of_interest_based_ads_enabled", info != null ? 111 //jObj.putOpt("opt_out_of_interest_based_ads_enabled", info != null ?
110 //info.isLimitAdTrackingEnabled() : ""); 112 //info.isLimitAdTrackingEnabled() : "");
111 } catch (JSONException | IOException e) { 113 } catch (JSONException | IOException e) {
...@@ -137,6 +139,7 @@ public class WarplyDeviceInfoCollector { ...@@ -137,6 +139,7 @@ public class WarplyDeviceInfoCollector {
137 jObj.putOpt("platform", "android"); 139 jObj.putOpt("platform", "android");
138 jObj.putOpt("os_version", getOsVersion()); 140 jObj.putOpt("os_version", getOsVersion());
139 jObj.putOpt("vendor", "google"); 141 jObj.putOpt("vendor", "google");
142 + jObj.putOpt("app_version", getAppVersion());
140 } catch (JSONException e) { 143 } catch (JSONException e) {
141 WarpUtils.log("************* WARPLY Warning ********************"); 144 WarpUtils.log("************* WARPLY Warning ********************");
142 WarpUtils.log("Problem when creating Device Info JSON", e); 145 WarpUtils.log("Problem when creating Device Info JSON", e);
...@@ -154,6 +157,7 @@ public class WarplyDeviceInfoCollector { ...@@ -154,6 +157,7 @@ public class WarplyDeviceInfoCollector {
154 jObj.putOpt("platform", "android"); 157 jObj.putOpt("platform", "android");
155 jObj.putOpt("os_version", getOsVersion()); 158 jObj.putOpt("os_version", getOsVersion());
156 jObj.putOpt("vendor", "huawei"); 159 jObj.putOpt("vendor", "huawei");
160 + jObj.putOpt("app_version", getAppVersion());
157 } catch (IOException e) { 161 } catch (IOException e) {
158 e.printStackTrace(); 162 e.printStackTrace();
159 } catch (JSONException e) { 163 } catch (JSONException e) {
...@@ -204,9 +208,23 @@ public class WarplyDeviceInfoCollector { ...@@ -204,9 +208,23 @@ public class WarplyDeviceInfoCollector {
204 } 208 }
205 209
206 private String getRegistrationGCM() { 210 private String getRegistrationGCM() {
211 + if (!TextUtils.isEmpty(WarpUtils.getDeviceToken(mContext)))
212 + return WarpUtils.getDeviceToken(mContext);
213 +
214 + WarpUtils.setDeviceToken(mContext, WarpUtils.getRegistrationGCM(mContext));
207 return WarpUtils.getRegistrationGCM(mContext); 215 return WarpUtils.getRegistrationGCM(mContext);
208 } 216 }
209 217
218 + private String getAppVersion() {
219 + try {
220 + PackageInfo pInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
221 + return pInfo.versionName;
222 + } catch (PackageManager.NameNotFoundException e) {
223 + e.printStackTrace();
224 + return "";
225 + }
226 + }
227 +
210 private String getHardwareId() { 228 private String getHardwareId() {
211 return (Build.SERIAL == null || 229 return (Build.SERIAL == null ||
212 Build.SERIAL.equals(android.os.Build.UNKNOWN)) ? "" : Build.SERIAL; 230 Build.SERIAL.equals(android.os.Build.UNKNOWN)) ? "" : Build.SERIAL;
......
...@@ -30,7 +30,7 @@ public class WarpConstants { ...@@ -30,7 +30,7 @@ public class WarpConstants {
30 /** 30 /**
31 * The version of the SDK installed in the device 31 * The version of the SDK installed in the device
32 */ 32 */
33 - public static final String SDK_VERSION = "4.5.4.3"; 33 + public static final String SDK_VERSION = "4.5.4.4";
34 34
35 /** 35 /**
36 * The URL of the server where it should ping 36 * The URL of the server where it should ping
......