From 02279e73010de50d7bff24b15326ac49d7b85bd5 Mon Sep 17 00:00:00 2001 From: uerceg Date: Thu, 30 May 2024 19:15:48 +0200 Subject: [PATCH 01/12] fix: remove remainings of the event buffering removal --- .../src/main/java/com/adjust/sdk/ActivityHandler.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index 8556e8a9a..dcc466475 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -2150,12 +2150,9 @@ private void updateHandlersStatusAndSendI() { } resumeSendingI(); - // if it's the first launch and it hasn't received the session response - if ((internalState.isFirstLaunch() && internalState.hasSessionResponseNotBeenProcessed())) - { - // try to send - packageHandler.sendFirstPackage(); - } + + // try to send + packageHandler.sendFirstPackage(); } private void pauseSendingI() { From 79a50e48226618e3108ab933b4f645e577676df6 Mon Sep 17 00:00:00 2001 From: Shashank Suhane Date: Thu, 30 May 2024 20:52:21 +0200 Subject: [PATCH 02/12] feat: use continue_in in package queue --- .../java/com/adjust/sdk/PackageHandler.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java index 43e796eac..d1b1fe699 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java @@ -134,7 +134,7 @@ public void onResponseDataCallback(final ResponseData responseData) { scheduler.submit(new Runnable() { @Override public void run() { - sendNextI(); + sendNextI(responseData.continueIn); } }); @@ -258,16 +258,32 @@ private Map generateSendingParametersI() { return sendingParameters; } - private void sendNextI() { + private void sendNextI(Long previousResponseContinueIn) { if (packageQueue.isEmpty()) { return; } packageQueue.remove(0); writePackageQueueI(); - isSending.set(false); - logger.verbose("Package handler can send"); - sendFirstI(); + + if (previousResponseContinueIn != null) { + Runnable runnable = new Runnable() { + @Override + public void run() { + logger.verbose("Package handler finished waiting to continue"); + isSending.set(false); + sendFirstPackage(); + } + }; + + logger.verbose("Waiting for %d seconds before continuing for next package in continue_in", previousResponseContinueIn / 1000.0); + scheduler.schedule(runnable, previousResponseContinueIn); + + } else { + logger.verbose("Package handler can send"); + isSending.set(false); + sendFirstI(); + } } private void flushI() { From 7e732cc6d1e02bf04fc64c1fae7bf879c892d3a4 Mon Sep 17 00:00:00 2001 From: Shashank Suhane Date: Thu, 30 May 2024 22:21:44 +0200 Subject: [PATCH 03/12] fix: check for continueIn value --- .../sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java index d1b1fe699..bcab223fe 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java @@ -266,7 +266,7 @@ private void sendNextI(Long previousResponseContinueIn) { packageQueue.remove(0); writePackageQueueI(); - if (previousResponseContinueIn != null) { + if (previousResponseContinueIn != null && previousResponseContinueIn > 0) { Runnable runnable = new Runnable() { @Override public void run() { From 642e21b40a7cc448c3c089c361f8405b36295874 Mon Sep 17 00:00:00 2001 From: uerceg Date: Fri, 31 May 2024 10:06:07 +0200 Subject: [PATCH 04/12] refac: rename deeplink to deferred deeplink listener --- .../com/adjust/examples/GlobalApplication.java | 7 ++----- .../examples/keyboard/GlobalApplication.java | 4 ++-- .../java/com/adjust/examples/GlobalApplication.kt | 2 +- .../com/adjust/examples/GlobalApplication.java | 4 ++-- .../main/java/com/adjust/sdk/ActivityHandler.java | 4 ++-- .../src/main/java/com/adjust/sdk/AdjustConfig.java | 14 +++++--------- ...ava => OnDeferredDeeplinkResponseListener.java} | 2 +- .../adjust/sdk/webbridge/AdjustBridgeInstance.java | 5 ++--- .../com/adjust/testapp/AdjustCommandExecutor.java | 6 +++--- 9 files changed, 20 insertions(+), 28 deletions(-) rename Adjust/sdk-core/src/main/java/com/adjust/sdk/{OnDeeplinkResponseListener.java => OnDeferredDeeplinkResponseListener.java} (72%) diff --git a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java index 3ff7c24c3..bba4d8d60 100644 --- a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java @@ -19,16 +19,13 @@ import com.adjust.sdk.OnAmazonAdIdReadListener; import com.adjust.sdk.OnAttributionChangedListener; import com.adjust.sdk.OnAttributionReadListener; -import com.adjust.sdk.OnDeeplinkResponseListener; +import com.adjust.sdk.OnDeferredDeeplinkResponseListener; import com.adjust.sdk.OnEventTrackingFailedListener; import com.adjust.sdk.OnEventTrackingSucceededListener; import com.adjust.sdk.OnGooglePlayInstallReferrerReadListener; import com.adjust.sdk.OnSessionTrackingFailedListener; import com.adjust.sdk.OnSessionTrackingSucceededListener; -import java.util.ArrayList; -import java.util.List; - /** * Created by pfms on 17/12/14. */ @@ -101,7 +98,7 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure sessionFailureR }); // Evaluate deferred deep link to be launched. - config.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + config.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { Log.d("example", "Deferred deep link callback called!"); diff --git a/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java b/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java index 215e64d07..5f49819b3 100644 --- a/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java +++ b/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java @@ -13,7 +13,7 @@ import com.adjust.sdk.AdjustEventSuccess; import com.adjust.sdk.LogLevel; import com.adjust.sdk.OnAttributionChangedListener; -import com.adjust.sdk.OnDeeplinkResponseListener; +import com.adjust.sdk.OnDeferredDeeplinkResponseListener; import com.adjust.sdk.OnEventTrackingFailedListener; import com.adjust.sdk.OnEventTrackingSucceededListener; import com.adjust.sdk.OnSessionTrackingFailedListener; @@ -84,7 +84,7 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure sessionFailureR }); // Evaluate deferred deep link to be launched. - config.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + config.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { Log.d("example", "Deferred deep link callback called!"); diff --git a/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt b/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt index 624fec504..d5f00cd6f 100644 --- a/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt +++ b/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt @@ -52,7 +52,7 @@ class GlobalApplication : Application() { } // Evaluate deferred deep link to be launched. - config.setOnDeeplinkResponseListener { deeplink -> + config.setOnDeferredDeeplinkResponseListener { deeplink -> Log.d("example", "Deferred deep link callback called!") Log.d("example", "Deep link URL: $deeplink") diff --git a/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java index 03d739ad9..7b61ce37f 100755 --- a/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java @@ -13,7 +13,7 @@ import com.adjust.sdk.AdjustEventSuccess; import com.adjust.sdk.LogLevel; import com.adjust.sdk.OnAttributionChangedListener; -import com.adjust.sdk.OnDeeplinkResponseListener; +import com.adjust.sdk.OnDeferredDeeplinkResponseListener; import com.adjust.sdk.OnEventTrackingFailedListener; import com.adjust.sdk.OnEventTrackingSucceededListener; import com.adjust.sdk.OnSessionTrackingFailedListener; @@ -81,7 +81,7 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure sessionFailureR }); // Evaluate deferred deep link to be launched. - config.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + config.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { Log.d("example", "Deferred deep link callback called!"); diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index dcc466475..4f481e6d7 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -1840,8 +1840,8 @@ public void run() { return; } boolean toLaunchDeeplink = true; - if (adjustConfig.onDeeplinkResponseListener != null) { - toLaunchDeeplink = adjustConfig.onDeeplinkResponseListener.launchReceivedDeeplink(deeplink); + if (adjustConfig.onDeferredDeeplinkResponseListener != null) { + toLaunchDeeplink = adjustConfig.onDeferredDeeplinkResponseListener.launchReceivedDeeplink(deeplink); } if (toLaunchDeeplink) { launchDeeplinkMain(deeplinkIntent, deeplink); diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java index d9e103b6c..6bf30716b 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java @@ -25,7 +25,7 @@ public class AdjustConfig { OnEventTrackingFailedListener onEventTrackingFailedListener; OnSessionTrackingSucceededListener onSessionTrackingSucceededListener; OnSessionTrackingFailedListener onSessionTrackingFailedListener; - OnDeeplinkResponseListener onDeeplinkResponseListener; + OnDeferredDeeplinkResponseListener onDeferredDeeplinkResponseListener; boolean sendInBackground; AdjustInstance.PreLaunchActions preLaunchActions; ILogger logger; @@ -107,10 +107,6 @@ public void setOnAttributionChangedListener(OnAttributionChangedListener onAttri this.onAttributionChangedListener = onAttributionChangedListener; } - public void setDeepLinkComponent(Class deepLinkComponent) { - this.deepLinkComponent = deepLinkComponent; - } - public void setOnEventTrackingSucceededListener(OnEventTrackingSucceededListener onEventTrackingSucceededListener) { this.onEventTrackingSucceededListener = onEventTrackingSucceededListener; } @@ -127,8 +123,8 @@ public void setOnSessionTrackingFailedListener(OnSessionTrackingFailedListener o this.onSessionTrackingFailedListener = onSessionTrackingFailedListener; } - public void setOnDeeplinkResponseListener(OnDeeplinkResponseListener onDeeplinkResponseListener) { - this.onDeeplinkResponseListener = onDeeplinkResponseListener; + public void setOnDeferredDeeplinkResponseListener(OnDeferredDeeplinkResponseListener onDeferredDeeplinkResponseListener) { + this.onDeferredDeeplinkResponseListener = onDeferredDeeplinkResponseListener; } public void setExternalDeviceId(String externalDeviceId) { @@ -245,8 +241,8 @@ public OnSessionTrackingFailedListener getOnSessionTrackingFailedListener() { return onSessionTrackingFailedListener; } - public OnDeeplinkResponseListener getOnDeeplinkResponseListener() { - return onDeeplinkResponseListener; + public OnDeferredDeeplinkResponseListener getOnDeeplinkResponseListener() { + return onDeferredDeeplinkResponseListener; } public boolean isSendInBackground() { diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeeplinkResponseListener.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeferredDeeplinkResponseListener.java similarity index 72% rename from Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeeplinkResponseListener.java rename to Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeferredDeeplinkResponseListener.java index 6075055ad..70762d87a 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeeplinkResponseListener.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeferredDeeplinkResponseListener.java @@ -5,6 +5,6 @@ /** * Created by pfms on 22/03/16. */ -public interface OnDeeplinkResponseListener { +public interface OnDeferredDeeplinkResponseListener { boolean launchReceivedDeeplink(Uri deeplink); } diff --git a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java index b3b89855e..6c114caaa 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java +++ b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java @@ -24,7 +24,7 @@ import com.adjust.sdk.OnAmazonAdIdReadListener; import com.adjust.sdk.OnAttributionChangedListener; import com.adjust.sdk.OnAttributionReadListener; -import com.adjust.sdk.OnDeeplinkResponseListener; +import com.adjust.sdk.OnDeferredDeeplinkResponseListener; import com.adjust.sdk.OnDeviceIdsRead; import com.adjust.sdk.OnEventTrackingFailedListener; import com.adjust.sdk.OnEventTrackingSucceededListener; @@ -38,7 +38,6 @@ import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; /** * Created by uerceg on 22/07/16. @@ -309,7 +308,7 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure failureResponse // Deferred deeplink callback final String deferredDeeplinkCallbackName = AdjustBridgeUtil.fieldToString(deferredDeeplinkCallbackNameField); if (deferredDeeplinkCallbackName != null) { - adjustConfig.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + adjustConfig.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { AdjustBridgeUtil.execSingleValueCallback(webView, deferredDeeplinkCallbackName, deeplink.toString()); diff --git a/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java b/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java index 3a1613ac8..3b178053a 100644 --- a/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java +++ b/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java @@ -27,7 +27,7 @@ import com.adjust.sdk.LogLevel; import com.adjust.sdk.OnAttributionChangedListener; import com.adjust.sdk.OnDeeplinkResolvedListener; -import com.adjust.sdk.OnDeeplinkResponseListener; +import com.adjust.sdk.OnDeferredDeeplinkResponseListener; import com.adjust.sdk.OnEventTrackingFailedListener; import com.adjust.sdk.OnEventTrackingSucceededListener; import com.adjust.sdk.OnPurchaseVerificationFinishedListener; @@ -315,7 +315,7 @@ private void config() { } if(command.containsParameter("deferredDeeplinkCallback")) { - adjustConfig.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + adjustConfig.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { if (deeplink == null) { @@ -439,7 +439,7 @@ public void onFinishedEventTrackingFailed(AdjustEventFailure eventFailureRespons String launchDeferredDeeplinkS = command.getFirstParameterValue("deferredDeeplinkCallback"); final boolean launchDeferredDeeplink = "true".equals(launchDeferredDeeplinkS); final String localBasePath = basePath; - adjustConfig.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + adjustConfig.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { Log.d("TestApp", "deferred_deep_link = " + deeplink.toString()); From e20984d9b06eb90e5f14e7f6105af4d18080552e Mon Sep 17 00:00:00 2001 From: uerceg Date: Fri, 31 May 2024 13:06:04 +0200 Subject: [PATCH 05/12] refac: clean up adjust config api and its usage --- .../adjust/examples/GlobalApplication.java | 111 +--------- .../examples/keyboard/GlobalApplication.java | 2 +- .../com/adjust/examples/GlobalApplication.kt | 49 +---- .../adjust/examples/GlobalApplication.java | 2 +- .../main/assets/AdjustExample-WebView.html | 4 - .../java/com/adjust/sdk/ActivityHandler.java | 16 +- .../java/com/adjust/sdk/AdjustConfig.java | 202 +++++++++--------- .../main/java/com/adjust/sdk/DeviceInfo.java | 4 +- .../java/com/adjust/sdk/PackageBuilder.java | 20 +- .../src/main/assets/adjust.js | 53 ++--- .../src/main/assets/adjust_config.js | 24 +-- .../sdk/webbridge/AdjustBridgeInstance.java | 46 ++-- .../adjust/testapp/AdjustCommandExecutor.java | 23 +- .../src/main/assets/command_executor.js | 25 ++- 14 files changed, 213 insertions(+), 368 deletions(-) diff --git a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java index bba4d8d60..25babb14c 100644 --- a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java @@ -30,7 +30,6 @@ * Created by pfms on 17/12/14. */ public class GlobalApplication extends Application { - @Override public void onCreate() { super.onCreate(); @@ -62,14 +61,6 @@ public void onFinishedEventTrackingSucceeded(AdjustEventSuccess eventSuccessResp } }); - - // Set url strategy -// List urlStrategy = new ArrayList<>(); -// urlStrategy.add("adjust.com"); -// urlStrategy.add("adjust.cn"); -// urlStrategy.add("eu.adjust.com"); -// config.setUrlStrategy(urlStrategy , true, false); - // Set event failure tracking delegate. config.setOnEventTrackingFailedListener(new OnEventTrackingFailedListener() { @Override @@ -108,17 +99,8 @@ public boolean launchReceivedDeeplink(Uri deeplink) { } }); - // Set default tracker. - // config.setDefaultTracker("{YourDefaultTracker}"); - - // Set process name. - // config.setProcessName("com.adjust.examples"); - // Allow to send in the background. - config.setSendInBackground(true); - - // Allow tracking preinstall - // config.setPreinstallTrackingEnabled(true); + config.enableSendingInBackground(); // Add session callback parameters. Adjust.addGlobalCallbackParameter("sc_foo", "sc_bar"); @@ -152,96 +134,5 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // Initialise the adjust SDK. Adjust.initSdk(config); - - - - - Adjust.getAttribution(new OnAttributionReadListener() { - @Override - public void onAttributionRead(AdjustAttribution attribution) { - Log.d("example", "Attribution callback called!"); - Log.d("example", "Attribution: " + attribution.toString()); - } - }); - - // Get the adid. - Adjust.getAdid(new OnAdidReadListener() { - @Override - public void onAdidRead(String adid) { - Log.d("example", "Adid callback called!"); - Log.d("example", "Adid: " + adid); - } - }); - - Adjust.getGooglePlayInstallReferrer(this, new OnGooglePlayInstallReferrerReadListener() { - @Override - public void onInstallReferrerRead(GooglePlayInstallReferrerDetails referrerDetails) { - Log.d("example", "referrerApi : " + referrerDetails.toString()); - } - - @Override - public void onFailure(String message) { - Log.d("example", "failed : " + message); - - } - }); - - // Register onResume and onPause events of all activities - // for applications with minSdkVersion >= 14. - registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks()); - - Adjust.getAmazonAdId(this, new OnAmazonAdIdReadListener() { - @Override - public void onAmazonAdIdRead(String amazonAdId) { - Log.d("example", "amazonAdId : " + amazonAdId); - } - - @Override - public void onFail(String message) { - Log.d("example", "failed : " + message); - } - }); - - // Put the SDK in offline mode. - // Adjust.switchToOfflineMode(); - - // Disable the SDK - // Adjust.disable(); - - // Send push notification token. - // Adjust.setPushToken("token"); - } - - // You can use this class if your app is for Android 4.0 or higher - private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks { - @Override - public void onActivityResumed(Activity activity) { - Adjust.onResume(); - } - - @Override - public void onActivityPaused(Activity activity) { - Adjust.onPause(); - } - - @Override - public void onActivityStopped(Activity activity) { - } - - @Override - public void onActivitySaveInstanceState(Activity activity, Bundle outState) { - } - - @Override - public void onActivityDestroyed(Activity activity) { - } - - @Override - public void onActivityCreated(Activity activity, Bundle savedInstanceState) { - } - - @Override - public void onActivityStarted(Activity activity) { - } } } diff --git a/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java b/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java index 5f49819b3..b0919b818 100644 --- a/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java +++ b/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java @@ -101,7 +101,7 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // config.setProcessName("com.adjust.examples"); // Allow to send in the background. - config.setSendInBackground(true); + config.enableSendingInBackground(true); // Add session callback parameters. Adjust.addGlobalCallbackParameter("sc_foo", "sc_bar"); diff --git a/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt b/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt index d5f00cd6f..5204dcad4 100644 --- a/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt +++ b/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt @@ -1,8 +1,6 @@ package com.adjust.examples -import android.app.Activity import android.app.Application -import android.os.Bundle import android.util.Log import com.adjust.sdk.Adjust import com.adjust.sdk.AdjustConfig @@ -59,18 +57,8 @@ class GlobalApplication : Application() { true } - // Set default tracker. - // config.setDefaultTracker("{YourDefaultTracker}"); - - // Set process name. - // config.setProcessName("com.adjust.examples"); - // Allow to send in the background. - config.setSendInBackground(true) - - - // Allow tracking preinstall - // config.setPreinstallTrackingEnabled(true); + config.enableSendingInBackground() // Add session callback parameters. Adjust.addGlobalCallbackParameter("sc_foo", "sc_bar") @@ -104,40 +92,5 @@ class GlobalApplication : Application() { // Initialise the adjust SDK. Adjust.initSdk(config) - - // Register onResume and onPause events of all activities - // for applications with minSdkVersion >= 14. - registerActivityLifecycleCallbacks(AdjustLifecycleCallbacks()) - - // Put the SDK in offline mode. - // Adjust.switchToOfflineMode(); - - // Disable the SDK - // Adjust.disable(); - - // Send push notification token. - // Adjust.setPushToken("token"); - - } - - // You can use this class if your app is for Android 4.0 or higher - private class AdjustLifecycleCallbacks : Application.ActivityLifecycleCallbacks { - override fun onActivityResumed(activity: Activity) { - Adjust.onResume() - } - - override fun onActivityPaused(activity: Activity) { - Adjust.onPause() - } - - override fun onActivityStopped(activity: Activity) {} - - override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {} - - override fun onActivityDestroyed(activity: Activity) {} - - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {} - - override fun onActivityStarted(activity: Activity) {} } } diff --git a/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java index 7b61ce37f..d4dccd525 100755 --- a/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java @@ -98,7 +98,7 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // config.setProcessName("com.adjust.examples"); // Allow to send in the background. - config.setSendInBackground(true); + config.enableSendingInBackground(true); // Add session callback parameters. Adjust.addGlobalCallbackParameter("sc_foo", "sc_bar"); diff --git a/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html b/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html index bca5cfab1..845ab2c2a 100755 --- a/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html +++ b/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html @@ -62,8 +62,6 @@

Adjust Web View SDK Demo var adjustConfig = new AdjustConfig('2fm9gkqubvpc', AdjustConfig.EnvironmentSandbox); adjustConfig.setLogLevel(AdjustConfig.LogLevelVerbose); - // adjustConfig.setOpenDeferredDeeplink(true); - // adjustConfig.setSendInBackground(true); adjustConfig.setAttributionCallback(attributionCallback); adjustConfig.setEventSuccessCallback(eventSuccessCallback); @@ -72,8 +70,6 @@

Adjust Web View SDK Demo adjustConfig.setSessionFailureCallback(sessionFailureCallback); adjustConfig.setDeferredDeeplinkCallback(deferredDeeplinkCallback); - - Adjust.initSdk(adjustConfig); window.onload = function() { diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index 4f481e6d7..1ce649dd0 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -948,7 +948,7 @@ public void run() { }, FOREGROUND_TIMER_START, FOREGROUND_TIMER_INTERVAL, FOREGROUND_TIMER_NAME); // create background timer - if (adjustConfig.sendInBackground) { + if (adjustConfig.isSendingInBackgroundEnabled) { logger.info("Send in background configured"); backgroundTimer = new TimerOnce(new Runnable() { @@ -1122,7 +1122,7 @@ private void checkForPreinstallI() { // sending preinstall referrer doesn't require preinstall tracking flag to be enabled sendPreinstallReferrerI(); - if (!adjustConfig.preinstallTrackingEnabled) return; + if (!adjustConfig.isPreinstallTrackingEnabled) return; if (internalState.hasPreinstallBeenRead()) return; if (deviceInfo.packageName == null || deviceInfo.packageName.isEmpty()) { @@ -1595,7 +1595,7 @@ private void trackEventI(AdjustEvent event) { packageHandler.sendFirstPackage(); // if it is in the background and it can send, start the background timer - if (adjustConfig.sendInBackground && internalState.isInBackground()) { + if (adjustConfig.isSendingInBackgroundEnabled && internalState.isInBackground()) { startBackgroundTimerI(); } @@ -1853,15 +1853,9 @@ public void run() { private Intent createDeeplinkIntentI(Uri deeplink) { Intent mapIntent; - if (adjustConfig.deepLinkComponent == null) { - mapIntent = new Intent(Intent.ACTION_VIEW, deeplink); - } else { - mapIntent = new Intent(Intent.ACTION_VIEW, deeplink, adjustConfig.context, adjustConfig.deepLinkComponent); - } + mapIntent = new Intent(Intent.ACTION_VIEW, deeplink); mapIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mapIntent.setPackage(adjustConfig.context.getPackageName()); - return mapIntent; } @@ -2862,7 +2856,7 @@ private boolean toSendI(boolean sdkClickHandlerOnly) { } // has the option to send in the background -> is to send - if (adjustConfig.sendInBackground) { + if (adjustConfig.isSendingInBackgroundEnabled) { return true; } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java index 6bf30716b..63d7efbc6 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java @@ -20,27 +20,26 @@ public class AdjustConfig { String sdkPrefix; String defaultTracker; OnAttributionChangedListener onAttributionChangedListener; - Class deepLinkComponent; OnEventTrackingSucceededListener onEventTrackingSucceededListener; OnEventTrackingFailedListener onEventTrackingFailedListener; OnSessionTrackingSucceededListener onSessionTrackingSucceededListener; OnSessionTrackingFailedListener onSessionTrackingFailedListener; OnDeferredDeeplinkResponseListener onDeferredDeeplinkResponseListener; - boolean sendInBackground; + boolean isSendingInBackgroundEnabled; AdjustInstance.PreLaunchActions preLaunchActions; ILogger logger; String pushToken; Boolean startEnabled; boolean startOffline; String externalDeviceId; - boolean preinstallTrackingEnabled; - Boolean needsCost; + boolean isPreinstallTrackingEnabled; + boolean isCostDataInAttributionEnabled; List urlStrategyDomains; boolean useSubdomains; boolean isDataResidency; String preinstallFilePath; String fbAppId; - boolean shouldReadDeviceIdsOnce; + boolean isDeviceIdsReadingOnceEnabled; OnDeeplinkResolvedListener cachedDeeplinkResolutionCallback; ArrayList cachedAdidReadCallbacks = new ArrayList<>(); Integer eventDeduplicationIdsMaxSize; @@ -77,20 +76,20 @@ private void init(Context context, String appToken, String environment, boolean this.environment = environment; // default values - this.sendInBackground = false; - this.preinstallTrackingEnabled = false; - this.shouldReadDeviceIdsOnce = false; - } - - - public void setSendInBackground(boolean sendInBackground) { - this.sendInBackground = sendInBackground; + this.isSendingInBackgroundEnabled = false; + this.isPreinstallTrackingEnabled = false; + this.isDeviceIdsReadingOnceEnabled = false; + this.isCostDataInAttributionEnabled = false; } public void setLogLevel(LogLevel logLevel) { setLogLevel(logLevel, environment); } + private void setLogLevel(LogLevel logLevel, String environment) { + logger.setLogLevel(logLevel, AdjustConfig.ENVIRONMENT_PRODUCTION.equals(environment)); + } + public void setSdkPrefix(String sdkPrefix) { this.sdkPrefix = sdkPrefix; } @@ -103,74 +102,70 @@ public void setDefaultTracker(String defaultTracker) { this.defaultTracker = defaultTracker; } - public void setOnAttributionChangedListener(OnAttributionChangedListener onAttributionChangedListener) { - this.onAttributionChangedListener = onAttributionChangedListener; + public void setExternalDeviceId(String externalDeviceId) { + this.externalDeviceId = externalDeviceId; } - public void setOnEventTrackingSucceededListener(OnEventTrackingSucceededListener onEventTrackingSucceededListener) { - this.onEventTrackingSucceededListener = onEventTrackingSucceededListener; + public void setPreinstallFilePath(String preinstallFilePath) { + this.preinstallFilePath = preinstallFilePath; } - public void setOnEventTrackingFailedListener(OnEventTrackingFailedListener onEventTrackingFailedListener) { - this.onEventTrackingFailedListener = onEventTrackingFailedListener; + public void setFbAppId(String fbAppId) { + this.fbAppId = fbAppId; } - public void setOnSessionTrackingSucceededListener(OnSessionTrackingSucceededListener onSessionTrackingSucceededListener) { - this.onSessionTrackingSucceededListener = onSessionTrackingSucceededListener; + public void setEventDeduplicationIdsMaxSize(Integer eventDeduplicationIdsMaxSize) { + this.eventDeduplicationIdsMaxSize = eventDeduplicationIdsMaxSize; } - public void setOnSessionTrackingFailedListener(OnSessionTrackingFailedListener onSessionTrackingFailedListener) { - this.onSessionTrackingFailedListener = onSessionTrackingFailedListener; + public void setUrlStrategy(List domains, boolean useSubdomains, boolean isDataResidency) { + if (domains == null || domains.isEmpty()) { + logger.error("Invalid URL strategy domains array"); + return; + } + this.urlStrategyDomains = domains; + this.useSubdomains = useSubdomains; + this.isDataResidency = isDataResidency; } - public void setOnDeferredDeeplinkResponseListener(OnDeferredDeeplinkResponseListener onDeferredDeeplinkResponseListener) { - this.onDeferredDeeplinkResponseListener = onDeferredDeeplinkResponseListener; + public void enablePreinstallTracking() { + this.isPreinstallTrackingEnabled = true; } - public void setExternalDeviceId(String externalDeviceId) { - this.externalDeviceId = externalDeviceId; + public void enableCostDataInAttribution() { + this.isCostDataInAttributionEnabled = true; } - public void setPreinstallTrackingEnabled(boolean preinstallTrackingEnabled) { - this.preinstallTrackingEnabled = preinstallTrackingEnabled; + public void enableSendingInBackground() { + this.isSendingInBackgroundEnabled = true; } - public void setPreinstallFilePath(String preinstallFilePath) { - this.preinstallFilePath = preinstallFilePath; + public void enableDeviceIdsReadingOnce() { + this.isDeviceIdsReadingOnceEnabled = true; } - public void setNeedsCost(boolean needsCost) { - this.needsCost = needsCost; + public void setOnAttributionChangedListener(OnAttributionChangedListener onAttributionChangedListener) { + this.onAttributionChangedListener = onAttributionChangedListener; } - public void setFbAppId(String fbAppId) { - this.fbAppId = fbAppId; + public void setOnEventTrackingSucceededListener(OnEventTrackingSucceededListener onEventTrackingSucceededListener) { + this.onEventTrackingSucceededListener = onEventTrackingSucceededListener; } - public boolean isValid() { - if (!checkAppToken(appToken)) return false; - if (!checkEnvironment(environment)) return false; - if (!checkContext(context)) return false; - - return true; + public void setOnEventTrackingFailedListener(OnEventTrackingFailedListener onEventTrackingFailedListener) { + this.onEventTrackingFailedListener = onEventTrackingFailedListener; } - public void setUrlStrategy(List domains, boolean useSubdomains, boolean isDataResidency) { - if (domains == null || domains.isEmpty()) { - logger.error("Invalid url strategy"); - return; - } - this.urlStrategyDomains = domains; - this.useSubdomains = useSubdomains; - this.isDataResidency = isDataResidency; + public void setOnSessionTrackingSucceededListener(OnSessionTrackingSucceededListener onSessionTrackingSucceededListener) { + this.onSessionTrackingSucceededListener = onSessionTrackingSucceededListener; } - public void readDeviceIdsOnce() { - this.shouldReadDeviceIdsOnce = true; + public void setOnSessionTrackingFailedListener(OnSessionTrackingFailedListener onSessionTrackingFailedListener) { + this.onSessionTrackingFailedListener = onSessionTrackingFailedListener; } - public void setEventDeduplicationIdsMaxSize(Integer eventDeduplicationIdsMaxSize) { - this.eventDeduplicationIdsMaxSize = eventDeduplicationIdsMaxSize; + public void setOnDeferredDeeplinkResponseListener(OnDeferredDeeplinkResponseListener onDeferredDeeplinkResponseListener) { + this.onDeferredDeeplinkResponseListener = onDeferredDeeplinkResponseListener; } public String getBasePath() { @@ -213,92 +208,84 @@ public String getDefaultTracker() { return defaultTracker; } - public OnAttributionChangedListener getOnAttributionChangedListener() { - return onAttributionChangedListener; - } - - public Class getDeepLinkComponent() { - return deepLinkComponent; - } - - public Integer getEventDeduplicationIdsMaxSize() { - return eventDeduplicationIdsMaxSize; + public String getPushToken() { + return pushToken; } - public OnEventTrackingSucceededListener getOnEventTrackingSucceededListener() { - return onEventTrackingSucceededListener; + public Boolean getStartEnabled() { + return startEnabled; } - public OnEventTrackingFailedListener getOnEventTrackingFailedListener() { - return onEventTrackingFailedListener; + public boolean isStartOffline() { + return startOffline; } - public OnSessionTrackingSucceededListener getOnSessionTrackingSucceededListener() { - return onSessionTrackingSucceededListener; + public String getExternalDeviceId() { + return externalDeviceId; } - public OnSessionTrackingFailedListener getOnSessionTrackingFailedListener() { - return onSessionTrackingFailedListener; + public boolean isPreinstallTrackingEnabled() { + return isPreinstallTrackingEnabled; } - public OnDeferredDeeplinkResponseListener getOnDeeplinkResponseListener() { - return onDeferredDeeplinkResponseListener; + public Boolean getCostDataInAttributionEnabled() { + return isCostDataInAttributionEnabled; } - public boolean isSendInBackground() { - return sendInBackground; + public boolean isSendingInBackgroundEnabled() { + return isSendingInBackgroundEnabled; } - public AdjustInstance.PreLaunchActions getPreLaunchActions() { - return preLaunchActions; + public Integer getEventDeduplicationIdsMaxSize() { + return eventDeduplicationIdsMaxSize; } - public ILogger getLogger() { - return logger; + public List getUrlStrategyDomains() { + return urlStrategyDomains; } - public String getPushToken() { - return pushToken; + public String getPreinstallFilePath() { + return preinstallFilePath; } - public Boolean getStartEnabled() { - return startEnabled; + public String getFbAppId() { + return fbAppId; } - public boolean isStartOffline() { - return startOffline; + public boolean isDeviceIdsReadingOnceEnabled() { + return isDeviceIdsReadingOnceEnabled; } - public String getExternalDeviceId() { - return externalDeviceId; + public OnAttributionChangedListener getOnAttributionChangedListener() { + return onAttributionChangedListener; } - public boolean isPreinstallTrackingEnabled() { - return preinstallTrackingEnabled; + public OnEventTrackingSucceededListener getOnEventTrackingSucceededListener() { + return onEventTrackingSucceededListener; } - public Boolean getNeedsCost() { - return needsCost; + public OnEventTrackingFailedListener getOnEventTrackingFailedListener() { + return onEventTrackingFailedListener; } - public List getUrlStrategyDomains() { - return urlStrategyDomains; + public OnSessionTrackingSucceededListener getOnSessionTrackingSucceededListener() { + return onSessionTrackingSucceededListener; } - public String getPreinstallFilePath() { - return preinstallFilePath; + public OnSessionTrackingFailedListener getOnSessionTrackingFailedListener() { + return onSessionTrackingFailedListener; } - public String getFbAppId() { - return fbAppId; + public OnDeferredDeeplinkResponseListener getOnDeeplinkResponseListener() { + return onDeferredDeeplinkResponseListener; } - public boolean shouldReadDeviceIdsOnce() { - return shouldReadDeviceIdsOnce; + public AdjustInstance.PreLaunchActions getPreLaunchActions() { + return preLaunchActions; } - private void setLogLevel(LogLevel logLevel, String environment) { - logger.setLogLevel(logLevel, AdjustConfig.ENVIRONMENT_PRODUCTION.equals(environment)); + public ILogger getLogger() { + return logger; } private boolean checkContext(Context context) { @@ -352,4 +339,17 @@ private boolean checkEnvironment(String environment) { logger.error("Unknown environment '%s'", environment); return false; } + + public boolean isValid() { + if (!checkAppToken(appToken)) { + return false; + } + if (!checkEnvironment(environment)) { + return false; + } + if (!checkContext(context)) { + return false; + } + return true; + } } \ No newline at end of file diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/DeviceInfo.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/DeviceInfo.java index 8d7a23183..25e8c8756 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/DeviceInfo.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/DeviceInfo.java @@ -140,7 +140,7 @@ class DeviceInfo { } void reloadPlayIds(final AdjustConfig adjustConfig, boolean coppaEnabled, boolean playStoreKidsAppEnabled) { - if (playIdsReadOnce && adjustConfig.shouldReadDeviceIdsOnce) { + if (playIdsReadOnce && adjustConfig.isDeviceIdsReadingOnceEnabled) { if (!Util.canReadPlayIds(adjustConfig, coppaEnabled, playStoreKidsAppEnabled)) { playAdId = null; isTrackingEnabled = null; @@ -250,7 +250,7 @@ void reloadNonPlayIds(final AdjustConfig adjustConfig, boolean coppaEnabled, boo void reloadOtherDeviceInfoParams(final AdjustConfig adjustConfig, final boolean coppaEnabled, final ILogger logger) { - if (adjustConfig.shouldReadDeviceIdsOnce && otherDeviceIdsParamsReadOnce) { + if (adjustConfig.isDeviceIdsReadingOnceEnabled && otherDeviceIdsParamsReadOnce) { return; } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java index 71266884e..5c73b4023 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java @@ -278,7 +278,7 @@ private Map getSessionParameters() { PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -369,7 +369,7 @@ public Map getEventParameters(AdjustEvent event) { PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "currency", event.currency); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -455,7 +455,7 @@ private Map getInfoParameters(String source) { PackageBuilder.addString(parameters, "app_token", adjustConfig.appToken); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "environment", adjustConfig.environment); PackageBuilder.addString(parameters, "external_device_id", adjustConfig.externalDeviceId); PackageBuilder.addBoolean(parameters, "needs_response_details", true); @@ -530,7 +530,7 @@ private Map getClickParameters(String source) { PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "deeplink", deeplink); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -627,7 +627,7 @@ private Map getAttributionParameters(String initiatedBy) { PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); PackageBuilder.addLong(parameters, "ui_mode", deviceInfo.uiMode); @@ -692,7 +692,7 @@ private Map getGdprParameters() { PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); PackageBuilder.addLong(parameters, "ui_mode", deviceInfo.uiMode); @@ -910,7 +910,7 @@ private Map getAdRevenueParameters(AdjustAdRevenue adjustAdReven PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -1008,7 +1008,7 @@ private Map getSubscriptionParameters(AdjustPlayStoreSubscriptio PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -1103,7 +1103,7 @@ private Map getVerificationParameters(AdjustPlayStorePurchase pu PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -1193,7 +1193,7 @@ private Map getVerificationParameters(AdjustEvent event) { PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); diff --git a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js index b38737c74..841c1ef4a 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js +++ b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js @@ -209,34 +209,35 @@ var Adjust = { } }, - getAmazonAdId: function (callbackSuccess,callbackFail) { - if (AdjustBridge) { - if (typeof callbackSuccess === 'string' || callbackSuccess instanceof String) { - this.getAmazonIdCallbackSuccessName = callbackSuccess; - } else { - this.getAmazonIdCallbackSuccessName = 'Adjust.adjust_getAmazonIdCallbackSuccess'; - this.getAmazonIdCallbackSuccessFunction = callbackSuccess; - } - if (typeof callbackFail === 'string' || callbackFail instanceof String) { - this.getAmazonIdCallbackFailName = callbackFail; - } else { - this.getAmazonIdCallbackFailName = 'Adjust.adjust_getAmazonIdCallbackFail'; - this.getAmazonIdCallbackFailFunction = callbackFail; - } - AdjustBridge.getAmazonAdId(this.getAmazonIdCallbackSuccessName,this.getAmazonIdCallbackFailName); + getAmazonAdId: function (callbackSuccess,callbackFail) { + if (AdjustBridge) { + if (typeof callbackSuccess === 'string' || callbackSuccess instanceof String) { + this.getAmazonIdCallbackSuccessName = callbackSuccess; + } else { + this.getAmazonIdCallbackSuccessName = 'Adjust.adjust_getAmazonIdCallbackSuccess'; + this.getAmazonIdCallbackSuccessFunction = callbackSuccess; } - }, - - adjust_getAmazonIdCallbackSuccess: function (amazonId) { - if (AdjustBridge && this.getAmazonIdCallbackSuccessFunction) { - this.getAmazonIdCallbackSuccessFunction(amazonId); - } - }, - adjust_getAmazonIdCallbackFail: function (message) { - if (AdjustBridge && this.getAmazonIdCallbackFailFunction) { - this.getAmazonIdCallbackFailName(message); + if (typeof callbackFail === 'string' || callbackFail instanceof String) { + this.getAmazonIdCallbackFailName = callbackFail; + } else { + this.getAmazonIdCallbackFailName = 'Adjust.adjust_getAmazonIdCallbackFail'; + this.getAmazonIdCallbackFailFunction = callbackFail; + } + AdjustBridge.getAmazonAdId(this.getAmazonIdCallbackSuccessName,this.getAmazonIdCallbackFailName); } - }, + }, + + adjust_getAmazonIdCallbackSuccess: function (amazonId) { + if (AdjustBridge && this.getAmazonIdCallbackSuccessFunction) { + this.getAmazonIdCallbackSuccessFunction(amazonId); + } + }, + + adjust_getAmazonIdCallbackFail: function (message) { + if (AdjustBridge && this.getAmazonIdCallbackFailFunction) { + this.getAmazonIdCallbackFailName(message); + } + }, getAttribution: function (callback) { if (AdjustBridge) { diff --git a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js index a536c97e2..f8aa13dbe 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js +++ b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js @@ -19,7 +19,7 @@ function AdjustConfig(appToken, environment, legacy) { } } - this.sendInBackground = null; + this.isSendingInBackgroundEnabled = null; this.logLevel = null; this.sdkPrefix = null; this.processName = null; @@ -27,7 +27,7 @@ function AdjustConfig(appToken, environment, legacy) { this.externalDeviceId = null; this.attributionCallbackName = null; this.attributionCallbackFunction = null; - this.needsCost = null; + this.isCostDataInAttributionEnabled = null; this.eventSuccessCallbackName = null; this.eventSuccessCallbackFunction = null; this.eventFailureCallbackName = null; @@ -36,7 +36,7 @@ function AdjustConfig(appToken, environment, legacy) { this.sessionSuccessCallbackFunction = null; this.sessionFailureCallbackName = null; this.sessionFailureCallbackFunction = null; - this.openDeferredDeeplink = null; + this.isOpeningDeferredDeeplinkEnabled = null; this.deferredDeeplinkCallbackName = null; this.deferredDeeplinkCallbackFunction = null; this.fbPixelDefaultEventToken = null; @@ -44,7 +44,7 @@ function AdjustConfig(appToken, environment, legacy) { this.urlStrategy = []; this.useSubDomain = null; this.isDataResidency = null; - this.preinstallTrackingEnabled = null; + this.isPreinstallTrackingEnabled = null; this.preinstallFilePath = null; this.fbAppId = null; this.shouldReadDeviceIdsOnce = null; @@ -66,8 +66,8 @@ AdjustConfig.prototype.getBridge = function() { return this.bridge; }; -AdjustConfig.prototype.setSendInBackground = function(isEnabled) { - this.sendInBackground = isEnabled; +AdjustConfig.prototype.enableSendingInBackground = function() { + this.isSendingInBackgroundEnabled = true; }; AdjustConfig.prototype.setLogLevel = function(logLevel) { @@ -109,8 +109,8 @@ AdjustConfig.prototype.adjust_attributionCallback = function(attribution) { } }; -AdjustConfig.prototype.setNeedsCost = function(needsCost) { - this.needsCost = needsCost; +AdjustConfig.prototype.enableCostDataInAttribution = function() { + this.isCostDataInAttributionEnabled = true; }; AdjustConfig.prototype.setEventSuccessCallback = function(callback) { @@ -173,8 +173,8 @@ AdjustConfig.prototype.adjust_sessionFailureCallback = function(sessionFailure) } }; -AdjustConfig.prototype.setOpenDeferredDeeplink = function(shouldOpen) { - this.openDeferredDeeplink = shouldOpen; +AdjustConfig.prototype.disableDeferredDeeplinkOpening = function() { + this.isOpeningDeferredDeeplinkEnabled = false; }; AdjustConfig.prototype.setDeferredDeeplinkCallback = function(callback) { @@ -209,8 +209,8 @@ AdjustConfig.prototype.setUrlStrategy = function(urlStrategy, useSubDomain , isD this.isDataResidency = isDataResidency; }; -AdjustConfig.prototype.setPreinstallTrackingEnabled = function(preinstallTrackingEnabled) { - this.preinstallTrackingEnabled = preinstallTrackingEnabled; +AdjustConfig.prototype.enablePreinstallTracking = function() { + this.isPreinstallTrackingEnabled = true; }; AdjustConfig.prototype.setPreinstallFilePath = function(preinstallFilePath) { diff --git a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java index 6c114caaa..2b757907a 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java +++ b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java @@ -57,7 +57,7 @@ public class AdjustBridgeInstance { private WebView webView; private Application application; private boolean isInitialized = false; - private boolean shouldDeferredDeeplinkBeLaunched = true; + private boolean isOpeningDeferredDeeplinkEnabled = true; private FacebookSDKJSInterface facebookSDKJSInterface = null; private String adjustSdkPrefix = null; @@ -149,26 +149,26 @@ public void initSdk(String adjustConfigString) { Object appTokenField = jsonAdjustConfig.get("appToken"); Object environmentField = jsonAdjustConfig.get("environment"); Object allowSuppressLogLevelField = jsonAdjustConfig.get("allowSuppressLogLevel"); - Object sendInBackgroundField = jsonAdjustConfig.get("sendInBackground"); + Object isSendingInBackgroundEnabledField = jsonAdjustConfig.get("isSendingInBackgroundEnabled"); Object logLevelField = jsonAdjustConfig.get("logLevel"); Object sdkPrefixField = jsonAdjustConfig.get("sdkPrefix"); Object processNameField = jsonAdjustConfig.get("processName"); Object defaultTrackerField = jsonAdjustConfig.get("defaultTracker"); Object externalDeviceIdField = jsonAdjustConfig.get("externalDeviceId"); Object attributionCallbackNameField = jsonAdjustConfig.get("attributionCallbackName"); - Object needsCostField = jsonAdjustConfig.get("needsCost"); + Object isCostDataInAttributionEnabledField = jsonAdjustConfig.get("isCostDataInAttributionEnabled"); Object eventSuccessCallbackNameField = jsonAdjustConfig.get("eventSuccessCallbackName"); Object eventFailureCallbackNameField = jsonAdjustConfig.get("eventFailureCallbackName"); Object sessionSuccessCallbackNameField = jsonAdjustConfig.get("sessionSuccessCallbackName"); Object sessionFailureCallbackNameField = jsonAdjustConfig.get("sessionFailureCallbackName"); - Object openDeferredDeeplinkField = jsonAdjustConfig.get("openDeferredDeeplink"); + Object isOpeningDeferredDeeplinkEnabledField = jsonAdjustConfig.get("isOpeningDeferredDeeplinkEnabled"); Object deferredDeeplinkCallbackNameField = jsonAdjustConfig.get("deferredDeeplinkCallbackName"); Object fbPixelDefaultEventTokenField = jsonAdjustConfig.get("fbPixelDefaultEventToken"); Object fbPixelMappingField = jsonAdjustConfig.get("fbPixelMapping"); Object urlStrategyField = jsonAdjustConfig.get("urlStrategy"); Object useSubDomainField = jsonAdjustConfig.get("useSubDomain"); Object isDataResidencyField = jsonAdjustConfig.get("isDataResidency"); - Object preinstallTrackingEnabledField = jsonAdjustConfig.get("preinstallTrackingEnabled"); + Object isPreinstallTrackingEnabledField = jsonAdjustConfig.get("isPreinstallTrackingEnabled"); Object preinstallFilePathField = jsonAdjustConfig.get("preinstallFilePath"); Object fbAppIdField = jsonAdjustConfig.get("fbAppId"); Object shouldReadDeviceIdsOnceField = jsonAdjustConfig.get("shouldReadDeviceIdsOnce"); @@ -190,9 +190,11 @@ public void initSdk(String adjustConfigString) { } // Send in the background - Boolean sendInBackground = AdjustBridgeUtil.fieldToBoolean(sendInBackgroundField); - if (sendInBackground != null) { - adjustConfig.setSendInBackground(sendInBackground); + Boolean isSendingInBackgroundEnabled = AdjustBridgeUtil.fieldToBoolean(isSendingInBackgroundEnabledField); + if (isSendingInBackgroundEnabled != null) { + if (isSendingInBackgroundEnabled) { + adjustConfig.enableSendingInBackground(); + } } // Log level @@ -252,9 +254,11 @@ public void onAttributionChanged(AdjustAttribution attribution) { } // Needs cost - Boolean needsCost = AdjustBridgeUtil.fieldToBoolean(needsCostField); - if (needsCost != null) { - adjustConfig.setNeedsCost(needsCost); + Boolean isCostDataInAttributionEnabled = AdjustBridgeUtil.fieldToBoolean(isCostDataInAttributionEnabledField); + if (isCostDataInAttributionEnabled != null) { + if (isCostDataInAttributionEnabled) { + adjustConfig.enableCostDataInAttribution(); + } } // Event success callback @@ -300,9 +304,9 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure failureResponse } // Should deferred deep link be opened? - Boolean openDeferredDeeplink = AdjustBridgeUtil.fieldToBoolean(openDeferredDeeplinkField); - if (openDeferredDeeplink != null) { - shouldDeferredDeeplinkBeLaunched = openDeferredDeeplink; + Boolean isOpeningDeferredDeeplinkEnabled = AdjustBridgeUtil.fieldToBoolean(isOpeningDeferredDeeplinkEnabledField); + if (isOpeningDeferredDeeplinkEnabled != null) { + this.isOpeningDeferredDeeplinkEnabled = isOpeningDeferredDeeplinkEnabled; } // Deferred deeplink callback @@ -312,7 +316,7 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure failureResponse @Override public boolean launchReceivedDeeplink(Uri deeplink) { AdjustBridgeUtil.execSingleValueCallback(webView, deferredDeeplinkCallbackName, deeplink.toString()); - return shouldDeferredDeeplinkBeLaunched; + return isOpeningDeferredDeeplinkEnabled; } }); } @@ -348,9 +352,11 @@ public boolean launchReceivedDeeplink(Uri deeplink) { } // Preinstall tracking - Boolean preinstallTrackingEnabled = AdjustBridgeUtil.fieldToBoolean(preinstallTrackingEnabledField); - if (preinstallTrackingEnabled != null) { - adjustConfig.setPreinstallTrackingEnabled(preinstallTrackingEnabled); + Boolean isPreinstallTrackingEnabled = AdjustBridgeUtil.fieldToBoolean(isPreinstallTrackingEnabledField); + if (isPreinstallTrackingEnabled != null) { + if (isPreinstallTrackingEnabled) { + adjustConfig.enablePreinstallTracking(); + } } // Preinstall secondary file path @@ -368,7 +374,7 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // read device info once Boolean shouldReadDeviceIdsOnce = AdjustBridgeUtil.fieldToBoolean(shouldReadDeviceIdsOnceField); if (shouldReadDeviceIdsOnce != null && shouldReadDeviceIdsOnce.booleanValue()) { - adjustConfig.readDeviceIdsOnce(); + adjustConfig.enableDeviceIdsReadingOnce(); } Integer eventDeduplicationIdsMaxSize = AdjustBridgeUtil.fieldToInteger(eventDeduplicationIdsMaxSizeField); @@ -770,7 +776,7 @@ public void fbPixelEvent(String pixelId, String event_name, String jsonString) { @JavascriptInterface public void teardown() { isInitialized = false; - shouldDeferredDeeplinkBeLaunched = true; + isOpeningDeferredDeeplinkEnabled = true; } public void setWebView(WebView webView) { diff --git a/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java b/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java index 3b178053a..371b9092c 100644 --- a/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java +++ b/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java @@ -284,23 +284,20 @@ private void config() { adjustConfig.setDefaultTracker(defaultTracker); } -// if (command.containsParameter("externalDeviceId")) { -// String externalDeviceId = command.getFirstParameterValue("externalDeviceId"); -// adjustConfig.setExternalDeviceId(externalDeviceId); -// } - - if (command.containsParameter("needsCost")) { - String needsCostS = command.getFirstParameterValue("needsCost"); - boolean needsCost = "true".equals(needsCostS); - adjustConfig.setNeedsCost(needsCost); + String isCostDataInAttributionEnabledS = command.getFirstParameterValue("needsCost"); + boolean isCostDataInAttributionEnabled = "true".equals(isCostDataInAttributionEnabledS); + if (isCostDataInAttributionEnabled) { + adjustConfig.enableCostDataInAttribution(); + } } - if (command.containsParameter("sendInBackground")) { - String sendInBackgroundS = command.getFirstParameterValue("sendInBackground"); - boolean sendInBackground = "true".equals(sendInBackgroundS); - adjustConfig.setSendInBackground(sendInBackground); + String isSendingInBackgroundEnabledS = command.getFirstParameterValue("sendInBackground"); + boolean isSendingInBackgroundEnabled = "true".equals(isSendingInBackgroundEnabledS); + if (isSendingInBackgroundEnabled) { + adjustConfig.enableSendingInBackground(); + } } if (command.containsParameter("eventDeduplicationIdsMaxSize")) { diff --git a/Adjust/test-app-webbridge/src/main/assets/command_executor.js b/Adjust/test-app-webbridge/src/main/assets/command_executor.js index 66a823d00..3b4df1d21 100644 --- a/Adjust/test-app-webbridge/src/main/assets/command_executor.js +++ b/Adjust/test-app-webbridge/src/main/assets/command_executor.js @@ -298,15 +298,19 @@ AdjustCommandExecutor.prototype.config = function(params) { } if ('needsCost' in params) { - var needsCostS = getFirstParameterValue(params, 'needsCost'); - var needsCost = needsCostS == 'true'; - adjustConfig.setNeedsCost(needsCost); + var isCostDataInAttributionEnabledS = getFirstParameterValue(params, 'needsCost'); + var isCostDataInAttributionEnabled = isCostDataInAttributionEnabledS == 'true'; + if (isCostDataInAttributionEnabled == true) { + adjustConfig.enableCostDataInAttribution(); + } } if ('sendInBackground' in params) { - var sendInBackgroundS = getFirstParameterValue(params, 'sendInBackground'); - var sendInBackground = sendInBackgroundS == 'true'; - adjustConfig.setSendInBackground(sendInBackground); + var isSendingInBackgroundEnabledS = getFirstParameterValue(params, 'sendInBackground'); + var isSendingInBackgroundEnabled = isSendingInBackgroundEnabledS == 'true'; + if (isSendingInBackgroundEnabled == true) { + adjustConfig.enableSendingInBackground(); + } } if ('eventDeduplicationIdsMaxSize' in params) { @@ -390,9 +394,12 @@ AdjustCommandExecutor.prototype.config = function(params) { if ('deferredDeeplinkCallback' in params) { var basePath = this.basePath; - var openDeeplinkS = getFirstParameterValue(params, 'deferredDeeplinkCallback'); - var openDeeplink = openDeeplinkS == 'true'; - adjustConfig.setOpenDeferredDeeplink(openDeeplink); + var isOpeningDeferredDeeplinkEnabledS = getFirstParameterValue(params, 'deferredDeeplinkCallback'); + var isOpeningDeferredDeeplinkEnabled = isOpeningDeferredDeeplinkEnabledS == 'true'; + if (isOpeningDeferredDeeplinkEnabled == false) { + adjustConfig.disableDeferredDeeplinkOpening(); + } + adjustConfig.setDeferredDeeplinkCallback(function(deeplink) { TestLibrary.addInfoToSend("deeplink", deeplink); TestLibrary.sendInfoToServer(basePath); From e324bdf07f122b652c3417bef174a9b3bf059025 Mon Sep 17 00:00:00 2001 From: uerceg Date: Fri, 31 May 2024 13:37:07 +0200 Subject: [PATCH 06/12] fix: fix getSdkVersion logic in web bridge --- .../src/main/assets/adjust.js | 16 ++++++++-------- .../sdk/webbridge/AdjustBridgeInstance.java | 3 --- .../src/main/assets/AdjustTestApp-WebView.html | 4 +++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js index 841c1ef4a..553434cb3 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js +++ b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js @@ -259,19 +259,19 @@ var Adjust = { getSdkVersion: function (callback) { if (AdjustBridge) { - if (typeof callback === 'string' || callback instanceof String) { - this.getSdkVersionCallbackName = callback; - } else { - this.getSdkVersionCallbackName = 'Adjust.adjust_getSdkVersionCallback'; - this.getSdkVersionCallbackFunction = callback; - } - AdjustBridge.getSdkVersion(this.getSdkVersionCallbackName); + if (typeof callback === 'string' || callback instanceof String) { + this.getSdkVersionCallbackName = callback; + } else { + this.getSdkVersionCallbackName = 'Adjust.adjust_getSdkVersionCallback'; + this.getSdkVersionCallbackFunction = callback; } + AdjustBridge.getSdkVersion(this.getSdkVersionCallbackName); + } }, adjust_getSdkVersionCallback: function (sdkVersion) { if (AdjustBridge && this.getSdkVersionCallbackFunction) { - this.getSdkVersionCallbackFunction(sdkVersion); + this.getSdkVersionCallbackFunction(this.getSdkPrefix() + '@' + sdkVersion); } }, diff --git a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java index 2b757907a..fa186f672 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java +++ b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java @@ -760,9 +760,6 @@ public void getSdkVersion(final String callback) { Adjust.getSdkVersion(new OnSdkVersionReadListener() { @Override public void onSdkVersionRead(String sdkVersion) { - if (adjustSdkPrefix != null && adjustSdkPrefix.length() > 0) { - sdkVersion = adjustSdkPrefix + "@" + sdkVersion; - } AdjustBridgeUtil.execSingleValueCallback(webView, callback, sdkVersion); } }); diff --git a/Adjust/test-app-webbridge/src/main/assets/AdjustTestApp-WebView.html b/Adjust/test-app-webbridge/src/main/assets/AdjustTestApp-WebView.html index e4a0ed006..846e4880d 100755 --- a/Adjust/test-app-webbridge/src/main/assets/AdjustTestApp-WebView.html +++ b/Adjust/test-app-webbridge/src/main/assets/AdjustTestApp-WebView.html @@ -22,7 +22,9 @@

Adjust Web View SDK Test

window.onload = function() { // TestLibrary.addTestDirectory('current/user-agent'); // TestLibrary.addTest('current/deeplink-deferred/Test_DeferredDeeplink_callback_false'); - TestLibrary.startTestSession(Adjust.getSdkVersion()); + Adjust.getSdkVersion(function(sdkVersion) { + TestLibrary.startTestSession(sdkVersion); + }); }
From d2b41d1e347182c03ddcde39df58da2ee44c577e Mon Sep 17 00:00:00 2001 From: uerceg Date: Fri, 31 May 2024 14:05:20 +0200 Subject: [PATCH 07/12] chore: fix code alignment --- .../test-app-webbridge/src/main/assets/command_executor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Adjust/test-app-webbridge/src/main/assets/command_executor.js b/Adjust/test-app-webbridge/src/main/assets/command_executor.js index 3b4df1d21..9d4c934a3 100644 --- a/Adjust/test-app-webbridge/src/main/assets/command_executor.js +++ b/Adjust/test-app-webbridge/src/main/assets/command_executor.js @@ -293,9 +293,9 @@ AdjustCommandExecutor.prototype.config = function(params) { } if ('externalDeviceId' in params) { - var externalDeviceId = getFirstParameterValue(params, 'externalDeviceId'); - adjustConfig.setExternalDeviceId(externalDeviceId); - } + var externalDeviceId = getFirstParameterValue(params, 'externalDeviceId'); + adjustConfig.setExternalDeviceId(externalDeviceId); + } if ('needsCost' in params) { var isCostDataInAttributionEnabledS = getFirstParameterValue(params, 'needsCost'); From b967fe56fbcfad9a02fc41bdab99dee47a057615 Mon Sep 17 00:00:00 2001 From: Shashank Suhane Date: Fri, 31 May 2024 14:30:46 +0200 Subject: [PATCH 08/12] feat: add signature library missing check --- .../src/main/java/com/adjust/sdk/AdjustInstance.java | 4 ++++ .../src/main/java/com/adjust/sdk/AdjustSigner.java | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java index fb09c786e..0370312ca 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java @@ -79,6 +79,10 @@ public PreLaunchActions() { * @param adjustConfig AdjustConfig object used for SDK initialisation */ public void initSdk(final AdjustConfig adjustConfig) { + if (!AdjustSigner.isPresent()) { + AdjustFactory.getLogger().error("Missing signature library, SDK can't be initialised"); + return; + } if (adjustConfig == null) { AdjustFactory.getLogger().error("AdjustConfig missing"); return; diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustSigner.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustSigner.java index 2d084b975..18c62fb0a 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustSigner.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustSigner.java @@ -13,6 +13,16 @@ public class AdjustSigner { private AdjustSigner() { } + public static boolean isPresent() { + getSignerInstance(); + + if (signerInstance != null) { + return true; + } + + return false; + } + public static void onResume(ILogger logger){ getSignerInstance(); From 597cd722c7c0aa6f5f6be92f6f1e3d778d5f24c2 Mon Sep 17 00:00:00 2001 From: Shashank Suhane Date: Fri, 31 May 2024 14:34:28 +0200 Subject: [PATCH 09/12] feat: update version to 5.0.0-SNAPSHOT --- Adjust/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adjust/build.gradle b/Adjust/build.gradle index 54ab560ce..a9495314e 100644 --- a/Adjust/build.gradle +++ b/Adjust/build.gradle @@ -9,7 +9,7 @@ ext { coreMinSdkVersion = 21 coreCompileSdkVersion = 34 coreTargetSdkVersion = 34 - coreVersionName = '5.0.0' + coreVersionName = '5.0.0-SNAPSHOT' defaultVersionCode = 1 webbridgeMinSdkVersion = 21 samsungReferrerMinSdkVersion = 21 From 7d94a118edb6d77a2540e0ccea88d84ddcffc1a6 Mon Sep 17 00:00:00 2001 From: Mahdi ZTD Date: Fri, 31 May 2024 14:57:08 +0200 Subject: [PATCH 10/12] fix: fix usage of enableSendingInBackground in examples --- .../examples/keyboard/GlobalApplication.java | 2 +- .../com/adjust/examples/GlobalApplication.java | 2 +- .../testappwebbridge/ExampleUnitTest.java | 17 ----------------- 3 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 Adjust/test-app-webbridge/src/test/java/com/example/testappwebbridge/ExampleUnitTest.java diff --git a/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java b/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java index b0919b818..04dac06e8 100644 --- a/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java +++ b/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java @@ -101,7 +101,7 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // config.setProcessName("com.adjust.examples"); // Allow to send in the background. - config.enableSendingInBackground(true); + config.enableSendingInBackground(); // Add session callback parameters. Adjust.addGlobalCallbackParameter("sc_foo", "sc_bar"); diff --git a/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java index d4dccd525..93284e4f1 100755 --- a/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java @@ -98,7 +98,7 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // config.setProcessName("com.adjust.examples"); // Allow to send in the background. - config.enableSendingInBackground(true); + config.enableSendingInBackground(); // Add session callback parameters. Adjust.addGlobalCallbackParameter("sc_foo", "sc_bar"); diff --git a/Adjust/test-app-webbridge/src/test/java/com/example/testappwebbridge/ExampleUnitTest.java b/Adjust/test-app-webbridge/src/test/java/com/example/testappwebbridge/ExampleUnitTest.java deleted file mode 100644 index 020b2e22e..000000000 --- a/Adjust/test-app-webbridge/src/test/java/com/example/testappwebbridge/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.testappwebbridge; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file From c6ddea066150caf126bd5fa68b42bf4d58d6c58f Mon Sep 17 00:00:00 2001 From: Mahdi ZTD Date: Fri, 31 May 2024 15:16:45 +0200 Subject: [PATCH 11/12] fix: remove activityLifeCycle registration in example tv and keyboard --- .../examples/keyboard/GlobalApplication.java | 43 +------------------ .../adjust/examples/GlobalApplication.java | 42 +----------------- 2 files changed, 4 insertions(+), 81 deletions(-) diff --git a/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java b/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java index 04dac06e8..55f30b016 100644 --- a/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java +++ b/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java @@ -1,9 +1,7 @@ package com.adjust.examples.keyboard; -import android.app.Activity; import android.app.Application; import android.net.Uri; -import android.os.Bundle; import android.util.Log; import com.adjust.sdk.Adjust; @@ -11,6 +9,8 @@ import com.adjust.sdk.AdjustConfig; import com.adjust.sdk.AdjustEventFailure; import com.adjust.sdk.AdjustEventSuccess; +import com.adjust.sdk.AdjustSessionFailure; +import com.adjust.sdk.AdjustSessionSuccess; import com.adjust.sdk.LogLevel; import com.adjust.sdk.OnAttributionChangedListener; import com.adjust.sdk.OnDeferredDeeplinkResponseListener; @@ -18,8 +18,6 @@ import com.adjust.sdk.OnEventTrackingSucceededListener; import com.adjust.sdk.OnSessionTrackingFailedListener; import com.adjust.sdk.OnSessionTrackingSucceededListener; -import com.adjust.sdk.AdjustSessionFailure; -import com.adjust.sdk.AdjustSessionSuccess; /** * Created by pfms on 17/12/14. @@ -136,10 +134,6 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // Initialise the adjust SDK. Adjust.initSdk(config); - // Register onResume and onPause events of all activities - // for applications with minSdkVersion >= 14. - registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks()); - // Put the SDK in offline mode. // Adjust.switchToOfflineMode(); @@ -149,37 +143,4 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // Send push notification token. // Adjust.setPushToken("token"); } - - // You can use this class if your app is for Android 4.0 or higher - private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks { - @Override - public void onActivityResumed(Activity activity) { - Adjust.onResume(); - } - - @Override - public void onActivityPaused(Activity activity) { - Adjust.onPause(); - } - - @Override - public void onActivityStopped(Activity activity) { - } - - @Override - public void onActivitySaveInstanceState(Activity activity, Bundle outState) { - } - - @Override - public void onActivityDestroyed(Activity activity) { - } - - @Override - public void onActivityCreated(Activity activity, Bundle savedInstanceState) { - } - - @Override - public void onActivityStarted(Activity activity) { - } - } } diff --git a/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java index 93284e4f1..ff6dce7d4 100755 --- a/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java @@ -1,9 +1,7 @@ package com.adjust.examples; -import android.app.Activity; import android.app.Application; import android.net.Uri; -import android.os.Bundle; import android.util.Log; import com.adjust.sdk.Adjust; @@ -11,6 +9,8 @@ import com.adjust.sdk.AdjustConfig; import com.adjust.sdk.AdjustEventFailure; import com.adjust.sdk.AdjustEventSuccess; +import com.adjust.sdk.AdjustSessionFailure; +import com.adjust.sdk.AdjustSessionSuccess; import com.adjust.sdk.LogLevel; import com.adjust.sdk.OnAttributionChangedListener; import com.adjust.sdk.OnDeferredDeeplinkResponseListener; @@ -18,8 +18,6 @@ import com.adjust.sdk.OnEventTrackingSucceededListener; import com.adjust.sdk.OnSessionTrackingFailedListener; import com.adjust.sdk.OnSessionTrackingSucceededListener; -import com.adjust.sdk.AdjustSessionFailure; -import com.adjust.sdk.AdjustSessionSuccess; public class GlobalApplication extends Application { @Override @@ -123,10 +121,6 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // Initialise the adjust SDK. Adjust.initSdk(config); - // Register onResume and onPause events of all activities - // for applications with minSdkVersion >= 14. - registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks()); - // Put the SDK in offline mode. // Adjust.switchToOfflineMode(); @@ -137,36 +131,4 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // Adjust.setPushToken("token"); } - // You can use this class if your app is for Android 4.0 or higher - private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks { - @Override - public void onActivityResumed(Activity activity) { - Adjust.onResume(); - } - - @Override - public void onActivityPaused(Activity activity) { - Adjust.onPause(); - } - - @Override - public void onActivityStopped(Activity activity) { - } - - @Override - public void onActivitySaveInstanceState(Activity activity, Bundle outState) { - } - - @Override - public void onActivityDestroyed(Activity activity) { - } - - @Override - public void onActivityCreated(Activity activity, Bundle savedInstanceState) { - } - - @Override - public void onActivityStarted(Activity activity) { - } - } } From 51e01137758b3021426207547474e3d994cebfe8 Mon Sep 17 00:00:00 2001 From: Mahdi ZTD Date: Fri, 31 May 2024 16:07:37 +0200 Subject: [PATCH 12/12] fix: renaming the local variable isOpeningDeferredDeeplinkEnabled --- .../java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java index fa186f672..9a8ef1281 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java +++ b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java @@ -304,9 +304,9 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure failureResponse } // Should deferred deep link be opened? - Boolean isOpeningDeferredDeeplinkEnabled = AdjustBridgeUtil.fieldToBoolean(isOpeningDeferredDeeplinkEnabledField); - if (isOpeningDeferredDeeplinkEnabled != null) { - this.isOpeningDeferredDeeplinkEnabled = isOpeningDeferredDeeplinkEnabled; + Boolean isOpeningDeferredDeeplinkEnabledObject = AdjustBridgeUtil.fieldToBoolean(isOpeningDeferredDeeplinkEnabledField); + if (isOpeningDeferredDeeplinkEnabledObject != null) { + isOpeningDeferredDeeplinkEnabled = isOpeningDeferredDeeplinkEnabledObject; } // Deferred deeplink callback