Skip to content

Commit

Permalink
SDK v7.11
Browse files Browse the repository at this point in the history
* commit 'ba11f80df734432dcc55c2e99615efb637a33ae9':
  Updated Release Notes, SDK version
  Added native interval for MSAN
  ONE_PX implementation (Imp Firing)
  Added Accept-Language to the UT request header
  Do Not Track signal for /ut/v3
  Merging the working Impression tests. Status: OMID/Click tracking incomplete
  • Loading branch information
avohraa committed Mar 25, 2021
2 parents e69a408 + ba11f80 commit fa4b4bc
Show file tree
Hide file tree
Showing 85 changed files with 6,873 additions and 95 deletions.
6 changes: 6 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 7.11
### Improvements/Bug Fixes
+ MS-4685 Added API to disable tracking cookies during auction.
+ MS-4714 Added improvements to Ad Expiry events for Native Ads.
+ MS-4699 Added Accept-Language parameter in the HTTP header for Ad Request.

## 7.10
### New Feature
+ MS-4659, MS-4674 Added support for User Id from external sources(Criteo, NetID, LiverRamp, The Trade Desk) [https://wiki.xandr.com/x/DAkYBg]
Expand Down
4 changes: 2 additions & 2 deletions instreamvideo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Project Properties
version = "1.25" // Instream SDK version
version = "1.26" // Instream SDK version

apply plugin: 'com.android.library'

Expand All @@ -10,7 +10,7 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
versionCode 23 // An integer value that represents the version of the code, relative to other versions. Increase for each release.
versionCode 24 // An integer value that represents the version of the code, relative to other versions. Increase for each release.
versionName version
consumerProguardFiles 'proguard-project.txt'
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Project properties
version = "7.10"
version = "7.11"
group='com.appnexus.opensdk'

// Android build
Expand All @@ -9,7 +9,7 @@ android {
compileSdkVersion 28
buildToolsVersion '29.0.0'
defaultConfig {
versionCode 80 // An integer value that represents the version of the code, relative to other versions. Increase for each release.
versionCode 81 // An integer value that represents the version of the code, relative to other versions. Increase for each release.
versionName version
consumerProguardFiles 'proguard-project.txt'
minSdkVersion 14
Expand Down
10 changes: 6 additions & 4 deletions sdk/src/com/appnexus/opensdk/ANNativeAdResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -103,8 +104,7 @@ public void run() {
registeredView = null;
clickables = null;
if (visibilityDetector != null) {
visibilityDetector.destroy();
visibilityDetector = null;
visibilityDetector.destroy(viewWeakReference);
}
impressionTrackers = null;
listener = null;
Expand Down Expand Up @@ -140,6 +140,7 @@ public void run() {
private ArrayList<ImpressionTracker> impressionTrackers;
private ProgressDialog progressDialog;
private ANClickThroughAction clickThroughAction = ANClickThroughAction.OPEN_SDK_BROWSER;
private WeakReference<View> viewWeakReference;

/**
* Process the metadata of native response from ad server
Expand Down Expand Up @@ -326,14 +327,15 @@ public void setCreativeId(String creativeId) {
protected boolean registerView(final View view, final NativeAdEventListener listener) {
if (!expired && view != null) {
this.listener = listener;
visibilityDetector = VisibilityDetector.create(view);
viewWeakReference = new WeakReference<>(view);
visibilityDetector = VisibilityDetector.create(viewWeakReference);
if (visibilityDetector == null) {
return false;
}

impressionTrackers = new ArrayList<ImpressionTracker>(imp_trackers.size());
for (String url : imp_trackers) {
ImpressionTracker impressionTracker = ImpressionTracker.create(url, visibilityDetector, view.getContext(), anOmidAdSession, new ImpressionTrackerListener() {
ImpressionTracker impressionTracker = ImpressionTracker.create(viewWeakReference, url, visibilityDetector, view.getContext(), anOmidAdSession, new ImpressionTrackerListener() {
@Override
public void onImpressionTrackerFired() {
if (listener != null) {
Expand Down
51 changes: 44 additions & 7 deletions sdk/src/com/appnexus/opensdk/AdView.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.appnexus.opensdk.utils.HTTPGet;
import com.appnexus.opensdk.utils.HTTPResponse;
import com.appnexus.opensdk.utils.Settings;
import com.appnexus.opensdk.utils.Settings.CountImpression;
import com.appnexus.opensdk.utils.ViewUtil;

import java.lang.ref.WeakReference;
Expand Down Expand Up @@ -168,6 +169,19 @@ boolean isMRAIDExpanded() {
return isMRAIDExpanded;
}

private void addVisibilityDetector(final WeakReference<View> view) {
final VisibilityDetector visibilityDetector = VisibilityDetector.create(view);
visibilityDetector.addVisibilityListener(view, new VisibilityDetector.VisibilityListener() {
@Override
public void onVisibilityChanged(boolean visible) {
if (visible && impressionTrackers != null && impressionTrackers.size() > 0) {
fireImpressionTracker();
visibilityDetector.destroy(view);
}
}
});
}

@Override
public boolean isReadyToStart() {
if (!(getContext() instanceof Activity)) {
Expand Down Expand Up @@ -1235,6 +1249,15 @@ private void handleBannerOrInterstitialAd(final AdResponse ad) {
handler.post(new Runnable() {
@Override
public void run() {
if (ad.getResponseData() != null && ad.getResponseData().getImpressionURLs() != null && ad.getResponseData().getImpressionURLs().size() > 0) {
impressionTrackers = ad.getResponseData().getImpressionURLs();
}
if (ad.getDisplayable() != null && ad.getMediaType().equals(MediaType.BANNER) && ad.getResponseData().getAdType().equalsIgnoreCase(UTConstants.AD_TYPE_BANNER)) {
if (getEffectiveImpressionCountingMethod() == CountImpression.ONE_PX) {
WeakReference<View> weakReferenceView = new WeakReference<View>(ad.getDisplayable().getView());
addVisibilityDetector(weakReferenceView);
}
}
setCreativeWidth(ad.getDisplayable().getCreativeWidth());
setCreativeHeight(ad.getDisplayable().getCreativeHeight());
setCreativeId(ad.getResponseData().getAdResponseInfo().getCreativeId());
Expand All @@ -1250,14 +1273,12 @@ public void run() {
display(ad.getDisplayable());
}

if (ad.getResponseData() != null && ad.getResponseData().getImpressionURLs() != null && ad.getResponseData().getImpressionURLs().size() > 0) {
impressionTrackers = ad.getResponseData().getImpressionURLs();
}


// Banner OnAdLoaded and if View is attached to window, or if the LazyLoad is enabled Impression is counted.
if (getMediaType().equals(MediaType.BANNER)) {
if (isAdViewAttachedToWindow() || countBannerImpressionOnAdLoad || (isLazyLoadEnabled() && isWebviewActivated() && ad.getResponseData().getAdType().equalsIgnoreCase(UTConstants.AD_TYPE_BANNER))) {
if (getEffectiveImpressionCountingMethod() == CountImpression.ON_LOAD ||
(getEffectiveImpressionCountingMethod() == CountImpression.LAZY_LOAD && isWebviewActivated() && ad.getResponseData().getAdType().equalsIgnoreCase(UTConstants.AD_TYPE_BANNER)) ||
(getEffectiveImpressionCountingMethod() == CountImpression.DEFAULT && isAdViewAttachedToWindow())) {
if (impressionTrackers != null && impressionTrackers.size() > 0) {
fireImpressionTracker();
}
Expand Down Expand Up @@ -1298,7 +1319,7 @@ protected void onAttachedToWindow() {
super.onAttachedToWindow();
isAttachedToWindow = true;
// OnAttaced to Window and Impresion tracker is non null then fire impression.
if (getMediaType().equals(MediaType.BANNER) && impressionTrackers != null && impressionTrackers.size() > 0) {
if (getEffectiveImpressionCountingMethod() == CountImpression.DEFAULT && getMediaType().equals(MediaType.BANNER) && impressionTrackers != null && impressionTrackers.size() > 0) {
fireImpressionTracker();
}

Expand Down Expand Up @@ -1333,6 +1354,7 @@ void fireImpressionTracker() {


void fireImpressionTracker(final String trackerUrl) {
Clog.d("FIRE_IMPRESSION", getEffectiveImpressionCountingMethod().name());
HTTPGet impTracker = new HTTPGet() {
@Override
protected void onPostExecute(HTTPResponse response) {
Expand Down Expand Up @@ -1573,7 +1595,7 @@ protected boolean loadLazyAd() {
* This returns if the Webview for the Lazy Load has been activated or not
* The webview once activated is de-activated by calling the deactivateWebviewForNextCall() {basically for AutoRefresh }
*/
private boolean isWebviewActivated() {
protected boolean isWebviewActivated() {
return activateWebview;
}

Expand All @@ -1592,4 +1614,19 @@ protected void deactivateWebviewForNextCall() {
protected boolean isLastResponseSuccessful() {
return getAdResponseInfo() != null && getAdResponseInfo().getAdType() == AdType.BANNER;
}

/**
* @return {@link CountImpression} Based on the boolean values set for the Impression Tracking
* */
public CountImpression getEffectiveImpressionCountingMethod() {
if (countBannerImpressionOnAdLoad) {
return CountImpression.ON_LOAD;
} else if (SDKSettings.getCountImpressionOn1pxRendering()) {
return CountImpression.ONE_PX;
} else if (isLazyLoadEnabled()) {
return CountImpression.LAZY_LOAD;
} else {
return CountImpression.DEFAULT;
}
}
}
9 changes: 8 additions & 1 deletion sdk/src/com/appnexus/opensdk/AdViewRequestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.appnexus.opensdk.ut.adresponse.RTBVASTAdResponse;
import com.appnexus.opensdk.ut.adresponse.SSMHTMLAdResponse;
import com.appnexus.opensdk.utils.Clog;
import com.appnexus.opensdk.utils.Settings;
import com.appnexus.opensdk.utils.Settings.CountImpression;
import com.appnexus.opensdk.utils.StringUtil;

import java.lang.ref.WeakReference;
Expand Down Expand Up @@ -180,7 +182,9 @@ public void onReceiveUTResponse(UTAdResponse response) {
}

private void fireImpressionTrackerEarly (AdView adView, BaseAdResponse response) {
if(adView.countBannerImpressionOnAdLoad){
if(adView.getEffectiveImpressionCountingMethod() == CountImpression.ON_LOAD ||
(adView.getEffectiveImpressionCountingMethod() == CountImpression.LAZY_LOAD &&
adView.isWebviewActivated() && response.getAdType().equalsIgnoreCase(UTConstants.AD_TYPE_BANNER))){
if(response.getImpressionURLs() != null && response.getImpressionURLs().size() > 0){
adView.impressionTrackers = response.getImpressionURLs();
adView.fireImpressionTracker();
Expand Down Expand Up @@ -428,6 +432,9 @@ protected void loadLazyAd() {
}

initiateWebview(adOwner, currentAd);
if (adOwner instanceof AdView) {
fireImpressionTrackerEarly((AdView) adOwner, currentAd);
}
}

}
6 changes: 6 additions & 0 deletions sdk/src/com/appnexus/opensdk/AdWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ public void loadAd(BaseAdResponse ad) {
isVideoAd = (UTConstants.AD_TYPE_VIDEO.equalsIgnoreCase(ad.getAdType()));
isNativeAd = (UTConstants.AD_TYPE_NATIVE.equalsIgnoreCase(ad.getAdType()));

if(adView.getEffectiveImpressionCountingMethod() == Settings.CountImpression.ON_LOAD ||
(adView.getEffectiveImpressionCountingMethod() == Settings.CountImpression.LAZY_LOAD &&
adView.isWebviewActivated() && ad.getAdType().equalsIgnoreCase(UTConstants.AD_TYPE_BANNER))) {
onAdImpression();
}

if (isNativeAd) {
isMRAIDEnabled = false;
html = getNativeRendererContent(ad);
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/com/appnexus/opensdk/BaseNativeAdResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ protected long getAboutToExpireTime(String contentSource, int memberId) {
aboutToExpireTime = Settings.NATIVE_AD_RESPONSE_EXPIRATION_TIME_CSM_CSR;
} else if (contentSource.equalsIgnoreCase("rtb") && memberId == 11217) {
aboutToExpireTime = Settings.NATIVE_AD_RESPONSE_EXPIRATION_TIME_TRIPLELIFT;
} else if (contentSource.equalsIgnoreCase("rtb") && memberId == 12085) {
aboutToExpireTime = Settings.NATIVE_AD_RESPONSE_EXPIRATION_TIME_MSAN;
}

return aboutToExpireTime - getExpiryInterval(contentSource, memberId);
Expand All @@ -106,6 +108,8 @@ protected long getExpiryInterval(String contentSource, int memberId) {
Clog.e(Clog.baseLogTag, "expiryInterval can not be set less then zero, default interval will be used.");
} else if((contentSource.equalsIgnoreCase("csm") || contentSource.equalsIgnoreCase("csr")) && expiryInterval >= Settings.NATIVE_AD_RESPONSE_EXPIRATION_TIME_CSM_CSR) {
Clog.e(Clog.baseLogTag, "facebook expiryInterval can not be greater than 60 minutes, default interval will be used.");
} else if (contentSource.equalsIgnoreCase("rtb") && memberId == 12085 && expiryInterval >= Settings.NATIVE_AD_RESPONSE_EXPIRATION_TIME_MSAN){
Clog.e(Clog.baseLogTag, "for RTB & member 12085 expiryInterval can not be greater than 10 minutes, default interval will be used.");
} else if (contentSource.equalsIgnoreCase("rtb") && memberId == 11217 && expiryInterval >= Settings.NATIVE_AD_RESPONSE_EXPIRATION_TIME_TRIPLELIFT){
Clog.e(Clog.baseLogTag, "for RTB & member 11217 expiryInterval can not be greater than 5 minutes, default interval will be used.");
} else if(expiryInterval >= Settings.NATIVE_AD_RESPONSE_EXPIRATION_TIME){
Expand Down
31 changes: 20 additions & 11 deletions sdk/src/com/appnexus/opensdk/ImpressionTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;

import com.appnexus.opensdk.utils.Clog;
import com.appnexus.opensdk.utils.HTTPGet;
import com.appnexus.opensdk.utils.HTTPResponse;
import com.appnexus.opensdk.utils.Settings;
import com.appnexus.opensdk.viewability.ANOmidAdSession;

import java.lang.ref.WeakReference;

class ImpressionTracker {
private String url;
private VisibilityDetector visibilityDetector;
Expand All @@ -33,18 +36,20 @@ class ImpressionTracker {
private ImpressionListener listener;
private ANOmidAdSession anOmidAdSession;
private ImpressionTrackerListener impressionTrackerListener;
private WeakReference<View> viewWeakReference;

static ImpressionTracker create(String url, VisibilityDetector visibilityDetector, Context context, ANOmidAdSession anOmidAdSession, ImpressionTrackerListener impressionTrackerListener) {
static ImpressionTracker create(WeakReference<View> viewWeakReference, String url, VisibilityDetector visibilityDetector, Context context, ANOmidAdSession anOmidAdSession, ImpressionTrackerListener impressionTrackerListener) {
if (visibilityDetector == null) {
return null;
} else {
ImpressionTracker impressionTracker = new ImpressionTracker(url, visibilityDetector, context, anOmidAdSession, impressionTrackerListener);
visibilityDetector.addVisibilityListener(impressionTracker.listener);
ImpressionTracker impressionTracker = new ImpressionTracker(viewWeakReference, url, visibilityDetector, context, anOmidAdSession, impressionTrackerListener);
visibilityDetector.addVisibilityListener(viewWeakReference, impressionTracker.listener);
return impressionTracker;
}
}

private ImpressionTracker(String url, VisibilityDetector visibilityDetector, Context context, ANOmidAdSession anOmidAdSession, ImpressionTrackerListener impressionTrackerListener) {
private ImpressionTracker(WeakReference<View> viewWeakReference, String url, VisibilityDetector visibilityDetector, Context context, ANOmidAdSession anOmidAdSession, ImpressionTrackerListener impressionTrackerListener) {
this.viewWeakReference = viewWeakReference;
this.url = url;
this.visibilityDetector = visibilityDetector;
this.listener = new ImpressionListener();
Expand Down Expand Up @@ -73,7 +78,7 @@ protected String getUrl() {
}
};
asyncTask.execute();
visibilityDetector.removeVisibilityListener(listener);
visibilityDetector.destroy(viewWeakReference);
listener = null;
} else {
nm.addURL(url, context, new ImpressionTrackerListener() {
Expand All @@ -97,13 +102,17 @@ class ImpressionListener implements VisibilityDetector.VisibilityListener {

@Override
public void onVisibilityChanged(boolean visible) {
if (visible) {
elapsedTime += VisibilityDetector.VISIBILITY_THROTTLE_MILLIS;
} else {
elapsedTime = 0;
}
if (elapsedTime >= Settings.NATIVE_AD_VISIBLE_PERIOD_MILLIS) {
if (visible && SDKSettings.getCountImpressionOn1pxRendering()) {
ImpressionTracker.this.fire();
} else {
if (visible) {
elapsedTime += VisibilityDetector.VISIBILITY_THROTTLE_MILLIS;
} else {
elapsedTime = 0;
}
if (elapsedTime >= Settings.NATIVE_AD_VISIBLE_PERIOD_MILLIS) {
ImpressionTracker.this.fire();
}
}
}
}
Expand Down
35 changes: 35 additions & 0 deletions sdk/src/com/appnexus/opensdk/SDKSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.util.Map;
import java.util.concurrent.Executor;

import static com.appnexus.opensdk.utils.Settings.countImpressionOn1pxRendering;

/**
* Global static functions that apply to all SDK views and calls.
*/
Expand Down Expand Up @@ -100,6 +102,24 @@ public static void disableAAIDUsage(boolean disable) {
Settings.getSettings().disableAAIDUsage = disable;
}

/**
Do not track flag. Set this to true/false if you have information in the app about user opt-out.
If set to true, tracking cookies and AAID will be disabled for all future auctions.
Default value is false.
*/
public static void setDoNotTrack(boolean dnt) {
Settings.getSettings().doNotTrack = dnt;
}

/**
* Returns true if Do not track is enabled.
* False otherwise.
*/
public static boolean getDoNotTrack() {
return Settings.getSettings().doNotTrack;
}


/**
* Returns true if the ad server calls will include location information
* or false otherwise.
Expand Down Expand Up @@ -452,5 +472,20 @@ public interface InitListener {
void onInitFinished();
}

/**
* @return boolean that states the value of countImpressionOn1pxRendering
* set by using {@link #setCountImpressionOn1pxRendering(boolean)}. Default is false.
* */
public static boolean getCountImpressionOn1pxRendering() {
return countImpressionOn1pxRendering;
}

/**
* To enable the Impression counting on 1px display
* @param enable set true to enable, false to disable. Default is false.
* */
public static void setCountImpressionOn1pxRendering(boolean enable) {
countImpressionOn1pxRendering = enable;
}

}
Loading

0 comments on commit fa4b4bc

Please sign in to comment.