Skip to content

Commit

Permalink
Merge pull request #558 from adjust/v500_sdk1939_sdk1941_sdk1999
Browse files Browse the repository at this point in the history
[Android] All about endpoints manipulation
  • Loading branch information
MahdiZTD authored May 30, 2024
2 parents 69f3b98 + fa72ebd commit 8fda767
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
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.
*/
Expand Down Expand Up @@ -62,6 +65,14 @@ public void onFinishedEventTrackingSucceeded(AdjustEventSuccess eventSuccessResp
}
});


// Set url strategy
// List<String> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ <h1 style="width:400px;height:35px;text-align:center;">Adjust Web View SDK Demo
adjustConfig.setSessionFailureCallback(sessionFailureCallback);
adjustConfig.setDeferredDeeplinkCallback(deferredDeeplinkCallback);

<!-- adjustConfig.setUrlStrategy(['adjust.com','adjust.cn','eu.adjust.com'], true, true);-->

Adjust.initSdk(adjustConfig);

window.onload = function() {
Expand Down
22 changes: 14 additions & 8 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,8 @@ public void run() {

IActivityPackageSender packageHandlerActivitySender =
new ActivityPackageSender(
adjustConfig.urlStrategy,
adjustConfig.urlStrategyDomains,
adjustConfig.useSubdomains,
adjustConfig.basePath,
adjustConfig.gdprPath,
adjustConfig.subscriptionPath,
Expand All @@ -966,7 +967,8 @@ public void run() {

IActivityPackageSender attributionHandlerActivitySender =
new ActivityPackageSender(
adjustConfig.urlStrategy,
adjustConfig.urlStrategyDomains,
adjustConfig.useSubdomains,
adjustConfig.basePath,
adjustConfig.gdprPath,
adjustConfig.subscriptionPath,
Expand All @@ -981,7 +983,8 @@ public void run() {

IActivityPackageSender sdkClickHandlerActivitySender =
new ActivityPackageSender(
adjustConfig.urlStrategy,
adjustConfig.urlStrategyDomains,
adjustConfig.useSubdomains,
adjustConfig.basePath,
adjustConfig.gdprPath,
adjustConfig.subscriptionPath,
Expand All @@ -996,7 +999,8 @@ public void run() {

IActivityPackageSender purchaseVerificationHandlerActivitySender =
new ActivityPackageSender(
adjustConfig.urlStrategy,
adjustConfig.urlStrategyDomains,
adjustConfig.useSubdomains,
adjustConfig.basePath,
adjustConfig.gdprPath,
adjustConfig.subscriptionPath,
Expand Down Expand Up @@ -2496,11 +2500,13 @@ private void verifyPurchaseI(final AdjustPurchase purchase, final OnPurchaseVeri
return;
}
// from this moment on we know that we can ping client callback in case of error
if (adjustConfig.urlStrategy != null &&
(adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_EU) ||
adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_US) ||
adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_TR))) {
if (adjustConfig.isDataResidency) {
logger.warn("Purchase verification not available for data residency users right now");
AdjustPurchaseVerificationResult result = new AdjustPurchaseVerificationResult(
"not_verified",
109,
"Purchase verification not available for data residency users right now");
callback.onVerificationFinished(result);
return;
}
if (!checkActivityStateI(activityState)) {
Expand Down
34 changes: 11 additions & 23 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;

import java.util.ArrayList;
import java.util.List;

/**
* Created by pfms on 06/11/14.
Expand Down Expand Up @@ -34,7 +35,9 @@ public class AdjustConfig {
String externalDeviceId;
boolean preinstallTrackingEnabled;
Boolean needsCost;
String urlStrategy;
List<String> urlStrategyDomains;
boolean useSubdomains;
boolean isDataResidency;
String preinstallFilePath;
String fbAppId;
boolean shouldReadDeviceIdsOnce;
Expand All @@ -46,14 +49,6 @@ public class AdjustConfig {
public static final String ENVIRONMENT_SANDBOX = "sandbox";
public static final String ENVIRONMENT_PRODUCTION = "production";

public static final String URL_STRATEGY_INDIA = "url_strategy_india";
public static final String URL_STRATEGY_CHINA = "url_strategy_china";
public static final String URL_STRATEGY_CN = "url_strategy_cn";
public static final String URL_STRATEGY_CN_ONLY = "url_strategy_cn_only";
public static final String DATA_RESIDENCY_EU = "data_residency_eu";
public static final String DATA_RESIDENCY_TR = "data_residency_tr";
public static final String DATA_RESIDENCY_US = "data_residency_us";

public AdjustConfig(Context context, String appToken, String environment) {
init(context, appToken, environment, false);
}
Expand Down Expand Up @@ -164,21 +159,14 @@ public boolean isValid() {
return true;
}

public void setUrlStrategy(String urlStrategy) {
if (urlStrategy == null || urlStrategy.isEmpty()) {
public void setUrlStrategy(List<String> domains, boolean useSubdomains, boolean isDataResidency) {
if (domains == null || domains.isEmpty()) {
logger.error("Invalid url strategy");
return;
}
if (!urlStrategy.equals(URL_STRATEGY_INDIA)
&& !urlStrategy.equals(URL_STRATEGY_CHINA)
&& !urlStrategy.equals(URL_STRATEGY_CN)
&& !urlStrategy.equals(URL_STRATEGY_CN_ONLY)
&& !urlStrategy.equals(DATA_RESIDENCY_EU)
&& !urlStrategy.equals(DATA_RESIDENCY_TR)
&& !urlStrategy.equals(DATA_RESIDENCY_US)) {
logger.warn("Unrecognised url strategy %s", urlStrategy);
}
this.urlStrategy = urlStrategy;
this.urlStrategyDomains = domains;
this.useSubdomains = useSubdomains;
this.isDataResidency = isDataResidency;
}

public void readDeviceIdsOnce() {
Expand Down Expand Up @@ -297,8 +285,8 @@ public Boolean getNeedsCost() {
return needsCost;
}

public String getUrlStrategy() {
return urlStrategy;
public List<String> getUrlStrategyDomains() {
return urlStrategyDomains;
}

public String getPreinstallFilePath() {
Expand Down
7 changes: 7 additions & 0 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public interface Constants {
String SUBSCRIPTION_URL = "https://subscription.adjust.com";
String PURCHASE_VERIFICATION_URL = "https://ssrv.adjust.com";

String BASE_URL_FORMAT = "https://app.%s";
String GDPR_URL_FORMAT = "https://gdpr.%s";
String SUBSCRIPTION_URL_FORMAT = "https://subscription.%s";
String PURCHASE_VERIFICATION_URL_FORMAT = "https://ssrv.%s";

String BASE_URL_NO_SUB_DOMAIN_FORMAT = "https://%s";

String SCHEME = "https";
String AUTHORITY = "app.adjust.com";
String CLIENT_SDK = "android5.0.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.net.ssl.HttpsURLConnection;
Expand All @@ -54,7 +55,8 @@ public class ActivityPackageSender implements IActivityPackageSender {
private IConnectionOptions connectionOptions;
private Context context;

public ActivityPackageSender(final String adjustUrlStrategy,
public ActivityPackageSender(final List<String> urlStrategyDomains,
final boolean useSubdomains,
final String basePath,
final String gdprPath,
final String subscriptionPath,
Expand All @@ -76,7 +78,8 @@ public ActivityPackageSender(final String adjustUrlStrategy,
AdjustFactory.getGdprUrl(),
AdjustFactory.getSubscriptionUrl(),
AdjustFactory.getPurchaseVerificationUrl(),
adjustUrlStrategy);
urlStrategyDomains,
useSubdomains);
httpsURLConnectionProvider = AdjustFactory.getHttpsURLConnectionProvider();
connectionOptions = AdjustFactory.getConnectionOptions();
}
Expand Down
Loading

0 comments on commit 8fda767

Please sign in to comment.