Skip to content

Commit

Permalink
Merge pull request #486 from adjust/v4270
Browse files Browse the repository at this point in the history
Version 4.27.0
  • Loading branch information
uerceg authored Mar 18, 2021
2 parents b98369d + 074d82d commit d7c3d27
Show file tree
Hide file tree
Showing 36 changed files with 2,249 additions and 1,235 deletions.
4 changes: 2 additions & 2 deletions Adjust/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ext {
coreMinSdkVersion = 9
coreCompileSdkVersion = 30
coreTargetSdkVersion = 30
coreVersionName = '4.26.2'
coreVersionName = '4.27.0'
defaultVersionCode = 1
webbridgeMinSdkVersion = 17

Expand All @@ -25,7 +25,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files.
Expand Down
33 changes: 33 additions & 0 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,16 @@ public void run() {
});
}

@Override
public void sendPreinstallReferrer() {
executor.submit(new Runnable() {
@Override
public void run() {
sendPreinstallReferrerI();
}
});
}

@Override
public void sendInstallReferrer(final ReferrerDetails referrerDetails,
final String referrerApi) {
Expand Down Expand Up @@ -928,6 +938,10 @@ private void checkForPreinstallI() {
if (activityState == null) return;
if (!activityState.enabled) return;
if (activityState.isGdprForgotten) return;

// sending preinstall referrer doesn't require preinstall tracking flag to be enabled
sendPreinstallReferrerI();

if (!adjustConfig.preinstallTrackingEnabled) return;
if (internalState.hasPreinstallBeenRead()) return;

Expand Down Expand Up @@ -1724,6 +1738,25 @@ private void sendReftagReferrerI() {
sdkClickHandler.sendReftagReferrers();
}

private void sendPreinstallReferrerI() {
if (!isEnabledI()) {
return;
}
if (internalState.hasFirstSdkStartNotOcurred()) {
return;
}

SharedPreferencesManager sharedPreferencesManager =
new SharedPreferencesManager(getContext());
String referrerPayload = sharedPreferencesManager.getPreinstallReferrer();

if (referrerPayload == null || referrerPayload.isEmpty()) {
return;
}

sdkClickHandler.sendPreinstallPayload(referrerPayload, Constants.SYSTEM_INSTALLER_REFERRER);
}

private void sendInstallReferrerI(ReferrerDetails referrerDetails, String referrerApi) {
if (!isEnabledI()) {
return;
Expand Down
2 changes: 1 addition & 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 @@ -32,7 +32,7 @@ private Adjust() {
*/
public static synchronized AdjustInstance getDefaultInstance() {
@SuppressWarnings("unused")
String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.26.2";
String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.27.0";

if (defaultInstance == null) {
defaultInstance = new AdjustInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class AdjustConfig {

public static final String URL_STRATEGY_INDIA = "url_strategy_india";
public static final String URL_STRATEGY_CHINA = "url_strategy_china";
public static final String DATA_RESIDENCY_EU = "data_residency_eu";

public static final String AD_REVENUE_MOPUB = "mopub";
public static final String AD_REVENUE_ADMOB = "admob";
Expand Down Expand Up @@ -202,7 +203,8 @@ public void setUrlStrategy(String urlStrategy) {
return;
}
if (!urlStrategy.equals(URL_STRATEGY_INDIA)
&& !urlStrategy.equals(URL_STRATEGY_CHINA))
&& !urlStrategy.equals(URL_STRATEGY_CHINA)
&& !urlStrategy.equals(DATA_RESIDENCY_EU))
{
logger.warn("Unrecognised url strategy %s", urlStrategy);
}
Expand Down
37 changes: 37 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 @@ -203,6 +203,26 @@ public void sendReferrer(final String rawReferrer, final Context context) {
}
}

/**
* Called to process preinstall payload information sent with SYSTEM_INSTALLER_REFERRER intent.
*
* @param referrer Preinstall referrer content
* @param context Application context
*/
public void sendPreinstallReferrer(final String referrer, final Context context) {
// Check for referrer validity. If invalid, return.
if (referrer == null || referrer.length() == 0) {
return;
}

savePreinstallReferrer(referrer, context);
if (checkActivityHandler("preinstall referrer")) {
if (activityHandler.isEnabled()) {
activityHandler.sendPreinstallReferrer();
}
}
}

/**
* Called to set SDK to offline or online mode.
*
Expand Down Expand Up @@ -541,6 +561,23 @@ public void run() {
Util.runInBackground(command);
}

/**
* Save preinstall referrer to shared preferences.
*
* @param referrer Preinstall referrer content
* @param context Application context
*/
private void savePreinstallReferrer(final String referrer, final Context context) {
Runnable command = new Runnable() {
@Override
public void run() {
SharedPreferencesManager sharedPreferencesManager = new SharedPreferencesManager(context);
sharedPreferencesManager.savePreinstallReferrer(referrer);
}
};
Util.runInBackground(command);
}

/**
* Save push token to shared preferences.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.adjust.sdk;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import static com.adjust.sdk.Constants.EXTRA_SYSTEM_INSTALLER_REFERRER;

public class AdjustPreinstallReferrerReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent == null) {
return;
}

String referrer = intent.getStringExtra(EXTRA_SYSTEM_INSTALLER_REFERRER);
if (referrer == null) {
return;
}

Adjust.getDefaultInstance().sendPreinstallReferrer(referrer, context);
}
}
4 changes: 3 additions & 1 deletion Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface Constants {

String SCHEME = "https";
String AUTHORITY = "app.adjust.com";
String CLIENT_SDK = "android4.26.2";
String CLIENT_SDK = "android4.27.0";
String LOGTAG = "Adjust";
String REFTAG = "reftag";
String INSTALL_REFERRER = "install_referrer";
Expand Down Expand Up @@ -77,11 +77,13 @@ public interface Constants {
String CONTENT_PROVIDER_INTENT_ACTION = "content_provider_intent_action";
String CONTENT_PROVIDER_NO_PERMISSION = "content_provider_no_permission";
String FILE_SYSTEM = "file_system";
String SYSTEM_INSTALLER_REFERRER = "system_installer_referrer";

String ADJUST_PREINSTALL_SYSTEM_PROPERTY_PREFIX = "adjust.preinstall.";
String ADJUST_PREINSTALL_SYSTEM_PROPERTY_PATH = "adjust.preinstall.path";
String ADJUST_PREINSTALL_CONTENT_URI_AUTHORITY = "com.adjust.preinstall";
String ADJUST_PREINSTALL_CONTENT_URI_PATH = "trackers";
String ADJUST_PREINSTALL_CONTENT_PROVIDER_INTENT_ACTION = "com.attribution.REFERRAL_PROVIDER";
String ADJUST_PREINSTALL_FILE_SYSTEM_PATH = "/data/local/tmp/adjust.preinstall";
String EXTRA_SYSTEM_INSTALLER_REFERRER = "com.attribution.EXTRA_SYSTEM_INSTALLER_REFERRER";
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public interface IActivityHandler {

void sendReftagReferrer();

void sendPreinstallReferrer();

void sendInstallReferrer(ReferrerDetails referrerDetails, String referrerApi);

void setOfflineMode(boolean enabled);
Expand Down
Loading

0 comments on commit d7c3d27

Please sign in to comment.