From 38db5e83ed6f04212f8bf44709c5703043843295 Mon Sep 17 00:00:00 2001 From: Daniel Berger Date: Mon, 21 Aug 2023 14:43:25 +0000 Subject: [PATCH 1/3] Pull request #716: added additional information for invalid response errors Merge in MOBILE-SDK/app_mobile-sdk-android from MS-5371_invalid_response_info to develop Squashed commit of the following: commit a1011954aa1337514548ccda438cc85f07556a01 Author: Daniel Berger Date: Wed Aug 16 10:56:31 2023 -0400 added missing semicolon and error details commit 03f15bd7fa367626242039d068153f4b08359e27 Author: Daniel Berger Date: Tue Aug 15 14:16:11 2023 -0400 added additional information for invalid response errors commit 5a3f6918ffdbc812b4a013ed562bf218c83c44fb Merge: 334c8214 1997a2fa Author: Ritesh Zaveri Date: Thu Jul 6 10:30:06 2023 +0000 Pull request #714: Release branch v8.7 Merge in MOBILE-SDK/app_mobile-sdk-android from release_branch_v8.7 to master * commit '1997a2fa5b209a52ea95bd40a7a02361864433e0': release version 8.7 Pull request #712: PR comments fix update mvp.js Added unit tests Move logic from AdWebview to BannerAdView Reverted SimpleBanner changes Changes for video orientation Pull request #710: Retrieve AAID only if permitted Added log message Added inline comment Added debug logs for onAdResponseReceived updated test cases fix_recyclerview_scrolling_issue commit 334c82149d67ff1250e6b30a761b2a08caca5d2e Merge: 26cf8d04 d3765cd4 Author: Ritesh Zaveri Date: Wed Jun 7 13:53:31 2023 +0000 Pull request #708: Release branch v8.6.1 Merge in MOBILE-SDK/app_mobile-sdk-android from release_branch_v8.6.1 to master * commit 'd3765cd4d5111fbd9842a814070dd1b61c322f29': (26 commits) release version 8.6.1 change sdk version release version 8.6.1 handled index out of bound exception jenkins test mediation changes and code clean uncommenting mediation classes UTAdResponse changes UTAd Responses test changes merged develop branch conflict commenting sdk settings for testing purpose native ad changes commenting mediation classes mediatition native ad working mediated timedout test working changes test unit case instream build roboelectric changes sdk build revert changes roboelectric lib changes revert instream build changes ... commit 26cf8d043f38d2bf301c281b566ccd4f81bbbd6b Merge: 642cf8da d0953704 Author: Ritesh Zaveri Date: Thu Apr 6 17:46:55 2023 +0000 Merge pull request #701 in MOBILE-SDK/app_mobile-sdk-android from release_branch_v8.6 to master * commit 'd0953704cd3d01025b4dc2b7e739f2d7eeed3477': version change in settings release version 8.6 MS-5199 Fix unit tests after gradle upgrade MS-5199 upgrade gradle version MS-5302 upgrade fb audience network MS-5306 NPE in loadAdFromVAST in VideoAd commit 642cf8dad847b4a89011fec261c82c633d6c32e1 Merge: 11659751 831178b6 Author: Ritesh Zaveri Date: Tue Mar 7 14:59:25 2023 +0000 Merge pull request #694 in MOBILE-SDK/app_mobile-sdk-android from release_branch_8.5 to master * commit '831178b69e087e37c4de3ae9df453a195aa938eb': release_version_8.5 MS-5269 optimize logs MS-5270 onInitFinished not getting triggered handle null pointer exception MS-5237 Removing info logs for request params and response deprecated optional sdk MS-5254 Logs for impression tracking type Updated mvp with Fullscreen fix commit 11659751b727cee866b1f1e88746cee00d4ca64e Merge: 4fa708b5 6d1aa90c Author: Ritesh Zaveri Date: Fri Feb 10 14:31:26 2023 +0000 Merge pull request #684 in MOBILE-SDK/app_mobile-sdk-android from release_branch_8.4 to master * commit '6d1aa90c5ffcd3cc8886532b35bb54888071f122': removed MS-5030 treewalker changes release 8.4 MS-5106_additional_flag to disable prefetching of webview preCacheMraidSupports -> false by default Code cleaning Code cleaning Fixed merge conflicts, added desired optimization Merge pull request #667 in MOBILE-SDK/app_mobile-sdk-android from MS-5143_analyze_CSM_load_time to develop MS-5229 Schibsted PR with tweaks optimise onInitFinished updated oninitfinished logic mraid changes MS-5030 treewalker eats cpu commit 4fa708b569ffdeb478357a3bd40ff0daa6dbc7d4 Merge: 3b592323 f8e460ac Author: Ritesh Zaveri Date: Tue Dec 20 16:26:05 2022 +0000 Merge pull request #678 in MOBILE-SDK/app_mobile-sdk-android from release_branch_8.3 to master * commit 'f8e460ace1c38aef2b6eab6cca042dbe64eb8765': release sdk version 8.3 MS-5210 update AdMob to latest version (21.3.0) to develop added mobile vast player updated sdk android new omid libs commit 3b5923236c1499f04745c53e336edc8ef8d6c035 Merge: 137c80ff 382f422d Author: Abhas Vohra Date: Thu Dec 1 08:44:15 2022 +0000 SDK v8.2 * commit '382f422db88565df869cf105783d240e2dd67c0a': Updated Release notes, sdk version to 8.2 MS-5172 GPP implementation MS-5195 FAN upgrade MS-5190 NPE while loadAdFromVAST MS-5024 Update proguard rules instructions MS-5132 fix failing build for Simple Video MS-5132 Add boolean to notify success / failure in onInitFinished MS-5099 Added performance test cases commit 137c80ff8dae92243ed76dda627f8bac494ca295 Merge: b1838c1d b26adf16 Author: Abhas Vohra Date: Fri Oct 7 20:19:43 2022 +0000 SDK v8.1 * commit 'b26adf1618ab8e39e92d7983616160d19108692f': Updated versionCode, versionName and RELEASE-NOTES MS-5080 Added support for High Impact media commit b1838c1d2922559cca61d2952715bf180a0b7a4e Merge: 11069a8c d30b3a1c Author: Abhas Vohra Date: Wed Aug 17 16:38:16 2022 +0000 SDK v8.0.1 * commit 'd30b3a1c3da5f52e30259201e260a9eee2ef0b98': Proguard Fix for CSR commit 11069a8ce29286cd8e9c1486eb534c43c6c00464 Merge: 10897bb7 94301421 Author: Abhas Vohra Date: Wed Aug 17 13:45:51 2022 +0000 SDK v8.0.1 * commit '94301421b6f09dc38bee1ad8fea7a99d965e737f': Updated Release notes, sdk version MS-5050 proguard fix CSR MS-5050 proguard fixes MS-5050 prevent callbacks and request after cancellation MS-5050 single ad request must not use ScheduledExecutorService MS-5050 MemoryLeak AdSessionContext MS-5050 HONEY_COMB related changes (removed HONEYCOMB checks) MS-5050 Use updated api for user agent MS-5050 Remove callbacks in destroy() MS-5050 memory leak in VisibilityDetector MS-5050 Use application context to init connectivity manager MS-5050 Destroy Webview after fetching user agent commit 10897bb76706e1df00778750a7a214f3b172fde8 Merge: bb9d8d29 1538ed35 Author: Abhas Vohra Date: Thu Jul 28 16:20:21 2022 +0000 SDK v8.0 * commit '1538ed35eca7c59ac84b85a4c1b7299f888f3f72': Updated Release Notes MS-5054 Visibility Detector MS-5011 MS-5040 Viewable Impression Android Video position preroll onPause is not getting tracked when application is in background SDK v8.0 OMSDKv1.3.31 MS-5042 Remove discontinued Adapters MS-4973 Remove deprecated APIs commit bb9d8d29a47ce642a01cbab8faeaeb9a30210a6e Merge: 9c00abc7 1a931d5e Author: Abhas Vohra Date: Tue May 17 16:45:01 2022 +0000 SDK v7.22 * commit '1a931d5e1fcf058b1d0727165df57bdb1737445c': Updated Release Notes, Updated SDK version Fixed Sample / Demo apps Fixed Unit Test Cases MS-5008 add callback for onAdImpression MS-4971 AdMob adapter MS-4870 Sas Adapter Upgrade MS-4872 Facebook Adapter Deprecation. Merge pull request #628 in MOBILE-SDK/app_mobile-sdk-android from MS-4793_AD_ID to develop MS-5021 ANR MRAID Updated the placement Id for test app. Merge pull request #625 in MOBILE-SDK/app_mobile-sdk-android from MS-4999-RendererID-Remove-DeprecationNotice-Android to develop MS-4950 Android Studio Build Issue MS-4951 update compileSdkVersion commit 9c00abc70ae379b7dba97725d66a83fba77ae1a3 Merge: 322414e2 3dabb03e Author: Abhas Vohra Date: Thu Mar 31 13:46:07 2022 +0000 SDK v7.21 * commit '3dabb03e43b8123e96f967bba0d841e50a42592e': SDK v7.21 commit 322414e2a633c55a2dbab8a0d84ca34b6412a584 Merge: 196766fa 4be86c8b Author: Rajshekhar Yadav Date: Wed Mar 30 17:27:05 2022 +0000 Sdk v7.21 * commit '4be86c8b3c7c984dfe7ede022b33649c42b60546': Added Release note and updated the sdk version. Removed deprecation for memberId Fix. for test failures MS-4936 Unit test Report Merge pull request #611 in MOBILE-SDK/app_mobile-sdk-android from MS-4953-UserID-Changes-Android to develop MS-4972 SDK size increases with increase in APK size MS-4982 ANR in MRAID Implementation MS-4705 Fix memory leak MS-4880 API for back press Added SideCar.txt Added-OMID_LICENSE Fixed Instream Video Settings Added MVP commit 196766fae587cf64a0e218a71a8d166e04055acf Merge: 010124e9 e33f41e9 Author: Rajshekhar Yadav Date: Wed Feb 2 16:54:37 2022 +0000 Merge pull request #604 in MOBILE-SDK/app_mobile-sdk-android from release_branch_7.20 to master * commit 'e33f41e94c917f78f2b2fe87ca930f0eb74d8b38': sdk version 7.20 Fixed Unit tests (Video encoding) MS-4916 Video creative rendering issue Readme update MS-4933 Handle null tags MS-4946 Android SDK spams the logcat console with visibility messages MS-4897 Sonarqube Implementation MS-4879 Fixed NPE in RequestManager MS-4748 : Fix Unit Test MS-4909 Fixed Crash while Forcing Native Creating to Banner AdView. commit 010124e9832f21d4c2cf454ff9545d1151bcafbb Merge: d46d3e5e a119bada Author: Abhas Vohra Date: Tue Nov 16 17:42:19 2021 +0000 SDK v.7.19.1 * commit 'a119badaa7c69209880fc6c896799c85eb8c6969': Fixed issue with native impression tracking --- extras/AndroidAdvertisingID/project.properties | 3 ++- sdk/src/com/appnexus/opensdk/AdFetcher.java | 2 +- sdk/src/com/appnexus/opensdk/AdViewRequestManager.java | 6 +++--- sdk/src/com/appnexus/opensdk/CSRNativeBannerController.java | 2 +- .../com/appnexus/opensdk/MediatedNativeAdController.java | 2 +- sdk/src/com/appnexus/opensdk/ut/UTAdRequest.java | 6 +++--- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/extras/AndroidAdvertisingID/project.properties b/extras/AndroidAdvertisingID/project.properties index 49f2a7c62..f26cf7065 100644 --- a/extras/AndroidAdvertisingID/project.properties +++ b/extras/AndroidAdvertisingID/project.properties @@ -7,7 +7,8 @@ # "ant.properties", and override values to adapt the script to your # project structure. # -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +# To enable ProGuard to shrink and obfuscate your +# code, uncomment this (available properties: sdk.dir, user.home): #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt android.library=true diff --git a/sdk/src/com/appnexus/opensdk/AdFetcher.java b/sdk/src/com/appnexus/opensdk/AdFetcher.java index 07c5bc4cd..ebb8b7127 100644 --- a/sdk/src/com/appnexus/opensdk/AdFetcher.java +++ b/sdk/src/com/appnexus/opensdk/AdFetcher.java @@ -280,7 +280,7 @@ synchronized public void handleMessage(Message msg) { fetcher.requestManager = new AdViewRequestManager(fetcher.owner); fetcher.requestManager.execute(); } else { - fetcher.owner.getAdDispatcher().onAdFailed(ResultCode.getNewInstance(ResultCode.INVALID_REQUEST), null); + fetcher.owner.getAdDispatcher().onAdFailed(ResultCode.getNewInstance(ResultCode.INVALID_REQUEST, "Media type unknown"), null); } } } diff --git a/sdk/src/com/appnexus/opensdk/AdViewRequestManager.java b/sdk/src/com/appnexus/opensdk/AdViewRequestManager.java index e767dac4d..055afc11e 100644 --- a/sdk/src/com/appnexus/opensdk/AdViewRequestManager.java +++ b/sdk/src/com/appnexus/opensdk/AdViewRequestManager.java @@ -344,8 +344,8 @@ private void handleRTBResponse(Ad ownerAd, BaseAdResponse rtbAdResponse) { AdView owner = (AdView) ownerAd; fireImpressionTrackerIfBeginToRender(owner, rtbAdResponse); } else { - Clog.e(Clog.baseLogTag, "AdType can not be identified."); - continueWaterfall(ResultCode.getNewInstance(ResultCode.INVALID_REQUEST)); + Clog.e(Clog.baseLogTag, "AdType cannot be identified."); + continueWaterfall(ResultCode.getNewInstance(ResultCode.INVALID_REQUEST, "AdType cannot be identified.")); } } } else { @@ -408,7 +408,7 @@ private void handleCSMResponse(Ad ownerAd, final CSMSDKAdResponse csmSdkAdRespon owner.getAdDispatcher()); } else { Clog.e(Clog.baseLogTag, "MediaType type can not be identified."); - continueWaterfall(ResultCode.getNewInstance(ResultCode.INVALID_REQUEST)); + continueWaterfall(ResultCode.getNewInstance(ResultCode.INVALID_REQUEST, "MediaType type can not be identified")); } } } diff --git a/sdk/src/com/appnexus/opensdk/CSRNativeBannerController.java b/sdk/src/com/appnexus/opensdk/CSRNativeBannerController.java index 24569bc56..a5fb7f90f 100644 --- a/sdk/src/com/appnexus/opensdk/CSRNativeBannerController.java +++ b/sdk/src/com/appnexus/opensdk/CSRNativeBannerController.java @@ -71,7 +71,7 @@ public class CSRNativeBannerController implements CSRController { this, requester.getRequestParams().getTargetingParameters()); } else { - errorCode = ResultCode.getNewInstance(ResultCode.INVALID_REQUEST); + errorCode = ResultCode.getNewInstance(ResultCode.INVALID_REQUEST, "Unable to get CSR mediated request params"); } } catch (ClassNotFoundException e) { // exception in Class.forName diff --git a/sdk/src/com/appnexus/opensdk/MediatedNativeAdController.java b/sdk/src/com/appnexus/opensdk/MediatedNativeAdController.java index 6c43b62ac..c9731b414 100644 --- a/sdk/src/com/appnexus/opensdk/MediatedNativeAdController.java +++ b/sdk/src/com/appnexus/opensdk/MediatedNativeAdController.java @@ -76,7 +76,7 @@ private MediatedNativeAdController(CSMSDKAdResponse currentAd, UTAdRequester req currentAd.getId(), this, requester.getRequestParams().getTargetingParameters()); } else { - errorCode = ResultCode.getNewInstance(ResultCode.INVALID_REQUEST); + errorCode = ResultCode.getNewInstance(ResultCode.INVALID_REQUEST, "Mediated request params not found"); } } catch (ClassNotFoundException e) { // exception in Class.forName diff --git a/sdk/src/com/appnexus/opensdk/ut/UTAdRequest.java b/sdk/src/com/appnexus/opensdk/ut/UTAdRequest.java index abeb949ce..8914cee8e 100644 --- a/sdk/src/com/appnexus/opensdk/ut/UTAdRequest.java +++ b/sdk/src/com/appnexus/opensdk/ut/UTAdRequest.java @@ -280,7 +280,7 @@ void processResponse(HashMap adResponseMap) { if (adResponseMap == null) { Clog.e(Clog.httpRespLogTag, Clog.getString(R.string.no_response)); - fail(ResultCode.getNewInstance(ResultCode.INVALID_REQUEST)); + fail(ResultCode.getNewInstance(ResultCode.INVALID_REQUEST, "Server did not respond and failed to map response")); return; } @@ -306,7 +306,7 @@ void processResponse(HashMap adResponseMap) { } } else if (anMultiAdRequest != null) { if (adResponseMap == null) { - ResultCode code = ResultCode.getNewInstance(ResultCode.INVALID_REQUEST); + ResultCode code = ResultCode.getNewInstance(ResultCode.INVALID_REQUEST, "Failed to map response"); Clog.e(Clog.SRMLogTag, "FAILED: " + code.getMessage()); anMultiAdRequest.onRequestFailed(code); } else { @@ -324,7 +324,7 @@ void processResponse(HashMap adResponseMap) { UTAdRequester requester = new AdViewRequestManager(ad); ad.getMultiAd().setRequestManager(requester); if (adResponseMap == null) { - ResultCode code = ResultCode.getNewInstance(ResultCode.INVALID_REQUEST); + ResultCode code = ResultCode.getNewInstance(ResultCode.INVALID_REQUEST, "Ad response mapping is null"); Clog.e(Clog.SRMLogTag, "FAILED: " + code.getMessage()); requester.failed(code, null); continue; From 076295f3ac349336883b1ba92d24d060ecd88164 Mon Sep 17 00:00:00 2001 From: Ritesh Zaveri Date: Mon, 21 Aug 2023 16:41:40 +0000 Subject: [PATCH 2/3] Pull request #715: LazyLoading for NativeAssembly Merge in MOBILE-SDK/app_mobile-sdk-android from MS-5349_lazyload_banner_native_rendering to develop Squashed commit of the following: commit 9e4e1e255084f4192be52e7ee21fb729f2361396 Author: Ritesh Zaveri Date: Thu Aug 3 19:23:31 2023 +0530 added autorefresh only for banner commit 6202e7cf1a7a342f67519bf7e8360d731ff6ccb6 Author: Ritesh Zaveri Date: Mon Jul 31 18:56:01 2023 +0530 removed unnecessary changes commit 3fb83fb86152ec3a6f00a55fb620bc42c6b18a62 Author: Ritesh Zaveri Date: Fri Jul 28 19:54:28 2023 +0530 resetting boolean flag commit 59ae3c8c16c4624470192e376dd6f60aa9c245a5 Author: Ritesh Zaveri Date: Fri Jul 28 19:21:49 2023 +0530 boolean name change commit 265fc9f3708a4c74771ce27aff422878f77b804f Author: Ritesh Zaveri Date: Fri Jul 28 14:58:18 2023 +0530 variable name change commit 55369fc38ee839888d1db7cdfaf00042f724f7de Author: Ritesh Zaveri Date: Wed Jul 26 22:24:29 2023 +0530 fixed native fail test cases commit 4cd157d9b3b5abe10e46e2d1abe408cb127c717b Author: Ritesh Zaveri Date: Wed Jul 26 20:21:56 2023 +0530 added unit test and change boolean variable commit 396f6259780c31a27fb302d22aa2b7522b4e56ce Author: Ritesh Zaveri Date: Mon Jul 24 20:28:45 2023 +0530 moved assembly boolean from adresponinfo to adview commit dfd34baeb171cdc6e861c4b7733b58e8b3c5d2a3 Author: Ritesh Zaveri Date: Thu Jul 20 16:07:31 2023 +0530 inline comment changes commit ced2a1fc88b0ee1aabfa808da19d6710d8d1f628 Author: Ritesh Zaveri Date: Fri Jul 14 19:47:25 2023 +0530 changed nativeassembly variable name commit 4c5217b0e8c7fa1dda0fe969d6af0d85ce103ef0 Author: Ritesh Zaveri Date: Fri Jul 14 18:03:22 2023 +0530 native assembly lazyload --- sdk/res/values/errors.xml | 2 +- sdk/src/com/appnexus/opensdk/AdFetcher.java | 6 ++ sdk/src/com/appnexus/opensdk/AdView.java | 23 +++- .../opensdk/AdViewRequestManager.java | 10 +- .../com/appnexus/opensdk/AdListenerTest.java | 102 ++++++++++++++++++ 5 files changed, 138 insertions(+), 5 deletions(-) diff --git a/sdk/res/values/errors.xml b/sdk/res/values/errors.xml index 4519e595a..581fac299 100644 --- a/sdk/res/values/errors.xml +++ b/sdk/res/values/errors.xml @@ -161,7 +161,7 @@ loadLazyAd() failed, the Ad isn\'t lazy loaded yet. enableLazyLoad() failed, AdRequest is already in progress. enableLazyLoad() failed, Already enabled once. - loadLazyAd() failed, loadLazyAd can be applied only to the Banner Ad Type. + loadLazyAd() failed, loadLazyAd can be applied only to the Banner or Native Assembly Ad Type. Request Manager can\'t proceed as it has wo initialized owners Ad Request can\'t proceed without Activity Context diff --git a/sdk/src/com/appnexus/opensdk/AdFetcher.java b/sdk/src/com/appnexus/opensdk/AdFetcher.java index ebb8b7127..8326b660e 100644 --- a/sdk/src/com/appnexus/opensdk/AdFetcher.java +++ b/sdk/src/com/appnexus/opensdk/AdFetcher.java @@ -249,6 +249,12 @@ synchronized public void handleMessage(Message msg) { Clog.w(Clog.lazyLoadLogTag, "Not Fetching due to Lazy Load"); return; } + + // Condition to restrict the Auto Refresh if the AdType is not AdType.BANNER. + if (fetcher.owner != null && fetcher.owner instanceof AdView && ((AdView)fetcher.owner).getAdResponseInfo() != null && ((AdView)fetcher.owner).getAdResponseInfo().getAdType() != AdType.BANNER) { + Clog.w(Clog.baseLogTag, "Not Fetching due to AdType is not BANNER"); + return; + } } // Checks if the lazy load is enabled and de activates the Webview (activateWebview - boolean in the AdView), so that the AutoRefresh for Lazy Load can work. // Doing this will deActivate the Webview, which will be required to be activated by calling the loadLazyAd() later. diff --git a/sdk/src/com/appnexus/opensdk/AdView.java b/sdk/src/com/appnexus/opensdk/AdView.java index df728c471..0e74e4524 100644 --- a/sdk/src/com/appnexus/opensdk/AdView.java +++ b/sdk/src/com/appnexus/opensdk/AdView.java @@ -112,6 +112,12 @@ public abstract class AdView extends FrameLayout implements Ad, MultiAd, Visibil */ protected boolean isAdResponseReceived = false; + /** + * This boolean keeps track, if the NativeAdResponse returned from impbus has a valid Native Renderer URL + * and is eligible to be displayed as a Banner Native Assembly Renderer Ad. + */ + protected boolean eligibleForNativeAssemblyRendering = false; + /** * Begin Construction */ @@ -1061,6 +1067,7 @@ public void run() { private void processAdLoaded(AdResponse ad) { isFetching = false; + eligibleForNativeAssemblyRendering = false; if (ad.getMediaType() == MediaType.BANNER || ad.getMediaType() == MediaType.INTERSTITIAL) { handleBannerOrInterstitialAd(ad); } else if (ad.getMediaType() == MediaType.NATIVE) { @@ -1092,6 +1099,7 @@ public void run() { private void processAdFailed(final ResultCode code, final ANAdResponseInfo adResponseInfo) { isFetching = false; + eligibleForNativeAssemblyRendering = false; handler.post(new Runnable() { @Override public void run() { @@ -1190,6 +1198,7 @@ public void run() { public void onAdResponseReceived() { Clog.d(Clog.baseLogTag, "onAdResponseReceived"); isAdResponseReceived = true; + eligibleForNativeAssemblyRendering = false; } private void handleNativeAd(AdResponse ad) { @@ -1596,8 +1605,8 @@ protected boolean loadLazyAd() { return false; } - // loadLazyAd() only if the AdType is AdType.BANNER - if (getAdResponseInfo().getAdType() != AdType.BANNER) { + // loadLazyAd() only if the AdType is AdType.BANNER or Native Assembly Ad Type + if (!isLastResponseSuccessful()) { Clog.w(Clog.lazyLoadLogTag, getContext().getString(R.string.apn_enable_lazy_webview_failure_non_banner)); return false; } @@ -1630,7 +1639,7 @@ protected void deactivateWebviewForNextCall() { * see {@link ANAdResponseInfo} */ protected boolean isLastResponseSuccessful() { - return getAdResponseInfo() != null && getAdResponseInfo().getAdType() == AdType.BANNER; + return getAdResponseInfo() != null && (getAdResponseInfo().getAdType() == AdType.BANNER || (getAdResponseInfo().getAdType() == AdType.NATIVE && isEligibleForNativeAssemblyRendering())); } @Override @@ -1650,4 +1659,12 @@ public Long getStartTime() { public Long getFinishTime() { return finishTime; } + + /** + * Retrieve the NativeAssemblyRenderer of the request + * + * @return true if it is NativeAssemblyRenderer, else false + * */ + public boolean isEligibleForNativeAssemblyRendering() { return eligibleForNativeAssemblyRendering; } + } diff --git a/sdk/src/com/appnexus/opensdk/AdViewRequestManager.java b/sdk/src/com/appnexus/opensdk/AdViewRequestManager.java index 055afc11e..eb1860353 100644 --- a/sdk/src/com/appnexus/opensdk/AdViewRequestManager.java +++ b/sdk/src/com/appnexus/opensdk/AdViewRequestManager.java @@ -266,8 +266,16 @@ private void handleNativeResponse(final Ad owner, final BaseAdResponse baseAdRes } if (owner instanceof BannerAdView && ((BannerAdView) owner).isNativeRenderingEnabled() && nativeAdResponse.getRendererUrl().length() > 0) { - initiateWebview(owner, baseAdResponse); + ((AdView)owner).eligibleForNativeAssemblyRendering = true; + if (((BannerAdView)owner).isLazyWebviewInactive()) { + ((AdDispatcher)owner.getAdDispatcher()).onLazyAdLoaded(currentAd.getAdResponseInfo()); + } else { + initiateWebview(owner, baseAdResponse); + } } else { + if (owner != null && owner instanceof BannerAdView) { + ((AdView)owner).eligibleForNativeAssemblyRendering = false; + } processNativeAd(nativeAdResponse, baseAdResponse); } } diff --git a/sdk/test/com/appnexus/opensdk/AdListenerTest.java b/sdk/test/com/appnexus/opensdk/AdListenerTest.java index 967606b52..b6e044656 100644 --- a/sdk/test/com/appnexus/opensdk/AdListenerTest.java +++ b/sdk/test/com/appnexus/opensdk/AdListenerTest.java @@ -454,7 +454,109 @@ public void testloadLazyAdForDisabledLazyLoad() { assertFalse(adFailed); } + //Native Assembly Load Lazy Testing + @Test + public void testLazyNativeAssemblyAdLoaded() { + ShadowCustomWebView.simulateRendererScriptSuccess = true; + server.setDispatcher(getDispatcher(TestResponsesUT.anNativeRenderer())); + bannerAdView.setAllowNativeDemand(true); + bannerAdView.enableNativeRendering(true); + bannerAdView.enableLazyLoad(); + executeBannerRequest(); + + assertLazyLoadCallbackInProgress(); + bannerAdView.loadLazyAd(); + Robolectric.flushBackgroundThreadScheduler(); + Robolectric.flushForegroundThreadScheduler(); + assertLazyLoadCallbackSuccess(); + } + + // This proves that the second loadAd() behaves as a Lazy load even after the Lazy Ad has already been loaded once (after calling loadLazyAd()) + @Test + public void testLazyNativeAssemblyAdLoadedSuccessAndLoadAgain() { + ShadowCustomWebView.simulateRendererScriptSuccess = true; + server.setDispatcher(getDispatcher(TestResponsesUT.anNativeRenderer())); + bannerAdView.setAllowNativeDemand(true); + bannerAdView.enableNativeRendering(true); + bannerAdView.enableLazyLoad(); + executeBannerRequest(); + assertFalse(bannerAdView.getChildAt(0) instanceof WebView); + assertLazyLoadCallbackInProgress(); + bannerAdView.loadLazyAd(); + Robolectric.flushBackgroundThreadScheduler(); + Robolectric.flushForegroundThreadScheduler(); + assertLazyLoadCallbackSuccess(); + assertTrue(bannerAdView.getChildAt(0) instanceof WebView); + adLoaded = false; + adLazyLoaded = false; + adFailed = false; + restartServer(); + ShadowCustomWebView.simulateRendererScriptSuccess = true; + server.setDispatcher(getDispatcher(TestResponsesUT.anNativeRenderer())); + bannerAdView.setAllowNativeDemand(true); + bannerAdView.enableNativeRendering(true); + executeBannerRequest(); + assertLazyLoadCallbackInProgress(); + bannerAdView.loadLazyAd(); + Robolectric.flushBackgroundThreadScheduler(); + Robolectric.flushForegroundThreadScheduler(); + assertLazyLoadCallbackSuccess(); + assertTrue(bannerAdView.getChildAt(0) instanceof WebView); + Robolectric.flushBackgroundThreadScheduler(); + Robolectric.flushForegroundThreadScheduler(); + } + @Test + public void testloadLazyNativeAssemblyAdAfterAdLoad() { + ShadowCustomWebView.simulateRendererScriptSuccess = true; + server.setDispatcher(getDispatcher(TestResponsesUT.anNativeRenderer())); + bannerAdView.setAllowNativeDemand(true); + bannerAdView.enableNativeRendering(true); + assertTrue(bannerAdView.enableLazyLoad()); + executeBannerRequest(); + assertLazyLoadCallbackInProgress(); + assertTrue(bannerAdView.loadLazyAd()); + Robolectric.flushBackgroundThreadScheduler(); + Robolectric.flushForegroundThreadScheduler(); + assertLazyLoadCallbackSuccess(); + adLoaded = false; + adFailed = false; + assertFalse(bannerAdView.loadLazyAd()); + assertFalse(adLoaded); + assertFalse(adFailed); + } + + @Test + public void testLazyNativeAssemblyAdLoadWithloadLazyAdAlreadyCalled() { + ShadowCustomWebView.simulateRendererScriptSuccess = true; + server.setDispatcher(getDispatcher(TestResponsesUT.anNativeRenderer())); + bannerAdView.setAllowNativeDemand(true); + bannerAdView.enableNativeRendering(true); + bannerAdView.enableLazyLoad(); + assertFalse(bannerAdView.loadLazyAd()); + executeBannerRequest(); + assertLazyLoadCallbackInProgress(); + assertTrue(bannerAdView.loadLazyAd()); + Robolectric.flushBackgroundThreadScheduler(); + Robolectric.flushForegroundThreadScheduler(); + assertLazyLoadCallbackSuccess(); + } + + @Test + public void testLazyNativeAssemblyAdFailed() { + ShadowCustomWebView.simulateRendererScriptSuccess = false; + server.setDispatcher(getDispatcher(TestResponsesUT.anNativeRenderer())); // First queue a banner Native response + bannerAdView.setAllowNativeDemand(false); + bannerAdView.enableNativeRendering(false); + bannerAdView.enableLazyLoad(); + executeBannerRequest(); + bannerAdView.loadLazyAd(); + Robolectric.flushBackgroundThreadScheduler(); + Robolectric.flushForegroundThreadScheduler(); + assertFalse(bannerAdView.loadLazyAd()); + assertFalse(adFailed); + assertFalse(adLazyLoaded); + } @Test public void testBannerAdFailed() { From d1d1b6697e5d48d0d8a95e56865bbaf1a951accf Mon Sep 17 00:00:00 2001 From: Ritesh Zaveri Date: Tue, 22 Aug 2023 14:56:05 +0530 Subject: [PATCH 3/3] release version 8.8 --- RELEASE-NOTES.md | 8 ++++++++ instreamvideo/build.gradle | 4 ++-- sdk/build.gradle | 4 ++-- sdk/src/com/appnexus/opensdk/utils/Settings.java | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 9c2988745..61ddced28 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,3 +1,11 @@ +## 8.8 + +### New Features ++ MS-5349 Enabled lazy loading for banner native rendering + +### Improvement/Bug Fixes ++ MS-5371 Added additional information for INVALID_REQUEST code error messages + ## 8.7 ### New Features diff --git a/instreamvideo/build.gradle b/instreamvideo/build.gradle index 722bdc137..4e0e0159b 100644 --- a/instreamvideo/build.gradle +++ b/instreamvideo/build.gradle @@ -1,5 +1,5 @@ // Project Properties -version = "1.46" // Instream SDK version +version = "1.47" // Instream SDK version apply plugin: 'com.android.library' @@ -10,7 +10,7 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 32 - versionCode 45 // An integer value that represents the version of the code, relative to other versions. Increase for each release. + versionCode 46 // An integer value that represents the version of the code, relative to other versions. Increase for each release. versionName version consumerProguardFiles 'proguard-project.txt' } diff --git a/sdk/build.gradle b/sdk/build.gradle index ffd176ff6..c156b84e0 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -1,5 +1,5 @@ // Project properties -version = "8.7" +version = "8.8" group='com.appnexus.opensdk' // Android build @@ -10,7 +10,7 @@ android { buildToolsVersion '32.0.0' defaultConfig { - versionCode 104 // An integer value that represents the version of the code, relative to other versions. Increase for each release. + versionCode 105 // 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 diff --git a/sdk/src/com/appnexus/opensdk/utils/Settings.java b/sdk/src/com/appnexus/opensdk/utils/Settings.java index 34de7087b..e35283094 100644 --- a/sdk/src/com/appnexus/opensdk/utils/Settings.java +++ b/sdk/src/com/appnexus/opensdk/utils/Settings.java @@ -68,7 +68,7 @@ public enum ImpressionType { public boolean debug_mode = false; // This should always be false here. public String ua = null; - public final String sdkVersion = "8.7"; + public final String sdkVersion = "8.8"; // BuildConfig.VERSION_NAME;