Skip to content

Commit

Permalink
Merge pull request #590 from adjust/v4380
Browse files Browse the repository at this point in the history
Version 4.38.0
  • Loading branch information
shashanksu authored Dec 21, 2023
2 parents 70fa9e9 + cbe9ff7 commit 6b58557
Show file tree
Hide file tree
Showing 26 changed files with 146 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Adjust/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ext {
coreMinSdkVersion = 9
coreCompileSdkVersion = 34
coreTargetSdkVersion = 34
coreVersionName = '4.37.1'
coreVersionName = '4.38.0'
defaultVersionCode = 1
webbridgeMinSdkVersion = 17
samsungReferrerMinSdkVersion = 18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Handler;
import android.text.TextUtils;

import com.adjust.sdk.network.ActivityPackageSender;
import com.adjust.sdk.network.IActivityPackageSender;
Expand Down Expand Up @@ -81,6 +82,7 @@ public class ActivityHandler implements IActivityHandler {
private InstallReferrer installReferrer;
private InstallReferrerHuawei installReferrerHuawei;
private InstallReferrerMeta installReferrerMeta;
private OnDeeplinkResolvedListener cachedDeeplinkResolutionCallback;

@Override
public void teardown() {
Expand Down Expand Up @@ -439,6 +441,16 @@ public void run() {
});
}

public void readOpenUrl(final Uri url, final long clickTime, final OnDeeplinkResolvedListener callback) {
this.cachedDeeplinkResolutionCallback = callback;
executor.submit(new Runnable() {
@Override
public void run() {
readOpenUrlI(url, clickTime);
}
});
}

private void updateAdidI(final String adid) {
if (adid == null) {
return;
Expand Down Expand Up @@ -860,6 +872,7 @@ public void run(ActivityHandler activityHandler) {
logger.info("Default tracker: '%s'", adjustConfig.defaultTracker);
}

// push token
if (adjustConfig.pushToken != null) {
logger.info("Push token: '%s'", adjustConfig.pushToken);
if (internalState.hasFirstSdkStartOcurred()) {
Expand All @@ -878,6 +891,11 @@ public void run(ActivityHandler activityHandler) {
}
}

// cached deep link resolution callback
if (this.cachedDeeplinkResolutionCallback == null) {
this.cachedDeeplinkResolutionCallback = adjustConfig.cachedDeeplinkResolutionCallback;
}

// GDPR
if (internalState.hasFirstSdkStartOcurred()) {
SharedPreferencesManager sharedPreferencesManager = SharedPreferencesManager.getDefaultInstance(getContext());
Expand Down Expand Up @@ -1520,6 +1538,19 @@ private void launchSdkClickResponseTasksI(SdkClickResponseData sdkClickResponseD
if (attributionUpdated) {
launchAttributionListenerI(handler);
}

if (!TextUtils.isEmpty(sdkClickResponseData.resolvedDeeplink)) {
if (cachedDeeplinkResolutionCallback != null) {
Runnable runnable = new Runnable() {
@Override
public void run() {
cachedDeeplinkResolutionCallback.onDeeplinkResolved(sdkClickResponseData.resolvedDeeplink);
cachedDeeplinkResolutionCallback = null;
}
};
handler.post(runnable);
}
}
}

private void launchSessionResponseTasksI(SessionResponseData sessionResponseData) {
Expand Down Expand Up @@ -1969,7 +2000,7 @@ private void readOpenUrlI(Uri url, long clickTime) {
}

if (Util.isUrlFilteredOut(url)) {
logger.debug("Deep link (" + url.toString() + ") processing skipped");
logger.debug("Deeplink (" + url.toString() + ") processing skipped");
return;
}

Expand Down
14 changes: 13 additions & 1 deletion Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private Adjust() {
*/
public static synchronized AdjustInstance getDefaultInstance() {
@SuppressWarnings("unused")
String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.37.1";
String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.38.0";

if (defaultInstance == null) {
defaultInstance = new AdjustInstance();
Expand Down Expand Up @@ -131,6 +131,18 @@ public static void appWillOpenUrl(Uri url, Context context) {
adjustInstance.appWillOpenUrl(url, extractApplicationContext(context));
}

/**
* Process the deep link that has opened an app and potentially get a resolved link.
*
* @param url Deep link URL to process
* @param callback Callback where either resolved or echoed deep link will be sent.
* @param context Application context
*/
public static void processDeeplink(Uri url, Context context, OnDeeplinkResolvedListener callback) {
AdjustInstance adjustInstance = Adjust.getDefaultInstance();
adjustInstance.processDeeplink(url, extractApplicationContext(context), callback);
}

/**
* Called to process referrer information sent with INSTALL_REFERRER intent.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.io.ObjectOutputStream;
import java.io.ObjectStreamField;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
* Created by pfms on 07/11/14.
Expand Down Expand Up @@ -102,6 +104,24 @@ public boolean equals(Object other) {
return true;
}

public Map<String, String> toMap() {
Map<String, String> fields = new HashMap<>();
if (trackerToken != null) fields.put("trackerToken", trackerToken);
if (trackerName != null) fields.put("trackerName", trackerName);
if (network != null) fields.put("network", network);
if (campaign != null) fields.put("campaign", campaign);
if (adgroup != null) fields.put("adgroup", adgroup);
if (creative != null) fields.put("creative", creative);
if (clickLabel != null) fields.put("clickLabel", clickLabel);
if (adid != null) fields.put("adid", adid);
if (costType != null) fields.put("costType", costType);
if (costAmount != null) fields.put("costAmount", costAmount.toString());
if (costCurrency != null) fields.put("costCurrency", costCurrency);
if (fbInstallReferrer != null) fields.put("fbInstallReferrer", fbInstallReferrer);

return fields;
}

@Override
public int hashCode() {
int hashCode = 17;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class AdjustConfig {
boolean finalAttributionEnabled;
String fbAppId;
boolean readDeviceInfoOnceEnabled;
OnDeeplinkResolvedListener cachedDeeplinkResolutionCallback;

public static final String ENVIRONMENT_SANDBOX = "sandbox";
public static final String ENVIRONMENT_PRODUCTION = "production";
Expand Down
29 changes: 29 additions & 0 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public PreLaunchActions() {

private PreLaunchActions preLaunchActions = new PreLaunchActions();

private OnDeeplinkResolvedListener cachedDeeplinkResolutionCallback;

/**
* Base path for Adjust packages.
*/
Expand Down Expand Up @@ -96,6 +98,7 @@ public void onCreate(final AdjustConfig adjustConfig) {
adjustConfig.gdprPath = this.gdprPath;
adjustConfig.subscriptionPath = this.subscriptionPath;
adjustConfig.purchaseVerificationPath = this.purchaseVerificationPath;
adjustConfig.cachedDeeplinkResolutionCallback = cachedDeeplinkResolutionCallback;

activityHandler = AdjustFactory.getActivityHandler(adjustConfig);
setSendingReferrersAsNotSent(adjustConfig.context);
Expand Down Expand Up @@ -193,6 +196,32 @@ public void appWillOpenUrl(final Uri url, final Context context) {
activityHandler.readOpenUrl(url, clickTime);
}

/**
* Process the deep link that has opened an app and potentially get a resolved link.
*
* @param url Deep link URL to process
* @param callback Callback where either resolved or echoed deep link will be sent.
* @param context Application context
*/
public void processDeeplink(Uri url, Context context, OnDeeplinkResolvedListener callback) {
// if resolution result is not wanted, fallback to default method
if (callback == null) {
appWillOpenUrl(url, context);
return;
}

// if deep link processing is triggered prior to SDK being initialized
long clickTime = System.currentTimeMillis();
if (!checkActivityHandler("processDeeplink", true)) {
saveDeeplink(url, clickTime, context);
this.cachedDeeplinkResolutionCallback = callback;
return;
}

// if deep link processing was triggered with SDK being initialized
activityHandler.readOpenUrl(url, clickTime, callback);
}

/**
* Called to process referrer information sent with INSTALL_REFERRER intent.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface Constants {

String SCHEME = "https";
String AUTHORITY = "app.adjust.com";
String CLIENT_SDK = "android4.37.1";
String CLIENT_SDK = "android4.38.0";
String LOGTAG = "Adjust";
String REFTAG = "reftag";
String INSTALL_REFERRER = "install_referrer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public interface IActivityHandler {

void readOpenUrl(Uri url, long clickTime);

void readOpenUrl(Uri url, long clickTime, OnDeeplinkResolvedListener callback);

boolean updateAttributionI(AdjustAttribution attribution);

void launchEventResponseTasks(EventResponseData eventResponseData);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.adjust.sdk;

public interface OnDeeplinkResolvedListener {
void onDeeplinkResolved(String resolvedLink);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ResponseData {

public ActivityPackage activityPackage;
public Map<String, String> sendingParameters;
public String resolvedDeeplink;

protected ResponseData() {
success = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ private void parseResponse(final ResponseData responseData, final String respons
attributionJson,
responseData.adid,
Util.getSdkPrefixPlatform(clientSdk));

responseData.resolvedDeeplink = UtilNetworking.extractJsonString(jsonResponse,"resolved_click_url");
}

private String buildAndExtractAuthorizationHeader(final Map<String, String> parameters,
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-criteo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.37.1'
// implementation 'com.adjust.sdk:adjust-android:4.38.0'
}

// read local properties
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-imei/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.37.1'
// implementation 'com.adjust.sdk:adjust-android:4.38.0'
}

// read local properties
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-oaid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.37.1'
// implementation 'com.adjust.sdk:adjust-android:4.38.0'
implementation 'com.huawei.hms:ads-identifier:3.4.56.300'
}

Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-samsung-referrer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.37.1'
// implementation 'com.adjust.sdk:adjust-android:4.38.0'

// Add Samsung referrer lib via Maven.
implementation 'store.galaxy.samsung.installreferrer:samsung_galaxystore_install_referrer:3.0.1'
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-sociomantic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.37.1'
// implementation 'com.adjust.sdk:adjust-android:4.38.0'
}

// read local properties
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-trademob/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.37.1'
// implementation 'com.adjust.sdk:adjust-android:4.38.0'
}

// read local properties
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-vivo-referrer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.37.1'
// implementation 'com.adjust.sdk:adjust-android:4.38.0'
}

// read local properties
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-webbridge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.37.1'
// implementation 'com.adjust.sdk:adjust-android:4.38.0'
}

// read local properties
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ var Adjust = {
if (this.adjustConfig) {
return this.adjustConfig.getSdkPrefix();
} else {
return 'web-bridge4.37.1';
return 'web-bridge4.38.0';
}
},

Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-xiaomi-referrer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.37.1'
// implementation 'com.adjust.sdk:adjust-android:4.38.0'

// Add xiaomi referrer lib via Maven.
implementation 'com.miui.referrer:homereferrer:1.0.0.6'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.adjust.sdk.OnDeeplinkResponseListener;
import com.adjust.sdk.OnEventTrackingFailedListener;
import com.adjust.sdk.OnEventTrackingSucceededListener;
import com.adjust.sdk.OnDeeplinkResolvedListener;
import com.adjust.sdk.OnPurchaseVerificationFinishedListener;
import com.adjust.sdk.OnSessionTrackingFailedListener;
import com.adjust.sdk.OnSessionTrackingSucceededListener;
Expand Down Expand Up @@ -92,6 +93,7 @@ public void executeCommand(final Command sentCommand) {
case "trackAdRevenueV2" : trackAdRevenueV2(); break;
case "trackSubscription": trackSubscription(); break;
case "verifyPurchase": verifyPurchase(); break;
case "processDeeplink" : processDeeplink(); break;
//case "testBegin": testBegin(); break;
// case "testEnd": testEnd(); break;
}
Expand Down Expand Up @@ -370,20 +372,7 @@ public boolean launchReceivedDeeplink(Uri deeplink) {
public void onAttributionChanged(AdjustAttribution attribution) {
Log.d("TestApp", "attribution = " + attribution.toString());

MainActivity.testLibrary.addInfoToSend("trackerToken", attribution.trackerToken);
MainActivity.testLibrary.addInfoToSend("trackerName", attribution.trackerName);
MainActivity.testLibrary.addInfoToSend("network", attribution.network);
MainActivity.testLibrary.addInfoToSend("campaign", attribution.campaign);
MainActivity.testLibrary.addInfoToSend("adgroup", attribution.adgroup);
MainActivity.testLibrary.addInfoToSend("creative", attribution.creative);
MainActivity.testLibrary.addInfoToSend("clickLabel", attribution.clickLabel);
MainActivity.testLibrary.addInfoToSend("adid", attribution.adid);
MainActivity.testLibrary.addInfoToSend("costType", attribution.costType);
if (attribution.costAmount != null) {
MainActivity.testLibrary.addInfoToSend("costAmount", attribution.costAmount.toString());
}
MainActivity.testLibrary.addInfoToSend("costCurrency", attribution.costCurrency);
MainActivity.testLibrary.addInfoToSend("fbInstallReferrer", attribution.fbInstallReferrer);
MainActivity.testLibrary.setInfoToSend(attribution.toMap());
MainActivity.testLibrary.sendInfoToServer(localBasePath);
}
});
Expand Down Expand Up @@ -844,6 +833,19 @@ public void onVerificationFinished(AdjustPurchaseVerificationResult result) {
}
});
}

private void processDeeplink() {
String deeplink = command.getFirstParameterValue("deeplink");
Uri deeplinkUri = Uri.parse(deeplink);
final String localBasePath = basePath;
Adjust.processDeeplink(deeplinkUri, context, new OnDeeplinkResolvedListener() {
@Override
public void onDeeplinkResolved(String resolvedLink) {
MainActivity.testLibrary.addInfoToSend("resolved_link", resolvedLink);
MainActivity.testLibrary.sendInfoToServer(localBasePath);
}
});
}
/*
private void testBegin() {
if (command.containsParameter("teardown")) {
Expand Down
Loading

0 comments on commit 6b58557

Please sign in to comment.