@@ -904,6 +904,7 @@ void JNI_completeLoadedAd(JNIEnv* env, jclass clazz, jlong data_ptr,
904
904
void JNI_NativeAd_completeLoadedAd (JNIEnv* env, jclass clazz, jlong data_ptr,
905
905
jlong native_internal_data_ptr,
906
906
jobject j_icon, jobjectArray j_images,
907
+ jobject j_adchoices_icon,
907
908
jobject j_response_info) {
908
909
FIREBASE_ASSERT (env);
909
910
FIREBASE_ASSERT (data_ptr);
@@ -922,18 +923,30 @@ void JNI_NativeAd_completeLoadedAd(JNIEnv* env, jclass clazz, jlong data_ptr,
922
923
923
924
// Invoke a friend of NativeAdInternal to update its icon image asset.
924
925
GmaInternal::InsertNativeInternalImage (native_ad_internal, icon_internal,
925
- true , true );
926
+ " icon " , true );
926
927
env->DeleteLocalRef (j_icon);
927
928
}
928
929
930
+ // getAdChoicesInfo().getImages() can return an empty list and a valid ad can
931
+ // exist without an adchoices icon image.
932
+ if (j_adchoices_icon != nullptr ) {
933
+ NativeAdImageInternal adchoices_icon_internal;
934
+ adchoices_icon_internal.native_ad_image = j_adchoices_icon;
935
+
936
+ // Invoke a friend of NativeAdInternal to update its icon image asset.
937
+ GmaInternal::InsertNativeInternalImage (
938
+ native_ad_internal, adchoices_icon_internal, " adchoices_icon" , true );
939
+ env->DeleteLocalRef (j_adchoices_icon);
940
+ }
941
+
929
942
const size_t len = env->GetArrayLength (j_images);
930
943
// Loop through images array.
931
944
for (size_t i = 0 ; i < len; ++i) {
932
945
jobject j_image = env->GetObjectArrayElement (j_images, i);
933
946
NativeAdImageInternal image_internal;
934
947
image_internal.native_ad_image = j_image;
935
948
GmaInternal::InsertNativeInternalImage (native_ad_internal, image_internal,
936
- false , false );
949
+ " image " , false );
937
950
}
938
951
939
952
FutureCallbackData<AdResult>* callback_data =
@@ -1224,7 +1237,7 @@ bool RegisterNatives() {
1224
1237
{" completeNativeLoadedAd" ,
1225
1238
" (JJLcom/google/android/gms/ads/nativead/NativeAd$Image;[Lcom/google/"
1226
1239
" android/gms/ads/nativead/NativeAd$Image;Lcom/google/android/gms/ads/"
1227
- " ResponseInfo;)V" ,
1240
+ " nativead/NativeAd$Image;Lcom/google/android/gms/ads/ ResponseInfo;)V" ,
1228
1241
reinterpret_cast <void *>(&JNI_NativeAd_completeLoadedAd)},
1229
1242
{" completeNativeLoadAdError" ,
1230
1243
" (JLcom/google/android/gms/ads/LoadAdError;ILjava/lang/String;)V" ,
0 commit comments