@@ -904,6 +904,7 @@ void JNI_completeLoadedAd(JNIEnv* env, jclass clazz, jlong data_ptr,
904904void JNI_NativeAd_completeLoadedAd (JNIEnv* env, jclass clazz, jlong data_ptr,
905905 jlong native_internal_data_ptr,
906906 jobject j_icon, jobjectArray j_images,
907+ jobject j_adchoices_icon,
907908 jobject j_response_info) {
908909 FIREBASE_ASSERT (env);
909910 FIREBASE_ASSERT (data_ptr);
@@ -922,18 +923,30 @@ void JNI_NativeAd_completeLoadedAd(JNIEnv* env, jclass clazz, jlong data_ptr,
922923
923924 // Invoke a friend of NativeAdInternal to update its icon image asset.
924925 GmaInternal::InsertNativeInternalImage (native_ad_internal, icon_internal,
925- true , true );
926+ " icon " , true );
926927 env->DeleteLocalRef (j_icon);
927928 }
928929
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+
929942 const size_t len = env->GetArrayLength (j_images);
930943 // Loop through images array.
931944 for (size_t i = 0 ; i < len; ++i) {
932945 jobject j_image = env->GetObjectArrayElement (j_images, i);
933946 NativeAdImageInternal image_internal;
934947 image_internal.native_ad_image = j_image;
935948 GmaInternal::InsertNativeInternalImage (native_ad_internal, image_internal,
936- false , false );
949+ " image " , false );
937950 }
938951
939952 FutureCallbackData<AdResult>* callback_data =
@@ -1224,7 +1237,7 @@ bool RegisterNatives() {
12241237 {" completeNativeLoadedAd" ,
12251238 " (JJLcom/google/android/gms/ads/nativead/NativeAd$Image;[Lcom/google/"
12261239 " 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" ,
12281241 reinterpret_cast <void *>(&JNI_NativeAd_completeLoadedAd)},
12291242 {" completeNativeLoadAdError" ,
12301243 " (JLcom/google/android/gms/ads/LoadAdError;ILjava/lang/String;)V" ,
0 commit comments