Panagiotis Triantafyllou

version 4.5.3

...@@ -32,13 +32,13 @@ public class SplashActivity extends BaseActivity { ...@@ -32,13 +32,13 @@ public class SplashActivity extends BaseActivity {
32 @Override 32 @Override
33 public void onWarplyInitTimeOut() { 33 public void onWarplyInitTimeOut() {
34 showToast("Warply initialization timeout!"); 34 showToast("Warply initialization timeout!");
35 - finish(); 35 + checkForAppUpdate();
36 } 36 }
37 37
38 @Override 38 @Override
39 public void onWarplyPermissionsDenied() { 39 public void onWarplyPermissionsDenied() {
40 showToast("Warply permissions denied!"); 40 showToast("Warply permissions denied!");
41 -// onWarplyReady(); 41 + checkForAppUpdate();
42 } 42 }
43 }); 43 });
44 } 44 }
...@@ -55,7 +55,7 @@ public class SplashActivity extends BaseActivity { ...@@ -55,7 +55,7 @@ public class SplashActivity extends BaseActivity {
55 // super.onRequestPermissionsResult(requestCode, permissions, grantResults); 55 // super.onRequestPermissionsResult(requestCode, permissions, grantResults);
56 // } 56 // }
57 57
58 - private void checkForAppUpdate(){ 58 + private void checkForAppUpdate() {
59 59
60 Warply.checkForAppUpdate(SplashActivity.this, new SimpleCallbackReceiver<Boolean>() { 60 Warply.checkForAppUpdate(SplashActivity.this, new SimpleCallbackReceiver<Boolean>() {
61 @Override 61 @Override
......
...@@ -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.2' 5 + PUBLISH_VERSION = '4.5.3'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
...@@ -48,6 +48,7 @@ dependencies { ...@@ -48,6 +48,7 @@ dependencies {
48 48
49 //------------------------------ GMS -----------------------------// 49 //------------------------------ GMS -----------------------------//
50 api 'com.google.android.gms:play-services-base:18.0.1' 50 api 'com.google.android.gms:play-services-base:18.0.1'
51 + api 'com.google.android.gms:play-services-location:19.0.1'
51 52
52 //------------------------------ Work Manager -----------------------------// 53 //------------------------------ Work Manager -----------------------------//
53 api 'androidx.work:work-runtime:2.7.1' 54 api 'androidx.work:work-runtime:2.7.1'
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
25 25
26 package ly.warp.sdk; 26 package ly.warp.sdk;
27 27
28 +import static ly.warp.sdk.utils.constants.WarpConstants.IN_APP_FILTER_ALL;
29 +
28 import android.content.ActivityNotFoundException; 30 import android.content.ActivityNotFoundException;
29 import android.content.Context; 31 import android.content.Context;
30 import android.content.DialogInterface; 32 import android.content.DialogInterface;
...@@ -33,11 +35,10 @@ import android.content.pm.PackageInfo; ...@@ -33,11 +35,10 @@ import android.content.pm.PackageInfo;
33 import android.content.pm.PackageManager.NameNotFoundException; 35 import android.content.pm.PackageManager.NameNotFoundException;
34 import android.database.Cursor; 36 import android.database.Cursor;
35 import android.net.Uri; 37 import android.net.Uri;
38 +import android.util.Log;
36 39
37 import androidx.appcompat.app.AlertDialog; 40 import androidx.appcompat.app.AlertDialog;
38 41
39 -import android.util.Log;
40 -
41 import org.json.JSONArray; 42 import org.json.JSONArray;
42 import org.json.JSONException; 43 import org.json.JSONException;
43 import org.json.JSONObject; 44 import org.json.JSONObject;
...@@ -47,47 +48,24 @@ import java.lang.ref.WeakReference; ...@@ -47,47 +48,24 @@ import java.lang.ref.WeakReference;
47 import java.util.ArrayList; 48 import java.util.ArrayList;
48 import java.util.Collections; 49 import java.util.Collections;
49 import java.util.Comparator; 50 import java.util.Comparator;
50 -import java.util.HashMap;
51 import java.util.Iterator; 51 import java.util.Iterator;
52 import java.util.Map; 52 import java.util.Map;
53 import java.util.concurrent.atomic.AtomicBoolean; 53 import java.util.concurrent.atomic.AtomicBoolean;
54 54
55 import ly.warp.sdk.db.WarplyDBHelper; 55 import ly.warp.sdk.db.WarplyDBHelper;
56 -import ly.warp.sdk.io.callbacks.BaseCallbackReceiver;
57 import ly.warp.sdk.io.callbacks.CallbackReceiver; 56 import ly.warp.sdk.io.callbacks.CallbackReceiver;
58 import ly.warp.sdk.io.callbacks.CampaignsHook; 57 import ly.warp.sdk.io.callbacks.CampaignsHook;
59 -import ly.warp.sdk.io.callbacks.ContactHook;
60 -import ly.warp.sdk.io.callbacks.ContentHook;
61 import ly.warp.sdk.io.callbacks.InboxStatsHook; 58 import ly.warp.sdk.io.callbacks.InboxStatsHook;
62 import ly.warp.sdk.io.callbacks.PostHook; 59 import ly.warp.sdk.io.callbacks.PostHook;
63 -import ly.warp.sdk.io.callbacks.ProductsHook;
64 -import ly.warp.sdk.io.callbacks.MerchantCategoriesHook;
65 -import ly.warp.sdk.io.callbacks.MerchantsHook;
66 import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver; 60 import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver;
67 -import ly.warp.sdk.io.callbacks.TagsCategoriesHook;
68 -import ly.warp.sdk.io.callbacks.TagsHook;
69 import ly.warp.sdk.io.callbacks.VolleyTransformer; 61 import ly.warp.sdk.io.callbacks.VolleyTransformer;
70 import ly.warp.sdk.io.callbacks.WarplyReadyCallback; 62 import ly.warp.sdk.io.callbacks.WarplyReadyCallback;
71 import ly.warp.sdk.io.models.Campaign; 63 import ly.warp.sdk.io.models.Campaign;
72 import ly.warp.sdk.io.models.CampaignList; 64 import ly.warp.sdk.io.models.CampaignList;
73 -import ly.warp.sdk.io.models.ContentList;
74 import ly.warp.sdk.io.models.InboxStats; 65 import ly.warp.sdk.io.models.InboxStats;
75 -import ly.warp.sdk.io.models.ProductList;
76 -import ly.warp.sdk.io.models.MerchantCategoriesList;
77 -import ly.warp.sdk.io.models.MerchantList;
78 -import ly.warp.sdk.io.models.TagsCategoriesList;
79 -import ly.warp.sdk.io.models.TagsList;
80 -import ly.warp.sdk.io.request.WarplyContactRequest;
81 -import ly.warp.sdk.io.request.WarplyContentRequest;
82 import ly.warp.sdk.io.request.WarplyInboxRequest; 66 import ly.warp.sdk.io.request.WarplyInboxRequest;
83 import ly.warp.sdk.io.request.WarplyJsonArrayRequest; 67 import ly.warp.sdk.io.request.WarplyJsonArrayRequest;
84 import ly.warp.sdk.io.request.WarplyJsonObjectRequest; 68 import ly.warp.sdk.io.request.WarplyJsonObjectRequest;
85 -import ly.warp.sdk.io.request.WarplyProductsRequest;
86 -import ly.warp.sdk.io.request.WarplyMerchantCategoriesRequest;
87 -import ly.warp.sdk.io.request.WarplyMerchantsRequest;
88 -import ly.warp.sdk.io.request.WarplyTagsCategoriesRequest;
89 -import ly.warp.sdk.io.request.WarplyTagsRequest;
90 -import ly.warp.sdk.io.volley.AuthFailureError;
91 import ly.warp.sdk.io.volley.Request.Method; 69 import ly.warp.sdk.io.volley.Request.Method;
92 import ly.warp.sdk.io.volley.RequestQueue; 70 import ly.warp.sdk.io.volley.RequestQueue;
93 import ly.warp.sdk.io.volley.toolbox.Volley; 71 import ly.warp.sdk.io.volley.toolbox.Volley;
...@@ -95,8 +73,8 @@ import ly.warp.sdk.receivers.WarplyBeaconsApplication; ...@@ -95,8 +73,8 @@ import ly.warp.sdk.receivers.WarplyBeaconsApplication;
95 import ly.warp.sdk.utils.GCMRegistrar; 73 import ly.warp.sdk.utils.GCMRegistrar;
96 import ly.warp.sdk.utils.ObjectSerializer; 74 import ly.warp.sdk.utils.ObjectSerializer;
97 import ly.warp.sdk.utils.WarpUtils; 75 import ly.warp.sdk.utils.WarpUtils;
98 -import ly.warp.sdk.utils.WarplyInitializer;
99 import ly.warp.sdk.utils.WarplyDeviceInfoCollector; 76 import ly.warp.sdk.utils.WarplyDeviceInfoCollector;
77 +import ly.warp.sdk.utils.WarplyInitializer;
100 import ly.warp.sdk.utils.WarplyPreferences; 78 import ly.warp.sdk.utils.WarplyPreferences;
101 import ly.warp.sdk.utils.WarplyProperty; 79 import ly.warp.sdk.utils.WarplyProperty;
102 import ly.warp.sdk.utils.constants.WarpConstants; 80 import ly.warp.sdk.utils.constants.WarpConstants;
...@@ -108,8 +86,6 @@ import ly.warp.sdk.utils.managers.WarplyServerPreferencesManager; ...@@ -108,8 +86,6 @@ import ly.warp.sdk.utils.managers.WarplyServerPreferencesManager;
108 import ly.warp.sdk.utils.managers.WarplyUserManager; 86 import ly.warp.sdk.utils.managers.WarplyUserManager;
109 import ly.warp.sdk.views.dialogs.InAppDialog; 87 import ly.warp.sdk.views.dialogs.InAppDialog;
110 88
111 -import static ly.warp.sdk.utils.constants.WarpConstants.IN_APP_FILTER_ALL;
112 -
113 public enum Warply { 89 public enum Warply {
114 90
115 INSTANCE; 91 INSTANCE;
...@@ -864,10 +840,8 @@ public enum Warply { ...@@ -864,10 +840,8 @@ public enum Warply {
864 isInitializedOrThrow(); 840 isInitializedOrThrow();
865 841
866 WarpUtils.log("************* WARPLY Microapp ********************"); 842 WarpUtils.log("************* WARPLY Microapp ********************");
867 - if (!WarplyServerPreferencesManager 843 + if (!WarplyServerPreferencesManager.isMicroAppActive(WarpConstants.MicroApp.APPLICATION_DATA)) {
868 - .isMicroAppActive(WarpConstants.MicroApp.APPLICATION_DATA)) { 844 + WarpUtils.log("[WARP Trace] Application Info Microapp is not active");
869 - WarpUtils
870 - .log("[WARP Trace] Application Info Microapp is not active");
871 return; 845 return;
872 } else { 846 } else {
873 WarpUtils.log("[WARP Trace] Application Info Microapp is active"); 847 WarpUtils.log("[WARP Trace] Application Info Microapp is active");
...@@ -882,100 +856,12 @@ public enum Warply { ...@@ -882,100 +856,12 @@ public enum Warply {
882 super.onResult(json, errorCode); 856 super.onResult(json, errorCode);
883 857
884 if (json != null) { 858 if (json != null) {
885 -// String jString = json.toString(); 859 + if (!WarpUtils.getIsDeviceInfoSaved(mContext.get())) {
886 -// if (!jString.equalsIgnoreCase(WarpUtils.getLastDeviceInfo(mContext.get()))) {
887 -
888 - if (!WarpUtils.getIsDeviceInfoSaved(mContext.get()) && !WarpUtils.getIsWarped(mContext.get())) {
889 - WarpUtils.log("********** DeviceInfo **********");
890 - WarpUtils.log(json.toString());
891 - WarpUtils.log("********************************");
892 -
893 - WarpUtils.setDeviceToken(mContext.get(), WarpUtils.getRegistrationGCM(mContext.get()));
894 WarpUtils.setIsDeviceInfoSaved(mContext.get(), true); 860 WarpUtils.setIsDeviceInfoSaved(mContext.get(), true);
895 - WarpUtils.setIsWarped(mContext.get(), true);
896 WarpUtils.setDeviceInfoObject(mContext.get(), json); 861 WarpUtils.setDeviceInfoObject(mContext.get(), json);
897 postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true); 862 postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
898 - } else if (!WarpUtils.getIsDeviceInfoSaved(mContext.get()) && WarpUtils.getIsWarped(mContext.get())) { 863 + } else {
899 - if (WarpUtils.getIsWarped(mContext.get()) && !WarpUtils.getDeviceToken(mContext.get()).equals(WarpUtils.getRegistrationGCM(mContext.get()))) { 864 + if (hasDeviceInfoDifference(WarpUtils.getDeviceInfoObject(mContext.get()), json)) {
900 - WarpUtils.log("********** DeviceInfo **********");
901 - WarpUtils.log(json.toString());
902 - WarpUtils.log("********************************");
903 -
904 - WarpUtils.setDeviceToken(mContext.get(), WarpUtils.getRegistrationGCM(mContext.get()));
905 - WarpUtils.setIsDeviceInfoSaved(mContext.get(), true);
906 - WarpUtils.setDeviceInfoObject(mContext.get(), json);
907 - postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
908 - } else {
909 - String gcm;
910 - gcm = (String) json.remove("registration_gcm");
911 -
912 - WarpUtils.log("********** DeviceInfo **********");
913 - WarpUtils.log(json.toString());
914 - WarpUtils.log("********************************");
915 -
916 - WarpUtils.setIsDeviceInfoSaved(mContext.get(), true);
917 - WarpUtils.setDeviceInfoObject(mContext.get(), json);
918 - postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
919 - }
920 - } else if (WarpUtils.getIsDeviceInfoSaved(mContext.get()) && !WarpUtils.getIsWarped(mContext.get())) {
921 - if (WarpUtils.getIsDeviceInfoSaved(mContext.get()) && hasDeviceInfoDifference(WarpUtils.getDeviceInfoObject(mContext.get()), json)) {
922 - WarpUtils.log("********** DeviceInfo **********");
923 - WarpUtils.log(json.toString());
924 - WarpUtils.log("********************************");
925 -
926 - WarpUtils.setIsWarped(mContext.get(), true);
927 - WarpUtils.setDeviceToken(mContext.get(), WarpUtils.getRegistrationGCM(mContext.get()));
928 - WarpUtils.setDeviceInfoObject(mContext.get(), json);
929 - postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
930 - } else {
931 - JSONObject deviceTokenJson = new JSONObject();
932 - try {
933 - deviceTokenJson.putOpt("registration_gcm", WarpUtils.getRegistrationGCM(mContext.get()));
934 - } catch (JSONException e) {
935 - WarpUtils.log("************* WARPLY Warning ********************");
936 - WarpUtils.log("Problem when creating Registration GCM Token JSON", e);
937 - WarpUtils.log("*************************************************");
938 - }
939 - WarpUtils.log("********** DeviceInfo **********");
940 - WarpUtils.log(deviceTokenJson.toString());
941 - WarpUtils.log("********************************");
942 -
943 - WarpUtils.setDeviceToken(mContext.get(), WarpUtils.getRegistrationGCM(mContext.get()));
944 - WarpUtils.setIsWarped(mContext.get(), true);
945 - postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, deviceTokenJson, true);
946 - }
947 - } else if (WarpUtils.getIsDeviceInfoSaved(mContext.get()) && WarpUtils.getIsWarped(mContext.get())) {
948 - if (WarpUtils.getDeviceToken(mContext.get()).equals(WarpUtils.getRegistrationGCM(mContext.get())) && hasDeviceInfoDifference(WarpUtils.getDeviceInfoObject(mContext.get()), json)) {
949 - String gcm;
950 - gcm = (String) json.remove("registration_gcm");
951 -
952 - WarpUtils.log("********** DeviceInfo **********");
953 - WarpUtils.log(json.toString());
954 - WarpUtils.log("********************************");
955 -
956 - WarpUtils.setDeviceInfoObject(mContext.get(), json);
957 - postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
958 - } else if (!WarpUtils.getDeviceToken(mContext.get()).equals(WarpUtils.getRegistrationGCM(mContext.get())) && !hasDeviceInfoDifference(WarpUtils.getDeviceInfoObject(mContext.get()), json)) {
959 - JSONObject deviceTokenJson = new JSONObject();
960 - try {
961 - deviceTokenJson.putOpt("registration_gcm", WarpUtils.getRegistrationGCM(mContext.get()));
962 - } catch (JSONException e) {
963 - WarpUtils.log("************* WARPLY Warning ********************");
964 - WarpUtils.log("Problem when creating Registration GCM Token JSON", e);
965 - WarpUtils.log("*************************************************");
966 - }
967 - WarpUtils.log("********** DeviceInfo **********");
968 - WarpUtils.log(deviceTokenJson.toString());
969 - WarpUtils.log("********************************");
970 -
971 - WarpUtils.setDeviceToken(mContext.get(), WarpUtils.getRegistrationGCM(mContext.get()));
972 - postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, deviceTokenJson, true);
973 - } else if (!WarpUtils.getDeviceToken(mContext.get()).equals(WarpUtils.getRegistrationGCM(mContext.get())) && hasDeviceInfoDifference(WarpUtils.getDeviceInfoObject(mContext.get()), json)) {
974 - WarpUtils.log("********** DeviceInfo **********");
975 - WarpUtils.log(json.toString());
976 - WarpUtils.log("********************************");
977 -
978 - WarpUtils.setDeviceToken(mContext.get(), WarpUtils.getRegistrationGCM(mContext.get()));
979 WarpUtils.setDeviceInfoObject(mContext.get(), json); 865 WarpUtils.setDeviceInfoObject(mContext.get(), json);
980 postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true); 866 postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
981 } 867 }
...@@ -1039,16 +925,15 @@ public enum Warply { ...@@ -1039,16 +925,15 @@ public enum Warply {
1039 PackageInfo info = mContext.get().getPackageManager().getPackageInfo(mContext.get().getApplicationContext().getPackageName(), 0); 925 PackageInfo info = mContext.get().getPackageManager().getPackageInfo(mContext.get().getApplicationContext().getPackageName(), 0);
1040 object.putOpt("app_version", info.versionName); 926 object.putOpt("app_version", info.versionName);
1041 object.putOpt("app_build", info.versionCode); 927 object.putOpt("app_build", info.versionCode);
1042 - String jString = object.toString();
1043 -// if ((jString.equals(WarpUtils.getLastApplicationData(mContext.get()))) == Boolean.FALSE) {
1044 -// WarpUtils.setLastApplicationData(mContext.get(), jString);
1045 if (!WarpUtils.getHasApplicationInfo(mContext.get())) { 928 if (!WarpUtils.getHasApplicationInfo(mContext.get())) {
1046 WarpUtils.setHasApplicationInfo(mContext.get(), true); 929 WarpUtils.setHasApplicationInfo(mContext.get(), true);
1047 WarpUtils.setAppDataObject(mContext.get(), object); 930 WarpUtils.setAppDataObject(mContext.get(), object);
1048 postMicroappData(WarpConstants.MICROAPP_APPLICATION_DATA, object, force); 931 postMicroappData(WarpConstants.MICROAPP_APPLICATION_DATA, object, force);
1049 - } else if (WarpUtils.getHasApplicationInfo(mContext.get()) && hasApplicationDataDifference(WarpUtils.getAppDataObject(mContext.get()), object)) { 932 + } else {
1050 - WarpUtils.setAppDataObject(mContext.get(), object); 933 + if (hasApplicationDataDifference(WarpUtils.getAppDataObject(mContext.get()), object)) {
1051 - postMicroappData(WarpConstants.MICROAPP_APPLICATION_DATA, object, force); 934 + WarpUtils.setAppDataObject(mContext.get(), object);
935 + postMicroappData(WarpConstants.MICROAPP_APPLICATION_DATA, object, force);
936 + }
1052 } 937 }
1053 } catch (JSONException e) { 938 } catch (JSONException e) {
1054 WarpUtils.warn("Problem when creating Device Info JSON", e); 939 WarpUtils.warn("Problem when creating Device Info JSON", e);
...@@ -1139,10 +1024,10 @@ public enum Warply { ...@@ -1139,10 +1024,10 @@ public enum Warply {
1139 registerWarply(); 1024 registerWarply();
1140 return; 1025 return;
1141 } 1026 }
1142 -// if (WarpUtils.getIsAPPDATAENABLED(mContext.get())) 1027 + if (WarpUtils.getIsAPPDATAENABLED(mContext.get()))
1143 -// postApplicationData(true); 1028 + postApplicationData(true);
1144 -// if (WarpUtils.getIsDEVICEINFOENABLED(mContext.get())) 1029 + if (WarpUtils.getIsDEVICEINFOENABLED(mContext.get()))
1145 -// postDeviceInfoData(); 1030 + postDeviceInfoData();
1146 tryWakingSendingTaskInternal(WarplyDBHelper.getInstance(mContext.get()) 1031 tryWakingSendingTaskInternal(WarplyDBHelper.getInstance(mContext.get())
1147 .getRequestsInQueueCount()); 1032 .getRequestsInQueueCount());
1148 } 1033 }
...@@ -1767,4 +1652,4 @@ public enum Warply { ...@@ -1767,4 +1652,4 @@ public enum Warply {
1767 } 1652 }
1768 }; 1653 };
1769 1654
1770 -} 1655 +}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -39,7 +39,7 @@ import android.widget.ImageView; ...@@ -39,7 +39,7 @@ import android.widget.ImageView;
39 import android.widget.ProgressBar; 39 import android.widget.ProgressBar;
40 import android.widget.RelativeLayout; 40 import android.widget.RelativeLayout;
41 41
42 -import java.util.Random; 42 +import java.security.SecureRandom;
43 import java.util.concurrent.ThreadLocalRandom; 43 import java.util.concurrent.ThreadLocalRandom;
44 import java.util.concurrent.TimeUnit; 44 import java.util.concurrent.TimeUnit;
45 45
...@@ -75,6 +75,7 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -75,6 +75,7 @@ public class WarpViewActivity extends WarpBaseActivity {
75 @Override 75 @Override
76 public void onCreate(Bundle savedInstanceState) { 76 public void onCreate(Bundle savedInstanceState) {
77 super.onCreate(savedInstanceState); 77 super.onCreate(savedInstanceState);
78 + WarplySessionManager.onCreateActivity(this);
78 initViews(); 79 initViews();
79 Warply.getInitializer(this).init(); 80 Warply.getInitializer(this).init();
80 setPageAccordingToIntent(); 81 setPageAccordingToIntent();
...@@ -203,7 +204,7 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -203,7 +204,7 @@ public class WarpViewActivity extends WarpBaseActivity {
203 if (Build.VERSION.SDK_INT >= 21) { 204 if (Build.VERSION.SDK_INT >= 21) {
204 return ThreadLocalRandom.current().nextInt(RANDOM_MIN, RANDOM_MAX + 1); 205 return ThreadLocalRandom.current().nextInt(RANDOM_MIN, RANDOM_MAX + 1);
205 } else { 206 } else {
206 - Random rand = new Random(); 207 + SecureRandom rand = new SecureRandom();
207 return rand.nextInt((RANDOM_MAX - RANDOM_MIN) + 1) + RANDOM_MIN; 208 return rand.nextInt((RANDOM_MAX - RANDOM_MIN) + 1) + RANDOM_MIN;
208 } 209 }
209 } 210 }
......
...@@ -84,11 +84,11 @@ public class VolleyTransformer implements Listener<JSONObject>, ErrorListener { ...@@ -84,11 +84,11 @@ public class VolleyTransformer implements Listener<JSONObject>, ErrorListener {
84 if (response.optJSONObject("context") != null) { 84 if (response.optJSONObject("context") != null) {
85 if (response.optJSONObject("context").optJSONObject("device_status") != null) { 85 if (response.optJSONObject("context").optJSONObject("device_status") != null) {
86 WarpUtils.setIsWarped(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("warped")); 86 WarpUtils.setIsWarped(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("warped"));
87 - WarpUtils.setDeviceToken(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optString("device_token")); 87 +// WarpUtils.setDeviceToken(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optString("device_token"));
88 - WarpUtils.setHasApplicationInfo(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("application_info_saved")); 88 +// WarpUtils.setHasApplicationInfo(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("application_info_saved"));
89 WarpUtils.setDeviceId(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optString("device_id")); 89 WarpUtils.setDeviceId(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optString("device_id"));
90 WarpUtils.setIsDeviceIdSaved(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("device_id_saved")); 90 WarpUtils.setIsDeviceIdSaved(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("device_id_saved"));
91 - WarpUtils.setIsDeviceInfoSaved(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("device_info_saved")); 91 +// WarpUtils.setIsDeviceInfoSaved(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("device_info_saved"));
92 if (response.optJSONObject("context").optJSONObject("device_status").optJSONObject("application_info") != null) { 92 if (response.optJSONObject("context").optJSONObject("device_status").optJSONObject("application_info") != null) {
93 WarpUtils.setAppDataObject(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("application_info")); 93 WarpUtils.setAppDataObject(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("application_info"));
94 WarpUtils.setSDKVersion(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("application_info").optString("sdk_version")); 94 WarpUtils.setSDKVersion(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("application_info").optString("sdk_version"));
......
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
...@@ -34,7 +34,9 @@ import android.content.Context; ...@@ -34,7 +34,9 @@ import android.content.Context;
34 import android.content.Intent; 34 import android.content.Intent;
35 import android.location.Location; 35 import android.location.Location;
36 import android.location.LocationManager; 36 import android.location.LocationManager;
37 -import android.os.Build; 37 +
38 +import java.util.HashMap;
39 +import java.util.Map;
38 40
39 public class LocationChangedReceiver extends BroadcastReceiver { 41 public class LocationChangedReceiver extends BroadcastReceiver {
40 42
...@@ -44,9 +46,6 @@ public class LocationChangedReceiver extends BroadcastReceiver { ...@@ -44,9 +46,6 @@ public class LocationChangedReceiver extends BroadcastReceiver {
44 46
45 @Override 47 @Override
46 public void onReceive(Context context, Intent intent) { 48 public void onReceive(Context context, Intent intent) {
47 -
48 - // Log.i("Location receiver", Integer.toString(counter++));
49 -
50 isAppShutDown = WarplyLocationManager.waprplyContext == null; 49 isAppShutDown = WarplyLocationManager.waprplyContext == null;
51 50
52 /** 51 /**
...@@ -64,23 +63,14 @@ public class LocationChangedReceiver extends BroadcastReceiver { ...@@ -64,23 +63,14 @@ public class LocationChangedReceiver extends BroadcastReceiver {
64 } 63 }
65 64
66 if (intent.hasExtra(LocationManager.KEY_LOCATION_CHANGED)) { 65 if (intent.hasExtra(LocationManager.KEY_LOCATION_CHANGED)) {
67 -
68 new WarplyPreferences(context).saveUpdateLocationServiceStatus("on"); 66 new WarplyPreferences(context).saveUpdateLocationServiceStatus("on");
69 67
70 Location location = (Location) intent.getExtras().get(LocationManager.KEY_LOCATION_CHANGED); 68 Location location = (Location) intent.getExtras().get(LocationManager.KEY_LOCATION_CHANGED);
71 -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
72 -// context.startForegroundService(new Intent(context, UpdateUserLocationService.class)
73 -// .putExtra("LOCATION_KEY", location));
74 -// } else {
75 -// context.startService(new Intent(context, UpdateUserLocationService.class)
76 -// .putExtra("LOCATION_KEY", location));
77 -// }
78 -
79 - UpdateUserLocationService.enqueueWork(context, new Intent(context, UpdateUserLocationService.class)
80 - .putExtra("LOCATION_KEY", location));
81 69
70 + Map<String, Object> mLocValues = new HashMap<>();
71 + mLocValues.put("latitude", location.getLatitude());
72 + mLocValues.put("longitude", location.getLongitude());
73 + UpdateUserLocationService.scheduleWork(context, mLocValues);
82 } 74 }
83 -
84 } 75 }
85 - 76 +}
86 -}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -28,8 +28,8 @@ import java.io.IOException; ...@@ -28,8 +28,8 @@ import java.io.IOException;
28 import java.io.InputStream; 28 import java.io.InputStream;
29 import java.net.HttpURLConnection; 29 import java.net.HttpURLConnection;
30 import java.net.URL; 30 import java.net.URL;
31 +import java.security.SecureRandom;
31 import java.util.List; 32 import java.util.List;
32 -import java.util.Random;
33 import java.util.concurrent.ThreadLocalRandom; 33 import java.util.concurrent.ThreadLocalRandom;
34 import java.util.concurrent.TimeUnit; 34 import java.util.concurrent.TimeUnit;
35 35
...@@ -98,6 +98,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -98,6 +98,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
98 public void onNewToken(@NonNull String s) { 98 public void onNewToken(@NonNull String s) {
99 super.onNewToken(s); 99 super.onNewToken(s);
100 GCMRegistrar.setRegistrationId(this, s); 100 GCMRegistrar.setRegistrationId(this, s);
101 + WarpUtils.setDeviceToken(this, s);
101 } 102 }
102 103
103 @Override 104 @Override
...@@ -146,7 +147,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -146,7 +147,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
146 if (Build.VERSION.SDK_INT >= 21) { 147 if (Build.VERSION.SDK_INT >= 21) {
147 return ThreadLocalRandom.current().nextInt(RANDOM_MIN, RANDOM_MAX + 1); 148 return ThreadLocalRandom.current().nextInt(RANDOM_MIN, RANDOM_MAX + 1);
148 } else { 149 } else {
149 - Random rand = new Random(); 150 + SecureRandom rand = new SecureRandom();
150 return rand.nextInt((RANDOM_MAX - RANDOM_MIN) + 1) + RANDOM_MIN; 151 return rand.nextInt((RANDOM_MAX - RANDOM_MIN) + 1) + RANDOM_MIN;
151 } 152 }
152 } 153 }
...@@ -164,7 +165,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -164,7 +165,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
164 165
165 WarpUtils.log("Showing campaign with session UUID: " + pc.getSessionUUID()); 166 WarpUtils.log("Showing campaign with session UUID: " + pc.getSessionUUID());
166 167
167 - Random randomGenerator = new Random(); 168 + SecureRandom randomGenerator = new SecureRandom();
168 169
169 int uid = randomGenerator.nextInt(1000); 170 int uid = randomGenerator.nextInt(1000);
170 if (!TextUtils.isEmpty(pc.getSessionUUID())) { 171 if (!TextUtils.isEmpty(pc.getSessionUUID())) {
...@@ -297,7 +298,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -297,7 +298,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
297 public void showNotification(Context context, String title, String ticker, 298 public void showNotification(Context context, String title, String ticker,
298 String message, Intent newIntent, String tag, int id) { 299 String message, Intent newIntent, String tag, int id) {
299 300
300 - Random randomGenerator = new Random(); 301 + SecureRandom randomGenerator = new SecureRandom();
301 int uid = randomGenerator.nextInt(1000); 302 int uid = randomGenerator.nextInt(1000);
302 WarpUtils.log("Showing notification with tag: " + tag + " and id: " 303 WarpUtils.log("Showing notification with tag: " + tag + " and id: "
303 + id); 304 + id);
...@@ -343,7 +344,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -343,7 +344,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
343 344
344 public void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) { 345 public void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) {
345 346
346 - Random randomGenerator = new Random(); 347 + SecureRandom randomGenerator = new SecureRandom();
347 int uid = randomGenerator.nextInt(1000); 348 int uid = randomGenerator.nextInt(1000);
348 if (id > 0) { 349 if (id > 0) {
349 uid = id; 350 uid = id;
......
...@@ -39,7 +39,7 @@ import android.os.SystemClock; ...@@ -39,7 +39,7 @@ import android.os.SystemClock;
39 import androidx.core.app.NotificationCompat; 39 import androidx.core.app.NotificationCompat;
40 import android.util.Log; 40 import android.util.Log;
41 41
42 -import java.util.Random; 42 +import java.security.SecureRandom;
43 import java.util.concurrent.TimeUnit; 43 import java.util.concurrent.TimeUnit;
44 44
45 import ly.warp.sdk.utils.GCMRegistrar; 45 import ly.warp.sdk.utils.GCMRegistrar;
...@@ -74,7 +74,7 @@ public abstract class GCMBaseIntentService extends IntentService { ...@@ -74,7 +74,7 @@ public abstract class GCMBaseIntentService extends IntentService {
74 // instance counter 74 // instance counter
75 private static int sCounter = 0; 75 private static int sCounter = 0;
76 76
77 - private static final Random sRandom = new Random(); 77 + private static final SecureRandom sRandom = new SecureRandom();
78 78
79 private static final int MAX_BACKOFF_MS = (int) TimeUnit.SECONDS 79 private static final int MAX_BACKOFF_MS = (int) TimeUnit.SECONDS
80 .toMillis(3600); // 1 hour 80 .toMillis(3600); // 1 hour
......
...@@ -14,7 +14,6 @@ import android.media.RingtoneManager; ...@@ -14,7 +14,6 @@ import android.media.RingtoneManager;
14 import android.os.Build; 14 import android.os.Build;
15 import android.os.Bundle; 15 import android.os.Bundle;
16 import android.text.TextUtils; 16 import android.text.TextUtils;
17 -import android.util.Log;
18 import android.widget.RemoteViews; 17 import android.widget.RemoteViews;
19 18
20 import androidx.core.app.NotificationCompat; 19 import androidx.core.app.NotificationCompat;
...@@ -33,9 +32,9 @@ import org.json.JSONObject; ...@@ -33,9 +32,9 @@ import org.json.JSONObject;
33 import java.io.InputStream; 32 import java.io.InputStream;
34 import java.net.HttpURLConnection; 33 import java.net.HttpURLConnection;
35 import java.net.URL; 34 import java.net.URL;
35 +import java.security.SecureRandom;
36 import java.util.Iterator; 36 import java.util.Iterator;
37 import java.util.List; 37 import java.util.List;
38 -import java.util.Random;
39 import java.util.concurrent.ThreadLocalRandom; 38 import java.util.concurrent.ThreadLocalRandom;
40 import java.util.concurrent.TimeUnit; 39 import java.util.concurrent.TimeUnit;
41 40
...@@ -91,18 +90,15 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -91,18 +90,15 @@ public class HMSBaseMessagingService extends HmsMessageService {
91 // =========================================================== 90 // ===========================================================
92 // URLThread class 91 // URLThread class
93 // =========================================================== 92 // ===========================================================
94 - public static class URLThread extends Thread 93 + public static class URLThread extends Thread {
95 - {
96 private String urlString = ""; 94 private String urlString = "";
97 95
98 - public URLThread(String url) 96 + public URLThread(String url) {
99 - {
100 this.urlString = url; 97 this.urlString = url;
101 } 98 }
102 99
103 @Override 100 @Override
104 - public void run() 101 + public void run() {
105 - {
106 try { 102 try {
107 URL url; 103 URL url;
108 HttpURLConnection urlConnection = null; 104 HttpURLConnection urlConnection = null;
...@@ -138,7 +134,7 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -138,7 +134,7 @@ public class HMSBaseMessagingService extends HmsMessageService {
138 public void onNewToken(String s, Bundle bundle) { 134 public void onNewToken(String s, Bundle bundle) {
139 super.onNewToken(s, bundle); 135 super.onNewToken(s, bundle);
140 GCMRegistrar.setRegistrationId(this, s); 136 GCMRegistrar.setRegistrationId(this, s);
141 - Log.v("HUAWEI TOKEN", "receive token:" + s); 137 + WarpUtils.setDeviceToken(this, s);
142 } 138 }
143 139
144 @Override 140 @Override
...@@ -146,7 +142,6 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -146,7 +142,6 @@ public class HMSBaseMessagingService extends HmsMessageService {
146 super.onMessageReceived(remoteMessage); 142 super.onMessageReceived(remoteMessage);
147 143
148 JSONObject data = new JSONObject(remoteMessage.getDataOfMap()); 144 JSONObject data = new JSONObject(remoteMessage.getDataOfMap());
149 - Log.v("DATA", "data is " + data);
150 if (data == null || !data.has("loyalty-action")) { 145 if (data == null || !data.has("loyalty-action")) {
151 return; 146 return;
152 } 147 }
...@@ -197,7 +192,7 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -197,7 +192,7 @@ public class HMSBaseMessagingService extends HmsMessageService {
197 if (Build.VERSION.SDK_INT >= 21) { 192 if (Build.VERSION.SDK_INT >= 21) {
198 return ThreadLocalRandom.current().nextInt(RANDOM_MIN, RANDOM_MAX + 1); 193 return ThreadLocalRandom.current().nextInt(RANDOM_MIN, RANDOM_MAX + 1);
199 } else { 194 } else {
200 - Random rand = new Random(); 195 + SecureRandom rand = new SecureRandom();
201 return rand.nextInt((RANDOM_MAX - RANDOM_MIN) + 1) + RANDOM_MIN; 196 return rand.nextInt((RANDOM_MAX - RANDOM_MIN) + 1) + RANDOM_MIN;
202 } 197 }
203 } 198 }
...@@ -215,7 +210,7 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -215,7 +210,7 @@ public class HMSBaseMessagingService extends HmsMessageService {
215 210
216 WarpUtils.log("Showing campaign with session UUID: " + pc.getSessionUUID()); 211 WarpUtils.log("Showing campaign with session UUID: " + pc.getSessionUUID());
217 212
218 - Random randomGenerator = new Random(); 213 + SecureRandom randomGenerator = new SecureRandom();
219 214
220 int uid = randomGenerator.nextInt(1000); 215 int uid = randomGenerator.nextInt(1000);
221 if (!TextUtils.isEmpty(pc.getSessionUUID())) { 216 if (!TextUtils.isEmpty(pc.getSessionUUID())) {
...@@ -346,7 +341,7 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -346,7 +341,7 @@ public class HMSBaseMessagingService extends HmsMessageService {
346 public void showNotification(Context context, String title, String ticker, 341 public void showNotification(Context context, String title, String ticker,
347 String message, Intent newIntent, String tag, int id) { 342 String message, Intent newIntent, String tag, int id) {
348 343
349 - Random randomGenerator = new Random(); 344 + SecureRandom randomGenerator = new SecureRandom();
350 int uid = randomGenerator.nextInt(1000); 345 int uid = randomGenerator.nextInt(1000);
351 WarpUtils.log("Showing notification with tag: " + tag + " and id: " 346 WarpUtils.log("Showing notification with tag: " + tag + " and id: "
352 + id); 347 + id);
...@@ -392,7 +387,7 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -392,7 +387,7 @@ public class HMSBaseMessagingService extends HmsMessageService {
392 387
393 public void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) { 388 public void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) {
394 389
395 - Random randomGenerator = new Random(); 390 + SecureRandom randomGenerator = new SecureRandom();
396 int uid = randomGenerator.nextInt(1000); 391 int uid = randomGenerator.nextInt(1000);
397 if (id > 0) { 392 if (id > 0) {
398 uid = id; 393 uid = id;
...@@ -544,7 +539,7 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -544,7 +539,7 @@ public class HMSBaseMessagingService extends HmsMessageService {
544 539
545 private static Bitmap loadDrawable(final String urlString) { 540 private static Bitmap loadDrawable(final String urlString) {
546 if (urlString == null || TextUtils.isEmpty(urlString)) 541 if (urlString == null || TextUtils.isEmpty(urlString))
547 - return null; 542 + return null;
548 543
549 // alternative solution to thread but only in debug mode 544 // alternative solution to thread but only in debug mode
550 // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); 545 // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
...@@ -569,10 +564,10 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -569,10 +564,10 @@ public class HMSBaseMessagingService extends HmsMessageService {
569 public static Bundle jsonToBundle(JSONObject jsonObject) throws JSONException { 564 public static Bundle jsonToBundle(JSONObject jsonObject) throws JSONException {
570 Bundle bundle = new Bundle(); 565 Bundle bundle = new Bundle();
571 Iterator iter = jsonObject.keys(); 566 Iterator iter = jsonObject.keys();
572 - while(iter.hasNext()){ 567 + while (iter.hasNext()) {
573 - String key = (String)iter.next(); 568 + String key = (String) iter.next();
574 String value = jsonObject.getString(key); 569 String value = jsonObject.getString(key);
575 - bundle.putString(key,value); 570 + bundle.putString(key, value);
576 } 571 }
577 return bundle; 572 return bundle;
578 } 573 }
......
...@@ -25,18 +25,23 @@ ...@@ -25,18 +25,23 @@
25 25
26 package ly.warp.sdk.services; 26 package ly.warp.sdk.services;
27 27
28 -import android.app.Service;
29 import android.content.Context; 28 import android.content.Context;
30 -import android.content.Intent;
31 import android.location.Location; 29 import android.location.Location;
32 -import android.os.Handler;
33 -import android.os.Handler.Callback;
34 -import android.os.IBinder;
35 -import android.os.Message;
36 import android.util.Log; 30 import android.util.Log;
37 31
38 import androidx.annotation.NonNull; 32 import androidx.annotation.NonNull;
39 -import androidx.core.app.JobIntentService; 33 +import androidx.work.Data;
34 +import androidx.work.ExistingPeriodicWorkPolicy;
35 +import androidx.work.PeriodicWorkRequest;
36 +import androidx.work.WorkManager;
37 +import androidx.work.Worker;
38 +import androidx.work.WorkerParameters;
39 +
40 +import com.google.android.gms.location.FusedLocationProviderClient;
41 +import com.google.android.gms.location.LocationRequest;
42 +import com.google.android.gms.location.LocationServices;
43 +import com.google.android.gms.tasks.CancellationToken;
44 +import com.google.android.gms.tasks.OnTokenCanceledListener;
40 45
41 import org.json.JSONArray; 46 import org.json.JSONArray;
42 import org.json.JSONException; 47 import org.json.JSONException;
...@@ -44,120 +49,77 @@ import org.json.JSONObject; ...@@ -44,120 +49,77 @@ import org.json.JSONObject;
44 49
45 import java.util.ArrayList; 50 import java.util.ArrayList;
46 import java.util.List; 51 import java.util.List;
47 -import java.util.Timer; 52 +import java.util.Map;
48 -import java.util.TimerTask; 53 +import java.util.concurrent.TimeUnit;
49 54
50 import ly.warp.sdk.BuildConfig; 55 import ly.warp.sdk.BuildConfig;
51 import ly.warp.sdk.Warply; 56 import ly.warp.sdk.Warply;
57 +import ly.warp.sdk.dexter.listener.DexterError;
58 +import ly.warp.sdk.dexter.listener.PermissionDeniedResponse;
52 import ly.warp.sdk.io.callbacks.CallbackReceiver; 59 import ly.warp.sdk.io.callbacks.CallbackReceiver;
53 import ly.warp.sdk.io.models.WarpGeoFence; 60 import ly.warp.sdk.io.models.WarpGeoFence;
54 import ly.warp.sdk.receivers.LocationChangedReceiver; 61 import ly.warp.sdk.receivers.LocationChangedReceiver;
62 +import ly.warp.sdk.utils.PermissionsUtil;
55 import ly.warp.sdk.utils.WarpJSONParser; 63 import ly.warp.sdk.utils.WarpJSONParser;
56 import ly.warp.sdk.utils.WarpUtils; 64 import ly.warp.sdk.utils.WarpUtils;
57 import ly.warp.sdk.utils.WarplyPreferences; 65 import ly.warp.sdk.utils.WarplyPreferences;
58 import ly.warp.sdk.utils.constants.WarpConstants; 66 import ly.warp.sdk.utils.constants.WarpConstants;
59 import ly.warp.sdk.utils.managers.WarplyLocationManager; 67 import ly.warp.sdk.utils.managers.WarplyLocationManager;
60 68
61 -import static ly.warp.sdk.utils.constants.WarpConstants.JOB_SERVICE_ID; 69 +public class UpdateUserLocationService extends Worker {
62 70
63 -public class UpdateUserLocationService extends /*Service*/ JobIntentService { 71 + public static final String TAG = "LOCATION_KEY";
64 72
65 - Timer timer; 73 + private int lastForProvider;
66 - 74 + private float lastForTime;
67 - int lastForProvider; 75 + private double lastForDistance;
68 - float lastForTime; 76 + private int lastBacProvider;
69 - double lastForDistance; 77 + private float lastBacTime;
70 - int lastBacProvider; 78 + private double lastBacDistance;
71 - float lastBacTime; 79 + private boolean geofencingEnabled = false;
72 - double lastBacDistance;
73 - boolean geofencingEnabled = false;
74 80
75 //Geofences 81 //Geofences
76 private List<WarpGeoFence> geofences = null; 82 private List<WarpGeoFence> geofences = null;
77 83
78 - int defaultCheckInterval = 30; 84 + private static int defaultCheckInterval = 15;
85 + private final static int defaultInterval = 15;
79 86
80 - @Override 87 + public UpdateUserLocationService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
81 - public void onCreate() { 88 + super(context, workerParams);
82 - timer = new Timer();
83 - timer.schedule(new firstTask(), 0, defaultCheckInterval * 1000);
84 - super.onCreate();
85 } 89 }
86 90
87 -// @Override 91 + @NonNull
88 -// public int onStartCommand(Intent intent, int flags, int startId) {
89 -//
90 -// if (intent != null) {
91 -// Location location = intent.getParcelableExtra("LOCATION_KEY");
92 -// if (location != null) {
93 -// //fences
94 -// if(isGeofencingEnabled()) {
95 -// if (isInsideFence(location.getLatitude(), location.getLongitude())) {
96 -// sendLocationData(location.getLatitude(), location.getLongitude());
97 -// }
98 -// }
99 -// else{
100 -// sendLocationData(location.getLatitude(), location.getLongitude());
101 -// }
102 -// }
103 -// }
104 -// // If we get killed, after returning from here, do not restart if there
105 -// // is no other intent pending
106 -// return START_NOT_STICKY;
107 -// }
108 -
109 @Override 92 @Override
110 - protected void onHandleWork(@NonNull Intent intent) { 93 + public Result doWork() {
111 - Location location = intent.getParcelableExtra("LOCATION_KEY"); 94 + if (Warply.getWarplyContext() != null) {
112 - if (location != null) { 95 + if (new WarplyPreferences(Warply.getWarplyContext()).getAppStatus().equals("foreground")
113 - //fences 96 + /*&& new WarplyPreferences(Warply.getWarplyContext()).getUpdateLocationServiceStatus().equals("on")*/) {
114 - if (isGeofencingEnabled()) { 97 + try {
115 - if (isInsideFence(location.getLatitude(), location.getLongitude())) { 98 + new PermissionsUtil(
116 - sendLocationData(location.getLatitude(), location.getLongitude()); 99 + Warply.getWarplyContext(),
100 + mPermissionsCallback,
101 + PermissionsUtil.PERMISSION_LOCATION_COARSE,
102 + PermissionsUtil.PERMISSION_LOCATION_FINE
103 + ).requestPermissions();
104 + } catch (SecurityException e) {
105 + if (BuildConfig.DEBUG) {
106 + e.printStackTrace();
107 + WorkManager.getInstance(Warply.getWarplyContext()).cancelAllWorkByTag(TAG);
108 + }
117 } 109 }
118 } else { 110 } else {
119 - sendLocationData(location.getLatitude(), location.getLongitude()); 111 + WorkManager.getInstance(Warply.getWarplyContext()).cancelAllWorkByTag(TAG);
120 } 112 }
113 + } else {
114 + WorkManager.getInstance(getApplicationContext()).cancelAllWorkByTag(TAG);
121 } 115 }
122 - }
123 116
124 -// @Override 117 + regulateLocationReporting();
125 -// public IBinder onBind(Intent arg0) {
126 -// // We don't provide binding, so return null
127 -// return null;
128 -// }
129 118
130 - // tells handler to send a message 119 + return Result.success();
131 - class firstTask extends TimerTask {
132 -
133 - @Override
134 - public void run() {
135 - handler.sendEmptyMessage(0);
136 - }
137 } 120 }
138 121
139 - final Handler handler = new Handler(new Callback() {
140 -
141 - @Override
142 - public boolean handleMessage(Message msg) {
143 - if (Warply.getWarplyContext() != null) {
144 - if ((new WarplyPreferences(Warply.getWarplyContext()).getUpdateLocationServiceStatus()).equals("off")) {
145 - timer.cancel();
146 - stopSelf();
147 - } else {
148 - if (isGeofencingEnabled() && (getGeofences() == null || getGeofences().isEmpty()))
149 - retrieveGeofences();
150 - }
151 - }
152 - Log.i("regulation", "regulation started");
153 - regulateLocationReporting();
154 -
155 - return false;
156 - }
157 - });
158 -
159 private void sendLocationData(double lat, double lon) { 122 private void sendLocationData(double lat, double lon) {
160 -
161 JSONObject jObj = new JSONObject(); 123 JSONObject jObj = new JSONObject();
162 try { 124 try {
163 jObj.putOpt("action", WarpConstants.MICROAPP_GEOFENCING_ACTION); 125 jObj.putOpt("action", WarpConstants.MICROAPP_GEOFENCING_ACTION);
...@@ -169,31 +131,41 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -169,31 +131,41 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
169 } 131 }
170 132
171 if (LocationChangedReceiver.wClient != null) { 133 if (LocationChangedReceiver.wClient != null) {
172 -
173 Warply.postReceiveMicroappData(WarpConstants.MICROAPP_GEOFENCING, jObj, new CallbackReceiver<JSONObject>() { 134 Warply.postReceiveMicroappData(WarpConstants.MICROAPP_GEOFENCING, jObj, new CallbackReceiver<JSONObject>() {
174 @Override 135 @Override
175 public void onSuccess(JSONObject result) { 136 public void onSuccess(JSONObject result) {
137 + WarpUtils.log("success sending location " + result.toString());
176 } 138 }
177 139
178 @Override 140 @Override
179 public void onFailure(int errorCode) { 141 public void onFailure(int errorCode) {
180 WarpUtils.log("failed during sending location data with error " + errorCode); 142 WarpUtils.log("failed during sending location data with error " + errorCode);
181 -
182 } 143 }
183 }); 144 });
184 -
185 } else { 145 } else {
186 -
187 WarpUtils.log("Could not send user location data. You must registrer to warply first"); 146 WarpUtils.log("Could not send user location data. You must registrer to warply first");
188 } 147 }
148 + }
149 +
150 + private void sendLocation(Location location) {
151 + if (isGeofencingEnabled()) {
152 + if (isInsideFence(location.getLatitude(), location.getLongitude())) {
153 + sendLocationData(location.getLatitude(), location.getLongitude());
154 + }
155 + } else {
156 + sendLocationData(location.getLatitude(), location.getLongitude());
157 + }
189 158
159 + if (isGeofencingEnabled() && (getGeofences() == null || getGeofences().isEmpty()))
160 + retrieveGeofences();
190 } 161 }
191 162
192 - // ------------------- Geofencing ------------------- 163 +// ------------------- Geofencing -------------------
193 164
194 private void retrieveGeofences() { 165 private void retrieveGeofences() {
195 if (!isGeofencingEnabled()) 166 if (!isGeofencingEnabled())
196 return; 167 return;
168 +
197 JSONObject jObj = new JSONObject(); 169 JSONObject jObj = new JSONObject();
198 try { 170 try {
199 jObj.putOpt("action", WarpConstants.MICROAPP_GEOFENCING_ACTION_GET_POIS); 171 jObj.putOpt("action", WarpConstants.MICROAPP_GEOFENCING_ACTION_GET_POIS);
...@@ -201,6 +173,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -201,6 +173,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
201 WarpUtils.log("JSON Exception thrown while creating the object in retrieveGeofences at WarplyLocationManager", e); 173 WarpUtils.log("JSON Exception thrown while creating the object in retrieveGeofences at WarplyLocationManager", e);
202 return; 174 return;
203 } 175 }
176 +
204 if (LocationChangedReceiver.wClient != null) { 177 if (LocationChangedReceiver.wClient != null) {
205 Warply.postReceiveMicroappData(WarpConstants.MICROAPP_GEOFENCING, jObj, new CallbackReceiver<JSONObject>() { 178 Warply.postReceiveMicroappData(WarpConstants.MICROAPP_GEOFENCING, jObj, new CallbackReceiver<JSONObject>() {
206 @Override 179 @Override
...@@ -244,18 +217,14 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -244,18 +217,14 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
244 } 217 }
245 218
246 219
247 - // ------------------- Location Modes ------------------- 220 +// ------------------- Location Modes -------------------
248 221
249 private void regulateLocationReporting() { 222 private void regulateLocationReporting() {
250 -
251 Warply.getContext(new CallbackReceiver<JSONObject>() { 223 Warply.getContext(new CallbackReceiver<JSONObject>() {
252 -
253 @Override 224 @Override
254 public void onSuccess(JSONObject result) { 225 public void onSuccess(JSONObject result) {
255 -
256 JSONObject json = result.optJSONObject("context"); 226 JSONObject json = result.optJSONObject("context");
257 if (json != null) { 227 if (json != null) {
258 -
259 JSONObject appDataJson = json.optJSONObject("application_data"); 228 JSONObject appDataJson = json.optJSONObject("application_data");
260 if (appDataJson != null) { 229 if (appDataJson != null) {
261 // location settings 230 // location settings
...@@ -277,16 +246,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -277,16 +246,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
277 Log.i("notification interval", Integer.toString(interval)); 246 Log.i("notification interval", Integer.toString(interval));
278 247
279 if (interval != defaultCheckInterval) { 248 if (interval != defaultCheckInterval) {
280 -
281 defaultCheckInterval = interval; 249 defaultCheckInterval = interval;
282 -
283 - timer.cancel();
284 - timer = new Timer();
285 - timer.schedule(new firstTask(), 0,
286 - defaultCheckInterval * 1000); // 86400 sec
287 - // reschedule every
288 - // day
289 -
290 } 250 }
291 251
292 Context context = Warply.getWarplyContext(); 252 Context context = Warply.getWarplyContext();
...@@ -299,7 +259,6 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -299,7 +259,6 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
299 WarplyLocationManager.disableConnectivityChangedReceiver(context); 259 WarplyLocationManager.disableConnectivityChangedReceiver(context);
300 260
301 } else if (foregroundProvider == WarpConstants.LocationModes.OFF.ordinal()) { 261 } else if (foregroundProvider == WarpConstants.LocationModes.OFF.ordinal()) {
302 -
303 /* 262 /*
304 * in case foreground provider is off and app is in 263 * in case foreground provider is off and app is in
305 * foreground mode then app should stop reporting the 264 * foreground mode then app should stop reporting the
...@@ -307,7 +266,6 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -307,7 +266,6 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
307 */ 266 */
308 if (!LocationChangedReceiver.isAppShutDown && appStatus.equals("foreground")) { 267 if (!LocationChangedReceiver.isAppShutDown && appStatus.equals("foreground")) {
309 WarplyLocationManager.stopReportingLocation(context); 268 WarplyLocationManager.stopReportingLocation(context);
310 -
311 /* 269 /*
312 * in case background provider is on and app is in 270 * in case background provider is on and app is in
313 * background mode or shut down then app should check for 271 * background mode or shut down then app should check for
...@@ -333,7 +291,6 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -333,7 +291,6 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
333 291
334 292
335 } else if (backgroundProvider == WarpConstants.LocationModes.OFF.ordinal()) { 293 } else if (backgroundProvider == WarpConstants.LocationModes.OFF.ordinal()) {
336 -
337 /* 294 /*
338 * in case background provider is off and app is in 295 * in case background provider is off and app is in
339 * background mode then app should stop reporting the 296 * background mode then app should stop reporting the
...@@ -341,7 +298,6 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -341,7 +298,6 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
341 */ 298 */
342 if (LocationChangedReceiver.isAppShutDown || appStatus.equals("background")) { 299 if (LocationChangedReceiver.isAppShutDown || appStatus.equals("background")) {
343 WarplyLocationManager.stopReportingLocation(context); 300 WarplyLocationManager.stopReportingLocation(context);
344 -
345 /* 301 /*
346 * in case foreground provider is on and app is in 302 * in case foreground provider is on and app is in
347 * foreground mode then app should check for settings 303 * foreground mode then app should check for settings
...@@ -365,9 +321,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -365,9 +321,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
365 321
366 } 322 }
367 } else { // cases foreground and background providers are on 323 } else { // cases foreground and background providers are on
368 -
369 if (!LocationChangedReceiver.isAppShutDown && appStatus.equals("foreground")) { 324 if (!LocationChangedReceiver.isAppShutDown && appStatus.equals("foreground")) {
370 -
371 if (!((lastForProvider == foregroundProvider) 325 if (!((lastForProvider == foregroundProvider)
372 && (lastForTime == foregroundMinTime) 326 && (lastForTime == foregroundMinTime)
373 && (lastForDistance == foregroundMinDistance))) { 327 && (lastForDistance == foregroundMinDistance))) {
...@@ -383,10 +337,8 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -383,10 +337,8 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
383 lastForDistance = foregroundMinDistance; 337 lastForDistance = foregroundMinDistance;
384 338
385 } 339 }
386 -
387 } else if (!((lastBacProvider == backgroundProvider) 340 } else if (!((lastBacProvider == backgroundProvider)
388 && (lastBacTime == backgroundMinTime) && (lastBacDistance == backgroundMinDistance))) { 341 && (lastBacTime == backgroundMinTime) && (lastBacDistance == backgroundMinDistance))) {
389 -
390 if (WarplyLocationManager.getLocationManager() == null) 342 if (WarplyLocationManager.getLocationManager() == null)
391 WarplyLocationManager.instantiateLocationManager(); 343 WarplyLocationManager.instantiateLocationManager();
392 344
...@@ -401,18 +353,15 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -401,18 +353,15 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
401 lastBacDistance = backgroundMinDistance; 353 lastBacDistance = backgroundMinDistance;
402 354
403 } 355 }
404 -
405 } // end else foregroundProvider = on and backgroundProvider = 356 } // end else foregroundProvider = on and backgroundProvider =
406 // on 357 // on
407 } 358 }
408 -
409 } 359 }
410 } 360 }
411 361
412 @Override 362 @Override
413 public void onFailure(int errorCode) { 363 public void onFailure(int errorCode) {
414 WarpUtils.log("Error with code " + errorCode + " while checking location modes"); 364 WarpUtils.log("Error with code " + errorCode + " while checking location modes");
415 -
416 } 365 }
417 }); 366 });
418 } 367 }
...@@ -425,7 +374,63 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -425,7 +374,63 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
425 return geofencingEnabled; 374 return geofencingEnabled;
426 } 375 }
427 376
428 - public static void enqueueWork(Context context, Intent work) { 377 + private static PeriodicWorkRequest buildWorkRequest(Map<String, Object> location) {
429 - enqueueWork(context, UpdateUserLocationService.class, JOB_SERVICE_ID, work); 378 + Data inputData = new Data.Builder().putAll(location).build();
379 + return new PeriodicWorkRequest.Builder(UpdateUserLocationService.class, defaultInterval, TimeUnit.MINUTES)
380 + .addTag(TAG)
381 + .setInputData(inputData)
382 + .build();
430 } 383 }
384 +
385 + public static void scheduleWork(Context context, Map<String, Object> location) {
386 + WorkManager.getInstance(context).enqueueUniquePeriodicWork(
387 + TAG,
388 + ExistingPeriodicWorkPolicy.KEEP,
389 + buildWorkRequest(location));
390 + }
391 +
392 + private final PermissionsUtil.PermissionCallback mPermissionsCallback = new PermissionsUtil.PermissionCallback() {
393 + @Override
394 + public void onError(DexterError error) {
395 + onPermissionDenied(null);
396 + }
397 +
398 + @Override
399 + public void onPermissionDenied(List<PermissionDeniedResponse> denied) {
400 + if (denied != null && denied.size() < 2)//1 location permission accepted
401 + onPermissionsGranted();
402 + }
403 +
404 + @Override
405 + public void onPermissionsGranted() {
406 + try {
407 + FusedLocationProviderClient locationClient = LocationServices.getFusedLocationProviderClient(Warply.getWarplyContext());
408 +
409 + locationClient.getCurrentLocation(LocationRequest.PRIORITY_HIGH_ACCURACY, new CancellationToken() {
410 + @NonNull
411 + @Override
412 + public CancellationToken onCanceledRequested(@NonNull OnTokenCanceledListener onTokenCanceledListener) {
413 + return null;
414 + }
415 +
416 + @Override
417 + public boolean isCancellationRequested() {
418 + return false;
419 + }
420 + })
421 + .addOnSuccessListener(location1 -> {
422 + if (location1 != null) {
423 + sendLocation(location1);
424 + }
425 + })
426 + .addOnFailureListener(e -> {
427 + WarpUtils.log("Could not get location data.");
428 + });
429 + } catch (SecurityException e) {
430 + if (BuildConfig.DEBUG) {
431 + e.printStackTrace();
432 + }
433 + }
434 + }
435 + };
431 } 436 }
......
...@@ -52,8 +52,8 @@ import org.json.JSONObject; ...@@ -52,8 +52,8 @@ import org.json.JSONObject;
52 52
53 import java.io.IOException; 53 import java.io.IOException;
54 import java.io.InputStream; 54 import java.io.InputStream;
55 +import java.security.SecureRandom;
55 import java.util.List; 56 import java.util.List;
56 -import java.util.Random;
57 57
58 import ly.warp.sdk.Warply; 58 import ly.warp.sdk.Warply;
59 import ly.warp.sdk.activities.WarpViewActivity; 59 import ly.warp.sdk.activities.WarpViewActivity;
...@@ -145,7 +145,7 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService { ...@@ -145,7 +145,7 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService {
145 145
146 WarpUtils.log("Showing campaign with session UUID: " + pc.getSessionUUID()); 146 WarpUtils.log("Showing campaign with session UUID: " + pc.getSessionUUID());
147 147
148 - Random randomGenerator = new Random(); 148 + SecureRandom randomGenerator = new SecureRandom();
149 149
150 int uid = randomGenerator.nextInt(1000); 150 int uid = randomGenerator.nextInt(1000);
151 if (!TextUtils.isEmpty(pc.getSessionUUID())) { 151 if (!TextUtils.isEmpty(pc.getSessionUUID())) {
...@@ -277,7 +277,7 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService { ...@@ -277,7 +277,7 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService {
277 public void showNotification(Context context, String title, String ticker, 277 public void showNotification(Context context, String title, String ticker,
278 String message, Intent newIntent, String tag, int id) { 278 String message, Intent newIntent, String tag, int id) {
279 279
280 - Random randomGenerator = new Random(); 280 + SecureRandom randomGenerator = new SecureRandom();
281 int uid = randomGenerator.nextInt(1000); 281 int uid = randomGenerator.nextInt(1000);
282 WarpUtils.log("Showing notification with tag: " + tag + " and id: " 282 WarpUtils.log("Showing notification with tag: " + tag + " and id: "
283 + id); 283 + id);
...@@ -323,7 +323,7 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService { ...@@ -323,7 +323,7 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService {
323 323
324 public void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) { 324 public void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) {
325 325
326 - Random randomGenerator = new Random(); 326 + SecureRandom randomGenerator = new SecureRandom();
327 int uid = randomGenerator.nextInt(1000); 327 int uid = randomGenerator.nextInt(1000);
328 if (id > 0) { 328 if (id > 0) {
329 uid = id; 329 uid = id;
......
...@@ -32,6 +32,7 @@ import android.app.PendingIntent; ...@@ -32,6 +32,7 @@ import android.app.PendingIntent;
32 import android.content.Context; 32 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.Bundle; 36 import android.os.Bundle;
36 import androidx.annotation.NonNull; 37 import androidx.annotation.NonNull;
37 import androidx.core.app.NotificationCompat; 38 import androidx.core.app.NotificationCompat;
...@@ -91,7 +92,12 @@ public class WarpInAppNotificationService extends WarpBaseIntentService { ...@@ -91,7 +92,12 @@ public class WarpInAppNotificationService extends WarpBaseIntentService {
91 .putExtra(KEY_SUBTITLE, mNotificationSubtitle); 92 .putExtra(KEY_SUBTITLE, mNotificationSubtitle);
92 93
93 94
94 - PendingIntent pendingIntent = PendingIntent.getBroadcast(this, uid, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); 95 + PendingIntent pendingIntent;
96 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
97 + pendingIntent = PendingIntent.getBroadcast(this, uid, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
98 + } else {
99 + pendingIntent = PendingIntent.getBroadcast(this, uid, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
100 + }
95 builder.setContentIntent(pendingIntent); 101 builder.setContentIntent(pendingIntent);
96 // builder.setFullScreenIntent(pendingIntent, true); // Heads up notification, always visible OR setPriority to HIGH and setContentIntent 102 // builder.setFullScreenIntent(pendingIntent, true); // Heads up notification, always visible OR setPriority to HIGH and setContentIntent
97 NotificationManager nm = (NotificationManager) this.getSystemService(NOTIFICATION_SERVICE); 103 NotificationManager nm = (NotificationManager) this.getSystemService(NOTIFICATION_SERVICE);
...@@ -106,14 +112,24 @@ public class WarpInAppNotificationService extends WarpBaseIntentService { ...@@ -106,14 +112,24 @@ public class WarpInAppNotificationService extends WarpBaseIntentService {
106 .putExtra(KEY_TITLE, title) 112 .putExtra(KEY_TITLE, title)
107 .putExtra(KEY_SUBTITLE, subtitle) 113 .putExtra(KEY_SUBTITLE, subtitle)
108 .putExtra(KEY_HEADS_UP, isHeadsUpNotification); 114 .putExtra(KEY_HEADS_UP, isHeadsUpNotification);
109 - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, uid, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); 115 + PendingIntent pendingIntent;
116 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
117 + pendingIntent = PendingIntent.getBroadcast(context, uid, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
118 + } else {
119 + pendingIntent = PendingIntent.getBroadcast(context, uid, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
120 + }
110 AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 121 AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
111 alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), interval, pendingIntent); 122 alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), interval, pendingIntent);
112 } 123 }
113 124
114 public static void cancelInAppNotificationAlarm(Context context, @NonNull int uid) { 125 public static void cancelInAppNotificationAlarm(Context context, @NonNull int uid) {
115 Intent notifyIntent = new Intent(context, WarplyInAppNotificationReceiver.class).putExtra(KEY_UID, uid); 126 Intent notifyIntent = new Intent(context, WarplyInAppNotificationReceiver.class).putExtra(KEY_UID, uid);
116 - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, uid, notifyIntent, PendingIntent.FLAG_CANCEL_CURRENT); 127 + PendingIntent pendingIntent;
128 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
129 + pendingIntent = PendingIntent.getBroadcast(context, uid, notifyIntent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE);
130 + } else {
131 + pendingIntent = PendingIntent.getBroadcast(context, uid, notifyIntent, PendingIntent.FLAG_CANCEL_CURRENT);
132 + }
117 AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 133 AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
118 alarmManager.cancel(pendingIntent); 134 alarmManager.cancel(pendingIntent);
119 pendingIntent.cancel(); 135 pendingIntent.cancel();
......
...@@ -2,10 +2,18 @@ package ly.warp.sdk.utils; ...@@ -2,10 +2,18 @@ package ly.warp.sdk.utils;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.content.Context; 4 import android.content.Context;
5 +import android.content.pm.PackageManager;
5 import android.os.Handler; 6 import android.os.Handler;
6 import android.os.Looper; 7 import android.os.Looper;
7 8
9 +import androidx.annotation.NonNull;
10 +import androidx.core.app.ActivityCompat;
11 +import androidx.core.content.ContextCompat;
12 +
13 +import java.util.ArrayList;
14 +import java.util.HashMap;
8 import java.util.List; 15 import java.util.List;
16 +import java.util.Map;
9 import java.util.concurrent.atomic.AtomicBoolean; 17 import java.util.concurrent.atomic.AtomicBoolean;
10 18
11 import ly.warp.sdk.dexter.listener.DexterError; 19 import ly.warp.sdk.dexter.listener.DexterError;
...@@ -13,25 +21,15 @@ import ly.warp.sdk.dexter.listener.PermissionDeniedResponse; ...@@ -13,25 +21,15 @@ import ly.warp.sdk.dexter.listener.PermissionDeniedResponse;
13 import ly.warp.sdk.io.callbacks.WarplyReadyCallback; 21 import ly.warp.sdk.io.callbacks.WarplyReadyCallback;
14 import ly.warp.sdk.utils.constants.WarpConstants; 22 import ly.warp.sdk.utils.constants.WarpConstants;
15 23
16 -public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequestPermissionsResultCallback */{ 24 +public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequestPermissionsResultCallback*/ {
17 25
18 // =========================================================== 26 // ===========================================================
19 // Constants 27 // Constants
20 // =========================================================== 28 // ===========================================================
21 -// private final String PREF_KEY_DENIED_PERMISSION_COUNT = "pref_key_denied_permissions_count";
22 29
23 private final long INIT_TIME_OUT = 1000 * 20; 30 private final long INIT_TIME_OUT = 1000 * 20;
24 private final long INIT_ATTEMPTS = 3; 31 private final long INIT_ATTEMPTS = 3;
25 - 32 + private final int REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS = 3001;
26 - // permissions
27 -// private static final String[] DANGEROUS_PERMISSIONS = {
28 -// android.Manifest.permission.ACCESS_FINE_LOCATION,
29 -// android.Manifest.permission.ACCESS_COARSE_LOCATION,
30 -// Manifest.permission.READ_PHONE_STATE,
31 -// Manifest.permission.WRITE_EXTERNAL_STORAGE
32 -// };
33 -//
34 -// private final int REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS = 124;
35 private boolean mPermissionsResultRequested = false; 33 private boolean mPermissionsResultRequested = false;
36 34
37 // =========================================================== 35 // ===========================================================
...@@ -39,10 +37,9 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ ...@@ -39,10 +37,9 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ
39 // =========================================================== 37 // ===========================================================
40 38
41 private Context mContext; 39 private Context mContext;
42 -// private Activity mPermissionsActivity; 40 + private Activity mPermissionsActivity;
43 private WarplyInitCallback mInitCallback; 41 private WarplyInitCallback mInitCallback;
44 private WarplyReadyCallback mReadyCallback; 42 private WarplyReadyCallback mReadyCallback;
45 -// private WarplyPreferences mPreferences;
46 43
47 private static volatile Handler mMainThreadHandler; 44 private static volatile Handler mMainThreadHandler;
48 private static volatile AtomicBoolean stopThreadLock; 45 private static volatile AtomicBoolean stopThreadLock;
...@@ -57,7 +54,6 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ ...@@ -57,7 +54,6 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ
57 this.mContext = context; 54 this.mContext = context;
58 this.mReadyCallback = readyCallback; 55 this.mReadyCallback = readyCallback;
59 this.mInitCallback = initCallback; 56 this.mInitCallback = initCallback;
60 -// this.mPreferences = new WarplyPreferences(mContext);
61 57
62 if (mMainThreadHandler == null) { 58 if (mMainThreadHandler == null) {
63 mMainThreadHandler = new Handler(Looper.getMainLooper()); 59 mMainThreadHandler = new Handler(Looper.getMainLooper());
...@@ -105,15 +101,14 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ ...@@ -105,15 +101,14 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ
105 101
106 // @Override 102 // @Override
107 // public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { 103 // public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
108 -//
109 // switch (requestCode) { 104 // switch (requestCode) {
110 // case REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS: 105 // case REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS:
111 -//
112 // if (permissions.length > 0) { 106 // if (permissions.length > 0) {
113 // Map<String, Integer> results = new HashMap<>(); 107 // Map<String, Integer> results = new HashMap<>();
114 -// for (String permission : DANGEROUS_PERMISSIONS) { 108 +// for (String permission : PermissionsUtil.DANGEROUS_PERMISSIONS) {
115 // results.put(permission, PackageManager.PERMISSION_GRANTED); 109 // results.put(permission, PackageManager.PERMISSION_GRANTED);
116 // } 110 // }
111 +//
117 // for (int i = 0; i < permissions.length; i++) { 112 // for (int i = 0; i < permissions.length; i++) {
118 // results.put(permissions[i], grantResults[i]); 113 // results.put(permissions[i], grantResults[i]);
119 // } 114 // }
...@@ -128,10 +123,8 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ ...@@ -128,10 +123,8 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ
128 // 123 //
129 // if (mReadyCallback != null && mPermissionsActivity != null) { 124 // if (mReadyCallback != null && mPermissionsActivity != null) {
130 // if (stillNeedRequest) { 125 // if (stillNeedRequest) {
131 -// //mPermissionsActivity.finish();
132 // mReadyCallback.onWarplyPermissionsDenied(); 126 // mReadyCallback.onWarplyPermissionsDenied();
133 // } 127 // }
134 -// // else {onResume() after close dialog of permission -> initWithPermissions()}
135 // } 128 // }
136 // mPermissionsResultRequested = true; 129 // mPermissionsResultRequested = true;
137 // } 130 // }
...@@ -179,6 +172,23 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ ...@@ -179,6 +172,23 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ
179 } 172 }
180 173
181 public synchronized void initWithPermissions(Activity activity) { 174 public synchronized void initWithPermissions(Activity activity) {
175 +// this.mPermissionsActivity = activity;
176 +//
177 +// int result;
178 +// List<String> listPermissionsNeeded = new ArrayList<>();
179 +// for (String p : PermissionsUtil.DANGEROUS_PERMISSIONS) {
180 +// result = ContextCompat.checkSelfPermission(activity, p);
181 +// if (result != PackageManager.PERMISSION_GRANTED) {
182 +// listPermissionsNeeded.add(p);
183 +// }
184 +// }
185 +//
186 +// if (!listPermissionsNeeded.isEmpty()) {
187 +// ActivityCompat.requestPermissions(activity, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]), REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS);
188 +//// init();
189 +// }
190 +// init();
191 +
182 PermissionsUtil permUtil = new PermissionsUtil( 192 PermissionsUtil permUtil = new PermissionsUtil(
183 activity, 193 activity,
184 new PermissionsUtil.PermissionCallback() { 194 new PermissionsUtil.PermissionCallback() {
...@@ -188,6 +198,7 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ ...@@ -188,6 +198,7 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ
188 if (mReadyCallback != null) 198 if (mReadyCallback != null)
189 mReadyCallback.onWarplyPermissionsDenied(); 199 mReadyCallback.onWarplyPermissionsDenied();
190 } 200 }
201 +
191 @Override 202 @Override
192 public void onPermissionsGranted() { 203 public void onPermissionsGranted() {
193 mPermissionsResultRequested = true; 204 mPermissionsResultRequested = true;
...@@ -195,47 +206,19 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ ...@@ -195,47 +206,19 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ
195 206
196 @Override 207 @Override
197 public void onError(DexterError error) { 208 public void onError(DexterError error) {
209 + if (error.toString().equals("REQUEST_ONGOING"))
210 + return;
198 onPermissionDenied(null); 211 onPermissionDenied(null);
199 } 212 }
200 }, 213 },
201 null //Requests all dangerous permissions 214 null //Requests all dangerous permissions
202 ); 215 );
203 - if(permUtil.requestNeeded() && !mPermissionsResultRequested){ 216 + if (permUtil.requestNeeded() && !mPermissionsResultRequested) {
204 permUtil.requestPermissions(); 217 permUtil.requestPermissions();
205 - } 218 + } else {
206 - else{
207 mPermissionsResultRequested = true; 219 mPermissionsResultRequested = true;
208 init(); 220 init();
209 } 221 }
210 -
211 -// this.mPermissionsActivity = activity;
212 -// final List<String> deniedPermissionsList = new ArrayList<>();
213 -// for (String permission : DANGEROUS_PERMISSIONS) {
214 -// if (ContextCompat.checkSelfPermission(mPermissionsActivity, permission)
215 -// != PackageManager.PERMISSION_GRANTED) {
216 -// deniedPermissionsList.add(permission);
217 -// }
218 -// }
219 -
220 -// if (deniedPermissionsList.size() == 0 || mPermissionsResultRequested) {
221 -//
222 -// // reset warply initialization if was initialized
223 -// // with wrong parameters without permissions or with another permissions count
224 -// int oldDeniedPermissionsCount = mPreferences.getInt(PREF_KEY_DENIED_PERMISSION_COUNT, deniedPermissionsList.size());
225 -// if (deniedPermissionsList.size() != oldDeniedPermissionsCount) {
226 -// WarpUtils.invalidateRegistrationWarply(mContext);
227 -// }
228 -// mPreferences.saveInt(PREF_KEY_DENIED_PERMISSION_COUNT, deniedPermissionsList.size());
229 -// init();
230 -// } else {
231 -// mPermissionsResultRequested = false;
232 -// //TODO: restore permission request
233 -//// ActivityCompat.requestPermissions(mPermissionsActivity,
234 -//// deniedPermissionsList.toArray(new String[deniedPermissionsList.size()]),
235 -//// REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS);
236 -// mPreferences.saveInt(PREF_KEY_DENIED_PERMISSION_COUNT, deniedPermissionsList.size());
237 -// init();
238 -// }
239 } 222 }
240 223
241 // =========================================================== 224 // ===========================================================
......
...@@ -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.2"; 33 + public static final String SDK_VERSION = "4.5.3";
34 34
35 /** 35 /**
36 * The URL of the server where it should ping 36 * The URL of the server where it should ping
......
...@@ -32,6 +32,9 @@ import android.content.Intent; ...@@ -32,6 +32,9 @@ import android.content.Intent;
32 import android.content.pm.PackageManager; 32 import android.content.pm.PackageManager;
33 import android.location.Criteria; 33 import android.location.Criteria;
34 import android.location.LocationManager; 34 import android.location.LocationManager;
35 +import android.os.Build;
36 +
37 +import androidx.work.WorkManager;
35 38
36 import java.util.List; 39 import java.util.List;
37 40
...@@ -97,11 +100,13 @@ public class WarplyLocationManager { ...@@ -97,11 +100,13 @@ public class WarplyLocationManager {
97 public void onError(DexterError error) { 100 public void onError(DexterError error) {
98 onPermissionDenied(null); 101 onPermissionDenied(null);
99 } 102 }
103 +
100 @Override 104 @Override
101 public void onPermissionDenied(List<PermissionDeniedResponse> denied) { 105 public void onPermissionDenied(List<PermissionDeniedResponse> denied) {
102 - if(denied != null && denied.size() < 2)//1 location permission accepted 106 + if (denied != null && denied.size() < 2)//1 location permission accepted
103 onPermissionsGranted(); 107 onPermissionsGranted();
104 } 108 }
109 +
105 @Override 110 @Override
106 public void onPermissionsGranted() { 111 public void onPermissionsGranted() {
107 /* 112 /*
...@@ -124,14 +129,14 @@ public class WarplyLocationManager { ...@@ -124,14 +129,14 @@ public class WarplyLocationManager {
124 } 129 }
125 }; 130 };
126 131
127 - try{ 132 + try {
128 new PermissionsUtil( 133 new PermissionsUtil(
129 act, 134 act,
130 callback, 135 callback,
131 PermissionsUtil.PERMISSION_LOCATION_COARSE, 136 PermissionsUtil.PERMISSION_LOCATION_COARSE,
132 PermissionsUtil.PERMISSION_LOCATION_FINE 137 PermissionsUtil.PERMISSION_LOCATION_FINE
133 ).requestPermissions(); 138 ).requestPermissions();
134 - }catch (Exception e){ 139 + } catch (Exception e) {
135 if (BuildConfig.DEBUG) 140 if (BuildConfig.DEBUG)
136 e.printStackTrace(); 141 e.printStackTrace();
137 } 142 }
...@@ -182,9 +187,15 @@ public class WarplyLocationManager { ...@@ -182,9 +187,15 @@ public class WarplyLocationManager {
182 public static void stopReportingLocation(Context wContext) { 187 public static void stopReportingLocation(Context wContext) {
183 188
184 if (locationManager != null) { 189 if (locationManager != null) {
185 - locationManager.removeUpdates(PendingIntent.getBroadcast(Warply.getWarplyContext(), 0, 190 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
186 - new Intent(Warply.getWarplyContext(), LocationChangedReceiver.class), 191 + locationManager.removeUpdates(PendingIntent.getBroadcast(Warply.getWarplyContext(), 0,
187 - PendingIntent.FLAG_UPDATE_CURRENT)); 192 + new Intent(Warply.getWarplyContext(), LocationChangedReceiver.class),
193 + PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE));
194 + } else {
195 + locationManager.removeUpdates(PendingIntent.getBroadcast(Warply.getWarplyContext(), 0,
196 + new Intent(Warply.getWarplyContext(), LocationChangedReceiver.class),
197 + PendingIntent.FLAG_UPDATE_CURRENT));
198 + }
188 } 199 }
189 200
190 disableLocationChangedReceiver(wContext); 201 disableLocationChangedReceiver(wContext);
...@@ -197,10 +208,17 @@ public class WarplyLocationManager { ...@@ -197,10 +208,17 @@ public class WarplyLocationManager {
197 enableLocationChangedReceiver(); 208 enableLocationChangedReceiver();
198 209
199 if (wContext != null) { 210 if (wContext != null) {
211 + final PendingIntent locationListenerPendingIntent;
212 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
213 + locationListenerPendingIntent = PendingIntent.getBroadcast(wContext, 0,
214 + new Intent(wContext, LocationChangedReceiver.class),
215 + PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
216 + } else {
217 + locationListenerPendingIntent = PendingIntent.getBroadcast(wContext, 0,
218 + new Intent(wContext, LocationChangedReceiver.class),
219 + PendingIntent.FLAG_UPDATE_CURRENT);
220 + }
200 221
201 - final PendingIntent locationListenerPendingIntent = PendingIntent.getBroadcast(wContext, 0,
202 - new Intent(wContext, LocationChangedReceiver.class),
203 - PendingIntent.FLAG_UPDATE_CURRENT);
204 final LocationManager lm = (LocationManager) wContext.getSystemService(Context.LOCATION_SERVICE); 222 final LocationManager lm = (LocationManager) wContext.getSystemService(Context.LOCATION_SERVICE);
205 223
206 if (lm != null) { 224 if (lm != null) {
...@@ -212,11 +230,13 @@ public class WarplyLocationManager { ...@@ -212,11 +230,13 @@ public class WarplyLocationManager {
212 public void onError(DexterError error) { 230 public void onError(DexterError error) {
213 onPermissionDenied(null); 231 onPermissionDenied(null);
214 } 232 }
233 +
215 @Override 234 @Override
216 public void onPermissionDenied(List<PermissionDeniedResponse> denied) { 235 public void onPermissionDenied(List<PermissionDeniedResponse> denied) {
217 - if(denied != null && denied.size() < 2)//1 location permission accepted 236 + if (denied != null && denied.size() < 2)//1 location permission accepted
218 onPermissionsGranted(); 237 onPermissionsGranted();
219 } 238 }
239 +
220 @Override 240 @Override
221 public void onPermissionsGranted() { 241 public void onPermissionsGranted() {
222 try { 242 try {
...@@ -323,6 +343,7 @@ public class WarplyLocationManager { ...@@ -323,6 +343,7 @@ public class WarplyLocationManager {
323 PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 343 PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
324 PackageManager.DONT_KILL_APP); 344 PackageManager.DONT_KILL_APP);
325 new WarplyPreferences(wContext).saveLocationChangedReceiverStatus("off"); 345 new WarplyPreferences(wContext).saveLocationChangedReceiverStatus("off");
346 + WorkManager.getInstance(Warply.getWarplyContext()).cancelAllWorkByTag(UpdateUserLocationService.TAG);
326 } 347 }
327 348
328 private static void enableConnectivityChangedReceiver() { 349 private static void enableConnectivityChangedReceiver() {
......
...@@ -54,7 +54,7 @@ public class WarplySessionManager { ...@@ -54,7 +54,7 @@ public class WarplySessionManager {
54 */ 54 */
55 public static void onCreateActivity(Activity activity) { 55 public static void onCreateActivity(Activity activity) {
56 synchronized (_activities) { 56 synchronized (_activities) {
57 - Warply.getInitializer(activity).init(); 57 +// Warply.getInitializer(activity).init();
58 _activities.add(activity); 58 _activities.add(activity);
59 if (_activities.size() == 1) 59 if (_activities.size() == 1)
60 onApplicationStart(); 60 onApplicationStart();
...@@ -74,7 +74,7 @@ public class WarplySessionManager { ...@@ -74,7 +74,7 @@ public class WarplySessionManager {
74 */ 74 */
75 public static void onStartActivity(Activity activity) { 75 public static void onStartActivity(Activity activity) {
76 synchronized (_activities) { 76 synchronized (_activities) {
77 - Warply.getInitializer(activity).init(); 77 +// Warply.getInitializer(activity).init();
78 _activities.add(activity); 78 _activities.add(activity);
79 if (_activities.size() == 1) 79 if (_activities.size() == 1)
80 onApplicationEnterForeground(); 80 onApplicationEnterForeground();
...@@ -106,14 +106,14 @@ public class WarplySessionManager { ...@@ -106,14 +106,14 @@ public class WarplySessionManager {
106 106
107 private static void onApplicationEnterForeground() { 107 private static void onApplicationEnterForeground() {
108 Warply.onApplicationEnterForeground(); 108 Warply.onApplicationEnterForeground();
109 - _receiver = new ConnectivityReceiver(); 109 +// _receiver = new ConnectivityReceiver();
110 - _receiver.startTracking(); 110 +// _receiver.startTracking();
111 } 111 }
112 112
113 private static void onApplicationEnterBackground() { 113 private static void onApplicationEnterBackground() {
114 Warply.onApplicationEnterBackground(); 114 Warply.onApplicationEnterBackground();
115 - if (_receiver != null) 115 +// if (_receiver != null)
116 - _receiver.stopTracking(); 116 +// _receiver.stopTracking();
117 } 117 }
118 118
119 private static class ConnectivityReceiver extends BroadcastReceiver { 119 private static class ConnectivityReceiver extends BroadcastReceiver {
......