Panagiotis Triantafyllou

REMOVE STEPS SERVICE

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.5.4r21'
PUBLISH_VERSION = '4.5.5.4r22'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -14,8 +14,8 @@
tools:node="remove" />
<uses-permission android:name="com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH" />
<uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" />
<!-- <uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH" />-->
<!-- <uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" />-->
<application android:largeHeap="true">
<!-- <meta-data-->
......@@ -116,12 +116,6 @@
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<!-- <activity-->
<!-- android:name="ly.warp.sdk.activities.LoyaltyWallet"-->
<!-- android:exported="false"-->
<!-- android:screenOrientation="portrait"-->
<!-- android:theme="@style/SDKAppTheme" />-->
<activity
android:name="ly.warp.sdk.activities.ActiveGiftsActivity"
android:exported="false"
......@@ -234,11 +228,11 @@
<!-- android:stopWithTask="false"-->
<!-- android:process=":warplyHealthService"-->
<service
android:name="ly.warp.sdk.services.WarplyHealthService"
android:exported="false"
android:foregroundServiceType="health"
android:permission="android.permission.BIND_JOB_SERVICE" />
<!-- <service-->
<!-- android:name="ly.warp.sdk.services.WarplyHealthService"-->
<!-- android:exported="false"-->
<!-- android:foregroundServiceType="health"-->
<!-- android:permission="android.permission.BIND_JOB_SERVICE" />-->
<service
android:name="ly.warp.sdk.services.WarplyBeaconsRangingService"
......
......@@ -39,18 +39,13 @@ import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -58,7 +53,6 @@ import ly.warp.sdk.R;
import ly.warp.sdk.Warply;
import ly.warp.sdk.activities.ContextualActivity;
import ly.warp.sdk.activities.CouponsetInfoActivity;
import ly.warp.sdk.activities.GiftsForYouActivity;
import ly.warp.sdk.activities.TelcoActivity;
import ly.warp.sdk.activities.WarpViewActivity;
import ly.warp.sdk.db.WarplyDBHelper;
......@@ -76,22 +70,16 @@ import ly.warp.sdk.io.models.LoyaltyBadgeModel;
import ly.warp.sdk.io.models.LoyaltyContextualOfferModel;
import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage;
import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.io.models.MerchantList;
import ly.warp.sdk.io.models.PushCampaign;
import ly.warp.sdk.io.models.UnifiedCoupon;
import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest;
import ly.warp.sdk.io.request.CosmoteSharingRequest;
import ly.warp.sdk.io.request.WarplyConsumerRequest;
import ly.warp.sdk.io.request.WarplyEditConsumerRequest;
import ly.warp.sdk.io.request.WarplyIntegrationRequest;
import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import ly.warp.sdk.services.EventService;
import ly.warp.sdk.services.EventUnifiedCouponsService;
import ly.warp.sdk.services.FCMBaseMessagingService;
import ly.warp.sdk.services.VouchersFetchedService;
import ly.warp.sdk.services.WarplyHealthService;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.utils.managers.WarplyManager;
......@@ -1464,10 +1452,10 @@ public class WarplyManagerHelper {
}
public static void logoutUser() {
if (isMyServiceRunning(WarplyHealthService.class)) {
Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
Warply.getWarplyContext().stopService(stepsServiceIntent);
}
// if (isMyServiceRunning(WarplyHealthService.class)) {
// Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// Warply.getWarplyContext().stopService(stepsServiceIntent);
// }
}
private static boolean isMyServiceRunning(Class<?> serviceClass) {
......
......@@ -26,14 +26,9 @@
package ly.warp.sdk.utils.managers;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.ArrayMap;
......@@ -54,7 +49,6 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
......@@ -68,9 +62,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import ly.warp.sdk.Warply;
import ly.warp.sdk.activities.CouponsetInfoActivity;
import ly.warp.sdk.activities.GiftsForYouActivity;
import ly.warp.sdk.activities.WarpViewActivity;
import ly.warp.sdk.db.WarplyDBHelper;
import ly.warp.sdk.io.callbacks.AddressHook;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
......@@ -100,7 +91,6 @@ import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.CouponsetsList;
import ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel;
import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.io.models.MerchantCategoriesList;
import ly.warp.sdk.io.models.MerchantList;
......@@ -116,7 +106,6 @@ import ly.warp.sdk.io.models.TransactionsList;
import ly.warp.sdk.io.models.TripMetrics;
import ly.warp.sdk.io.models.UnifiedCampaignModel;
import ly.warp.sdk.io.models.UnifiedCoupon;
import ly.warp.sdk.io.models.WarplyPacingEventModel;
import ly.warp.sdk.io.request.CosmoteCouponSharingRequest;
import ly.warp.sdk.io.request.CosmotePostEventRequest;
import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest;
......@@ -167,7 +156,6 @@ import ly.warp.sdk.io.volley.ApiClient;
import ly.warp.sdk.io.volley.ApiService;
import ly.warp.sdk.services.EventCampaignService;
import ly.warp.sdk.services.EventUnifiedCouponsService;
import ly.warp.sdk.services.WarplyHealthService;
import ly.warp.sdk.utils.WarpJSONParser;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyDeviceInfoCollector;
......@@ -982,30 +970,20 @@ public class WarplyManager {
WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge"));
}
if (profMetadata.has("steps_enabled") && profMetadata.optBoolean("steps_enabled")) {
if (!isMyServiceRunning(WarplyHealthService.class)) {
Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// AlarmManager mgr = (AlarmManager) Warply.getWarplyContext().getSystemService(Context.ALARM_SERVICE);
// PendingIntent pi = PendingIntent.getService(Warply.getWarplyContext(), 2002, stepsServiceIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
// mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1000, pi);
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// if (profMetadata.has("steps_enabled") && profMetadata.optBoolean("steps_enabled")) {
// if (!isMyServiceRunning(WarplyHealthService.class)) {
// Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Warply.getWarplyContext().startForegroundService(stepsServiceIntent);
// } else {
// Warply.getWarplyContext().startService(stepsServiceIntent);
// }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Warply.getWarplyContext().startForegroundService(stepsServiceIntent);
} else {
Warply.getWarplyContext().startService(stepsServiceIntent);
}
WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
pacingVisible.setVisible(true);
EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
}
}
//
// WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
// pacingVisible.setVisible(true);
// EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
// }
// }
}
}
}
......@@ -1126,30 +1104,20 @@ public class WarplyManager {
WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge"));
}
if (profMetadata.has("steps_enabled") && profMetadata.optBoolean("steps_enabled")) {
if (!isMyServiceRunning(WarplyHealthService.class)) {
Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// AlarmManager mgr = (AlarmManager) Warply.getWarplyContext().getSystemService(Context.ALARM_SERVICE);
// PendingIntent pi = PendingIntent.getService(Warply.getWarplyContext(), 2002, stepsServiceIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
// mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1000, pi);
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// if (profMetadata.has("steps_enabled") && profMetadata.optBoolean("steps_enabled")) {
// if (!isMyServiceRunning(WarplyHealthService.class)) {
// Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Warply.getWarplyContext().startForegroundService(stepsServiceIntent);
// } else {
// Warply.getWarplyContext().startService(stepsServiceIntent);
// }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Warply.getWarplyContext().startForegroundService(stepsServiceIntent);
} else {
Warply.getWarplyContext().startService(stepsServiceIntent);
}
WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
pacingVisible.setVisible(true);
EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
}
}
//
// WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
// pacingVisible.setVisible(true);
// EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
// }
// }
}
}
}
......@@ -1252,30 +1220,20 @@ public class WarplyManager {
WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge"));
}
if (profMetadata.has("steps_enabled") && profMetadata.optBoolean("steps_enabled")) {
if (!isMyServiceRunning(WarplyHealthService.class)) {
Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// AlarmManager mgr = (AlarmManager) Warply.getWarplyContext().getSystemService(Context.ALARM_SERVICE);
// PendingIntent pi = PendingIntent.getService(Warply.getWarplyContext(), 2002, stepsServiceIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
// mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1000, pi);
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// if (profMetadata.has("steps_enabled") && profMetadata.optBoolean("steps_enabled")) {
// if (!isMyServiceRunning(WarplyHealthService.class)) {
// Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Warply.getWarplyContext().startForegroundService(stepsServiceIntent);
// } else {
// Warply.getWarplyContext().startService(stepsServiceIntent);
// }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Warply.getWarplyContext().startForegroundService(stepsServiceIntent);
} else {
Warply.getWarplyContext().startService(stepsServiceIntent);
}
WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
pacingVisible.setVisible(true);
EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
}
}
//
// WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
// pacingVisible.setVisible(true);
// EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
// }
// }
}
}
}
......@@ -4869,30 +4827,20 @@ public class WarplyManager {
WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge"));
}
if (profMetadata.has("steps_enabled") && profMetadata.optBoolean("steps_enabled")) {
if (!isMyServiceRunning(WarplyHealthService.class)) {
Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// AlarmManager mgr = (AlarmManager) Warply.getWarplyContext().getSystemService(Context.ALARM_SERVICE);
// PendingIntent pi = PendingIntent.getService(Warply.getWarplyContext(), 2002, stepsServiceIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
// mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1000, pi);
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// if (profMetadata.has("steps_enabled") && profMetadata.optBoolean("steps_enabled")) {
// if (!isMyServiceRunning(WarplyHealthService.class)) {
// Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Warply.getWarplyContext().startForegroundService(stepsServiceIntent);
// } else {
// Warply.getWarplyContext().startService(stepsServiceIntent);
// }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Warply.getWarplyContext().startForegroundService(stepsServiceIntent);
} else {
Warply.getWarplyContext().startService(stepsServiceIntent);
}
WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
pacingVisible.setVisible(true);
EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
}
}
//
// WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
// pacingVisible.setVisible(true);
// EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
// }
// }
}
}
}
......
......@@ -104,10 +104,8 @@ import ly.warp.sdk.io.models.UnifiedCoupon;
import ly.warp.sdk.io.models.WarplyCCMSEnabledModel;
import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
import ly.warp.sdk.io.models.WarplyPacingCardEventModel;
import ly.warp.sdk.io.models.WarplyPacingEventModel;
import ly.warp.sdk.io.models.WarplyUnifiedActivatedEventModel;
import ly.warp.sdk.services.EventCampaignService;
import ly.warp.sdk.services.WarplyHealthService;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.WarplyProperty;
......@@ -126,7 +124,6 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
private static final String URL_ACTION_MARKET = "market";
private static final String URL_ACTION_INTENT = "intent";
private static final String URL_ACTION_MARKET_AUTHORITY = "play.google.com";
private static final String TAG_STEPS_WORKER = "ly.warp.sdk.services.WarplyHealthService";
// ===========================================================
// Fields
......@@ -430,12 +427,12 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
if (!EventBus.getDefault().isRegistered(this))
EventBus.getDefault().register(this);
if (mWebviewLoaded) {
String scriptSourceInit = "webviewDidFocus(" + String.valueOf(mWebviewLoaded) + "," + String.valueOf(isMyServiceRunning(WarplyHealthService.class)) + ");";
WarpView.this.evaluateJavascript(scriptSourceInit, s -> {
});
}
// if (mWebviewLoaded) {
// String scriptSourceInit = "webviewDidFocus(" + String.valueOf(mWebviewLoaded) + "," + String.valueOf(isMyServiceRunning(WarplyHealthService.class)) + ");";
// WarpView.this.evaluateJavascript(scriptSourceInit, s -> {
//
// });
// }
}
@Override
......@@ -549,29 +546,29 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
pacingWidgetVisible.setVisible(true);
EventBus.getDefault().post(new WarplyEventBusManager(pacingWidgetVisible));
} else if (parts[1].equals("steps") && parts[2].equals("shortcutEnabled")) { // This is for the pacing service
if (!isMyServiceRunning(WarplyHealthService.class)) {
LoyaltySDKFirebaseEventModel analyticsEvent = new LoyaltySDKFirebaseEventModel();
analyticsEvent.setEventName("loyalty_steps_activation");
EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent));
Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Warply.getWarplyContext().startForegroundService(stepsServiceIntent);
} else {
Warply.getWarplyContext().startService(stepsServiceIntent);
}
WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
pacingVisible.setVisible(true);
EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
}
// if (!isMyServiceRunning(WarplyHealthService.class)) {
// LoyaltySDKFirebaseEventModel analyticsEvent = new LoyaltySDKFirebaseEventModel();
// analyticsEvent.setEventName("loyalty_steps_activation");
// EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent));
//
// Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Warply.getWarplyContext().startForegroundService(stepsServiceIntent);
// } else {
// Warply.getWarplyContext().startService(stepsServiceIntent);
// }
//
// WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
// pacingVisible.setVisible(true);
// EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
// }
} else if (parts[1].equals("steps") && parts[2].equals("shortcutDisabled")) { // This is for the pacing service
Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
Warply.getWarplyContext().stopService(stepsServiceIntent);
WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
pacingVisible.setVisible(false);
EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
// Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class);
// Warply.getWarplyContext().stopService(stepsServiceIntent);
//
// WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
// pacingVisible.setVisible(false);
// EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
} else if (parts[1].equals("request") || parts[1].equals("response")) {
WarpUtils.log("**************** WARPLY Webview Log START *****************");
WarpUtils.log(message);
......