Skip to content

Commit

Permalink
Merge pull request #600 from adjust/v4384
Browse files Browse the repository at this point in the history
Version 4.38.4
  • Loading branch information
shashanksu authored May 14, 2024
2 parents 65b3b8a + a0abd45 commit b322fd4
Show file tree
Hide file tree
Showing 28 changed files with 224 additions and 47 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.38.3'
coreVersionName = '4.38.4'
defaultVersionCode = 1
webbridgeMinSdkVersion = 17
samsungReferrerMinSdkVersion = 18
Expand Down
19 changes: 17 additions & 2 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,7 @@ private void trackEventI(AdjustEvent event) {
updateActivityStateI(now);

PackageBuilder eventBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, sessionParameters, now);
eventBuilder.internalState = internalState;
ActivityPackage eventPackage = eventBuilder.buildEventPackage(event, internalState.isInDelayedStart());
packageHandler.addPackage(eventPackage);

Expand Down Expand Up @@ -1984,7 +1985,8 @@ private void sendInstallReferrerI(ReferrerDetails referrerDetails, String referr
activityState,
adjustConfig,
deviceInfo,
sessionParameters);
sessionParameters,
internalState);

sdkClickHandler.sendSdkClick(sdkClickPackage);
}
Expand Down Expand Up @@ -2017,7 +2019,8 @@ private void readOpenUrlI(Uri url, long clickTime) {
activityState,
adjustConfig,
deviceInfo,
sessionParameters);
sessionParameters,
internalState);

if (sdkClickPackage == null) {
return;
Expand Down Expand Up @@ -2105,6 +2108,7 @@ public static boolean deleteSessionPartnerParameters(Context context) {
private void transferSessionPackageI(long now) {
PackageBuilder builder = new PackageBuilder(adjustConfig, deviceInfo, activityState,
sessionParameters, now);
builder.internalState = internalState;
ActivityPackage sessionPackage = builder.buildSessionPackage(internalState.isInDelayedStart());
packageHandler.addPackage(sessionPackage);
packageHandler.sendFirstPackage();
Expand Down Expand Up @@ -2369,6 +2373,7 @@ private void setPushTokenI(String token) {

long now = System.currentTimeMillis();
PackageBuilder infoPackageBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, sessionParameters, now);
infoPackageBuilder.internalState = internalState;

ActivityPackage infoPackage = infoPackageBuilder.buildInfoPackage(Constants.PUSH);
packageHandler.addPackage(infoPackage);
Expand All @@ -2393,6 +2398,7 @@ private void gdprForgetMeI() {

long now = System.currentTimeMillis();
PackageBuilder gdprPackageBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, sessionParameters, now);
gdprPackageBuilder.internalState = internalState;

ActivityPackage gdprPackage = gdprPackageBuilder.buildGdprPackage();
packageHandler.addPackage(gdprPackage);
Expand Down Expand Up @@ -2427,6 +2433,7 @@ private void disableThirdPartySharingI() {

long now = System.currentTimeMillis();
PackageBuilder packageBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, sessionParameters, now);
packageBuilder.internalState = internalState;

ActivityPackage activityPackage = packageBuilder.buildDisableThirdPartySharingPackage();
packageHandler.addPackage(activityPackage);
Expand Down Expand Up @@ -2457,6 +2464,7 @@ private void trackThirdPartySharingI(final AdjustThirdPartySharing adjustThirdPa
long now = System.currentTimeMillis();
PackageBuilder packageBuilder = new PackageBuilder(
adjustConfig, deviceInfo, activityState, sessionParameters, now);
packageBuilder.internalState = internalState;

ActivityPackage activityPackage =
packageBuilder.buildThirdPartySharingPackage(adjustThirdPartySharing);
Expand All @@ -2480,6 +2488,7 @@ private void trackMeasurementConsentI(final boolean consentMeasurement) {
long now = System.currentTimeMillis();
PackageBuilder packageBuilder = new PackageBuilder(
adjustConfig, deviceInfo, activityState, sessionParameters, now);
packageBuilder.internalState = internalState;

ActivityPackage activityPackage =
packageBuilder.buildMeasurementConsentPackage(consentMeasurement);
Expand All @@ -2500,6 +2509,7 @@ private void trackAdRevenueI(String source, JSONObject adRevenueJson) {
long now = System.currentTimeMillis();

PackageBuilder packageBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, sessionParameters, now);
packageBuilder.internalState = internalState;

ActivityPackage adRevenuePackage = packageBuilder.buildAdRevenuePackage(source, adRevenueJson);
packageHandler.addPackage(adRevenuePackage);
Expand All @@ -2515,6 +2525,7 @@ private void trackAdRevenueI(AdjustAdRevenue adjustAdRevenue) {
long now = System.currentTimeMillis();

PackageBuilder packageBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, sessionParameters, now);
packageBuilder.internalState = internalState;

ActivityPackage adRevenuePackage = packageBuilder.buildAdRevenuePackage(adjustAdRevenue, internalState.isInDelayedStart());
packageHandler.addPackage(adRevenuePackage);
Expand All @@ -2529,6 +2540,7 @@ private void trackSubscriptionI(final AdjustPlayStoreSubscription subscription)
long now = System.currentTimeMillis();

PackageBuilder packageBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, sessionParameters, now);
packageBuilder.internalState = internalState;

ActivityPackage subscriptionPackage = packageBuilder.buildSubscriptionPackage(subscription, internalState.isInDelayedStart());
packageHandler.addPackage(subscriptionPackage);
Expand Down Expand Up @@ -2588,6 +2600,8 @@ private void verifyPurchaseI(final AdjustPurchase purchase, final OnPurchaseVeri

long now = System.currentTimeMillis();
PackageBuilder packageBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, sessionParameters, now);
packageBuilder.internalState = internalState;

ActivityPackage verificationPackage = packageBuilder.buildVerificationPackage(purchase, callback);
if (verificationPackage == null) {
logger.warn("Purchase verification aborted because verification package is null");
Expand Down Expand Up @@ -2926,6 +2940,7 @@ private void disableThirdPartySharingForCoppaEnabledI() {
long now = System.currentTimeMillis();
PackageBuilder packageBuilder = new PackageBuilder(
adjustConfig, deviceInfo, activityState, sessionParameters, now);
packageBuilder.internalState = internalState;

ActivityPackage activityPackage =
packageBuilder.buildThirdPartySharingPackage(adjustThirdPartySharing);
Expand Down
51 changes: 51 additions & 0 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

package com.adjust.sdk;

import com.adjust.sdk.network.ErrorCodes;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Expand All @@ -32,6 +34,10 @@ public class ActivityPackage implements Serializable {
new ObjectStreamField("suffix", String.class),
new ObjectStreamField("callbackParameters", (Class<Map<String,String>>)(Class)Map.class),
new ObjectStreamField("partnerParameters", (Class<Map<String,String>>)(Class)Map.class),
new ObjectStreamField("retryCount", int.class),
new ObjectStreamField("firstErrorCode", int.class),
new ObjectStreamField("lastErrorCode", int.class),
new ObjectStreamField("waitBeforeSendTimeSeconds", double.class),
};

private transient int hashCode;
Expand Down Expand Up @@ -61,6 +67,10 @@ public class ActivityPackage implements Serializable {
private String installVersion;
private Boolean googlePlayInstant;
private Boolean isClick;
private int retryCount;
private int firstErrorCode;
private int lastErrorCode;
private double waitBeforeSendTimeSeconds;

public String getPath() {
return path;
Expand Down Expand Up @@ -226,6 +236,35 @@ public String getFailureMessage() {
return Util.formatString("Failed to track %s%s", activityKind.toString(), suffix);
}

public int getRetryCount() {
return retryCount;
}

public int getFirstErrorCode() {
return firstErrorCode;
}

public int getLastErrorCode() {
return lastErrorCode;
}

public double getWaitBeforeSendTimeSeconds() {
return waitBeforeSendTimeSeconds;
}

public void setWaitBeforeSendTimeSeconds(double waitSeconds) {
waitBeforeSendTimeSeconds = waitSeconds;
}

public void addError(int errorCode) {
retryCount++;
if (firstErrorCode == 0) {
firstErrorCode = errorCode;
} else {
lastErrorCode = errorCode;
}
}

private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
}
Expand All @@ -240,6 +279,10 @@ private void readObject(ObjectInputStream stream) throws ClassNotFoundException,
suffix = Util.readStringField(fields, "suffix", null);
callbackParameters = Util.readObjectField(fields, "callbackParameters", null);
partnerParameters = Util.readObjectField(fields, "partnerParameters", null);
retryCount = Util.readIntField(fields, "errorCount", 0);
firstErrorCode = Util.readIntField(fields, "firstErrorCode", 0);
lastErrorCode = Util.readIntField(fields, "lastErrorCode", 0);
waitBeforeSendTimeSeconds = Util.readDoubleField(fields, "waitBeforeSendTimeSeconds", 0.0);
}

@Override
Expand All @@ -256,6 +299,10 @@ public boolean equals(Object other) {
if (!Util.equalString(suffix, otherActivityPackage.suffix)) return false;
if (!Util.equalObject(callbackParameters, otherActivityPackage.callbackParameters)) return false;
if (!Util.equalObject(partnerParameters, otherActivityPackage.partnerParameters)) return false;
if (!Util.equalInt(retryCount, otherActivityPackage.retryCount)) return false;
if (!Util.equalInt(firstErrorCode, otherActivityPackage.firstErrorCode)) return false;
if (!Util.equalInt(lastErrorCode, otherActivityPackage.lastErrorCode)) return false;
if (!Util.equalsDouble(waitBeforeSendTimeSeconds, otherActivityPackage.waitBeforeSendTimeSeconds)) return false;
return true;
}

Expand All @@ -270,6 +317,10 @@ public int hashCode() {
hashCode = Util.hashString(suffix, hashCode);
hashCode = Util.hashObject(callbackParameters, hashCode);
hashCode = Util.hashObject(partnerParameters, hashCode);
hashCode = 37 * hashCode + retryCount;
hashCode = 37 * hashCode + firstErrorCode;
hashCode = 37 * hashCode + lastErrorCode;
hashCode = Util.hashDouble(waitBeforeSendTimeSeconds, hashCode);
}
return hashCode;
}
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 @@ -34,7 +34,7 @@ private Adjust() {
*/
public static synchronized AdjustInstance getDefaultInstance() {
@SuppressWarnings("unused")
String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.38.3";
String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.38.4";

if (defaultInstance == null) {
defaultInstance = new AdjustInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private void sendAttributionRequestI() {
}

// Create attribution package before sending attribution request.
ActivityPackage attributionPackage = buildAndGetAttributionPackage();
ActivityPackage attributionPackage = buildAndGetAttributionPackage(activityHandlerWeakRef.get().getInternalState());
logger.verbose("%s", attributionPackage.getExtendedString());

Map<String, String> sendingParameters = generateSendingParametersI();
Expand All @@ -254,7 +254,7 @@ private Map<String, String> generateSendingParametersI() {
return sendingParameters;
}

private ActivityPackage buildAndGetAttributionPackage() {
private ActivityPackage buildAndGetAttributionPackage(ActivityHandler.InternalState internalState) {
long now = System.currentTimeMillis();
IActivityHandler activityHandler = activityHandlerWeakRef.get();
PackageBuilder packageBuilder = new PackageBuilder(
Expand All @@ -263,6 +263,8 @@ private ActivityPackage buildAndGetAttributionPackage() {
activityHandler.getActivityState(),
activityHandler.getSessionParameters(),
now);
packageBuilder.internalState = internalState;

ActivityPackage activityPackage = packageBuilder.buildAttributionPackage(lastInitiatedBy);
lastInitiatedBy = null;
return activityPackage;
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.38.3";
String CLIENT_SDK = "android4.38.4";
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 @@ -98,4 +98,6 @@ public interface IActivityHandler {
ActivityState getActivityState();

SessionParameters getSessionParameters();

ActivityHandler.InternalState getInternalState();
}
22 changes: 22 additions & 0 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class PackageBuilder {
AdjustAttribution attribution;
Map<String, String> extraParameters;
Boolean isClick;
ActivityHandler.InternalState internalState;

private class ActivityStateCopy {
int eventCount = -1;
Expand Down Expand Up @@ -1321,6 +1322,19 @@ private ActivityPackage getDefaultActivityPackage(ActivityKind activityKind) {
}

private void injectFeatureFlagsWithParameters(Map<String, String> parameters) {

PackageBuilder.addBoolean(parameters, "event_buffering_enabled", adjustConfig.eventBufferingEnabled);
PackageBuilder.addBoolean(parameters, "send_in_background_enabled", adjustConfig.sendInBackground);

if (internalState != null) {
PackageBuilder.addBoolean(parameters, "offline_mode_enabled", internalState.offline);
if (internalState.isInForeground()) {
PackageBuilder.addBoolean(parameters, "foreground", true);
} else {
PackageBuilder.addBoolean(parameters, "background", true);
}
}

if (adjustConfig.coppaCompliantEnabled) {
PackageBuilder.addLong(parameters, "ff_coppa", 1);
}
Expand Down Expand Up @@ -1374,6 +1388,14 @@ public static void addLong(Map<String, String> parameters, String key, long valu
PackageBuilder.addString(parameters, key, valueString);
}

public static void addDouble(Map<String, String> parameters, String key, double value) {
if (value < 0.0) {
return;
}
String valueString = Double.toString(value);
PackageBuilder.addString(parameters, key, valueString);
}

private static void addDateInMilliseconds(Map<String, String> parameters, String key, long value) {
if (value <= 0) {
return;
Expand Down
Loading

0 comments on commit b322fd4

Please sign in to comment.