Skip to content

Commit 231e38e

Browse files
committed
SDK v7.13
* commit '8732d1269e4c8b689dde7f125316114d031a6d7f': Updated SDK version, RELEASE-NOTES Merge pull request #516 in MOBILE-SDK/app_mobile-sdk-android from NoCookie_Changes_Android to develop
2 parents f694034 + 8732d12 commit 231e38e

15 files changed

+91
-33
lines changed

RELEASE-NOTES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 7.13
2+
### New Feature
3+
+ MS-4693 Added support for Cookieless domain requests
4+
15
## 7.12
26
### Improvements/Bug Fixes
37
+ MS-4704 Added support for OMID containerGeometry and onScreenContainerGeometry for Instream & OutStream Video Ads

instreamvideo/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Project Properties
2-
version = "1.26" // Instream SDK version
2+
version = "1.27" // Instream SDK version
33

44
apply plugin: 'com.android.library'
55

@@ -10,7 +10,7 @@ android {
1010
defaultConfig {
1111
minSdkVersion 14
1212
targetSdkVersion 28
13-
versionCode 24 // An integer value that represents the version of the code, relative to other versions. Increase for each release.
13+
versionCode 25 // An integer value that represents the version of the code, relative to other versions. Increase for each release.
1414
versionName version
1515
consumerProguardFiles 'proguard-project.txt'
1616
}

sdk/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Project properties
2-
version = "7.12"
2+
version = "7.13"
33
group='com.appnexus.opensdk'
44

55
// Android build
@@ -9,7 +9,7 @@ android {
99
compileSdkVersion 28
1010
buildToolsVersion '29.0.0'
1111
defaultConfig {
12-
versionCode 82 // An integer value that represents the version of the code, relative to other versions. Increase for each release.
12+
versionCode 83 // An integer value that represents the version of the code, relative to other versions. Increase for each release.
1313
versionName version
1414
consumerProguardFiles 'proguard-project.txt'
1515
minSdkVersion 14

sdk/src/com/appnexus/opensdk/AdWebView.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public void loadAd(BaseAdResponse ad) {
249249
html = prependViewPort(html);
250250
html = omidAdSession.prependOMIDJSToHTML(html);
251251
}
252-
this.loadDataWithBaseURL(Settings.getBaseUrl(), html, "text/html", "UTF-8", null);
252+
this.loadDataWithBaseURL(Settings.getWebViewBaseUrl(), html, "text/html", "UTF-8", null);
253253
}
254254
} catch (OutOfMemoryError exception) {
255255
// System is running low in memory and cannot process loadAd just return a failure.
@@ -337,7 +337,7 @@ protected void onPostExecute(HTTPResponse response) {
337337
html = prependRawResources(html);
338338
html = prependViewPort(html);
339339

340-
loadDataWithBaseURL(Settings.getBaseUrl(), html, "text/html", "UTF-8", null);
340+
loadDataWithBaseURL(Settings.getWebViewBaseUrl(), html, "text/html", "UTF-8", null);
341341
fireMRAIDEnabled();
342342
}
343343
}

sdk/src/com/appnexus/opensdk/SDKSettings.java

+10
Original file line numberDiff line numberDiff line change
@@ -488,4 +488,14 @@ public static void setCountImpressionOn1pxRendering(boolean enable) {
488488
countImpressionOn1pxRendering = enable;
489489
}
490490

491+
492+
/**
493+
* @deprecated This will be removed in future releases. This is introduced just a fail safe kill switch for initial rollout. No Alternative.
494+
* To allow/disallow using ib.adnxs-simple.com domain for Ad Requests.
495+
* @param allow set true to enable, false to disable. Default is true.
496+
* */
497+
public static void setAllowUsingSimpleDomain(boolean allow) {
498+
Settings.getSettings().simpleDomainUsageAllowed = allow;
499+
}
500+
491501
}

sdk/src/com/appnexus/opensdk/ut/UTAdRequest.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ private void fail(ResultCode code) {
128128
HashMap<String, UTAdResponse> makeRequest() {
129129
try {
130130

131-
String baseUrl = UTConstants.REQUEST_BASE_URL_UT;
131+
Settings.getSettings().deviceAccessAllowed = ANGDPRSettings.canIAccessDeviceData(requestParams.getContext()); // Make sure GDPR device access is allowed.
132+
String baseUrl = Settings.getAdRequestUrl();
132133
URL url = new URL(baseUrl);
133134
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
134135
conn.setDoOutput(true);
@@ -137,7 +138,7 @@ HashMap<String, UTAdResponse> makeRequest() {
137138
conn.setRequestProperty("Accept", "application/json");
138139
conn.setRequestProperty("Accept-Language", Settings.getSettings().language);
139140
conn.setRequestProperty("User-Agent", Settings.getSettings().ua);
140-
if (ANGDPRSettings.canIAccessDeviceData(requestParams.getContext()) && !Settings.getSettings().doNotTrack) {
141+
if (Settings.getSettings().deviceAccessAllowed && !Settings.getSettings().doNotTrack) {
141142
String cookieString = WebviewUtil.getCookie();
142143
if (!TextUtils.isEmpty(cookieString)) {
143144
conn.setRequestProperty("Cookie", cookieString);
@@ -183,7 +184,7 @@ HashMap<String, UTAdResponse> makeRequest() {
183184

184185
Clog.i(Clog.httpRespLogTag, "RESPONSE - " + result);
185186
Map<String, List<String>> headers = conn.getHeaderFields();
186-
if (ANGDPRSettings.canIAccessDeviceData(requestParams.getContext()) && !Settings.getSettings().doNotTrack) {
187+
if (Settings.getSettings().deviceAccessAllowed && !Settings.getSettings().doNotTrack) {
187188
WebviewUtil.cookieSync(headers);
188189
}
189190
ANMultiAdRequest anMultiAdRequest = getMultiAdRequest();

sdk/src/com/appnexus/opensdk/ut/UTConstants.java

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ public class UTConstants {
2828
public static final String MRAID_JS_FILENAME = "mraid.js";
2929
public static final String EXTRAS_KEY_MRAID = "MRAID";
3030
public static final String EXTRAS_KEY_ORIENTATION = "ORIENTATION";
31+
32+
// URL Constants below should never be directly accessed inside SDK.
33+
// Always use Settings.getWebViewBaseUrl() / Settings.getAdRequestUrl() / Settings.getCookieDomain()
3134
public static String REQUEST_BASE_URL_UT = "https://mediation.adnxs.com/ut/v3";
35+
public static String WEBVIEW_BASE_URL_UT = "https://mediation.adnxs.com/";
36+
public static String COOKIE_DOMAIN = "https://mediation.adnxs.com"; // There is only one cookie domain. No cookies for ib.adnxs-simple
37+
38+
public static String REQUEST_BASE_URL_SIMPLE = "https://ib.adnxs-simple.com/ut/v3";
39+
public static String WEBVIEW_BASE_URL_SIMPLE = "https://ib.adnxs-simple.com/";
3240

3341
}

sdk/src/com/appnexus/opensdk/ut/UTRequestParameters.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,10 @@ private JSONObject getDeviceObject() {
10311031
// limited ad tracking
10321032
device.put(DEVICE_LMT, Settings.getSettings().limitTrackingEnabled);
10331033

1034-
if (ANGDPRSettings.canIAccessDeviceData(context) && !SDKSettings.isAAIDUsageDisabled() && !Settings.getSettings().doNotTrack) {
1034+
// Update the value of device access consent in setting each time a request is made.
1035+
Settings.getSettings().deviceAccessAllowed = ANGDPRSettings.canIAccessDeviceData(context);
1036+
1037+
if (Settings.getSettings().deviceAccessAllowed && !SDKSettings.isAAIDUsageDisabled() && !Settings.getSettings().doNotTrack) {
10351038
if (!StringUtil.isEmpty(Settings.getSettings().aaid)) {
10361039
JSONObject device_id = new JSONObject();
10371040
device_id.put(DEVICE_ID_AAID, Settings.getSettings().aaid);

sdk/src/com/appnexus/opensdk/utils/HTTPGet.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ private HttpURLConnection createConnection(URL url) throws IOException {
8686

8787
private void setConnectionParams(HttpURLConnection connection) throws ProtocolException {
8888
connection.setRequestProperty("User-Agent", Settings.getSettings().ua);
89-
String cookieString = WebviewUtil.getCookie();
90-
if (!TextUtils.isEmpty(cookieString)) {
91-
connection.setRequestProperty("Cookie",cookieString);
89+
if (Settings.getSettings().deviceAccessAllowed && !Settings.getSettings().doNotTrack) {
90+
String cookieString = WebviewUtil.getCookie();
91+
if (!TextUtils.isEmpty(cookieString)) {
92+
connection.setRequestProperty("Cookie", cookieString);
93+
}
9294
}
9395
connection.setConnectTimeout(Settings.HTTP_CONNECTION_TIMEOUT);
9496
connection.setReadTimeout(Settings.HTTP_SOCKET_TIMEOUT);

sdk/src/com/appnexus/opensdk/utils/Settings.java

+29-15
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818

1919
import android.location.Location;
2020
import android.os.Build;
21+
import android.text.TextUtils;
2122

2223
import com.appnexus.opensdk.ANExternalUserIdSource;
24+
import com.appnexus.opensdk.ANGDPRSettings;
2325
import com.appnexus.opensdk.BuildConfig;
2426
import com.appnexus.opensdk.MediaType;
2527
import com.appnexus.opensdk.R;
28+
import com.appnexus.opensdk.ut.UTConstants;
2629

30+
import java.net.URL;
2731
import java.util.HashMap;
2832
import java.util.HashSet;
2933
import java.util.Locale;
@@ -50,6 +54,10 @@ public enum CountImpression {
5054
public String carrierName = null;
5155
public String aaid = null;
5256
public boolean limitTrackingEnabled = false;
57+
// Caches the value of DeviceAccessConsent for each request and is updated every time a request is made.
58+
// Use this value instead of calling and fetching from shared preference each time.
59+
public boolean deviceAccessAllowed = true;
60+
5361
@Deprecated
5462
public boolean useHttps=true;
5563

@@ -100,6 +108,13 @@ public enum CountImpression {
100108
* */
101109
public static boolean countImpressionOn1pxRendering = false;
102110

111+
/**
112+
* @deprecated
113+
* This feature flag is responsible for turning on/off ib.adnxs-simple.com domain usage.
114+
* By default this is true. This feature flag will be removed in future releases. This is introduced just as a failsafe kill switch.
115+
* */
116+
public static boolean simpleDomainUsageAllowed = true;
117+
103118
// STATICS
104119
public static final int HTTP_CONNECTION_TIMEOUT = 15000;
105120
public static final int HTTP_SOCKET_TIMEOUT = 20000;
@@ -134,11 +149,7 @@ public enum CountImpression {
134149

135150
public static final int VIDEO_AUTOPLAY_PERCENTAGE = 50;
136151

137-
private static String COOKIE_DOMAIN = "https://mediation.adnxs.com";
138152
public static final String AN_UUID = "uuid2";
139-
private static String BASE_URL = "https://mediation.adnxs.com/";
140-
private static String REQUEST_BASE_URL = "https://mediation.adnxs.com/mob?";
141-
private static String INSTALL_BASE_URL = "https://mediation.adnxs.com/install?";
142153

143154
private static String VIDEO_HTML = "file:///android_asset/apn_vastvideo.html";
144155

@@ -185,26 +196,29 @@ public HashSet<String> getInvalidNetwork(MediaType type) {
185196
return null;
186197
}
187198

188-
public static String getBaseUrl() {
189-
return BASE_URL;
190-
}
191-
192-
public static String getRequestBaseUrl() {
193-
return REQUEST_BASE_URL;
199+
// Returns ib.adnxs-simple.com if we do not have deviceAccessConsent as per GDPR or when doNotTrack is turned on by publisher
200+
public static String getWebViewBaseUrl() {
201+
if ((!Settings.getSettings().deviceAccessAllowed || Settings.getSettings().doNotTrack) && Settings.getSettings().simpleDomainUsageAllowed) {
202+
return UTConstants.WEBVIEW_BASE_URL_SIMPLE;
203+
}
204+
return UTConstants.WEBVIEW_BASE_URL_UT;
194205
}
195206

196-
public static String getInstallBaseUrl() {
197-
return INSTALL_BASE_URL;
207+
// Returns ib.adnxs-simple.com if we do not have deviceAccessConsent as per GDPR or when doNotTrack is turned on by publisher
208+
public static String getAdRequestUrl() {
209+
if ((!Settings.getSettings().deviceAccessAllowed || Settings.getSettings().doNotTrack) && Settings.getSettings().simpleDomainUsageAllowed) {
210+
return UTConstants.REQUEST_BASE_URL_SIMPLE;
211+
}
212+
return UTConstants.REQUEST_BASE_URL_UT;
198213
}
199214

200-
201215
public static String getVideoHtmlPage() {
202216
return Settings.getSettings().debug_mode ? VIDEO_HTML.replace("apn_vastvideo.html", "apn_vastvideo.html?ast_debug=true") : VIDEO_HTML;
203217
}
204218

205-
219+
// There is only one cookie domain
206220
public static String getCookieDomain(){
207-
return COOKIE_DOMAIN;
221+
return UTConstants.COOKIE_DOMAIN;
208222
}
209223

210224
}

sdk/src/com/appnexus/opensdk/utils/WebviewUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public static String getCookie() {
188188
Clog.i(Clog.httpRespLogTag, "Unable to find a CookieManager");
189189
return null;
190190
}
191-
return cm.getCookie(Settings.getBaseUrl());
191+
return cm.getCookie(Settings.getCookieDomain());
192192
}catch (Exception e){
193193
// Catches PackageManager$NameNotFoundException for webview
194194
Clog.e(Clog.httpRespLogTag, "Unable to find a CookieManager - Exception: "+e.getMessage());

sdk/test/com/appnexus/opensdk/BaseRoboTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void setup() {
4444
server.start();
4545
HttpUrl url= server.url("/");
4646
UTConstants.REQUEST_BASE_URL_UT = url.toString();
47+
UTConstants.REQUEST_BASE_URL_SIMPLE = url.toString();
4748
System.out.println(UTConstants.REQUEST_BASE_URL_UT);
4849
ShadowSettings.setTestURL(url.toString());
4950
TestResponsesUT.setTestURL(url.toString());
@@ -106,6 +107,7 @@ public void restartServer() {
106107
server.start();
107108
HttpUrl url= server.url("/");
108109
UTConstants.REQUEST_BASE_URL_UT = url.toString();
110+
UTConstants.REQUEST_BASE_URL_SIMPLE = url.toString();
109111
System.out.println(UTConstants.REQUEST_BASE_URL_UT);
110112
ShadowSettings.setTestURL(url.toString());
111113
TestResponsesUT.setTestURL(url.toString());

sdk/test/com/appnexus/opensdk/DefaultSettingsTest.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
@Config(sdk = 21)
3131
@RunWith(RobolectricTestRunner.class)
32-
public class DefaultSettingsTest {
32+
public class DefaultSettingsTest extends BaseRoboTest {
3333

3434
@Before
3535
public void setup() {
@@ -38,6 +38,7 @@ public void setup() {
3838

3939
@After
4040
public void tearDown() {
41+
Settings.getSettings().deviceAccessAllowed = true; // Reset to defaultduring setup
4142
}
4243

4344
@Test
@@ -54,8 +55,17 @@ public void testDefaultStaticValues() {
5455
assertEquals(50, Settings.MIN_PERCENTAGE_VIEWED);
5556
assertEquals("https://mediation.adnxs.com", Settings.getCookieDomain());
5657
assertEquals("uuid2", Settings.AN_UUID);
57-
assertEquals("https://mediation.adnxs.com/", Settings.getBaseUrl());
58-
assertEquals("https://mediation.adnxs.com/mob?", Settings.getRequestBaseUrl());
59-
assertEquals("https://mediation.adnxs.com/install?", Settings.getInstallBaseUrl());
58+
assertEquals("https://mediation.adnxs.com/", Settings.getWebViewBaseUrl());
59+
assertEquals("https://mediation.adnxs.com/ut/v3", Settings.getAdRequestUrl());
60+
}
61+
62+
@Test
63+
public void testDeviceAccessConsentFalseStaticValues() {
64+
Settings.getSettings().deviceAccessAllowed = false;
65+
assertEquals("https://mediation.adnxs.com", Settings.getCookieDomain()); // No seperate cookie domain
66+
assertEquals("https://ib.adnxs-simple.com/", Settings.getWebViewBaseUrl());
67+
System.out.println("Setting WebView Base URL"+Settings.getWebViewBaseUrl());
68+
assertEquals("https://ib.adnxs-simple.com/ut/v3", Settings.getAdRequestUrl());
69+
System.out.println("REQUEST Request URL"+Settings.getAdRequestUrl());
6070
}
6171
}

sdk/test/com/appnexus/opensdk/NativeRequestTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public MockResponse dispatch(RecordedRequest request) throws InterruptedExceptio
111111
server.setDispatcher(dispatcher);
112112
HttpUrl impbus = server.url("/");
113113
UTConstants.REQUEST_BASE_URL_UT = impbus.toString();
114+
UTConstants.REQUEST_BASE_URL_SIMPLE = impbus.toString();
114115
NativeAdRequestListener listener = new NativeAdRequestListener() {
115116

116117
@Override

sdk/test/com/appnexus/opensdk/UTAdRequestTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public void setup() {
7474
utRequestParameters.setPrimarySize(new AdSize(1, 1));
7575
Settings.getSettings().ua = "";
7676
SDKSettings.disableAAIDUsage(false);
77+
SDKSettings.setDoNotTrack(false);
7778
}
7879

7980
@Test
@@ -615,13 +616,15 @@ public void testGDPRSettings() throws Exception {
615616
executionSteps();
616617
JSONObject postDataBeforeGDPRValueSet = inspectPostData();
617618
assertFalse(postDataBeforeGDPRValueSet.has("gdpr_consent"));
619+
assertTrue(Settings.getSettings().deviceAccessAllowed); // Default case with no GDPR settings device access should be allowed
618620

619621
ANGDPRSettings.setConsentRequired(activity, true);
620622
ANGDPRSettings.setConsentString(activity, "fooBar");
621623
executionSteps();
622624
JSONObject postDataWithGDPRValueSet = inspectPostData();
623625
assertEquals(true, postDataWithGDPRValueSet.getJSONObject("gdpr_consent").getBoolean("consent_required"));
624626
assertEquals("fooBar", postDataWithGDPRValueSet.getJSONObject("gdpr_consent").getString("consent_string"));
627+
assertFalse(Settings.getSettings().deviceAccessAllowed); // When consent required set to true and no purpose consent string deviceAccess is not allowed
625628
}
626629

627630
/**

0 commit comments

Comments
 (0)