Skip to content

Commit

Permalink
Merge pull request #535 from adjust/v4300
Browse files Browse the repository at this point in the history
Version 4.30.0
  • Loading branch information
shashanksu authored Apr 11, 2022
2 parents bf847e5 + 4069de1 commit 22c5ad1
Show file tree
Hide file tree
Showing 36 changed files with 458 additions and 152 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 = 31
coreTargetSdkVersion = 31
coreVersionName = '4.29.1'
coreVersionName = '4.30.0'
defaultVersionCode = 1
webbridgeMinSdkVersion = 17

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

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files.
Expand Down
2 changes: 1 addition & 1 deletion Adjust/example-app-java/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

<!-- Use ONLY IF you are using plugin-imei and if your app is NOT DISTRIBUTED in Play Store -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" />-->

<!-- Use ONLY IF you are supporting preinstall tracker via content provider -->
<uses-permission android:name="com.adjust.preinstall.READ_PERMISSION"/>
Expand Down
2 changes: 1 addition & 1 deletion Adjust/example-app-keyboard/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

<!-- Use ONLY IF you are using plugin-imei and if your app is NOT DISTRIBUTED in Play Store -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" />-->

<application
android:name=".GlobalApplication"
Expand Down
2 changes: 1 addition & 1 deletion Adjust/example-app-kotlin/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

<!-- Use ONLY IF you are using plugin-imei and if your app is NOT DISTRIBUTED in Play Store -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" />-->

<application
android:name=".GlobalApplication"
Expand Down
99 changes: 96 additions & 3 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -788,11 +788,32 @@ public void run(ActivityHandler activityHandler) {
logger.info("Event buffering is enabled");
}

deviceInfo.reloadPlayIds(adjustConfig.context);
deviceInfo.reloadPlayIds(adjustConfig);
if (deviceInfo.playAdId == null) {
logger.warn("Unable to get Google Play Services Advertising ID at start time");
if (!Util.canReadPlayIds(adjustConfig)) {
if (adjustConfig.coppaCompliantEnabled) {
logger.info("Cannot read Google Play Services Advertising ID with COPPA enabled");
}

if (adjustConfig.playStoreKidsAppEnabled) {
logger.info("Cannot read Google Play Services Advertising ID with play store kids app enabled");
}
} else {
logger.warn("Unable to get Google Play Services Advertising ID at start time");
}

if (deviceInfo.androidId == null) {
logger.error("Unable to get any device id's. Please check if Proguard is correctly set with Adjust SDK");
if (!Util.canReadNonPlayIds(adjustConfig)) {
if (adjustConfig.coppaCompliantEnabled) {
logger.info("Cannot read non Play IDs with COPPA enabled");
}

if (adjustConfig.playStoreKidsAppEnabled) {
logger.info("Cannot read non Play IDs with play store kids app enabled");
}
} else {
logger.error("Unable to get any Device IDs. Please check if Proguard is correctly set with Adjust SDK");
}
}
} else {
logger.info("Google Play Services Advertising ID read correctly at start time");
Expand Down Expand Up @@ -1131,6 +1152,8 @@ private void startI() {

updateHandlersStatusAndSendI();

processCoppaComplianceI();

processSessionI();

checkAttributionStateI();
Expand All @@ -1156,6 +1179,8 @@ private void startFirstSessionI() {
if (sharedPreferencesManager.getGdprForgetMe()) {
gdprForgetMeI();
} else {
processCoppaComplianceI();

// check if disable third party sharing request came, then send it first
if (sharedPreferencesManager.getDisableThirdPartySharing()) {
disableThirdPartySharingI();
Expand Down Expand Up @@ -1607,6 +1632,8 @@ private void setEnabledI(boolean enabled) {
if (sharedPreferencesManager.getGdprForgetMe()) {
gdprForgetMeI();
} else {
processCoppaComplianceI();

if (sharedPreferencesManager.getDisableThirdPartySharing()) {
disableThirdPartySharingI();
}
Expand Down Expand Up @@ -2223,6 +2250,10 @@ private void disableThirdPartySharingI() {
if (!isEnabledI()) { return; }
if (activityState.isGdprForgotten) { return; }
if (activityState.isThirdPartySharingDisabled) { return; }
if (adjustConfig.coppaCompliantEnabled) {
logger.warn("Call to disable third party sharing API ignored, already done when COPPA enabled");
return;
}

activityState.isThirdPartySharingDisabled = true;
writeActivityStateI();
Expand Down Expand Up @@ -2251,6 +2282,10 @@ private void trackThirdPartySharingI(final AdjustThirdPartySharing adjustThirdPa
}
if (!isEnabledI()) { return; }
if (activityState.isGdprForgotten) { return; }
if (adjustConfig.coppaCompliantEnabled) {
logger.warn("Calling third party sharing API not allowed when COPPA enabled");
return;
}

long now = System.currentTimeMillis();
PackageBuilder packageBuilder = new PackageBuilder(
Expand Down Expand Up @@ -2576,4 +2611,62 @@ private void checkForInstallReferrerInfo(final SdkClickResponseData responseData

writeActivityStateI();
}

private void processCoppaComplianceI() {
if (!adjustConfig.coppaCompliantEnabled) {
resetThirdPartySharingCoppaActivityStateI();
return;
}

disableThirdPartySharingForCoppaEnabledI();
}

private void disableThirdPartySharingForCoppaEnabledI() {
if (!shouldDisableThirdPartySharingWhenCoppaEnabled()) {
return;
}

activityState.isThirdPartySharingDisabledForCoppa = true;
writeActivityStateI();
AdjustThirdPartySharing adjustThirdPartySharing =
new AdjustThirdPartySharing(false);

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

ActivityPackage activityPackage =
packageBuilder.buildThirdPartySharingPackage(adjustThirdPartySharing);
packageHandler.addPackage(activityPackage);

if (adjustConfig.eventBufferingEnabled) {
logger.info("Buffered event %s", activityPackage.getSuffix());
} else {
packageHandler.sendFirstPackage();
}
}

private void resetThirdPartySharingCoppaActivityStateI() {
if (activityState == null) { return; }
if (activityState.isThirdPartySharingDisabledForCoppa) {
activityState.isThirdPartySharingDisabledForCoppa = false;
writeActivityStateI();
}
}

private boolean shouldDisableThirdPartySharingWhenCoppaEnabled() {
if (activityState == null) {
return false;
}

if (!isEnabledI()) {
return false;
}

if (activityState.isGdprForgotten) {
return false;
}

return !activityState.isThirdPartySharingDisabledForCoppa;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ public class ActivityState implements Serializable, Cloneable {
new ObjectStreamField("installBeginHuawei", long.class),
new ObjectStreamField("installReferrerHuawei", String.class),
new ObjectStreamField("installReferrerHuaweiAppGallery", String.class),
new ObjectStreamField("isThirdPartySharingDisabledForCoppa", boolean.class),
};

// persistent data
protected String uuid;
protected boolean enabled;
protected boolean isGdprForgotten;
protected boolean isThirdPartySharingDisabled;
protected boolean isThirdPartySharingDisabledForCoppa;
protected boolean askingAttribution;

// global counters
Expand Down Expand Up @@ -98,6 +100,7 @@ protected ActivityState() {
enabled = true;
isGdprForgotten = false;
isThirdPartySharingDisabled = false;
isThirdPartySharingDisabledForCoppa = false;
askingAttribution = false;
eventCount = 0; // no events yet
sessionCount = 0; // the first session just started
Expand Down Expand Up @@ -168,6 +171,7 @@ public boolean equals(Object other) {
if (!Util.equalBoolean(enabled, otherActivityState.enabled)) return false;
if (!Util.equalBoolean(isGdprForgotten, otherActivityState.isGdprForgotten)) return false;
if (!Util.equalBoolean(isThirdPartySharingDisabled, otherActivityState.isThirdPartySharingDisabled)) return false;
if (!Util.equalBoolean(isThirdPartySharingDisabledForCoppa, otherActivityState.isThirdPartySharingDisabledForCoppa)) return false;
if (!Util.equalBoolean(askingAttribution, otherActivityState.askingAttribution)) return false;
if (!Util.equalInt(eventCount, otherActivityState.eventCount)) return false;
if (!Util.equalInt(sessionCount, otherActivityState.sessionCount)) return false;
Expand Down Expand Up @@ -200,6 +204,7 @@ public int hashCode() {
hashCode = 37 * hashCode + Util.hashBoolean(enabled);
hashCode = 37 * hashCode + Util.hashBoolean(isGdprForgotten);
hashCode = 37 * hashCode + Util.hashBoolean(isThirdPartySharingDisabled);
hashCode = 37 * hashCode + Util.hashBoolean(isThirdPartySharingDisabledForCoppa);
hashCode = 37 * hashCode + Util.hashBoolean(askingAttribution);
hashCode = 37 * hashCode + eventCount;
hashCode = 37 * hashCode + sessionCount;
Expand Down Expand Up @@ -241,6 +246,7 @@ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFo
enabled = Util.readBooleanField(fields, "enabled", true);
isGdprForgotten = Util.readBooleanField(fields, "isGdprForgotten", false);
isThirdPartySharingDisabled = Util.readBooleanField(fields, "isThirdPartySharingDisabled", false);
isThirdPartySharingDisabledForCoppa = Util.readBooleanField(fields, "isThirdPartySharingDisabledForCoppa", false);
askingAttribution = Util.readBooleanField(fields, "askingAttribution", false);

updatePackages = Util.readBooleanField(fields, "updatePackages", false);
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.29.1";
String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.30.0";

if (defaultInstance == null) {
defaultInstance = new AdjustInstance();
Expand Down
10 changes: 10 additions & 0 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class AdjustConfig {
Boolean needsCost;
String urlStrategy;
String preinstallFilePath;
boolean playStoreKidsAppEnabled;
boolean coppaCompliantEnabled;

public static final String ENVIRONMENT_SANDBOX = "sandbox";
public static final String ENVIRONMENT_PRODUCTION = "production";
Expand Down Expand Up @@ -184,6 +186,14 @@ public void setNeedsCost(boolean needsCost) {
this.needsCost = needsCost;
}

public void setPlayStoreKidsAppEnabled(boolean playStoreKidsAppEnabled) {
this.playStoreKidsAppEnabled = playStoreKidsAppEnabled;
}

public void setCoppaCompliantEnabled(boolean coppaCompliantEnabled) {
this.coppaCompliantEnabled = coppaCompliantEnabled;
}

public boolean isValid() {
if (!checkAppToken(appToken)) return false;
if (!checkEnvironment(environment)) return false;
Expand Down
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.29.1";
String CLIENT_SDK = "android4.30.0";
String LOGTAG = "Adjust";
String REFTAG = "reftag";
String INSTALL_REFERRER = "install_referrer";
Expand Down
19 changes: 15 additions & 4 deletions Adjust/sdk-core/src/main/java/com/adjust/sdk/DeviceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class DeviceInfo {

String playAdId;
String playAdIdSource;
int playAdIdAttempt;
int playAdIdAttempt = -1;
Boolean isTrackingEnabled;
private boolean nonGoogleIdsReadOnce = false;
String androidId;
Expand Down Expand Up @@ -113,7 +113,12 @@ class DeviceInfo {
uiMode = getDeviceUiMode(configuration);
}

void reloadPlayIds(Context context) {
void reloadPlayIds(final AdjustConfig adjustConfig) {
if (!Util.canReadPlayIds(adjustConfig)) {
return;
}

Context context = adjustConfig.context;
String previousPlayAdId = playAdId;
Boolean previousIsTrackingEnabled = isTrackingEnabled;

Expand Down Expand Up @@ -184,11 +189,15 @@ void reloadPlayIds(Context context) {
}
}

void reloadNonPlayIds(Context context) {
void reloadNonPlayIds(final AdjustConfig adjustConfig) {
if (!Util.canReadNonPlayIds(adjustConfig)) {
return;
}

if (nonGoogleIdsReadOnce) {
return;
}
androidId = Util.getAndroidId(context);
androidId = Util.getAndroidId(adjustConfig.context);
nonGoogleIdsReadOnce = true;
}

Expand Down Expand Up @@ -402,4 +411,6 @@ private String getAppUpdateTime(Context context) {
return null;
}
}


}
Loading

0 comments on commit 22c5ad1

Please sign in to comment.