diff --git a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/HwImaAdapter.java b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/HwImaAdapter.java index 431a7ce..9eacf37 100644 --- a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/HwImaAdapter.java +++ b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/HwImaAdapter.java @@ -32,8 +32,7 @@ public class HwImaAdapter { - private final static String TAG = "HwImaPluginLatest"; - + private static final String TAG = "HwImaAdapter"; private static HwImaAdapter instance; private SimpleExoPlayer player; @@ -71,7 +70,6 @@ private void clearInstance() { } private void analyseMediaItems() { - for (int i = 0; i < player.getMediaItemCount(); i++) { MediaItem item = player.getMediaItemAt(i); if (item.playbackProperties != null && item.playbackProperties.adsConfiguration != null) { @@ -89,38 +87,31 @@ private void analyseGoogleAds() { Uri adTagUri = entry.getValue(); Set args = adTagUri.getQueryParameterNames(); - ads.adUri = adTagUri; - ads.contentUri = entry.getKey(); - - if (args.contains(AdTagURLVariables.output)) { - ads.xmlOutputType = adTagUri.getQueryParameter(AdTagURLVariables.output); - } - if (args.contains(AdTagURLVariables.vPos)) { - ads.adPosition = adTagUri.getQueryParameter(AdTagURLVariables.vPos); - } - if (args.contains(AdTagURLVariables.vAdType)) { - ads.adType = adTagUri.getQueryParameter(AdTagURLVariables.vAdType); - } - if (args.contains(AdTagURLVariables.maxAdDuration)) { - ads.maxAdDuration = Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.maxAdDuration)); - } - if (args.contains(AdTagURLVariables.minAdDuration)) { - ads.minAdDuration = Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.minAdDuration)); - } + ads.setAdUri(adTagUri); + ads.setContentUri(entry.getKey()); + + if (args.contains(AdTagURLVariables.output)) + ads.setXmlOutputType(adTagUri.getQueryParameter(AdTagURLVariables.output)); + if (args.contains(AdTagURLVariables.vPos)) + ads.setAdPosition(adTagUri.getQueryParameter(AdTagURLVariables.vPos)); + if (args.contains(AdTagURLVariables.vAdType)) + ads.setAdType(adTagUri.getQueryParameter(AdTagURLVariables.vAdType)); + if (args.contains(AdTagURLVariables.maxAdDuration)) + ads.setMaxAdDuration(Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.maxAdDuration))); + if (args.contains(AdTagURLVariables.minAdDuration)) + ads.setMinAdDuration(Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.minAdDuration))); if (args.contains(AdTagURLVariables.size)) { - try { - String[] whAdSlot = adTagUri.getQueryParameter(AdTagURLVariables.size).split("x"); - ads.width = Integer.parseInt(whAdSlot[0]); - ads.height = Integer.parseInt(whAdSlot[1]); - } catch (Exception e) { - Log.e(TAG, "Ad URL: Slot size parse failed"); + String[] whAdSlot = adTagUri.getQueryParameter(AdTagURLVariables.size).split("x"); + if (whAdSlot.length > 0) { + ads.setWidth(Integer.parseInt(whAdSlot[0])); + ads.setHeight(Integer.parseInt(whAdSlot[1])); } } if (args.contains(AdTagURLVariables.npa)) { - ads.npaStatus = Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.npa)); + ads.setNpaStatus(Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.npa))); } if (args.contains(AdTagURLVariables.tfcd)) { - ads.tcfdStatus = Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.tfcd)); + ads.setTcfdStatus(Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.tfcd))); } googleAds.add(ads); @@ -129,15 +120,16 @@ private void analyseGoogleAds() { } catch (Exception e) { Log.i(TAG, e.toString()); } + } private void requestVastSDK() { for (GoogleAds ads : googleAds) { - if (ads.xmlOutputType.equals(AdTagURLVariables.vast)) { + if (ads.getXmlOutputType().equals(AdTagURLVariables.vast)) { configureSDKRequest(ads); makeRequestForVast(ads); - } else if (ads.xmlOutputType.equals(AdTagURLVariables.vmap)) { + } else if (ads.getXmlOutputType().equals(AdTagURLVariables.vmap)) { List vmapAds = VastXMLCreator.getGoogleAdsFromVMAP(ads); if (vmapAds != null) { @@ -160,11 +152,9 @@ public void onAdsLoadedSuccess(AdsData adsData) { for (LinearCreative creative : linearAds) { - if (creative.skipDuration != 0) { + if (creative.skipDuration != 0 && !handler.checkGoogleHasOffset(ad)) { //check google ad contain offset - if (!handler.checkGoogleHasOffset(ad)) { - creative.skipDuration = -1; - } + creative.skipDuration = -1; } String vXML = VastXMLCreator.create(creative, false); @@ -172,12 +162,12 @@ public void onAdsLoadedSuccess(AdsData adsData) { hwAdsUris.add(uri); } - createMediaItemForVast(ad.contentUri, hwAdsUris.get(0)); + createMediaItemForVast(ad.getContentUri(), hwAdsUris.get(0)); } else { /** * if there is no ad from vast sdk, set media item that contains google ad */ - createMediaItemForVast(ad.contentUri, ad.adUri); + createMediaItemForVast(ad.getContentUri(), ad.getAdUri()); } } @@ -186,7 +176,7 @@ public void onAdsLoadFailed() { /** * if there is no ad from vast sdk, set media item that contains google ad */ - createMediaItemForVast(ad.contentUri, ad.adUri); + createMediaItemForVast(ad.getContentUri(), ad.getAdUri()); } }); } @@ -215,10 +205,8 @@ public void onAdsLoadedSuccess(AdsData adsData) { TagRequestHandler handler = new TagRequestHandler(); for (LinearCreative creative : linearAds) { - if (creative.skipDuration != 0) { - if (!handler.checkGoogleHasOffset(vmapAd)) { - creative.skipDuration = -1; - } + if (creative.skipDuration != 0 && !handler.checkGoogleHasOffset(vmapAd)) { + creative.skipDuration = -1; } String vXML = VastXMLCreator.create(creative, true); hwAdXMLs.add(vXML); @@ -243,7 +231,7 @@ public void onAdsLoadFailed() { checkCallBackState(); } - Log.e("HwImaPluginLatest", "failed"); + Log.e(TAG, "failed"); } }); } @@ -264,7 +252,7 @@ private void createMediaItemsForVmap(List hwAdXMLs, List ads, String vXML = VastXMLCreator.setVastToVmap(hwAdXMLs, ads); Uri uri = Util.getDataUriForString(MimeTypes.BASE_TYPE_TEXT, vXML); //XML has created in client side based on the VAST SDK's response - MediaItem mediaItem = new MediaItem.Builder().setUri(vmapAdTagUrlInfo.contentUri).setAdTagUri(uri).build(); + MediaItem mediaItem = new MediaItem.Builder().setUri(vmapAdTagUrlInfo.getContentUri()).setAdTagUri(uri).build(); hwMediaItems.add(mediaItem); } @@ -272,7 +260,7 @@ private void createMediaItemsForVmap(List hwAdXMLs, List ads, private void checkCallBackState() { Log.i(TAG, "item size : " + hwMediaItems.size() + " google ad size : " + googleAds.size()); - if (hwMediaItems.size() == googleAds.size()) { //TODO check + if (hwMediaItems.size() == googleAds.size()) { for (MediaItem item : hwMediaItems) { if (player.getMediaItemCount() == 0) { @@ -288,47 +276,47 @@ private void checkCallBackState() { private void configureSDKRequest(GoogleAds ad) { - ad = checkParameterValues(ad); + GoogleAds checkedAd = checkParameterValues(ad); - if (ad.maxAdDuration / 1000 > 1) { - ad.maxAdDuration = ad.maxAdDuration / 1000; + if (checkedAd.getMaxAdDuration() / 1000 > 1) { + checkedAd.setMaxAdDuration(checkedAd.getMaxAdDuration() / 1000); } - Log.i(TAG, "height: " + ad.height); - Log.i(TAG, "width: " + ad.width); - Log.i(TAG, "maxAdDuration: " + ad.maxAdDuration); + Log.i(TAG, "height: " + checkedAd.getHeight()); + Log.i(TAG, "width: " + checkedAd.getWidth()); + Log.i(TAG, "maxAdDuration: " + checkedAd.getMaxAdDuration()); CreativeMatchStrategy creativeMatchStrategy = new CreativeMatchStrategy(CreativeMatchStrategy.CreativeMatchType.ANY); RequestOptions requestOptions = new RequestOptions.Builder().setRequestLocation(true) - .setNonPersonalizedAd(ad.npaStatus) + .setNonPersonalizedAd(checkedAd.getNpaStatus()) .setConsent("") .setAdContentClassification("A") - .setTagForChildProtection(ad.tcfdStatus) + .setTagForChildProtection(checkedAd.getTcfdStatus()) .setTagForUnderAgeOfPromise(-1) .build(); mLinearAdSlot = new LinearAdSlot(); mLinearAdSlot.setSlotId(this.adUnitID); - mLinearAdSlot.setTotalDuration(ad.maxAdDuration); + mLinearAdSlot.setTotalDuration(checkedAd.getMaxAdDuration()); mLinearAdSlot.setCreativeMatchStrategy(creativeMatchStrategy); mLinearAdSlot.setAllowMobileTraffic(true); mLinearAdSlot.setOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mLinearAdSlot.setRequestOptions(requestOptions); - mLinearAdSlot.setSize(ad.width, ad.height); + mLinearAdSlot.setSize(checkedAd.getWidth(), checkedAd.getHeight()); } private GoogleAds checkParameterValues(GoogleAds ad) { - if (ad.height == 0) - ad.height = 640; - if (ad.width == 0) - ad.width = 360; - if (ad.maxAdDuration == 0) - ad.maxAdDuration = 20; - if (ad.tcfdStatus == 0) - ad.tcfdStatus = -1; + if (ad.getHeight() == 0) + ad.setHeight(640); + if (ad.getWidth() == 0) + ad.setWidth(360); + if (ad.getMaxAdDuration() == 0) + ad.setMaxAdDuration(20); + if (ad.getTcfdStatus() == 0) + ad.setTcfdStatus(-1); return ad; } } diff --git a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/HwTagConverter.java b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/HwTagConverter.java index 4f9499e..462d2e0 100644 --- a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/HwTagConverter.java +++ b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/HwTagConverter.java @@ -27,17 +27,15 @@ public class HwTagConverter { private static HwTagConverter instance; - private final static String TAG = "HwImaPluginLatest"; - + private static final String TAG = "HwImaAdapter"; private Uri googleAdTag; private TagConverterListener listener; - private String adUnitID; private GoogleAds googleAds = new GoogleAds(); private LinearAdSlot mLinearAdSlot; - private final String mimeType = "application/xml"; + private static final String mimeType = "application/xml"; public static void init(@NonNull String TagUrl, @NonNull String adUnitId, TagConverterListener tagConverterListener) { @@ -57,41 +55,38 @@ public static void init(@NonNull String TagUrl, @NonNull String adUnitId, TagCon } private void analyseGoogleAds() { - try { Set args = instance.googleAdTag.getQueryParameterNames(); - googleAds.adUri = instance.googleAdTag; + googleAds.setAdUri(instance.googleAdTag); if (args.contains(AdTagURLVariables.output)) { - googleAds.xmlOutputType = instance.googleAdTag.getQueryParameter(AdTagURLVariables.output); + googleAds.setXmlOutputType(instance.googleAdTag.getQueryParameter(AdTagURLVariables.output)); } if (args.contains(AdTagURLVariables.vPos)) { - googleAds.adPosition = instance.googleAdTag.getQueryParameter(AdTagURLVariables.vPos); + googleAds.setAdPosition(instance.googleAdTag.getQueryParameter(AdTagURLVariables.vPos)); } if (args.contains(AdTagURLVariables.vAdType)) { - googleAds.adType = instance.googleAdTag.getQueryParameter(AdTagURLVariables.vAdType); + googleAds.setAdType(instance.googleAdTag.getQueryParameter(AdTagURLVariables.vAdType)); } if (args.contains(AdTagURLVariables.maxAdDuration)) { - googleAds.maxAdDuration = Integer.parseInt(instance.googleAdTag.getQueryParameter(AdTagURLVariables.maxAdDuration)); + googleAds.setMaxAdDuration(Integer.parseInt(instance.googleAdTag.getQueryParameter(AdTagURLVariables.maxAdDuration))); } if (args.contains(AdTagURLVariables.minAdDuration)) { - googleAds.minAdDuration = Integer.parseInt(instance.googleAdTag.getQueryParameter(AdTagURLVariables.minAdDuration)); + googleAds.setMinAdDuration(Integer.parseInt(instance.googleAdTag.getQueryParameter(AdTagURLVariables.minAdDuration))); } if (args.contains(AdTagURLVariables.size)) { - try { - String[] whAdSlot = instance.googleAdTag.getQueryParameter(AdTagURLVariables.size).split("x"); - googleAds.width = Integer.parseInt(whAdSlot[0]); - googleAds.height = Integer.parseInt(whAdSlot[1]); - } catch (Exception e) { - Log.e(TAG, "Ad URL: Slot size parse failed"); + String[] whAdSlot = instance.googleAdTag.getQueryParameter(AdTagURLVariables.size).split("x"); + if (whAdSlot.length > 0) { + googleAds.setWidth(Integer.parseInt(whAdSlot[0])); + googleAds.setHeight(Integer.parseInt(whAdSlot[1])); } } if (args.contains(AdTagURLVariables.npa)) { - googleAds.npaStatus = Integer.parseInt(instance.googleAdTag.getQueryParameter(AdTagURLVariables.npa)); + googleAds.setNpaStatus(Integer.parseInt(instance.googleAdTag.getQueryParameter(AdTagURLVariables.npa))); } if (args.contains(AdTagURLVariables.tfcd)) { - googleAds.tcfdStatus = Integer.parseInt(instance.googleAdTag.getQueryParameter(AdTagURLVariables.tfcd)); + googleAds.setTcfdStatus(Integer.parseInt(instance.googleAdTag.getQueryParameter(AdTagURLVariables.tfcd))); } } catch (Exception e) { Log.i(TAG, e.toString()); @@ -105,14 +100,14 @@ private void clearInstance() { private void requestVastSDK() { - if (googleAds.xmlOutputType.equals("vmap")) { + if (googleAds.getXmlOutputType().equals(AdTagURLVariables.vmap)) { List vmapAds = VastXMLCreator.getGoogleAdsFromVMAP(googleAds); if (vmapAds != null) { makeRequestForMultipleAd(vmapAds, googleAds); } - } else if (googleAds.xmlOutputType.equals("vast")) { + } else if (googleAds.getXmlOutputType().equals(AdTagURLVariables.vast)) { configureVastRequest(googleAds); makeRequestForSingleAd(googleAds); } @@ -129,16 +124,12 @@ public void onAdsLoadedSuccess(AdsData adsData) { TagRequestHandler handler = new TagRequestHandler(); for (LinearCreative creative : linearAds) { - - if (creative.skipDuration != 0) { + if (creative.skipDuration != 0 && !handler.checkGoogleHasOffset(ad)) { //check google ad contain offset - if (!handler.checkGoogleHasOffset(ad)) { - creative.skipDuration = -1; - } + creative.skipDuration = -1; } String vXML = VastXMLCreator.create(creative, false); - Uri uri = Uri.parse("data:" + mimeType + ";base64," + Base64.encodeToString(vXML.getBytes(), Base64.NO_WRAP)); if (uri != null) { @@ -179,24 +170,18 @@ public void onAdsLoadedSuccess(AdsData adsData) { for (LinearCreative creative : linearAds) { - if (creative.skipDuration != 0) { - if (!handler.checkGoogleHasOffset(vmapAd)) { - creative.skipDuration = -1; - } + if (creative.skipDuration != 0 && !handler.checkGoogleHasOffset(vmapAd)) { + creative.skipDuration = -1; } String vXML = VastXMLCreator.create(creative, true); hwAdXMLs.add(vXML); } - - } else { hwAdXMLs.add(""); } if (hwAdXMLs.size() == ads.size()) { - - updateTagsForVmap(hwAdXMLs, ads, vmapAdTagUrlInfo); - + updateTagsForVmap(hwAdXMLs, ads); } } @@ -205,7 +190,7 @@ public void onAdsLoadFailed() { hwAdXMLs.add(""); if (hwAdXMLs.size() == ads.size()) { - updateTagsForVmap(hwAdXMLs, ads, vmapAdTagUrlInfo); + updateTagsForVmap(hwAdXMLs, ads); } Log.e(TAG, "failed"); @@ -216,14 +201,14 @@ public void onAdsLoadFailed() { private void configureVastRequest(GoogleAds ads) { - ads = checkParameterValues(ads); + GoogleAds checkedAd = checkParameterValues(ads); - if (ads.maxAdDuration / 1000 > 1) { - ads.maxAdDuration = ads.maxAdDuration / 1000; + if (checkedAd.getMaxAdDuration() / 1000 > 1) { + checkedAd.setMaxAdDuration(checkedAd.getMaxAdDuration() / 1000); } - Log.i(TAG, "height: " + ads.height); - Log.i(TAG, "width: " + ads.width); - Log.i(TAG, "maxAdDuration: " + ads.maxAdDuration); + Log.i(TAG, "height: " + checkedAd.getHeight()); + Log.i(TAG, "width: " + checkedAd.getWidth()); + Log.i(TAG, "maxAdDuration: " + checkedAd.getMaxAdDuration()); CreativeMatchStrategy creativeMatchStrategy = new CreativeMatchStrategy(CreativeMatchStrategy.CreativeMatchType.ANY); @@ -232,36 +217,34 @@ private void configureVastRequest(GoogleAds ads) { .setNonPersonalizedAd(0) .setConsent("") .setAdContentClassification("A") - .setTagForChildProtection(ads.tcfdStatus) + .setTagForChildProtection(checkedAd.getTcfdStatus()) .setTagForUnderAgeOfPromise(-1) .build(); mLinearAdSlot = new LinearAdSlot(); mLinearAdSlot.setSlotId(this.adUnitID); - mLinearAdSlot.setTotalDuration(ads.maxAdDuration); + mLinearAdSlot.setTotalDuration(checkedAd.getMaxAdDuration()); mLinearAdSlot.setCreativeMatchStrategy(creativeMatchStrategy); mLinearAdSlot.setAllowMobileTraffic(true); mLinearAdSlot.setOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mLinearAdSlot.setRequestOptions(requestOptions); - mLinearAdSlot.setSize(ads.width, ads.height); + mLinearAdSlot.setSize(checkedAd.getWidth(), checkedAd.getHeight()); } private GoogleAds checkParameterValues(GoogleAds ad) { - if (ad.height == 0) { - ad.height = 640; - } - if (ad.width == 0) { - ad.width = 360; - } - if (ad.maxAdDuration == 0) { - ad.maxAdDuration = 20; - } - if (ad.tcfdStatus == 0) - ad.tcfdStatus = -1; + if (ad.getHeight() == 0) + ad.setHeight(640); + if (ad.getWidth() == 0) + ad.setWidth(360); + if (ad.getMaxAdDuration() == 0) + ad.setMaxAdDuration(20); + if (ad.getTcfdStatus() == 0) + ad.setTcfdStatus(-1); return ad; + } - private void updateTagsForVmap(List hwAdXMLs, List ads, GoogleAds vmapAdTagUrlInfo) { + private void updateTagsForVmap(List hwAdXMLs, List ads) { for (int i = 0; i < ads.size(); i++) { /** @@ -273,7 +256,6 @@ private void updateTagsForVmap(List hwAdXMLs, List ads, Googl hwAdXMLs.add(i, TagRequestHandler.getResponseXML(googleBackupAd)); } } - String vXML = VastXMLCreator.setVastToVmap(hwAdXMLs, ads); Uri uri = Uri.parse("data:" + mimeType + ";base64," + Base64.encodeToString(vXML.getBytes(), Base64.NO_WRAP)); diff --git a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/application/AdapterApplication.java b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/application/AdapterApplication.java index 9bd2ac9..024e69b 100644 --- a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/application/AdapterApplication.java +++ b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/application/AdapterApplication.java @@ -9,6 +9,6 @@ public class AdapterApplication extends Application { @Override public void onCreate() { super.onCreate(); - VastApplication.init(AdapterApplication.this, true); //TODO change parameters + VastApplication.init(AdapterApplication.this, true); } } \ No newline at end of file diff --git a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/constants/AdTagURLVariables.java b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/constants/AdTagURLVariables.java index 8f1a33f..fbd77e3 100644 --- a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/constants/AdTagURLVariables.java +++ b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/constants/AdTagURLVariables.java @@ -2,16 +2,21 @@ public class AdTagURLVariables { - public static String output = "output"; - public static String vPos = "vpos"; - public static String vAdType = "vad_type"; - public static String maxAdDuration = "max_ad_duration"; - public static String minAdDuration = "min_ad_duration"; - public static String size = "sz"; - public static String npa = "npa"; - public static String tfcd = "tfcd"; + private AdTagURLVariables() { + } - public static String vast = "vast"; - public static String vmap = "vmap"; + public static final String output = "output"; + public static final String vPos = "vpos"; + public static final String vAdType = "vad_type"; + public static final String maxAdDuration = "max_ad_duration"; + public static final String minAdDuration = "min_ad_duration"; + public static final String size = "sz"; + public static final String npa = "npa"; + public static final String tfcd = "tfcd"; + + public static final String vast = "vast"; + public static final String vmap = "vmap"; + + public static final String utfStandard = "UTF-8"; } diff --git a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/constants/VastVmapVariables.java b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/constants/VastVmapVariables.java index 93ac868..40e05ac 100644 --- a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/constants/VastVmapVariables.java +++ b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/constants/VastVmapVariables.java @@ -2,7 +2,10 @@ public class VastVmapVariables { - public static String hw_vast = + private VastVmapVariables() { + } + + public static final String hwVast = "" + " " + " " + @@ -54,28 +57,57 @@ public class VastVmapVariables { " " + " "; - - public static String hw_vmap = + public static final String hwVmap = "" + "" + "" + "" + - hw_vast + + hwVast + "" + "" + "" + ""; - public static String hw_vmap_dynamic = + public static final String hwVmapDynamic = "" + - ""; - public static String hw_vmap_dynamic_element = + public static final String hwVmapDynamicElement = "" + "" + "" + "" + "" + ""; + + public static final String ad = "Ad"; + public static final String error = "Error"; + public static final String impression = "Impression"; + public static final String linear = "Linear"; + public static final String duration = "Duration"; + public static final String tracking = "Tracking"; + public static final String trackingEvents = "TrackingEvents"; + public static final String clickThrough = "ClickThrough"; + public static final String clickTracking = "ClickTracking"; + public static final String mediaFile = "MediaFile"; + public static final String icon = "Icon"; + public static final String staticResource = "StaticResource"; + public static final String iconClickThrough = "IconClickThrough"; + public static final String id = "id"; + public static final String skipOffset = "skipoffset"; + public static final String event = "event"; + public static final String delivery = "delivery"; + public static final String type = "type"; + public static final String width = "width"; + public static final String height = "height"; + public static final String xPosition = "xPosition"; + public static final String yPosition = "yPosition"; + public static final String breakId = "breakId"; + public static final String breakType = "breakType"; + public static final String timeOffset = "timeOffset"; + public static final String linearS = "linear"; + public static final String vmapAdBreak = "vmap:AdBreak"; + public static final String vmapAdTagURI = "vmap:AdTagURI"; + public static final String vmapVmap = "vmap:VMAP"; + public static final String vmapVastAdData = "vmap:VASTAdData"; } diff --git a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/model/GoogleAds.java b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/model/GoogleAds.java index 153648c..d06f251 100644 --- a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/model/GoogleAds.java +++ b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/model/GoogleAds.java @@ -4,63 +4,159 @@ public class GoogleAds { + public Uri getAdUri() { + return adUri; + } + + public void setAdUri(Uri adUri) { + this.adUri = adUri; + } + + public Uri getContentUri() { + return contentUri; + } + + public void setContentUri(Uri contentUri) { + this.contentUri = contentUri; + } + + public String getAdPosition() { + return adPosition; + } + + public void setAdPosition(String adPosition) { + this.adPosition = adPosition; + } + + public String getAdType() { + return adType; + } + + public void setAdType(String adType) { + this.adType = adType; + } + + public String getXmlOutputType() { + return xmlOutputType; + } + + public void setXmlOutputType(String xmlOutputType) { + this.xmlOutputType = xmlOutputType; + } + + public int getMaxAdDuration() { + return maxAdDuration; + } + + public void setMaxAdDuration(int maxAdDuration) { + this.maxAdDuration = maxAdDuration; + } + + public int getMinAdDuration() { + return minAdDuration; + } + + public void setMinAdDuration(int minAdDuration) { + this.minAdDuration = minAdDuration; + } + + public String getOffset() { + return offset; + } + + public void setOffset(String offset) { + this.offset = offset; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width = width; + } + + public int getHeight() { + return height; + } + + public void setHeight(int height) { + this.height = height; + } + + public int getNpaStatus() { + return npaStatus; + } + + public void setNpaStatus(int npaStatus) { + this.npaStatus = npaStatus; + } + + public int getTcfdStatus() { + return tcfdStatus; + } + + public void setTcfdStatus(int tcfdStatus) { + this.tcfdStatus = tcfdStatus; + } + /** * Uri of Ad */ - public Uri adUri; + private Uri adUri; /** * Uri of content */ - public Uri contentUri; + private Uri contentUri; /** * Reklam post-pre-mid */ - public String adPosition; + private String adPosition; /** * Linear-NonLinear */ - public String adType; + private String adType; /** * Vast-Vmap */ - public String xmlOutputType; + private String xmlOutputType; /** * Maks duration of Ad */ - public int maxAdDuration; + private int maxAdDuration; /** * Min duration of Ad */ - public int minAdDuration; + private int minAdDuration; /** * Min duration of Ad */ - public String offset; + private String offset; /** * Size of master video ad slot width */ - public int width; + private int width; /** * Size of master video ad slot width */ - public int height; + private int height; /** * The non-personalized ads parameter */ - public int npaStatus; + private int npaStatus; /** * The child-directed parameter */ - public int tcfdStatus; + private int tcfdStatus; } diff --git a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/util/TagRequestHandler.java b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/util/TagRequestHandler.java index 5186b4c..705f5da 100644 --- a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/util/TagRequestHandler.java +++ b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/util/TagRequestHandler.java @@ -3,6 +3,7 @@ import android.os.StrictMode; import android.util.Log; +import com.huawei.hms.ads.ima.adapter.constants.VastVmapVariables; import com.huawei.hms.ads.ima.adapter.model.GoogleAds; import org.xmlpull.v1.XmlPullParser; @@ -13,25 +14,29 @@ import java.io.InputStreamReader; import java.net.URL; +import static com.huawei.hms.ads.ima.adapter.constants.AdTagURLVariables.utfStandard; + public class TagRequestHandler { + private static final String TAG = "HwImaAdapter"; + public static XmlPullParser makeRequest(GoogleAds ad) { try { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); - URL url = new URL(ad.adUri.toString()); + URL url = new URL(ad.getAdUri().toString()); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(false); XmlPullParser xpp = factory.newPullParser(); - xpp.setInput(url.openConnection().getInputStream(), "UTF_8"); + xpp.setInput(url.openConnection().getInputStream(), utfStandard); return xpp; } catch (Exception e) { - Log.e("TAG", "makeRequest: "); + Log.e(TAG, e.toString()); return null; } } @@ -39,7 +44,7 @@ public static XmlPullParser makeRequest(GoogleAds ad) { public static String getResponseXML(GoogleAds ad) { try { - URL url = new URL(ad.adUri.toString()); + URL url = new URL(ad.getAdUri().toString()); InputStream inputStream = url.openConnection().getInputStream(); BufferedReader r = new BufferedReader(new InputStreamReader(inputStream)); @@ -50,7 +55,7 @@ public static String getResponseXML(GoogleAds ad) { return total.toString(); } catch (Exception e) { - Log.e("TAG", "getResponseXML: "); + Log.e(TAG, e.toString()); return ""; } } @@ -59,23 +64,24 @@ public boolean checkGoogleHasOffset(GoogleAds ad) { boolean result = false; try { XmlPullParser xpp = makeRequest(ad); - int eventType = xpp.getEventType(); + if(xpp != null){ + int eventType = xpp.getEventType(); - while (eventType != XmlPullParser.END_DOCUMENT) { - if (eventType == XmlPullParser.START_TAG) { - if (xpp.getName().equalsIgnoreCase("Linear")) { - if (xpp.getAttributeValue(null, "skipoffset") != null && !xpp.getAttributeValue(null, "skipoffset").equals("00:00:00")) { + while (eventType != XmlPullParser.END_DOCUMENT) { + if (eventType == XmlPullParser.START_TAG && xpp.getName().equalsIgnoreCase(VastVmapVariables.linear)) { + if (xpp.getAttributeValue(null, VastVmapVariables.skipOffset) != null && !xpp.getAttributeValue(null, VastVmapVariables.skipOffset).equals("00:00:00")) { result = true; break; } } + eventType = xpp.next(); } - eventType = xpp.next(); } return result; + } catch (Exception e) { - Log.e("TAG", e.toString()); + Log.e(TAG, e.toString()); return false; } } diff --git a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/util/VastXMLCreator.java b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/util/VastXMLCreator.java index 1228321..fdd2fc3 100644 --- a/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/util/VastXMLCreator.java +++ b/ima_adapter/src/main/java/com/huawei/hms/ads/ima/adapter/util/VastXMLCreator.java @@ -41,96 +41,103 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import static com.huawei.hms.ads.ima.adapter.constants.AdTagURLVariables.utfStandard; + public class VastXMLCreator { + private VastXMLCreator() { + } + + private static final String TAG = "HwImaAdapter"; + public static String create(LinearCreative creative, boolean vast) { try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = null; ByteArrayInputStream input; if (vast) { - input = new ByteArrayInputStream(VastVmapVariables.hw_vast.getBytes("UTF-8")); + input = new ByteArrayInputStream(VastVmapVariables.hwVast.getBytes(utfStandard)); } else { - input = new ByteArrayInputStream(VastVmapVariables.hw_vmap.getBytes("UTF-8")); + input = new ByteArrayInputStream(VastVmapVariables.hwVmap.getBytes(utfStandard)); } - doc = builder.parse(input); - - if (doc != null) { - // Ad > id - doc.getElementsByTagName("Ad").item(0).getAttributes().getNamedItem("id").setTextContent(creative.id); - - //Error - doc.getElementsByTagName("Error").item(0).setTextContent(creative.errorUrlList.get(0)); - - //Impression - doc.getElementsByTagName("Impression").item(0).setTextContent(creative.errorUrlList.get(0)); - - //SkipOffSet - doc.getElementsByTagName("Linear").item(0).getAttributes().getNamedItem("skipoffset").setTextContent(convertLongToTime(creative.skipDuration)); - - //Duration - doc.getElementsByTagName("Duration").item(0).setTextContent(convertLongToTime(creative.duration)); - - //TrackingEvents - for (int i = 0; i < creative.trackingEvents.size(); i++) { - Element node = doc.createElement("Tracking"); - node.setAttribute("event", ""); - doc.getElementsByTagName("TrackingEvents").item(0).appendChild(node); - } - int j = 0; - NodeList trackingEvents = doc.getElementsByTagName("TrackingEvents").item(0).getChildNodes(); - for (Map.Entry> entry : creative.trackingEvents.entrySet()) { - boolean pass = true; - while (pass) { - if (trackingEvents.item(j) instanceof Element) { - NamedNodeMap trackingElement = (trackingEvents.item(j)).getAttributes(); - Node nodeTrackingElement = trackingElement.getNamedItem("event"); - nodeTrackingElement.setTextContent(entry.getKey()); - (trackingEvents.item(j)).setTextContent(entry.getValue().get(0).url); - pass = false; + DocumentBuilder builder = createDocumentBuilder(); + if (builder != null) { + doc = builder.parse(input); + + if (doc != null) { + // Ad > id + doc.getElementsByTagName(VastVmapVariables.ad).item(0).getAttributes().getNamedItem(VastVmapVariables.id).setTextContent(creative.id); + //Error + doc.getElementsByTagName(VastVmapVariables.error).item(0).setTextContent(creative.errorUrlList.get(0)); + //Impression + doc.getElementsByTagName(VastVmapVariables.impression).item(0).setTextContent(creative.errorUrlList.get(0)); + //SkipOffSet + doc.getElementsByTagName(VastVmapVariables.linear).item(0).getAttributes().getNamedItem(VastVmapVariables.skipOffset).setTextContent(convertLongToTime(creative.skipDuration)); + //Duration + doc.getElementsByTagName(VastVmapVariables.duration).item(0).setTextContent(convertLongToTime(creative.duration)); + //TrackingEvents + for (int i = 0; i < creative.trackingEvents.size(); i++) { + Element node = doc.createElement(VastVmapVariables.tracking); + node.setAttribute(VastVmapVariables.event, ""); + doc.getElementsByTagName(VastVmapVariables.trackingEvents).item(0).appendChild(node); + } + int j = 0; + NodeList trackingEvents = doc.getElementsByTagName(VastVmapVariables.trackingEvents).item(0).getChildNodes(); + for (Map.Entry> entry : creative.trackingEvents.entrySet()) { + boolean pass = true; + while (pass) { + if (trackingEvents.item(j) instanceof Element) { + NamedNodeMap trackingElement = (trackingEvents.item(j)).getAttributes(); + Node nodeTrackingElement = trackingElement.getNamedItem(VastVmapVariables.event); + nodeTrackingElement.setTextContent(entry.getKey()); + (trackingEvents.item(j)).setTextContent(entry.getValue().get(0).url); + pass = false; + } + j++; } - j++; } - } - //ClickThrough - doc.getElementsByTagName("ClickThrough").item(0).setTextContent(creative.clickThrough); - - //ClickTracking - doc.getElementsByTagName("ClickTracking").item(0).setTextContent(creative.videoClickTrackingList.get(0).url); - - //MediaFile - NamedNodeMap nodeMapMediaFile = doc.getElementsByTagName("MediaFile").item(0).getAttributes(); - nodeMapMediaFile.getNamedItem("delivery").setTextContent(creative.delivery); - nodeMapMediaFile.getNamedItem("type").setTextContent(creative.type); - nodeMapMediaFile.getNamedItem("width").setTextContent(String.valueOf(creative.width)); - nodeMapMediaFile.getNamedItem("height").setTextContent(String.valueOf(creative.height)); - doc.getElementsByTagName("MediaFile").item(0).setTextContent(creative.url); - - //Icon - NamedNodeMap iconNamedNodeMap = doc.getElementsByTagName("Icon").item(0).getAttributes(); - iconNamedNodeMap.getNamedItem("width").setTextContent(String.valueOf(creative.icon.width / 2)); - iconNamedNodeMap.getNamedItem("height").setTextContent(String.valueOf(creative.icon.height / 2)); - iconNamedNodeMap.getNamedItem("xPosition").setTextContent(String.valueOf(creative.icon.xPosition).equals("-1") ? "top" : String.valueOf(creative.icon.xPosition)); - iconNamedNodeMap.getNamedItem("yPosition").setTextContent(String.valueOf(creative.icon.yPosition).equals("-1") ? "left" : String.valueOf(creative.icon.yPosition)); - iconNamedNodeMap.getNamedItem("yPosition").setTextContent(String.valueOf(creative.icon.yPosition)); - doc.getElementsByTagName("StaticResource").item(0).setTextContent(creative.icon.imgUrl); - doc.getElementsByTagName("IconClickThrough").item(0).setTextContent(creative.icon.clickThrough); + //ClickThrough + doc.getElementsByTagName(VastVmapVariables.clickThrough).item(0).setTextContent(creative.clickThrough); + //ClickTracking + doc.getElementsByTagName(VastVmapVariables.clickTracking).item(0).setTextContent(creative.videoClickTrackingList.get(0).url); + //MediaFile + NamedNodeMap nodeMapMediaFile = doc.getElementsByTagName(VastVmapVariables.mediaFile).item(0).getAttributes(); + nodeMapMediaFile.getNamedItem(VastVmapVariables.delivery).setTextContent(creative.delivery); + nodeMapMediaFile.getNamedItem(VastVmapVariables.type).setTextContent(creative.type); + nodeMapMediaFile.getNamedItem(VastVmapVariables.width).setTextContent(String.valueOf(creative.width)); + nodeMapMediaFile.getNamedItem(VastVmapVariables.height).setTextContent(String.valueOf(creative.height)); + doc.getElementsByTagName(VastVmapVariables.mediaFile).item(0).setTextContent(creative.url); + //Icon + NamedNodeMap iconNamedNodeMap = doc.getElementsByTagName(VastVmapVariables.icon).item(0).getAttributes(); + iconNamedNodeMap.getNamedItem(VastVmapVariables.width).setTextContent(String.valueOf(creative.icon.width / 2)); + iconNamedNodeMap.getNamedItem(VastVmapVariables.height).setTextContent(String.valueOf(creative.icon.height / 2)); + iconNamedNodeMap.getNamedItem(VastVmapVariables.xPosition).setTextContent(String.valueOf(creative.icon.xPosition).equals("-1") ? "top" : String.valueOf(creative.icon.xPosition)); + iconNamedNodeMap.getNamedItem(VastVmapVariables.yPosition).setTextContent(String.valueOf(creative.icon.yPosition).equals("-1") ? "left" : String.valueOf(creative.icon.yPosition)); + doc.getElementsByTagName(VastVmapVariables.staticResource).item(0).setTextContent(creative.icon.imgUrl); + doc.getElementsByTagName(VastVmapVariables.iconClickThrough).item(0).setTextContent(creative.icon.clickThrough); + } } - return convertDocumentToString(doc); } catch (Exception e) { - Log.e("HwImagePluginLatest", e.toString()); + Log.e(TAG, e.toString()); } return ""; } + private static DocumentBuilder createDocumentBuilder() { + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + return factory.newDocumentBuilder(); + } catch (Exception e) { + Log.e(TAG, e.toString()); + return null; + } + } + private static String convertDocumentToString(Document doc) { try { DOMSource domSource = new DOMSource(doc); @@ -158,13 +165,13 @@ public static List getGoogleAdsFromVMAP(GoogleAds ads) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); - URL url = new URL(ads.adUri.toString()); + URL url = new URL(ads.getAdUri().toString()); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(false); XmlPullParser xpp = factory.newPullParser(); - xpp.setInput(url.openConnection().getInputStream(), "UTF_8"); + xpp.setInput(url.openConnection().getInputStream(), utfStandard); // Returns the type of current event: START_TAG, END_TAG, etc.. int eventType = xpp.getEventType(); @@ -174,48 +181,48 @@ public static List getGoogleAdsFromVMAP(GoogleAds ads) { while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { GoogleAds resultAd = new GoogleAds(); - if (xpp.getName().equalsIgnoreCase("vmap:AdBreak")) { - if (xpp.getAttributeValue(null, "breakId") != null) { - resultAd.adPosition = xpp.getAttributeValue(null, "breakId"); + if (xpp.getName().equalsIgnoreCase(VastVmapVariables.vmapAdBreak)) { + if (xpp.getAttributeValue(null, VastVmapVariables.breakId) != null) { + resultAd.setAdPosition(xpp.getAttributeValue(null, VastVmapVariables.breakId)); } - if (xpp.getAttributeValue(null, "timeOffset") != null) { - resultAd.offset = xpp.getAttributeValue(null, "timeOffset"); + if (xpp.getAttributeValue(null, VastVmapVariables.timeOffset) != null) { + resultAd.setOffset(xpp.getAttributeValue(null, VastVmapVariables.timeOffset)); } result.add(resultAd); } - if (xpp.getName().equalsIgnoreCase("vmap:AdTagURI")) { + if (xpp.getName().equalsIgnoreCase(VastVmapVariables.vmapAdTagURI)) { Uri adTagUri = Uri.parse(xpp.nextText()); - result.get(result.size() - 1).adUri = adTagUri; + result.get(result.size() - 1).setAdUri(adTagUri); Set args = adTagUri.getQueryParameterNames(); if (args.contains(AdTagURLVariables.output)) { - result.get(result.size() - 1).xmlOutputType = adTagUri.getQueryParameter(AdTagURLVariables.output); + result.get(result.size() - 1).setXmlOutputType(adTagUri.getQueryParameter(AdTagURLVariables.output)); } if (args.contains(AdTagURLVariables.vAdType)) { - result.get(result.size() - 1).adType = adTagUri.getQueryParameter(AdTagURLVariables.vAdType); + result.get(result.size() - 1).setAdType(adTagUri.getQueryParameter(AdTagURLVariables.vAdType)); } if (args.contains(AdTagURLVariables.maxAdDuration)) { - result.get(result.size() - 1).maxAdDuration = Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.maxAdDuration)); + result.get(result.size() - 1).setMaxAdDuration(Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.maxAdDuration))); } if (args.contains(AdTagURLVariables.minAdDuration)) { - result.get(result.size() - 1).minAdDuration = Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.minAdDuration)); + result.get(result.size() - 1).setMinAdDuration(Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.minAdDuration))); } if (args.contains(AdTagURLVariables.size)) { try { String[] whAdSlot = adTagUri.getQueryParameter(AdTagURLVariables.size).split("x"); - result.get(result.size() - 1).width = Integer.parseInt(whAdSlot[0]); - result.get(result.size() - 1).height = Integer.parseInt(whAdSlot[1]); + result.get(result.size() - 1).setWidth(Integer.parseInt(whAdSlot[0])); + result.get(result.size() - 1).setHeight(Integer.parseInt(whAdSlot[1])); } catch (Exception e) { - Log.e("HwImaPlugin", "Ad slot size parse failed" + e.toString()); + Log.e(TAG, "Ad slot size parse failed" + e.toString()); } } - if (args.contains(AdTagURLVariables.npa)){ - ads.npaStatus = Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.npa)); + if (args.contains(AdTagURLVariables.npa)) { + ads.setNpaStatus(Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.npa))); } - if (args.contains(AdTagURLVariables.tfcd)){ - ads.tcfdStatus = Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.tfcd)); + if (args.contains(AdTagURLVariables.tfcd)) { + ads.setTcfdStatus(Integer.parseInt(adTagUri.getQueryParameter(AdTagURLVariables.tfcd))); } } } @@ -225,43 +232,44 @@ public static List getGoogleAdsFromVMAP(GoogleAds ads) { return result; } catch (Exception e) { - Log.e("HwImaPluginLatest", e.toString()); + Log.e(TAG, e.toString()); } return null; } public static String setVastToVmap(List vastXMLs, List ads) { try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - ByteArrayInputStream input = new ByteArrayInputStream(VastVmapVariables.hw_vmap_dynamic.getBytes("UTF-8")); - Document doc = builder.parse(input); - - if (doc != null) { - //TrackingEvents - for (int i = 0; i < vastXMLs.size(); i++) { - Document valueDoc = builder.parse( - new InputSource(new StringReader(VastVmapVariables.hw_vmap_dynamic_element))); - Node valueElement = doc.importNode(valueDoc.getDocumentElement(), true); - doc.getElementsByTagName("vmap:VMAP").item(0).appendChild(valueElement); - - NamedNodeMap nodeMapMediaFile = doc.getElementsByTagName("vmap:AdBreak").item(i).getAttributes(); - nodeMapMediaFile.getNamedItem("timeOffset").setTextContent(ads.get(i).offset); - nodeMapMediaFile.getNamedItem("breakType").setTextContent("linear"); - - Document value = builder.parse( - new InputSource(new StringReader(vastXMLs.get(i)))); - Node nodeVast = doc.importNode(value.getDocumentElement(), true); - doc.getElementsByTagName("vmap:VASTAdData").item(i).appendChild(nodeVast); + Document doc = null; + DocumentBuilder builder = createDocumentBuilder(); + if (builder != null) { + ByteArrayInputStream input = new ByteArrayInputStream(VastVmapVariables.hwVmapDynamic.getBytes(utfStandard)); + doc = builder.parse(input); + if (doc != null) { + //TrackingEvents + for (int i = 0; i < vastXMLs.size(); i++) { + Document valueDoc = builder.parse( + new InputSource(new StringReader(VastVmapVariables.hwVmapDynamicElement))); + Node valueElement = doc.importNode(valueDoc.getDocumentElement(), true); + doc.getElementsByTagName(VastVmapVariables.vmapVmap).item(0).appendChild(valueElement); + + NamedNodeMap nodeMapMediaFile = doc.getElementsByTagName(VastVmapVariables.vmapAdBreak).item(i).getAttributes(); + nodeMapMediaFile.getNamedItem(VastVmapVariables.timeOffset).setTextContent(ads.get(i).getOffset()); + nodeMapMediaFile.getNamedItem(VastVmapVariables.breakType).setTextContent(VastVmapVariables.linearS); + + Document value = builder.parse( + new InputSource(new StringReader(vastXMLs.get(i)))); + Node nodeVast = doc.importNode(value.getDocumentElement(), true); + doc.getElementsByTagName(VastVmapVariables.vmapVastAdData).item(i).appendChild(nodeVast); + } } } return convertDocumentToString(doc); } catch (Exception e) { - Log.e("HwImaPluginLatest", e.toString()); + Log.e(TAG, e.toString()); } return "";