From f80cab42d5b40ea2fcdd270790d5b946ffd8955d Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:14:38 -0400 Subject: [PATCH] [interactive_media_ads] Adds initial Android implementation (#6733) Android implementation for https://github.com/flutter/flutter/issues/134228 --- packages/interactive_media_ads/CHANGELOG.md | 4 + .../android/build.gradle | 6 + .../AdDisplayContainerProxyApi.kt | 14 + .../AdErrorEventProxyApi.kt | 21 + .../AdErrorListenerProxyApi.kt | 27 + .../interactive_media_ads/AdErrorProxyApi.kt | 61 + .../AdEventListenerProxyApi.kt | 26 + .../interactive_media_ads/AdEventProxyApi.kt | 49 + .../AdMediaInfoProxyApi.kt | 20 + .../AdPodInfoProxyApi.kt | 40 + .../AdsLoadedListenerProxyApi.kt | 28 + .../AdsLoaderProxyApi.kt | 36 + .../AdsManagerLoadedEventProxyApi.kt | 21 + .../AdsManagerProxyApi.kt | 28 + .../AdsRequestProxyApi.kt | 37 + .../BaseDisplayContainerProxyApi.kt | 14 + .../BaseManagerProxyApi.kt | 40 + .../ContentProgressProviderProxyApi.kt | 15 + .../FrameLayoutProxyApi.kt | 20 + .../ImaSdkFactoryProxyApi.kt | 49 + .../ImaSdkSettingsProxyApi.kt | 14 + .../InteractiveMediaAdsLibrary.g.kt | 3625 +++++++++++++ .../InteractiveMediaAdsPlugin.kt | 79 +- .../MediaPlayerProxyApi.kt | 36 + .../ProxyApiRegistrar.kt | 128 + .../VideoAdPlayerCallbackProxyApi.kt | 87 + .../VideoAdPlayerProxyApi.kt | 80 + .../VideoProgressUpdateProxyApi.kt | 27 + .../VideoViewProxyApi.kt | 38 + .../ViewGroupProxyApi.kt | 21 + .../interactive_media_ads/ViewProxyApi.kt | 14 + .../src/test/kotlin/android/net/Uri.kt | 22 + .../AdErrorEventProxyApiTest.kt | 25 + .../AdErrorListenerProxyApiTest.kt | 35 + .../AdErrorProxyApiTest.kt | 53 + .../AdEventListenerProxyApiTest.kt | 34 + .../AdEventProxyApiTest.kt | 23 + .../AdMediaInfoProxyApiTest.kt | 23 + .../AdPodInfoProxyApiTest.kt | 73 + .../AdsLoadedListenerProxyApiTest.kt | 34 + .../AdsLoaderProxyApiTest.kt | 47 + .../AdsManagerLoadedEventProxyApiTest.kt | 25 + .../AdsManagerProxyApiTest.kt | 42 + .../AdsRequestProxyApiTest.kt | 35 + .../BaseManagerProxyApiTest.kt | 56 + .../ImaSdkFactoryProxyApiTest.kt | 54 + .../InteractiveMediaAdsPluginTest.kt | 31 - .../MediaPlayerProxyApiTest.kt | 64 + .../TestProxyApiRegistrar.kt | 17 + .../VideoAdPlayerCallbackProxyApiTest.kt | 124 + .../VideoAdPlayerProxyApiTest.kt | 132 + .../VideoViewProxyApiTest.kt | 38 + .../ViewGroupProxyApiTest.kt | 24 + .../android/app/src/main/AndroidManifest.xml | 4 + .../example/lib/main.dart | 169 +- .../example/pubspec.yaml | 1 + .../lib/interactive_media_ads.dart | 15 +- .../android/android_ad_display_container.dart | 279 + .../lib/src/android/android_ads_loader.dart | 143 + .../lib/src/android/android_ads_manager.dart | 88 + .../android/android_ads_manager_delegate.dart | 11 + .../android_interactive_media_ads.dart | 40 + .../lib/src/android/android_view_widget.dart | 103 + .../android/enum_converter_extensions.dart | 85 + .../src/android/interactive_media_ads.g.dart | 4726 +++++++++++++++++ .../android/interactive_media_ads_proxy.dart | 90 + .../android/platform_views_service_proxy.dart | 53 + .../platform_ads_manager.dart | 2 +- .../pigeons/copyright.txt | 3 + .../interactive_media_ads_android.dart | 723 +++ packages/interactive_media_ads/pubspec.yaml | 4 +- .../android/ad_display_container_test.dart | 518 ++ .../ad_display_container_test.mocks.dart | 1266 +++++ .../test/android/ads_loader_test.dart | 322 ++ .../test/android/ads_loader_test.mocks.dart | 1771 ++++++ .../test/android/ads_manager_tests.dart | 136 + .../test/android/ads_manager_tests.mocks.dart | 501 ++ .../test/version_test.dart | 27 + 78 files changed, 16725 insertions(+), 71 deletions(-) create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdDisplayContainerProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorEventProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorListenerProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventListenerProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdMediaInfoProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdPodInfoProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoadedListenerProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoaderProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerLoadedEventProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseDisplayContainerProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/FrameLayoutProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkFactoryProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkSettingsProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/MediaPlayerProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ProxyApiRegistrar.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerCallbackProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoProgressUpdateProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoViewProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ViewGroupProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ViewProxyApi.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/android/net/Uri.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorEventProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorListenerProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventListenerProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdMediaInfoProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdPodInfoProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoadedListenerProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoaderProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerLoadedEventProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkFactoryProxyApiTest.kt delete mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPluginTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/MediaPlayerProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/TestProxyApiRegistrar.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerCallbackProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoViewProxyApiTest.kt create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ViewGroupProxyApiTest.kt create mode 100644 packages/interactive_media_ads/lib/src/android/android_ad_display_container.dart create mode 100644 packages/interactive_media_ads/lib/src/android/android_ads_loader.dart create mode 100644 packages/interactive_media_ads/lib/src/android/android_ads_manager.dart create mode 100644 packages/interactive_media_ads/lib/src/android/android_ads_manager_delegate.dart create mode 100644 packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart create mode 100644 packages/interactive_media_ads/lib/src/android/android_view_widget.dart create mode 100644 packages/interactive_media_ads/lib/src/android/enum_converter_extensions.dart create mode 100644 packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart create mode 100644 packages/interactive_media_ads/lib/src/android/interactive_media_ads_proxy.dart create mode 100644 packages/interactive_media_ads/lib/src/android/platform_views_service_proxy.dart create mode 100644 packages/interactive_media_ads/pigeons/copyright.txt create mode 100644 packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart create mode 100644 packages/interactive_media_ads/test/android/ad_display_container_test.dart create mode 100644 packages/interactive_media_ads/test/android/ad_display_container_test.mocks.dart create mode 100644 packages/interactive_media_ads/test/android/ads_loader_test.dart create mode 100644 packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart create mode 100644 packages/interactive_media_ads/test/android/ads_manager_tests.dart create mode 100644 packages/interactive_media_ads/test/android/ads_manager_tests.mocks.dart create mode 100644 packages/interactive_media_ads/test/version_test.dart diff --git a/packages/interactive_media_ads/CHANGELOG.md b/packages/interactive_media_ads/CHANGELOG.md index 838b76b7d944..68c213c1c792 100644 --- a/packages/interactive_media_ads/CHANGELOG.md +++ b/packages/interactive_media_ads/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.2 + +* Adds Android implementation. + ## 0.0.1+3 * Fixes the pub badge source. diff --git a/packages/interactive_media_ads/android/build.gradle b/packages/interactive_media_ads/android/build.gradle index eab18ff2d763..282ddf2c7f41 100644 --- a/packages/interactive_media_ads/android/build.gradle +++ b/packages/interactive_media_ads/android/build.gradle @@ -51,10 +51,16 @@ android { dependencies { implementation 'androidx.annotation:annotation:1.8.0' + implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.33.0' testImplementation 'junit:junit:4.13.2' testImplementation 'org.jetbrains.kotlin:kotlin-test' + testImplementation "org.mockito.kotlin:mockito-kotlin:4.1.0" testImplementation 'org.mockito:mockito-inline:5.1.0' testImplementation 'androidx.test:core:1.3.0' + + // org.jetbrains.kotlin:kotlin-bom artifact purpose is to align kotlin stdlib and related code versions. + // See: https://youtrack.jetbrains.com/issue/KT-55297/kotlin-stdlib-should-declare-constraints-on-kotlin-stdlib-jdk8-and-kotlin-stdlib-jdk7 + implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.10")) } lintOptions { diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdDisplayContainerProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdDisplayContainerProxyApi.kt new file mode 100644 index 000000000000..225abe612669 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdDisplayContainerProxyApi.kt @@ -0,0 +1,14 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +/** + * ProxyApi implementation for [com.google.ads.interactivemedia.v3.api.AdDisplayContainer]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdDisplayContainerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdDisplayContainer(pigeonRegistrar) diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorEventProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorEventProxyApi.kt new file mode 100644 index 000000000000..63e52492cd8c --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorEventProxyApi.kt @@ -0,0 +1,21 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdError +import com.google.ads.interactivemedia.v3.api.AdErrorEvent + +/** + * ProxyApi implementation for [AdErrorEvent]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdErrorEventProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdErrorEvent(pigeonRegistrar) { + override fun error(pigeon_instance: AdErrorEvent): AdError { + return pigeon_instance.error + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorListenerProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorListenerProxyApi.kt new file mode 100644 index 000000000000..0fc8ee253333 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorListenerProxyApi.kt @@ -0,0 +1,27 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdErrorEvent + +/** + * ProxyApi implementation for [AdErrorEvent.AdErrorListener]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdErrorListenerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdErrorListener(pigeonRegistrar) { + internal class AdErrorListenerImpl(val api: AdErrorListenerProxyApi) : + AdErrorEvent.AdErrorListener { + override fun onAdError(event: AdErrorEvent) { + api.pigeonRegistrar.runOnMainThread { api.onAdError(this, event) {} } + } + } + + override fun pigeon_defaultConstructor(): AdErrorEvent.AdErrorListener { + return AdErrorListenerImpl(this) + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorProxyApi.kt new file mode 100644 index 000000000000..5e06fe2c3b70 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorProxyApi.kt @@ -0,0 +1,61 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdError + +/** + * ProxyApi implementation for [AdError]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdErrorProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdError(pigeonRegistrar) { + override fun errorCode(pigeon_instance: AdError): AdErrorCode { + return when (pigeon_instance.errorCode) { + AdError.AdErrorCode.ADS_PLAYER_NOT_PROVIDED -> AdErrorCode.ADS_PLAYER_WAS_NOT_PROVIDED + AdError.AdErrorCode.INTERNAL_ERROR -> AdErrorCode.INTERNAL_ERROR + AdError.AdErrorCode.VAST_MALFORMED_RESPONSE -> AdErrorCode.VAST_MALFORMED_RESPONSE + AdError.AdErrorCode.UNKNOWN_AD_RESPONSE -> AdErrorCode.UNKNOWN_AD_RESPONSE + AdError.AdErrorCode.VAST_TRAFFICKING_ERROR -> AdErrorCode.VAST_TRAFFICKING_ERROR + AdError.AdErrorCode.VAST_LOAD_TIMEOUT -> AdErrorCode.VAST_LOAD_TIMEOUT + AdError.AdErrorCode.VAST_TOO_MANY_REDIRECTS -> AdErrorCode.VAST_TOO_MANY_REDIRECTS + AdError.AdErrorCode.VAST_NO_ADS_AFTER_WRAPPER -> AdErrorCode.VAST_NO_ADS_AFTER_WRAPPER + AdError.AdErrorCode.VIDEO_PLAY_ERROR -> AdErrorCode.VIDEO_PLAY_ERROR + AdError.AdErrorCode.VAST_MEDIA_LOAD_TIMEOUT -> AdErrorCode.VAST_MEDIA_LOAD_TIMEOUT + AdError.AdErrorCode.VAST_LINEAR_ASSET_MISMATCH -> AdErrorCode.VAST_LINEAR_ASSET_MISMATCH + AdError.AdErrorCode.OVERLAY_AD_PLAYING_FAILED -> AdErrorCode.OVERLAY_AD_PLAYING_FAILED + AdError.AdErrorCode.OVERLAY_AD_LOADING_FAILED -> AdErrorCode.OVERLAY_AD_LOADING_FAILED + AdError.AdErrorCode.VAST_NONLINEAR_ASSET_MISMATCH -> AdErrorCode.VAST_NONLINEAR_ASSET_MISMATCH + AdError.AdErrorCode.COMPANION_AD_LOADING_FAILED -> AdErrorCode.COMPANION_AD_LOADING_FAILED + AdError.AdErrorCode.UNKNOWN_ERROR -> AdErrorCode.UNKNOWN_ERROR + AdError.AdErrorCode.VAST_EMPTY_RESPONSE -> AdErrorCode.VAST_EMPTY_RESPONSE + AdError.AdErrorCode.FAILED_TO_REQUEST_ADS -> AdErrorCode.FAILED_TO_REQUEST_ADS + AdError.AdErrorCode.VAST_ASSET_NOT_FOUND -> AdErrorCode.VAST_ASSET_NOT_FOUND + AdError.AdErrorCode.ADS_REQUEST_NETWORK_ERROR -> AdErrorCode.ADS_REQUEST_NETWORK_ERROR + AdError.AdErrorCode.INVALID_ARGUMENTS -> AdErrorCode.INVALID_ARGUMENTS + AdError.AdErrorCode.PLAYLIST_NO_CONTENT_TRACKING -> AdErrorCode.PLAYLIST_NO_CONTENT_TRACKING + AdError.AdErrorCode.UNEXPECTED_ADS_LOADED_EVENT -> AdErrorCode.UNEXPECTED_ADS_LOADED_EVENT + else -> AdErrorCode.UNKNOWN + } + } + + override fun errorCodeNumber(pigeon_instance: AdError): Long { + return pigeon_instance.errorCodeNumber.toLong() + } + + override fun errorType(pigeon_instance: AdError): AdErrorType { + return when (pigeon_instance.errorType) { + AdError.AdErrorType.LOAD -> AdErrorType.LOAD + AdError.AdErrorType.PLAY -> AdErrorType.PLAY + else -> AdErrorType.UNKNOWN + } + } + + override fun message(pigeon_instance: AdError): String { + return pigeon_instance.message + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventListenerProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventListenerProxyApi.kt new file mode 100644 index 000000000000..9037799d1a89 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventListenerProxyApi.kt @@ -0,0 +1,26 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdEvent + +/** + * ProxyApi implementation for [AdEvent.AdEventListener]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdEventListenerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdEventListener(pigeonRegistrar) { + internal class AdEventListenerImpl(val api: AdEventListenerProxyApi) : AdEvent.AdEventListener { + override fun onAdEvent(event: AdEvent) { + api.pigeonRegistrar.runOnMainThread { api.onAdEvent(this, event) {} } + } + } + + override fun pigeon_defaultConstructor(): AdEvent.AdEventListener { + return AdEventListenerImpl(this) + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApi.kt new file mode 100644 index 000000000000..c490a1643c9a --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApi.kt @@ -0,0 +1,49 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdEvent + +/** + * ProxyApi implementation for [AdEvent]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdEventProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdEvent(pigeonRegistrar) { + override fun type(pigeon_instance: AdEvent): AdEventType { + return when (pigeon_instance.type) { + AdEvent.AdEventType.ALL_ADS_COMPLETED -> AdEventType.ALL_ADS_COMPLETED + AdEvent.AdEventType.AD_BREAK_FETCH_ERROR -> AdEventType.AD_BREAK_FETCH_ERROR + AdEvent.AdEventType.CLICKED -> AdEventType.CLICKED + AdEvent.AdEventType.COMPLETED -> AdEventType.COMPLETED + AdEvent.AdEventType.CUEPOINTS_CHANGED -> AdEventType.CUEPOINTS_CHANGED + AdEvent.AdEventType.CONTENT_PAUSE_REQUESTED -> AdEventType.CONTENT_PAUSE_REQUESTED + AdEvent.AdEventType.CONTENT_RESUME_REQUESTED -> AdEventType.CONTENT_RESUME_REQUESTED + AdEvent.AdEventType.FIRST_QUARTILE -> AdEventType.FIRST_QUARTILE + AdEvent.AdEventType.LOG -> AdEventType.LOG + AdEvent.AdEventType.AD_BREAK_READY -> AdEventType.AD_BREAK_READY + AdEvent.AdEventType.MIDPOINT -> AdEventType.MIDPOINT + AdEvent.AdEventType.PAUSED -> AdEventType.PAUSED + AdEvent.AdEventType.RESUMED -> AdEventType.RESUMED + AdEvent.AdEventType.SKIPPABLE_STATE_CHANGED -> AdEventType.SKIPPABLE_STATE_CHANGED + AdEvent.AdEventType.SKIPPED -> AdEventType.SKIPPED + AdEvent.AdEventType.STARTED -> AdEventType.STARTED + AdEvent.AdEventType.TAPPED -> AdEventType.TAPPED + AdEvent.AdEventType.ICON_TAPPED -> AdEventType.ICON_TAPPED + AdEvent.AdEventType.ICON_FALLBACK_IMAGE_CLOSED -> AdEventType.ICON_FALLBACK_IMAGE_CLOSED + AdEvent.AdEventType.THIRD_QUARTILE -> AdEventType.THIRD_QUARTILE + AdEvent.AdEventType.LOADED -> AdEventType.LOADED + AdEvent.AdEventType.AD_PROGRESS -> AdEventType.AD_PROGRESS + AdEvent.AdEventType.AD_BUFFERING -> AdEventType.AD_BUFFERING + AdEvent.AdEventType.AD_BREAK_STARTED -> AdEventType.AD_BREAK_STARTED + AdEvent.AdEventType.AD_BREAK_ENDED -> AdEventType.AD_BREAK_ENDED + AdEvent.AdEventType.AD_PERIOD_STARTED -> AdEventType.AD_PERIOD_STARTED + AdEvent.AdEventType.AD_PERIOD_ENDED -> AdEventType.AD_PERIOD_ENDED + else -> AdEventType.UNKNOWN + } + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdMediaInfoProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdMediaInfoProxyApi.kt new file mode 100644 index 000000000000..cb1e03500b12 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdMediaInfoProxyApi.kt @@ -0,0 +1,20 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + +/** + * ProxyApi implementation for [AdMediaInfo]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdMediaInfoProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdMediaInfo(pigeonRegistrar) { + override fun url(pigeon_instance: AdMediaInfo): String { + return pigeon_instance.url + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdPodInfoProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdPodInfoProxyApi.kt new file mode 100644 index 000000000000..367d5f5416a2 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdPodInfoProxyApi.kt @@ -0,0 +1,40 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdPodInfo + +/** + * ProxyApi implementation for [AdPodInfo]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdPodInfoProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdPodInfo(pigeonRegistrar) { + override fun adPosition(pigeon_instance: AdPodInfo): Long { + return pigeon_instance.adPosition.toLong() + } + + override fun maxDuration(pigeon_instance: AdPodInfo): Double { + return pigeon_instance.maxDuration + } + + override fun podIndex(pigeon_instance: AdPodInfo): Long { + return pigeon_instance.podIndex.toLong() + } + + override fun timeOffset(pigeon_instance: AdPodInfo): Double { + return pigeon_instance.timeOffset + } + + override fun totalAds(pigeon_instance: AdPodInfo): Long { + return pigeon_instance.totalAds.toLong() + } + + override fun isBumper(pigeon_instance: AdPodInfo): Boolean { + return pigeon_instance.isBumper + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoadedListenerProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoadedListenerProxyApi.kt new file mode 100644 index 000000000000..2054e84dac34 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoadedListenerProxyApi.kt @@ -0,0 +1,28 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdsLoader +import com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent + +/** + * ProxyApi implementation for [AdsLoader.AdsLoadedListener]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdsLoadedListenerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdsLoadedListener(pigeonRegistrar) { + internal class AdsLoadedListenerImpl(val api: AdsLoadedListenerProxyApi) : + AdsLoader.AdsLoadedListener { + override fun onAdsManagerLoaded(event: AdsManagerLoadedEvent) { + api.pigeonRegistrar.runOnMainThread { api.onAdsManagerLoaded(this, event) {} } + } + } + + override fun pigeon_defaultConstructor(): AdsLoader.AdsLoadedListener { + return AdsLoadedListenerImpl(this) + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoaderProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoaderProxyApi.kt new file mode 100644 index 000000000000..5b5d1d7721e8 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoaderProxyApi.kt @@ -0,0 +1,36 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdErrorEvent +import com.google.ads.interactivemedia.v3.api.AdsLoader +import com.google.ads.interactivemedia.v3.api.AdsRequest + +/** + * ProxyApi implementation for [AdsLoader]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdsLoaderProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdsLoader(pigeonRegistrar) { + override fun addAdErrorListener( + pigeon_instance: AdsLoader, + listener: AdErrorEvent.AdErrorListener + ) { + pigeon_instance.addAdErrorListener(listener) + } + + override fun addAdsLoadedListener( + pigeon_instance: AdsLoader, + listener: AdsLoader.AdsLoadedListener + ) { + pigeon_instance.addAdsLoadedListener(listener) + } + + override fun requestAds(pigeon_instance: AdsLoader, request: AdsRequest) { + pigeon_instance.requestAds(request) + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerLoadedEventProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerLoadedEventProxyApi.kt new file mode 100644 index 000000000000..1374ecde4a12 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerLoadedEventProxyApi.kt @@ -0,0 +1,21 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdsManager +import com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent + +/** + * ProxyApi implementation for [AdsManagerLoadedEvent]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdsManagerLoadedEventProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdsManagerLoadedEvent(pigeonRegistrar) { + override fun manager(pigeon_instance: AdsManagerLoadedEvent): AdsManager { + return pigeon_instance.adsManager + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerProxyApi.kt new file mode 100644 index 000000000000..022a81417e2a --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerProxyApi.kt @@ -0,0 +1,28 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdsManager + +/** + * ProxyApi implementation for [AdsManager]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdsManagerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdsManager(pigeonRegistrar) { + override fun discardAdBreak(pigeon_instance: AdsManager) { + pigeon_instance.discardAdBreak() + } + + override fun pause(pigeon_instance: AdsManager) { + pigeon_instance.pause() + } + + override fun start(pigeon_instance: AdsManager) { + pigeon_instance.start() + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt new file mode 100644 index 000000000000..9222ea80d40b --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt @@ -0,0 +1,37 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdsRequest +import com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider + +/** + * ProxyApi implementation for [AdsRequest]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiAdsRequest(pigeonRegistrar) { + companion object { + /** + * The current version of the `interactive_media_ads` plugin. + * + * This must match the version in pubspec.yaml. + */ + const val pluginVersion = "0.0.2" + } + + override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) { + pigeon_instance.adTagUrl = "$adTagUrl&request_agent=Flutter-IMA-$pluginVersion" + } + + override fun setContentProgressProvider( + pigeon_instance: AdsRequest, + provider: ContentProgressProvider + ) { + pigeon_instance.contentProgressProvider = provider + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseDisplayContainerProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseDisplayContainerProxyApi.kt new file mode 100644 index 000000000000..6499138ad9cf --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseDisplayContainerProxyApi.kt @@ -0,0 +1,14 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +/** + * ProxyApi implementation for [com.google.ads.interactivemedia.v3.api.BaseDisplayContainer]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class BaseDisplayContainerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiBaseDisplayContainer(pigeonRegistrar) diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApi.kt new file mode 100644 index 000000000000..92d7558fa7cc --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApi.kt @@ -0,0 +1,40 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdErrorEvent +import com.google.ads.interactivemedia.v3.api.AdEvent +import com.google.ads.interactivemedia.v3.api.BaseManager + +/** + * ProxyApi implementation for [BaseManager]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class BaseManagerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiBaseManager(pigeonRegistrar) { + override fun addAdErrorListener( + pigeon_instance: BaseManager, + errorListener: AdErrorEvent.AdErrorListener + ) { + pigeon_instance.addAdErrorListener(errorListener) + } + + override fun addAdEventListener( + pigeon_instance: BaseManager, + adEventListener: AdEvent.AdEventListener + ) { + pigeon_instance.addAdEventListener(adEventListener) + } + + override fun destroy(pigeon_instance: BaseManager) { + pigeon_instance.destroy() + } + + override fun init(pigeon_instance: BaseManager) { + pigeon_instance.init() + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt new file mode 100644 index 000000000000..0fa1308d1383 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt @@ -0,0 +1,15 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +/** + * ProxyApi implementation for + * [com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class ContentProgressProviderProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiContentProgressProvider(pigeonRegistrar) diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/FrameLayoutProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/FrameLayoutProxyApi.kt new file mode 100644 index 000000000000..c2d6ee342787 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/FrameLayoutProxyApi.kt @@ -0,0 +1,20 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import android.widget.FrameLayout + +/** + * ProxyApi implementation for [FrameLayout]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class FrameLayoutProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiFrameLayout(pigeonRegistrar) { + override fun pigeon_defaultConstructor(): FrameLayout { + return FrameLayout(pigeonRegistrar.context) + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkFactoryProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkFactoryProxyApi.kt new file mode 100644 index 000000000000..eaed1baabe25 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkFactoryProxyApi.kt @@ -0,0 +1,49 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import android.view.ViewGroup +import com.google.ads.interactivemedia.v3.api.AdDisplayContainer +import com.google.ads.interactivemedia.v3.api.AdsLoader +import com.google.ads.interactivemedia.v3.api.AdsRequest +import com.google.ads.interactivemedia.v3.api.ImaSdkFactory +import com.google.ads.interactivemedia.v3.api.ImaSdkSettings +import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer + +/** + * ProxyApi implementation for [ImaSdkFactory]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class ImaSdkFactoryProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiImaSdkFactory(pigeonRegistrar) { + override fun instance(): ImaSdkFactory { + return ImaSdkFactory.getInstance() + } + + override fun createAdDisplayContainer( + container: ViewGroup, + player: VideoAdPlayer + ): AdDisplayContainer { + return ImaSdkFactory.createAdDisplayContainer(container, player) + } + + override fun createImaSdkSettings(pigeon_instance: ImaSdkFactory): ImaSdkSettings { + return pigeon_instance.createImaSdkSettings() + } + + override fun createAdsLoader( + pigeon_instance: ImaSdkFactory, + settings: ImaSdkSettings, + container: AdDisplayContainer + ): AdsLoader { + return pigeon_instance.createAdsLoader(pigeonRegistrar.context, settings, container) + } + + override fun createAdsRequest(pigeon_instance: ImaSdkFactory): AdsRequest { + return pigeon_instance.createAdsRequest() + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkSettingsProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkSettingsProxyApi.kt new file mode 100644 index 000000000000..c95fd1d71e02 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkSettingsProxyApi.kt @@ -0,0 +1,14 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +/** + * ProxyApi implementation for [com.google.ads.interactivemedia.v3.api.ImaSdkSettings]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class ImaSdkSettingsProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiImaSdkSettings(pigeonRegistrar) diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt new file mode 100644 index 000000000000..49d21f7b51eb --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt @@ -0,0 +1,3625 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// Autogenerated from Pigeon (v19.1.0), do not edit directly. +// See also: https://pub.dev/packages/pigeon +@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass", "SyntheticAccessor") + +package dev.flutter.packages.interactive_media_ads + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return if (exception is FlutterError) { + listOf(exception.code, exception.message, exception.details) + } else { + listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)) + } +} + +private fun createConnectionError(channelName: String): FlutterError { + return FlutterError( + "channel-error", "Unable to establish connection on channel: '$channelName'.", "") +} + +/** + * Error class for passing custom error details to Flutter via a thrown PlatformException. + * + * @property code The error code. + * @property message The error message. + * @property details The error details. Must be a datatype supported by the api codec. + */ +class FlutterError( + val code: String, + override val message: String? = null, + val details: Any? = null +) : Throwable() +/** + * Maintains instances used to communicate with the corresponding objects in Dart. + * + *

Objects stored in this container are represented by an object in Dart that is also stored in + * an InstanceManager with the same identifier. + * + *

When an instance is added with an identifier, either can be used to retrieve the other. + * + *

Added instances are added as a weak reference and a strong reference. When the strong + * reference is removed with [remove] and the weak reference is deallocated, the + * `finalizationListener` is made with the instance's identifier. However, if the strong reference + * is removed and then the identifier is retrieved with the intention to pass the identifier to Dart + * (e.g. calling [getIdentifierForStrongReference]), the strong reference to the instance is + * recreated. The strong reference will then need to be removed manually again. + */ +@Suppress("UNCHECKED_CAST", "MemberVisibilityCanBePrivate", "unused") +class PigeonInstanceManager(private val finalizationListener: PigeonFinalizationListener) { + /** Interface for listening when a weak reference of an instance is removed from the manager. */ + interface PigeonFinalizationListener { + fun onFinalize(identifier: Long) + } + + private val identifiers = java.util.WeakHashMap() + private val weakInstances = HashMap>() + private val strongInstances = HashMap() + private val referenceQueue = java.lang.ref.ReferenceQueue() + private val weakReferencesToIdentifiers = HashMap, Long>() + private val handler = android.os.Handler(android.os.Looper.getMainLooper()) + private var nextIdentifier: Long = minHostCreatedIdentifier + private var hasFinalizationListenerStopped = false + + /** + * Modifies the time interval used to define how often this instance removes garbage collected + * weak references to native Android objects that this instance was managing. + */ + var clearFinalizedWeakReferencesInterval: Long = 3000 + set(value) { + handler.removeCallbacks { this.releaseAllFinalizedInstances() } + field = value + releaseAllFinalizedInstances() + } + + init { + handler.postDelayed({ releaseAllFinalizedInstances() }, clearFinalizedWeakReferencesInterval) + } + + companion object { + // Identifiers are locked to a specific range to avoid collisions with objects + // created simultaneously from Dart. + // Host uses identifiers >= 2^16 and Dart is expected to use values n where, + // 0 <= n < 2^16. + private const val minHostCreatedIdentifier: Long = 65536 + private const val tag = "PigeonInstanceManager" + + /** + * Instantiate a new manager. + * + * When the manager is no longer needed, [stopFinalizationListener] must be called. + * + * @param finalizationListener the listener for garbage collected weak references. + * @return a new `PigeonInstanceManager`. + */ + fun create(finalizationListener: PigeonFinalizationListener): PigeonInstanceManager { + return PigeonInstanceManager(finalizationListener) + } + } + + /** + * Removes `identifier` and its associated strongly referenced instance, if present, from the + * manager. + * + * @param identifier the identifier paired to an instance. + * @param the expected return type. + * @return the removed instance if the manager contains the given identifier, otherwise `null` if + * the manager doesn't contain the value. + */ + fun remove(identifier: Long): T? { + logWarningIfFinalizationListenerHasStopped() + return strongInstances.remove(identifier) as T? + } + + /** + * Retrieves the identifier paired with an instance. + * + * If the manager contains a strong reference to `instance`, it will return the identifier + * associated with `instance`. If the manager contains only a weak reference to `instance`, a new + * strong reference to `instance` will be added and will need to be removed again with [remove]. + * + * If this method returns a nonnull identifier, this method also expects the Dart + * `PigeonInstanceManager` to have, or recreate, a weak reference to the Dart instance the + * identifier is associated with. + * + * @param instance an instance that may be stored in the manager. + * @return the identifier associated with `instance` if the manager contains the value, otherwise + * `null` if the manager doesn't contain the value. + */ + fun getIdentifierForStrongReference(instance: Any?): Long? { + logWarningIfFinalizationListenerHasStopped() + val identifier = identifiers[instance] + if (identifier != null) { + strongInstances[identifier] = instance!! + } + return identifier + } + + /** + * Adds a new instance that was instantiated from Dart. + * + * The same instance can be added multiple times, but each identifier must be unique. This allows + * two objects that are equivalent (e.g. the `equals` method returns true and their hashcodes are + * equal) to both be added. + * + * @param instance the instance to be stored. + * @param identifier the identifier to be paired with instance. This value must be >= 0 and + * unique. + */ + fun addDartCreatedInstance(instance: Any, identifier: Long) { + logWarningIfFinalizationListenerHasStopped() + addInstance(instance, identifier) + } + + /** + * Adds a new instance that was instantiated from the host platform. + * + * @param instance the instance to be stored. This must be unique to all other added instances. + * @return the unique identifier (>= 0) stored with instance. + */ + fun addHostCreatedInstance(instance: Any): Long { + logWarningIfFinalizationListenerHasStopped() + require(!containsInstance(instance)) { + "Instance of ${instance.javaClass} has already been added." + } + val identifier = nextIdentifier++ + addInstance(instance, identifier) + return identifier + } + + /** + * Retrieves the instance associated with identifier. + * + * @param identifier the identifier associated with an instance. + * @param the expected return type. + * @return the instance associated with `identifier` if the manager contains the value, otherwise + * `null` if the manager doesn't contain the value. + */ + fun getInstance(identifier: Long): T? { + logWarningIfFinalizationListenerHasStopped() + val instance = weakInstances[identifier] as java.lang.ref.WeakReference? + return instance?.get() + } + + /** + * Returns whether this manager contains the given `instance`. + * + * @param instance the instance whose presence in this manager is to be tested. + * @return whether this manager contains the given `instance`. + */ + fun containsInstance(instance: Any?): Boolean { + logWarningIfFinalizationListenerHasStopped() + return identifiers.containsKey(instance) + } + + /** + * Stop the periodic run of the [PigeonFinalizationListener] for instances that have been garbage + * collected. + * + * The InstanceManager can continue to be used, but the [PigeonFinalizationListener] will no + * longer be called and methods will log a warning. + */ + fun stopFinalizationListener() { + handler.removeCallbacks { this.releaseAllFinalizedInstances() } + hasFinalizationListenerStopped = true + } + + /** + * Removes all of the instances from this manager. + * + * The manager will be empty after this call returns. + */ + fun clear() { + identifiers.clear() + weakInstances.clear() + strongInstances.clear() + weakReferencesToIdentifiers.clear() + } + + /** + * Whether the [PigeonFinalizationListener] is still being called for instances that are garbage + * collected. + * + * See [stopFinalizationListener]. + */ + fun hasFinalizationListenerStopped(): Boolean { + return hasFinalizationListenerStopped + } + + private fun releaseAllFinalizedInstances() { + if (hasFinalizationListenerStopped()) { + return + } + var reference: java.lang.ref.WeakReference? + while ((referenceQueue.poll() as java.lang.ref.WeakReference?).also { reference = it } != + null) { + val identifier = weakReferencesToIdentifiers.remove(reference) + if (identifier != null) { + weakInstances.remove(identifier) + strongInstances.remove(identifier) + finalizationListener.onFinalize(identifier) + } + } + handler.postDelayed({ releaseAllFinalizedInstances() }, clearFinalizedWeakReferencesInterval) + } + + private fun addInstance(instance: Any, identifier: Long) { + require(identifier >= 0) { "Identifier must be >= 0: $identifier" } + require(!weakInstances.containsKey(identifier)) { + "Identifier has already been added: $identifier" + } + val weakReference = java.lang.ref.WeakReference(instance, referenceQueue) + identifiers[instance] = identifier + weakInstances[identifier] = weakReference + weakReferencesToIdentifiers[weakReference] = identifier + strongInstances[identifier] = instance + } + + private fun logWarningIfFinalizationListenerHasStopped() { + if (hasFinalizationListenerStopped()) { + Log.w( + tag, + "The manager was used after calls to the PigeonFinalizationListener has been stopped.") + } + } +} + +/** Generated API for managing the Dart and native `PigeonInstanceManager`s. */ +private class PigeonInstanceManagerApi(val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by PigeonInstanceManagerApi. */ + val codec: MessageCodec by lazy { StandardMessageCodec() } + + /** + * Sets up an instance of `PigeonInstanceManagerApi` to handle messages from the + * `binaryMessenger`. + */ + fun setUpMessageHandlers( + binaryMessenger: BinaryMessenger, + instanceManager: PigeonInstanceManager? + ) { + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference", + codec) + if (instanceManager != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val identifierArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + instanceManager.remove(identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.clear", + codec) + if (instanceManager != null) { + channel.setMessageHandler { _, reply -> + val wrapped: List = + try { + instanceManager.clear() + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + fun removeStrongReference(identifierArg: Long, callback: (Result) -> Unit) { + val channelName = + "dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Provides implementations for each ProxyApi implementation and provides access to resources needed + * by any implementation. + */ +abstract class PigeonProxyApiRegistrar(val binaryMessenger: BinaryMessenger) { + val instanceManager: PigeonInstanceManager + private var _codec: StandardMessageCodec? = null + val codec: StandardMessageCodec + get() { + if (_codec == null) { + _codec = PigeonProxyApiBaseCodec(this) + } + return _codec!! + } + + init { + val api = PigeonInstanceManagerApi(binaryMessenger) + instanceManager = + PigeonInstanceManager.create( + object : PigeonInstanceManager.PigeonFinalizationListener { + override fun onFinalize(identifier: Long) { + api.removeStrongReference(identifier) { + if (it.isFailure) { + Log.e( + "PigeonProxyApiRegistrar", + "Failed to remove Dart strong reference with identifier: $identifier") + } + } + } + }) + } + + /** + * An implementation of [PigeonApiBaseDisplayContainer] used to add a new Dart instance of + * `BaseDisplayContainer` to the Dart `InstanceManager`. + */ + open fun getPigeonApiBaseDisplayContainer(): PigeonApiBaseDisplayContainer { + return PigeonApiBaseDisplayContainer(this) + } + + /** + * An implementation of [PigeonApiAdDisplayContainer] used to add a new Dart instance of + * `AdDisplayContainer` to the Dart `InstanceManager`. + */ + open fun getPigeonApiAdDisplayContainer(): PigeonApiAdDisplayContainer { + return PigeonApiAdDisplayContainer(this) + } + + /** + * An implementation of [PigeonApiAdsLoader] used to add a new Dart instance of `AdsLoader` to the + * Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdsLoader(): PigeonApiAdsLoader + + /** + * An implementation of [PigeonApiAdsManagerLoadedEvent] used to add a new Dart instance of + * `AdsManagerLoadedEvent` to the Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdsManagerLoadedEvent(): PigeonApiAdsManagerLoadedEvent + + /** + * An implementation of [PigeonApiAdErrorEvent] used to add a new Dart instance of `AdErrorEvent` + * to the Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdErrorEvent(): PigeonApiAdErrorEvent + + /** + * An implementation of [PigeonApiAdError] used to add a new Dart instance of `AdError` to the + * Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdError(): PigeonApiAdError + + /** + * An implementation of [PigeonApiAdsRequest] used to add a new Dart instance of `AdsRequest` to + * the Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdsRequest(): PigeonApiAdsRequest + + /** + * An implementation of [PigeonApiContentProgressProvider] used to add a new Dart instance of + * `ContentProgressProvider` to the Dart `InstanceManager`. + */ + open fun getPigeonApiContentProgressProvider(): PigeonApiContentProgressProvider { + return PigeonApiContentProgressProvider(this) + } + + /** + * An implementation of [PigeonApiAdsManager] used to add a new Dart instance of `AdsManager` to + * the Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdsManager(): PigeonApiAdsManager + + /** + * An implementation of [PigeonApiBaseManager] used to add a new Dart instance of `BaseManager` to + * the Dart `InstanceManager`. + */ + abstract fun getPigeonApiBaseManager(): PigeonApiBaseManager + + /** + * An implementation of [PigeonApiAdEvent] used to add a new Dart instance of `AdEvent` to the + * Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdEvent(): PigeonApiAdEvent + + /** + * An implementation of [PigeonApiImaSdkFactory] used to add a new Dart instance of + * `ImaSdkFactory` to the Dart `InstanceManager`. + */ + abstract fun getPigeonApiImaSdkFactory(): PigeonApiImaSdkFactory + + /** + * An implementation of [PigeonApiImaSdkSettings] used to add a new Dart instance of + * `ImaSdkSettings` to the Dart `InstanceManager`. + */ + open fun getPigeonApiImaSdkSettings(): PigeonApiImaSdkSettings { + return PigeonApiImaSdkSettings(this) + } + + /** + * An implementation of [PigeonApiVideoProgressUpdate] used to add a new Dart instance of + * `VideoProgressUpdate` to the Dart `InstanceManager`. + */ + abstract fun getPigeonApiVideoProgressUpdate(): PigeonApiVideoProgressUpdate + + /** + * An implementation of [PigeonApiAdMediaInfo] used to add a new Dart instance of `AdMediaInfo` to + * the Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdMediaInfo(): PigeonApiAdMediaInfo + + /** + * An implementation of [PigeonApiAdPodInfo] used to add a new Dart instance of `AdPodInfo` to the + * Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdPodInfo(): PigeonApiAdPodInfo + + /** + * An implementation of [PigeonApiFrameLayout] used to add a new Dart instance of `FrameLayout` to + * the Dart `InstanceManager`. + */ + abstract fun getPigeonApiFrameLayout(): PigeonApiFrameLayout + + /** + * An implementation of [PigeonApiViewGroup] used to add a new Dart instance of `ViewGroup` to the + * Dart `InstanceManager`. + */ + abstract fun getPigeonApiViewGroup(): PigeonApiViewGroup + + /** + * An implementation of [PigeonApiVideoView] used to add a new Dart instance of `VideoView` to the + * Dart `InstanceManager`. + */ + abstract fun getPigeonApiVideoView(): PigeonApiVideoView + + /** + * An implementation of [PigeonApiView] used to add a new Dart instance of `View` to the Dart + * `InstanceManager`. + */ + open fun getPigeonApiView(): PigeonApiView { + return PigeonApiView(this) + } + + /** + * An implementation of [PigeonApiMediaPlayer] used to add a new Dart instance of `MediaPlayer` to + * the Dart `InstanceManager`. + */ + abstract fun getPigeonApiMediaPlayer(): PigeonApiMediaPlayer + + /** + * An implementation of [PigeonApiVideoAdPlayerCallback] used to add a new Dart instance of + * `VideoAdPlayerCallback` to the Dart `InstanceManager`. + */ + abstract fun getPigeonApiVideoAdPlayerCallback(): PigeonApiVideoAdPlayerCallback + + /** + * An implementation of [PigeonApiVideoAdPlayer] used to add a new Dart instance of + * `VideoAdPlayer` to the Dart `InstanceManager`. + */ + abstract fun getPigeonApiVideoAdPlayer(): PigeonApiVideoAdPlayer + + /** + * An implementation of [PigeonApiAdsLoadedListener] used to add a new Dart instance of + * `AdsLoadedListener` to the Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdsLoadedListener(): PigeonApiAdsLoadedListener + + /** + * An implementation of [PigeonApiAdErrorListener] used to add a new Dart instance of + * `AdErrorListener` to the Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdErrorListener(): PigeonApiAdErrorListener + + /** + * An implementation of [PigeonApiAdEventListener] used to add a new Dart instance of + * `AdEventListener` to the Dart `InstanceManager`. + */ + abstract fun getPigeonApiAdEventListener(): PigeonApiAdEventListener + + fun setUp() { + PigeonInstanceManagerApi.setUpMessageHandlers(binaryMessenger, instanceManager) + PigeonApiAdsLoader.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsLoader()) + PigeonApiAdsRequest.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsRequest()) + PigeonApiAdsManager.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsManager()) + PigeonApiBaseManager.setUpMessageHandlers(binaryMessenger, getPigeonApiBaseManager()) + PigeonApiImaSdkFactory.setUpMessageHandlers(binaryMessenger, getPigeonApiImaSdkFactory()) + PigeonApiVideoProgressUpdate.setUpMessageHandlers( + binaryMessenger, getPigeonApiVideoProgressUpdate()) + PigeonApiFrameLayout.setUpMessageHandlers(binaryMessenger, getPigeonApiFrameLayout()) + PigeonApiViewGroup.setUpMessageHandlers(binaryMessenger, getPigeonApiViewGroup()) + PigeonApiVideoView.setUpMessageHandlers(binaryMessenger, getPigeonApiVideoView()) + PigeonApiMediaPlayer.setUpMessageHandlers(binaryMessenger, getPigeonApiMediaPlayer()) + PigeonApiVideoAdPlayerCallback.setUpMessageHandlers( + binaryMessenger, getPigeonApiVideoAdPlayerCallback()) + PigeonApiVideoAdPlayer.setUpMessageHandlers(binaryMessenger, getPigeonApiVideoAdPlayer()) + PigeonApiAdsLoadedListener.setUpMessageHandlers( + binaryMessenger, getPigeonApiAdsLoadedListener()) + PigeonApiAdErrorListener.setUpMessageHandlers(binaryMessenger, getPigeonApiAdErrorListener()) + PigeonApiAdEventListener.setUpMessageHandlers(binaryMessenger, getPigeonApiAdEventListener()) + } + + fun tearDown() { + PigeonInstanceManagerApi.setUpMessageHandlers(binaryMessenger, null) + PigeonApiAdsLoader.setUpMessageHandlers(binaryMessenger, null) + PigeonApiAdsRequest.setUpMessageHandlers(binaryMessenger, null) + PigeonApiAdsManager.setUpMessageHandlers(binaryMessenger, null) + PigeonApiBaseManager.setUpMessageHandlers(binaryMessenger, null) + PigeonApiImaSdkFactory.setUpMessageHandlers(binaryMessenger, null) + PigeonApiVideoProgressUpdate.setUpMessageHandlers(binaryMessenger, null) + PigeonApiFrameLayout.setUpMessageHandlers(binaryMessenger, null) + PigeonApiViewGroup.setUpMessageHandlers(binaryMessenger, null) + PigeonApiVideoView.setUpMessageHandlers(binaryMessenger, null) + PigeonApiMediaPlayer.setUpMessageHandlers(binaryMessenger, null) + PigeonApiVideoAdPlayerCallback.setUpMessageHandlers(binaryMessenger, null) + PigeonApiVideoAdPlayer.setUpMessageHandlers(binaryMessenger, null) + PigeonApiAdsLoadedListener.setUpMessageHandlers(binaryMessenger, null) + PigeonApiAdErrorListener.setUpMessageHandlers(binaryMessenger, null) + PigeonApiAdEventListener.setUpMessageHandlers(binaryMessenger, null) + } +} + +private class PigeonProxyApiBaseCodec(val registrar: PigeonProxyApiRegistrar) : + StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return registrar.instanceManager.getInstance( + readValue(buffer).let { if (it is Int) it.toLong() else it as Long }) + } + else -> super.readValueOfType(type, buffer) + } + } + + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + if (value is com.google.ads.interactivemedia.v3.api.AdDisplayContainer) { + registrar.getPigeonApiAdDisplayContainer().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.BaseDisplayContainer) { + registrar.getPigeonApiBaseDisplayContainer().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdsLoader) { + registrar.getPigeonApiAdsLoader().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent) { + registrar.getPigeonApiAdsManagerLoadedEvent().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdErrorEvent) { + registrar.getPigeonApiAdErrorEvent().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdError) { + registrar.getPigeonApiAdError().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdsRequest) { + registrar.getPigeonApiAdsRequest().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider) { + registrar.getPigeonApiContentProgressProvider().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdsManager) { + registrar.getPigeonApiAdsManager().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.BaseManager) { + registrar.getPigeonApiBaseManager().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdEvent) { + registrar.getPigeonApiAdEvent().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.ImaSdkFactory) { + registrar.getPigeonApiImaSdkFactory().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.ImaSdkSettings) { + registrar.getPigeonApiImaSdkSettings().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate) { + registrar.getPigeonApiVideoProgressUpdate().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.player.AdMediaInfo) { + registrar.getPigeonApiAdMediaInfo().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdPodInfo) { + registrar.getPigeonApiAdPodInfo().pigeon_newInstance(value) {} + } else if (value is android.widget.FrameLayout) { + registrar.getPigeonApiFrameLayout().pigeon_newInstance(value) {} + } else if (value is android.view.ViewGroup) { + registrar.getPigeonApiViewGroup().pigeon_newInstance(value) {} + } else if (value is android.widget.VideoView) { + registrar.getPigeonApiVideoView().pigeon_newInstance(value) {} + } else if (value is android.view.View) { + registrar.getPigeonApiView().pigeon_newInstance(value) {} + } else if (value is android.media.MediaPlayer) { + registrar.getPigeonApiMediaPlayer().pigeon_newInstance(value) {} + } else if (value + is com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback) { + registrar.getPigeonApiVideoAdPlayerCallback().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer) { + registrar.getPigeonApiVideoAdPlayer().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener) { + registrar.getPigeonApiAdsLoadedListener().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener) { + registrar.getPigeonApiAdErrorListener().pigeon_newInstance(value) {} + } else if (value is com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener) { + registrar.getPigeonApiAdEventListener().pigeon_newInstance(value) {} + } + + when { + registrar.instanceManager.containsInstance(value) -> { + stream.write(128) + writeValue(stream, registrar.instanceManager.getIdentifierForStrongReference(value)) + } + else -> super.writeValue(stream, value) + } + } +} + +/** + * The types of error that can be encountered. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.AdErrorCode.html. + */ +enum class AdErrorCode(val raw: Int) { + /** Ads player was not provided. */ + ADS_PLAYER_WAS_NOT_PROVIDED(0), + /** There was a problem requesting ads from the server. */ + ADS_REQUEST_NETWORK_ERROR(1), + /** A companion ad failed to load or render. */ + COMPANION_AD_LOADING_FAILED(2), + /** There was a problem requesting ads from the server. */ + FAILED_TO_REQUEST_ADS(3), + /** An error internal to the SDK occurred. */ + INTERNAL_ERROR(4), + /** Invalid arguments were provided to SDK methods. */ + INVALID_ARGUMENTS(5), + /** An overlay ad failed to load. */ + OVERLAY_AD_LOADING_FAILED(6), + /** An overlay ad failed to render. */ + OVERLAY_AD_PLAYING_FAILED(7), + /** Ads list was returned but ContentProgressProvider was not configured. */ + PLAYLIST_NO_CONTENT_TRACKING(8), + /** Ads loader sent ads loaded event when it was not expected. */ + UNEXPECTED_ADS_LOADED_EVENT(9), + /** The ad response was not understood and cannot be parsed. */ + UNKNOWN_AD_RESPONSE(10), + /** An unexpected error occurred and the cause is not known. */ + UNKNOWN_ERROR(11), + /** No assets were found in the VAST ad response. */ + VAST_ASSET_NOT_FOUND(12), + /** A VAST response containing a single `` tag with no child tags. */ + VAST_EMPTY_RESPONSE(13), + /** + * Assets were found in the VAST ad response for a linear ad, but none of them matched the video + * player's capabilities. + */ + VAST_LINEAR_ASSET_MISMATCH(14), + /** + * At least one VAST wrapper ad loaded successfully and a subsequent wrapper or inline ad load has + * timed out. + */ + VAST_LOAD_TIMEOUT(15), + /** The ad response was not recognized as a valid VAST ad. */ + VAST_MALFORMED_RESPONSE(16), + /** Failed to load media assets from a VAST response. */ + VAST_MEDIA_LOAD_TIMEOUT(17), + /** + * Assets were found in the VAST ad response for a nonlinear ad, but none of them matched the + * video player's capabilities. + */ + VAST_NONLINEAR_ASSET_MISMATCH(18), + /** No Ads VAST response after one or more wrappers. */ + VAST_NO_ADS_AFTER_WRAPPER(19), + /** The maximum number of VAST wrapper redirects has been reached. */ + VAST_TOO_MANY_REDIRECTS(20), + /** + * Trafficking error. + * + * Video player received an ad type that it was not expecting and/or cannot display. + */ + VAST_TRAFFICKING_ERROR(21), + /** There was an error playing the video ad. */ + VIDEO_PLAY_ERROR(22), + /** The error code is not recognized by this wrapper. */ + UNKNOWN(23); + + companion object { + fun ofRaw(raw: Int): AdErrorCode? { + return values().firstOrNull { it.raw == raw } + } + } +} + +/** + * Specifies when the error was encountered, during either ad loading or playback. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.AdErrorType.html. + */ +enum class AdErrorType(val raw: Int) { + /** Indicates that the error was encountered when the ad was being loaded. */ + LOAD(0), + /** Indicates that the error was encountered after the ad loaded, during ad play. */ + PLAY(1), + /** The error is not recognized by this wrapper. */ + UNKNOWN(2); + + companion object { + fun ofRaw(raw: Int): AdErrorType? { + return values().firstOrNull { it.raw == raw } + } + } +} + +/** + * Types of events that can occur during ad playback. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventType.html. + */ +enum class AdEventType(val raw: Int) { + /** Fired when an ad break in a stream ends. */ + AD_BREAK_ENDED(0), + /** Fired when an ad break will not play back any ads. */ + AD_BREAK_FETCH_ERROR(1), + /** Fired when an ad break is ready from VMAP or ad rule ads. */ + AD_BREAK_READY(2), + /** Fired when an ad break in a stream starts. */ + AD_BREAK_STARTED(3), + /** Fired when playback stalls while the ad buffers. */ + AD_BUFFERING(4), + /** Fired when an ad period in a stream ends. */ + AD_PERIOD_ENDED(5), + /** Fired when an ad period in a stream starts. */ + AD_PERIOD_STARTED(6), + /** Fired to inform of ad progress and can be used by publisher to display a countdown timer. */ + AD_PROGRESS(7), + /** + * Fired when the ads manager is done playing all the valid ads in the ads response, or when the + * response doesn't return any valid ads. + */ + ALL_ADS_COMPLETED(8), + /** Fired when an ad is clicked. */ + CLICKED(9), + /** Fired when an ad completes playing. */ + COMPLETED(10), + /** Fired when content should be paused. */ + CONTENT_PAUSE_REQUESTED(11), + /** Fired when content should be resumed. */ + CONTENT_RESUME_REQUESTED(12), + /** Fired when VOD stream cuepoints have changed. */ + CUEPOINTS_CHANGED(13), + /** Fired when the ad playhead crosses first quartile. */ + FIRST_QUARTILE(14), + /** The user has closed the icon fallback image dialog. */ + ICON_FALLBACK_IMAGE_CLOSED(15), + /** The user has tapped an ad icon. */ + ICON_TAPPED(16), + /** Fired when the VAST response has been received. */ + LOADED(17), + /** Fired to enable the SDK to communicate a message to be logged, which is stored in adData. */ + LOG(18), + /** Fired when the ad playhead crosses midpoint. */ + MIDPOINT(19), + /** Fired when an ad is paused. */ + PAUSED(20), + /** Fired when an ad is resumed. */ + RESUMED(21), + /** Fired when an ad changes its skippable state. */ + SKIPPABLE_STATE_CHANGED(22), + /** Fired when an ad was skipped. */ + SKIPPED(23), + /** Fired when an ad starts playing. */ + STARTED(24), + /** Fired when a non-clickthrough portion of a video ad is clicked. */ + TAPPED(25), + /** Fired when the ad playhead crosses third quartile. */ + THIRD_QUARTILE(26), + /** The event type is not recognized by this wrapper. */ + UNKNOWN(27); + + companion object { + fun ofRaw(raw: Int): AdEventType? { + return values().firstOrNull { it.raw == raw } + } + } +} +/** + * A base class for more specialized container interfaces. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseDisplayContainer.html. + */ +@Suppress("UNCHECKED_CAST") +open class PigeonApiBaseDisplayContainer(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of BaseDisplayContainer and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.BaseDisplayContainer, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = + "dev.flutter.pigeon.interactive_media_ads.BaseDisplayContainer.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * A container in which to display the ads. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdDisplayContainer. + */ +@Suppress("UNCHECKED_CAST") +open class PigeonApiAdDisplayContainer(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdDisplayContainer and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdDisplayContainer, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = + "dev.flutter.pigeon.interactive_media_ads.AdDisplayContainer.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + @Suppress("FunctionName") + /** An implementation of [PigeonApiBaseDisplayContainer] used to access callback methods */ + fun pigeon_getPigeonApiBaseDisplayContainer(): PigeonApiBaseDisplayContainer { + return pigeonRegistrar.getPigeonApiBaseDisplayContainer() + } +} +/** + * An object which allows publishers to request ads from ad servers or a dynamic ad insertion + * stream. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdsLoader(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** Registers a listener for errors that occur during the ads request. */ + abstract fun addAdErrorListener( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsLoader, + listener: com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener + ) + + /** Registers a listener for the ads manager loaded event. */ + abstract fun addAdsLoadedListener( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsLoader, + listener: com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener + ) + + /** Requests ads from a server. */ + abstract fun requestAds( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsLoader, + request: com.google.ads.interactivemedia.v3.api.AdsRequest + ) + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiAdsLoader?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.AdsLoader.addAdErrorListener", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsLoader + val listenerArg = + args[1] as com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener + val wrapped: List = + try { + api.addAdErrorListener(pigeon_instanceArg, listenerArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.AdsLoader.addAdsLoadedListener", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsLoader + val listenerArg = + args[1] as com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener + val wrapped: List = + try { + api.addAdsLoadedListener(pigeon_instanceArg, listenerArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.AdsLoader.requestAds", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsLoader + val requestArg = args[1] as com.google.ads.interactivemedia.v3.api.AdsRequest + val wrapped: List = + try { + api.requestAds(pigeon_instanceArg, requestArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdsLoader and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsLoader, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.AdsLoader.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * An event raised when ads are successfully loaded from the ad server through an AdsLoader. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManagerLoadedEvent.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdsManagerLoadedEvent(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** + * The ads manager that will control playback of the loaded ads, or null when using dynamic ad + * insertion. + */ + abstract fun manager( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent + ): com.google.ads.interactivemedia.v3.api.AdsManager + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdsManagerLoadedEvent and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val managerArg = manager(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = + "dev.flutter.pigeon.interactive_media_ads.AdsManagerLoadedEvent.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg, managerArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * An event raised when there is an error loading or playing ads. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdErrorEvent(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** The AdError that caused this event. */ + abstract fun error( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdErrorEvent + ): com.google.ads.interactivemedia.v3.api.AdError + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdErrorEvent and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdErrorEvent, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val errorArg = error(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.AdErrorEvent.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg, errorArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * An error that occurred in the SDK. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdError(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** The error's code. */ + abstract fun errorCode( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdError + ): AdErrorCode + + /** The error code's number. */ + abstract fun errorCodeNumber( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdError + ): Long + + /** The error's type. */ + abstract fun errorType( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdError + ): AdErrorType + + /** A human-readable summary of the error. */ + abstract fun message(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdError): String + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdError and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdError, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val errorCodeArg = errorCode(pigeon_instanceArg) + val errorCodeNumberArg = errorCodeNumber(pigeon_instanceArg) + val errorTypeArg = errorType(pigeon_instanceArg) + val messageArg = message(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send( + listOf( + pigeon_identifierArg, + errorCodeArg.raw, + errorCodeNumberArg, + errorTypeArg.raw, + messageArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback( + Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * An object containing the data used to request ads from the server. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdsRequest(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** Sets the URL from which ads will be requested. */ + abstract fun setAdTagUrl( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest, + adTagUrl: String + ) + + /** + * Attaches a ContentProgressProvider instance to allow scheduling ad breaks based on content + * progress (cue points). + */ + abstract fun setContentProgressProvider( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest, + provider: com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider + ) + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiAdsRequest?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.AdsRequest.setAdTagUrl", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest + val adTagUrlArg = args[1] as String + val wrapped: List = + try { + api.setAdTagUrl(pigeon_instanceArg, adTagUrlArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentProgressProvider", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest + val providerArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider + val wrapped: List = + try { + api.setContentProgressProvider(pigeon_instanceArg, providerArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdsRequest and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsRequest, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.AdsRequest.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Defines an interface to allow SDK to track progress of the content video. + * + * See + * https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. + */ +@Suppress("UNCHECKED_CAST") +open class PigeonApiContentProgressProvider(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of ContentProgressProvider and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = + "dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * An object which handles playing ads after they've been received from the server. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManager. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdsManager(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** Discards current ad break and resumes content. */ + abstract fun discardAdBreak(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsManager) + + /** Pauses the current ad. */ + abstract fun pause(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsManager) + + /** Starts playing the ads. */ + abstract fun start(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsManager) + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiAdsManager?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.AdsManager.discardAdBreak", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsManager + val wrapped: List = + try { + api.discardAdBreak(pigeon_instanceArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, "dev.flutter.pigeon.interactive_media_ads.AdsManager.pause", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsManager + val wrapped: List = + try { + api.pause(pigeon_instanceArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, "dev.flutter.pigeon.interactive_media_ads.AdsManager.start", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsManager + val wrapped: List = + try { + api.start(pigeon_instanceArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdsManager and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsManager, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.AdsManager.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + @Suppress("FunctionName") + /** An implementation of [PigeonApiBaseManager] used to access callback methods */ + fun pigeon_getPigeonApiBaseManager(): PigeonApiBaseManager { + return pigeonRegistrar.getPigeonApiBaseManager() + } +} +/** + * Base interface for managing ads.. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiBaseManager(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** + * Registers a listener for errors that occur during the ad or stream initialization and playback. + */ + abstract fun addAdErrorListener( + pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager, + errorListener: com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener + ) + + /** + * Registers a listener for ad events that occur during ad or stream initialization and playback. + */ + abstract fun addAdEventListener( + pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager, + adEventListener: com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener + ) + + /** Stops the ad and all tracking, then releases all assets that were loaded to play the ad. */ + abstract fun destroy(pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager) + + /** Initializes the ad experience using default rendering settings */ + abstract fun init(pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager) + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiBaseManager?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.BaseManager.addAdErrorListener", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.BaseManager + val errorListenerArg = + args[1] as com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener + val wrapped: List = + try { + api.addAdErrorListener(pigeon_instanceArg, errorListenerArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.BaseManager.addAdEventListener", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.BaseManager + val adEventListenerArg = + args[1] as com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener + val wrapped: List = + try { + api.addAdEventListener(pigeon_instanceArg, adEventListenerArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.BaseManager.destroy", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.BaseManager + val wrapped: List = + try { + api.destroy(pigeon_instanceArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, "dev.flutter.pigeon.interactive_media_ads.BaseManager.init", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.BaseManager + val wrapped: List = + try { + api.init(pigeon_instanceArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of BaseManager and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.BaseManager, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.BaseManager.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Event to notify publisher that an event occurred with an Ad. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdEvent(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** The type of event that occurred. */ + abstract fun type(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdEvent): AdEventType + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdEvent and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdEvent, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val typeArg = type(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg, typeArg.raw)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Factory class for creating SDK objects. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiImaSdkFactory(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + abstract fun instance(): com.google.ads.interactivemedia.v3.api.ImaSdkFactory + + abstract fun createAdDisplayContainer( + container: android.view.ViewGroup, + player: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer + ): com.google.ads.interactivemedia.v3.api.AdDisplayContainer + + /** Creates an `ImaSdkSettings` object for configuring the IMA SDK. */ + abstract fun createImaSdkSettings( + pigeon_instance: com.google.ads.interactivemedia.v3.api.ImaSdkFactory + ): com.google.ads.interactivemedia.v3.api.ImaSdkSettings + + /** Creates an `AdsLoader` for requesting ads using the specified settings object. */ + abstract fun createAdsLoader( + pigeon_instance: com.google.ads.interactivemedia.v3.api.ImaSdkFactory, + settings: com.google.ads.interactivemedia.v3.api.ImaSdkSettings, + container: com.google.ads.interactivemedia.v3.api.AdDisplayContainer + ): com.google.ads.interactivemedia.v3.api.AdsLoader + + /** Creates an AdsRequest object to contain the data used to request ads. */ + abstract fun createAdsRequest( + pigeon_instance: com.google.ads.interactivemedia.v3.api.ImaSdkFactory + ): com.google.ads.interactivemedia.v3.api.AdsRequest + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiImaSdkFactory?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.instance", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.instance(), pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdDisplayContainer", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val containerArg = args[0] as android.view.ViewGroup + val playerArg = args[1] as com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer + val wrapped: List = + try { + listOf(api.createAdDisplayContainer(containerArg, playerArg)) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createImaSdkSettings", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.ImaSdkFactory + val wrapped: List = + try { + listOf(api.createImaSdkSettings(pigeon_instanceArg)) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdsLoader", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.ImaSdkFactory + val settingsArg = args[1] as com.google.ads.interactivemedia.v3.api.ImaSdkSettings + val containerArg = args[2] as com.google.ads.interactivemedia.v3.api.AdDisplayContainer + val wrapped: List = + try { + listOf(api.createAdsLoader(pigeon_instanceArg, settingsArg, containerArg)) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdsRequest", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.ImaSdkFactory + val wrapped: List = + try { + listOf(api.createAdsRequest(pigeon_instanceArg)) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of ImaSdkFactory and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.ImaSdkFactory, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Defines general SDK settings that are used when creating an `AdsLoader`. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkSettings.html. + */ +@Suppress("UNCHECKED_CAST") +open class PigeonApiImaSdkSettings(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of ImaSdkSettings and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.ImaSdkSettings, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.ImaSdkSettings.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Defines an update to the video's progress. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoProgressUpdate.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiVideoProgressUpdate(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + abstract fun pigeon_defaultConstructor( + currentTimeMs: Long, + durationMs: Long + ): com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + + /** Value to use for cases when progress is not yet defined, such as video initialization. */ + abstract fun videoTimeNotReady(): + com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiVideoProgressUpdate?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.pigeon_defaultConstructor", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val currentTimeMsArg = + args[1].let { num -> if (num is Int) num.toLong() else num as Long } + val durationMsArg = args[2].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.pigeon_defaultConstructor(currentTimeMsArg, durationMsArg), + pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.videoTimeNotReady", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.videoTimeNotReady(), pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of VideoProgressUpdate and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = + "dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * The minimal information required to play an ad. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/AdMediaInfo.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdMediaInfo(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + abstract fun url( + pigeon_instance: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + ): String + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdMediaInfo and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val urlArg = url(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.AdMediaInfo.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg, urlArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * An ad may be part of a pod of ads. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdPodInfo.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdPodInfo(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** + * The position of the ad within the pod. + * + * The value returned is one-based, for example, 1 of 2, 2 of 2, etc. If the ad is not part of a + * pod, this will return 1. + */ + abstract fun adPosition(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdPodInfo): Long + + /** + * The maximum duration of the pod in seconds. + * + * For unknown duration, -1 is returned. + */ + abstract fun maxDuration( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdPodInfo + ): Double + + /** Client side and DAI VOD: Returns the index of the ad pod. */ + abstract fun podIndex(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdPodInfo): Long + + /** + * The content time offset at which the current ad pod was scheduled. + * + * For preroll pod, 0 is returned. For midrolls, the scheduled time is returned in seconds. For + * postroll, -1 is returned. Defaults to 0 if this ad is not part of a pod, or the pod is not part + * of an ad playlist. + */ + abstract fun timeOffset(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdPodInfo): Double + + /** The total number of ads contained within this pod, including bumpers. */ + abstract fun totalAds(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdPodInfo): Long + + /** Returns true if the ad is a bumper ad. */ + abstract fun isBumper(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdPodInfo): Boolean + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdPodInfo and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdPodInfo, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val adPositionArg = adPosition(pigeon_instanceArg) + val maxDurationArg = maxDuration(pigeon_instanceArg) + val podIndexArg = podIndex(pigeon_instanceArg) + val timeOffsetArg = timeOffset(pigeon_instanceArg) + val totalAdsArg = totalAds(pigeon_instanceArg) + val isBumperArg = isBumper(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send( + listOf( + pigeon_identifierArg, + adPositionArg, + maxDurationArg, + podIndexArg, + timeOffsetArg, + totalAdsArg, + isBumperArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback( + Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * FrameLayout is designed to block out an area on the screen to display a single item. + * + * See https://developer.android.com/reference/android/widget/FrameLayout. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiFrameLayout(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + abstract fun pigeon_defaultConstructor(): android.widget.FrameLayout + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiFrameLayout?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.FrameLayout.pigeon_defaultConstructor", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.pigeon_defaultConstructor(), pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of FrameLayout and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: android.widget.FrameLayout, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.FrameLayout.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + @Suppress("FunctionName") + /** An implementation of [PigeonApiViewGroup] used to access callback methods */ + fun pigeon_getPigeonApiViewGroup(): PigeonApiViewGroup { + return pigeonRegistrar.getPigeonApiViewGroup() + } +} +/** + * A special view that can contain other views (called children.) + * + * See https://developer.android.com/reference/android/view/ViewGroup. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiViewGroup(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + abstract fun addView(pigeon_instance: android.view.ViewGroup, view: android.view.View) + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiViewGroup?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.ViewGroup.addView", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.view.ViewGroup + val viewArg = args[1] as android.view.View + val wrapped: List = + try { + api.addView(pigeon_instanceArg, viewArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of ViewGroup and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: android.view.ViewGroup, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.ViewGroup.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + @Suppress("FunctionName") + /** An implementation of [PigeonApiView] used to access callback methods */ + fun pigeon_getPigeonApiView(): PigeonApiView { + return pigeonRegistrar.getPigeonApiView() + } +} +/** + * Displays a video file. + * + * See https://developer.android.com/reference/android/widget/VideoView. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiVideoView(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + abstract fun pigeon_defaultConstructor(): android.widget.VideoView + + /** Sets the URI of the video. */ + abstract fun setVideoUri(pigeon_instance: android.widget.VideoView, uri: String) + + /** + * The current position of the playing video. + * + * In milliseconds. + */ + abstract fun getCurrentPosition(pigeon_instance: android.widget.VideoView): Long + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiVideoView?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoView.pigeon_defaultConstructor", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.pigeon_defaultConstructor(), pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoView.setVideoUri", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.widget.VideoView + val uriArg = args[1] as String + val wrapped: List = + try { + api.setVideoUri(pigeon_instanceArg, uriArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoView.getCurrentPosition", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.widget.VideoView + val wrapped: List = + try { + listOf(api.getCurrentPosition(pigeon_instanceArg)) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of VideoView and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: android.widget.VideoView, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + throw IllegalStateException( + "Attempting to create a new Dart instance of VideoView, but the class has a nonnull callback method.") + } + + /** Callback to be invoked when the media source is ready for playback. */ + fun onPrepared( + pigeon_instanceArg: android.widget.VideoView, + playerArg: android.media.MediaPlayer, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoView.onPrepared" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, playerArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + /** Callback to be invoked when playback of a media source has completed. */ + fun onCompletion( + pigeon_instanceArg: android.widget.VideoView, + playerArg: android.media.MediaPlayer, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoView.onCompletion" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, playerArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + /** Callback to be invoked when there has been an error during an asynchronous operation. */ + fun onError( + pigeon_instanceArg: android.widget.VideoView, + playerArg: android.media.MediaPlayer, + whatArg: Long, + extraArg: Long, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoView.onError" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, playerArg, whatArg, extraArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + @Suppress("FunctionName") + /** An implementation of [PigeonApiView] used to access callback methods */ + fun pigeon_getPigeonApiView(): PigeonApiView { + return pigeonRegistrar.getPigeonApiView() + } +} +/** + * This class represents the basic building block for user interface components. + * + * See https://developer.android.com/reference/android/view/View. + */ +@Suppress("UNCHECKED_CAST") +open class PigeonApiView(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of View and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance(pigeon_instanceArg: android.view.View, callback: (Result) -> Unit) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.View.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * MediaPlayer class can be used to control playback of audio/video files and streams. + * + * See https://developer.android.com/reference/android/media/MediaPlayer. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiMediaPlayer(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** Gets the duration of the file. */ + abstract fun getDuration(pigeon_instance: android.media.MediaPlayer): Long + + /** Seeks to specified time position. */ + abstract fun seekTo(pigeon_instance: android.media.MediaPlayer, mSec: Long) + + /** Starts or resumes playback. */ + abstract fun start(pigeon_instance: android.media.MediaPlayer) + + /** Pauses playback. */ + abstract fun pause(pigeon_instance: android.media.MediaPlayer) + + /** Stops playback after playback has been started or paused. */ + abstract fun stop(pigeon_instance: android.media.MediaPlayer) + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiMediaPlayer?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.MediaPlayer.getDuration", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.media.MediaPlayer + val wrapped: List = + try { + listOf(api.getDuration(pigeon_instanceArg)) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.MediaPlayer.seekTo", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.media.MediaPlayer + val mSecArg = args[1].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.seekTo(pigeon_instanceArg, mSecArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.MediaPlayer.start", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.media.MediaPlayer + val wrapped: List = + try { + api.start(pigeon_instanceArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.MediaPlayer.pause", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.media.MediaPlayer + val wrapped: List = + try { + api.pause(pigeon_instanceArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, "dev.flutter.pigeon.interactive_media_ads.MediaPlayer.stop", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.media.MediaPlayer + val wrapped: List = + try { + api.stop(pigeon_instanceArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of MediaPlayer and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: android.media.MediaPlayer, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.MediaPlayer.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Callbacks that the player must fire. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.VideoAdPlayerCallback.html + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + /** Fire this callback periodically as ad playback occurs. */ + abstract fun onAdProgress( + pigeon_instance: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, + videoProgressUpdate: com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + ) + + /** Fire this callback when video playback stalls waiting for data. */ + abstract fun onBuffering( + pigeon_instance: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + ) + + /** Fire this callback when all content has finished playing. */ + abstract fun onContentComplete( + pigeon_instance: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + ) + + /** Fire this callback when the video finishes playing. */ + abstract fun onEnded( + pigeon_instance: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + ) + + /** Fire this callback when the video has encountered an error. */ + abstract fun onError( + pigeon_instance: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + ) + + /** Fire this callback when the video is ready to begin playback. */ + abstract fun onLoaded( + pigeon_instance: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + ) + + /** Fire this callback when the video is paused. */ + abstract fun onPause( + pigeon_instance: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + ) + + /** Fire this callback when the player begins playing a video. */ + abstract fun onPlay( + pigeon_instance: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + ) + + /** Fire this callback when the video is unpaused. */ + abstract fun onResume( + pigeon_instance: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + ) + + /** Fire this callback when the playback volume changes. */ + abstract fun onVolumeChanged( + pigeon_instance: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, + percentage: Long + ) + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers( + binaryMessenger: BinaryMessenger, + api: PigeonApiVideoAdPlayerCallback? + ) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onAdProgress", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] + as + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + val adMediaInfoArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + val videoProgressUpdateArg = + args[2] as com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + val wrapped: List = + try { + api.onAdProgress(pigeon_instanceArg, adMediaInfoArg, videoProgressUpdateArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onBuffering", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] + as + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + val adMediaInfoArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + val wrapped: List = + try { + api.onBuffering(pigeon_instanceArg, adMediaInfoArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onContentComplete", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] + as + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + val wrapped: List = + try { + api.onContentComplete(pigeon_instanceArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onEnded", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] + as + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + val adMediaInfoArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + val wrapped: List = + try { + api.onEnded(pigeon_instanceArg, adMediaInfoArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onError", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] + as + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + val adMediaInfoArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + val wrapped: List = + try { + api.onError(pigeon_instanceArg, adMediaInfoArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onLoaded", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] + as + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + val adMediaInfoArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + val wrapped: List = + try { + api.onLoaded(pigeon_instanceArg, adMediaInfoArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onPause", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] + as + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + val adMediaInfoArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + val wrapped: List = + try { + api.onPause(pigeon_instanceArg, adMediaInfoArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onPlay", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] + as + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + val adMediaInfoArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + val wrapped: List = + try { + api.onPlay(pigeon_instanceArg, adMediaInfoArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onResume", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] + as + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + val adMediaInfoArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + val wrapped: List = + try { + api.onResume(pigeon_instanceArg, adMediaInfoArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onVolumeChanged", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] + as + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback + val adMediaInfoArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.AdMediaInfo + val percentageArg = args[2].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.onVolumeChanged(pigeon_instanceArg, adMediaInfoArg, percentageArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of VideoAdPlayerCallback and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + val pigeon_identifierArg = + pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.pigeon_newInstance" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_identifierArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Defines the set of methods that a video player must implement to be used by the IMA SDK, as well + * as a set of callbacks that it must fire. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + abstract fun pigeon_defaultConstructor(): + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer + + /** The volume of the player as a percentage from 0 to 100. */ + abstract fun setVolume( + pigeon_instance: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, + value: Long + ) + + /** The `VideoProgressUpdate` describing playback progress of the current video. */ + abstract fun setAdProgress( + pigeon_instance: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, + progress: com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + ) + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiVideoAdPlayer?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pigeon_defaultConstructor", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.pigeon_defaultConstructor(), pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.setVolume", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] as com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer + val valueArg = args[1].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.setVolume(pigeon_instanceArg, valueArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.setAdProgress", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] as com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer + val progressArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + val wrapped: List = + try { + api.setAdProgress(pigeon_instanceArg, progressArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of VideoAdPlayer and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + throw IllegalStateException( + "Attempting to create a new Dart instance of VideoAdPlayer, but the class has a nonnull callback method.") + } + + /** Adds a callback. */ + fun addCallback( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, + callbackArg: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.addCallback" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, callbackArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + /** Loads a video ad hosted at AdMediaInfo. */ + fun loadAd( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, + adMediaInfoArg: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, + adPodInfoArg: com.google.ads.interactivemedia.v3.api.AdPodInfo, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.loadAd" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, adMediaInfoArg, adPodInfoArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + /** Pauses playing the current ad. */ + fun pauseAd( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, + adMediaInfoArg: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pauseAd" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, adMediaInfoArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + /** + * Starts or resumes playing the video ad referenced by the AdMediaInfo, provided loadAd has + * already been called for it. + */ + fun playAd( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, + adMediaInfoArg: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.playAd" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, adMediaInfoArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + /** Cleans up and releases all resources used by the `VideoAdPlayer`. */ + fun release( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.release" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + /** Removes a callback. */ + fun removeCallback( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, + callbackArg: + com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.removeCallback" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, callbackArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } + + /** Stops playing the current ad. */ + fun stopAd( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, + adMediaInfoArg: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.stopAd" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, adMediaInfoArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Listener interface for notification of ad load or stream load completion. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader.AdsLoadedListener.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdsLoadedListener(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + abstract fun pigeon_defaultConstructor(): + com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiAdsLoadedListener?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.AdsLoadedListener.pigeon_defaultConstructor", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.pigeon_defaultConstructor(), pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdsLoadedListener and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + throw IllegalStateException( + "Attempting to create a new Dart instance of AdsLoadedListener, but the class has a nonnull callback method.") + } + + /** Called once the AdsManager or StreamManager has been loaded. */ + fun onAdsManagerLoaded( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener, + eventArg: com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = + "dev.flutter.pigeon.interactive_media_ads.AdsLoadedListener.onAdsManagerLoaded" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, eventArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Interface for classes that will listen to AdErrorEvents. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.AdErrorListener.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdErrorListener(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + abstract fun pigeon_defaultConstructor(): + com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiAdErrorListener?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.AdErrorListener.pigeon_defaultConstructor", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.pigeon_defaultConstructor(), pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdErrorListener and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + throw IllegalStateException( + "Attempting to create a new Dart instance of AdErrorListener, but the class has a nonnull callback method.") + } + + /** Called when an error occurs. */ + fun onAdError( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener, + eventArg: com.google.ads.interactivemedia.v3.api.AdErrorEvent, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.AdErrorListener.onAdError" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, eventArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} +/** + * Listener interface for ad events. + * + * See + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventListener.html. + */ +@Suppress("UNCHECKED_CAST") +abstract class PigeonApiAdEventListener(open val pigeonRegistrar: PigeonProxyApiRegistrar) { + abstract fun pigeon_defaultConstructor(): + com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiAdEventListener?) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.AdEventListener.pigeon_defaultConstructor", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.pigeon_defaultConstructor(), pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + + @Suppress("LocalVariableName", "FunctionName") + /** Creates a Dart instance of AdEventListener and attaches it to [pigeon_instanceArg]. */ + fun pigeon_newInstance( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener, + callback: (Result) -> Unit + ) { + if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { + Result.success(Unit) + return + } + throw IllegalStateException( + "Attempting to create a new Dart instance of AdEventListener, but the class has a nonnull callback method.") + } + + /** Respond to an occurrence of an AdEvent. */ + fun onAdEvent( + pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener, + eventArg: com.google.ads.interactivemedia.v3.api.AdEvent, + callback: (Result) -> Unit + ) { + val binaryMessenger = pigeonRegistrar.binaryMessenger + val codec = pigeonRegistrar.codec + val channelName = "dev.flutter.pigeon.interactive_media_ads.AdEventListener.onAdEvent" + val channel = BasicMessageChannel(binaryMessenger, channelName, codec) + channel.send(listOf(pigeon_instanceArg, eventArg)) { + if (it is List<*>) { + if (it.size > 1) { + callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) + } else { + callback(Result.success(Unit)) + } + } else { + callback(Result.failure(createConnectionError(channelName))) + } + } + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPlugin.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPlugin.kt index 50595236588a..5dd456e0d723 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPlugin.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPlugin.kt @@ -4,34 +4,73 @@ package dev.flutter.packages.interactive_media_ads +import android.content.Context +import android.view.View import io.flutter.embedding.engine.plugins.FlutterPlugin -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel -import io.flutter.plugin.common.MethodChannel.MethodCallHandler -import io.flutter.plugin.common.MethodChannel.Result +import io.flutter.embedding.engine.plugins.activity.ActivityAware +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding +import io.flutter.plugin.common.StandardMessageCodec +import io.flutter.plugin.platform.PlatformView +import io.flutter.plugin.platform.PlatformViewFactory /** InteractiveMediaAdsPlugin */ -class InteractiveMediaAdsPlugin : FlutterPlugin, MethodCallHandler { - /// The MethodChannel that will the communication between Flutter and native Android - /// - /// This local reference serves to register the plugin with the Flutter Engine and unregister it - /// when the Flutter Engine is detached from the Activity - private lateinit var channel: MethodChannel +class InteractiveMediaAdsPlugin : FlutterPlugin, ActivityAware { + private lateinit var pluginBinding: FlutterPlugin.FlutterPluginBinding + private lateinit var registrar: ProxyApiRegistrar override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { - channel = MethodChannel(flutterPluginBinding.binaryMessenger, "interactive_media_ads") - channel.setMethodCallHandler(this) - } + pluginBinding = flutterPluginBinding - override fun onMethodCall(call: MethodCall, result: Result) { - if (call.method == "getPlatformVersion") { - result.success("Android ${android.os.Build.VERSION.RELEASE}") - } else { - result.notImplemented() - } + registrar = + ProxyApiRegistrar(pluginBinding.binaryMessenger, context = pluginBinding.applicationContext) + registrar.setUp() + + flutterPluginBinding.platformViewRegistry.registerViewFactory( + "interactive_media_ads.packages.flutter.dev/view", + FlutterViewFactory(registrar.instanceManager)) } override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { - channel.setMethodCallHandler(null) + registrar.tearDown() + registrar.instanceManager.clear() + } + + override fun onAttachedToActivity(binding: ActivityPluginBinding) { + registrar.context = binding.activity + } + + override fun onDetachedFromActivityForConfigChanges() { + registrar.context = pluginBinding.applicationContext + } + + override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { + registrar.context = binding.activity + } + + override fun onDetachedFromActivity() { + registrar.context = pluginBinding.applicationContext + } +} + +internal class FlutterViewFactory(private val instanceManager: PigeonInstanceManager) : + PlatformViewFactory(StandardMessageCodec.INSTANCE) { + + override fun create(context: Context, viewId: Int, args: Any?): PlatformView { + val identifier = + args as Int? + ?: throw IllegalStateException("An identifier is required to retrieve a View instance.") + val instance: Any? = instanceManager.getInstance(identifier.toLong()) + if (instance is PlatformView) { + return instance + } else if (instance is View) { + return object : PlatformView { + override fun getView(): View { + return instance + } + + override fun dispose() {} + } + } + throw IllegalStateException("Unable to find a PlatformView or View instance: $args, $instance") } } diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/MediaPlayerProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/MediaPlayerProxyApi.kt new file mode 100644 index 000000000000..61915a2bc03a --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/MediaPlayerProxyApi.kt @@ -0,0 +1,36 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import android.media.MediaPlayer + +/** + * ProxyApi implementation for [MediaPlayer]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class MediaPlayerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiMediaPlayer(pigeonRegistrar) { + override fun getDuration(pigeon_instance: MediaPlayer): Long { + return pigeon_instance.duration.toLong() + } + + override fun seekTo(pigeon_instance: MediaPlayer, mSec: Long) { + pigeon_instance.seekTo(mSec.toInt()) + } + + override fun start(pigeon_instance: MediaPlayer) { + pigeon_instance.start() + } + + override fun pause(pigeon_instance: MediaPlayer) { + pigeon_instance.pause() + } + + override fun stop(pigeon_instance: MediaPlayer) { + pigeon_instance.stop() + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ProxyApiRegistrar.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ProxyApiRegistrar.kt new file mode 100644 index 000000000000..ee15a91c2f35 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ProxyApiRegistrar.kt @@ -0,0 +1,128 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import android.content.Context +import android.os.Handler +import android.os.Looper +import io.flutter.plugin.common.BinaryMessenger + +/** + * Implementation of [PigeonProxyApiRegistrar] that provides each ProxyApi implementation and any + * additional resources needed by an implementation. + */ +open class ProxyApiRegistrar(binaryMessenger: BinaryMessenger, var context: Context) : + PigeonProxyApiRegistrar(binaryMessenger) { + + // Added to be overriden for tests. The test implementation calls `callback` immediately, instead + // of waiting for the main thread to run it. + internal open fun runOnMainThread(callback: Runnable) { + Handler(Looper.getMainLooper()).post { callback.run() } + } + + override fun getPigeonApiBaseDisplayContainer(): PigeonApiBaseDisplayContainer { + return BaseDisplayContainerProxyApi(this) + } + + override fun getPigeonApiAdDisplayContainer(): PigeonApiAdDisplayContainer { + return AdDisplayContainerProxyApi(this) + } + + override fun getPigeonApiAdsLoader(): PigeonApiAdsLoader { + return AdsLoaderProxyApi(this) + } + + override fun getPigeonApiAdsManagerLoadedEvent(): PigeonApiAdsManagerLoadedEvent { + return AdsManagerLoadedEventProxyApi(this) + } + + override fun getPigeonApiAdsLoadedListener(): PigeonApiAdsLoadedListener { + return AdsLoadedListenerProxyApi(this) + } + + override fun getPigeonApiAdErrorListener(): PigeonApiAdErrorListener { + return AdErrorListenerProxyApi(this) + } + + override fun getPigeonApiAdErrorEvent(): PigeonApiAdErrorEvent { + return AdErrorEventProxyApi(this) + } + + override fun getPigeonApiAdError(): PigeonApiAdError { + return AdErrorProxyApi(this) + } + + override fun getPigeonApiAdsRequest(): PigeonApiAdsRequest { + return AdsRequestProxyApi(this) + } + + override fun getPigeonApiContentProgressProvider(): PigeonApiContentProgressProvider { + return ContentProgressProviderProxyApi(this) + } + + override fun getPigeonApiAdsManager(): PigeonApiAdsManager { + return AdsManagerProxyApi(this) + } + + override fun getPigeonApiBaseManager(): PigeonApiBaseManager { + return BaseManagerProxyApi(this) + } + + override fun getPigeonApiAdEventListener(): PigeonApiAdEventListener { + return AdEventListenerProxyApi(this) + } + + override fun getPigeonApiAdEvent(): PigeonApiAdEvent { + return AdEventProxyApi(this) + } + + override fun getPigeonApiImaSdkFactory(): PigeonApiImaSdkFactory { + return ImaSdkFactoryProxyApi(this) + } + + override fun getPigeonApiImaSdkSettings(): PigeonApiImaSdkSettings { + return ImaSdkSettingsProxyApi(this) + } + + override fun getPigeonApiVideoAdPlayer(): PigeonApiVideoAdPlayer { + return VideoAdPlayerProxyApi(this) + } + + override fun getPigeonApiVideoProgressUpdate(): PigeonApiVideoProgressUpdate { + return VideoProgressUpdateProxyApi(this) + } + + override fun getPigeonApiVideoAdPlayerCallback(): PigeonApiVideoAdPlayerCallback { + return VideoAdPlayerCallbackProxyApi(this) + } + + override fun getPigeonApiAdMediaInfo(): PigeonApiAdMediaInfo { + return AdMediaInfoProxyApi(this) + } + + override fun getPigeonApiAdPodInfo(): PigeonApiAdPodInfo { + return AdPodInfoProxyApi(this) + } + + override fun getPigeonApiFrameLayout(): PigeonApiFrameLayout { + return FrameLayoutProxyApi(this) + } + + override fun getPigeonApiViewGroup(): PigeonApiViewGroup { + return ViewGroupProxyApi(this) + } + + override fun getPigeonApiVideoView(): PigeonApiVideoView { + return VideoViewProxyApi(this) + } + + override fun getPigeonApiView(): PigeonApiView { + return ViewProxyApi(this) + } + + override fun getPigeonApiMediaPlayer(): PigeonApiMediaPlayer { + return MediaPlayerProxyApi(this) + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerCallbackProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerCallbackProxyApi.kt new file mode 100644 index 000000000000..dc10cbd77533 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerCallbackProxyApi.kt @@ -0,0 +1,87 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.player.AdMediaInfo +import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer +import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + +/** + * ProxyApi implementation for [VideoAdPlayer.VideoAdPlayerCallback]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class VideoAdPlayerCallbackProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiVideoAdPlayerCallback(pigeonRegistrar) { + override fun onAdProgress( + pigeon_instance: VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: AdMediaInfo, + videoProgressUpdate: VideoProgressUpdate + ) { + pigeon_instance.onAdProgress(adMediaInfo, videoProgressUpdate) + } + + override fun onBuffering( + pigeon_instance: VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: AdMediaInfo + ) { + pigeon_instance.onBuffering(adMediaInfo) + } + + override fun onContentComplete(pigeon_instance: VideoAdPlayer.VideoAdPlayerCallback) { + pigeon_instance.onContentComplete() + } + + override fun onEnded( + pigeon_instance: VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: AdMediaInfo + ) { + pigeon_instance.onEnded(adMediaInfo) + } + + override fun onError( + pigeon_instance: VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: AdMediaInfo + ) { + pigeon_instance.onError(adMediaInfo) + } + + override fun onLoaded( + pigeon_instance: VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: AdMediaInfo + ) { + pigeon_instance.onLoaded(adMediaInfo) + } + + override fun onPause( + pigeon_instance: VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: AdMediaInfo + ) { + pigeon_instance.onPause(adMediaInfo) + } + + override fun onPlay( + pigeon_instance: VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: AdMediaInfo + ) { + pigeon_instance.onPlay(adMediaInfo) + } + + override fun onResume( + pigeon_instance: VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: AdMediaInfo + ) { + pigeon_instance.onResume(adMediaInfo) + } + + override fun onVolumeChanged( + pigeon_instance: VideoAdPlayer.VideoAdPlayerCallback, + adMediaInfo: AdMediaInfo, + percentage: Long + ) { + pigeon_instance.onVolumeChanged(adMediaInfo, percentage.toInt()) + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerProxyApi.kt new file mode 100644 index 000000000000..5c79153bac74 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerProxyApi.kt @@ -0,0 +1,80 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdPodInfo +import com.google.ads.interactivemedia.v3.api.player.AdMediaInfo +import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer +import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + +/** + * ProxyApi implementation for [VideoAdPlayer]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class VideoAdPlayerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiVideoAdPlayer(pigeonRegistrar) { + override fun pigeon_defaultConstructor(): VideoAdPlayer { + return VideoAdPlayerImpl(this) + } + + internal class VideoAdPlayerImpl(val api: VideoAdPlayerProxyApi) : VideoAdPlayer { + var savedVolume: Int = 0 + + var savedAdProgress: VideoProgressUpdate = VideoProgressUpdate.VIDEO_TIME_NOT_READY + + override fun getAdProgress(): VideoProgressUpdate { + return savedAdProgress + } + + override fun getVolume(): Int { + return savedVolume + } + + override fun addCallback(callback: VideoAdPlayer.VideoAdPlayerCallback) { + api.pigeonRegistrar.runOnMainThread { api.addCallback(this, callbackArg = callback) {} } + } + + override fun loadAd(adMediaInfo: AdMediaInfo, adPodInfo: AdPodInfo) { + api.pigeonRegistrar.runOnMainThread { api.loadAd(this, adMediaInfo, adPodInfo) {} } + } + + override fun pauseAd(adMediaInfo: AdMediaInfo) { + api.pigeonRegistrar.runOnMainThread { api.pauseAd(this, adMediaInfo) {} } + } + + override fun playAd(adMediaInfo: AdMediaInfo) { + api.pigeonRegistrar.runOnMainThread { api.playAd(this, adMediaInfo) {} } + } + + override fun release() { + api.pigeonRegistrar.runOnMainThread { api.release(this) {} } + } + + override fun removeCallback(callback: VideoAdPlayer.VideoAdPlayerCallback) { + api.pigeonRegistrar.runOnMainThread { api.removeCallback(this, callbackArg = callback) {} } + } + + override fun stopAd(adMediaInfo: AdMediaInfo) { + api.pigeonRegistrar.runOnMainThread { api.stopAd(this, adMediaInfo) {} } + } + } + + /** + * Sets the internal `volume` variable that is returned in the [VideoAdPlayer.getVolume] callback. + */ + override fun setVolume(pigeon_instance: VideoAdPlayer, value: Long) { + (pigeon_instance as VideoAdPlayerImpl).savedVolume = value.toInt() + } + + /** + * Sets the internal `adProgress` variable that is returned in the [VideoAdPlayer.getAdProgress] + * callback. + */ + override fun setAdProgress(pigeon_instance: VideoAdPlayer, progress: VideoProgressUpdate) { + (pigeon_instance as VideoAdPlayerImpl).savedAdProgress = progress + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoProgressUpdateProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoProgressUpdateProxyApi.kt new file mode 100644 index 000000000000..307bf6ec3f3b --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoProgressUpdateProxyApi.kt @@ -0,0 +1,27 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + +/** + * ProxyApi implementation for [VideoProgressUpdate]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class VideoProgressUpdateProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiVideoProgressUpdate(pigeonRegistrar) { + override fun pigeon_defaultConstructor( + currentTimeMs: Long, + durationMs: Long + ): VideoProgressUpdate { + return VideoProgressUpdate(currentTimeMs, durationMs) + } + + override fun videoTimeNotReady(): VideoProgressUpdate { + return VideoProgressUpdate.VIDEO_TIME_NOT_READY + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoViewProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoViewProxyApi.kt new file mode 100644 index 000000000000..983f97e7f775 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/VideoViewProxyApi.kt @@ -0,0 +1,38 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import android.media.MediaPlayer +import android.net.Uri +import android.widget.VideoView + +/** + * ProxyApi implementation for [VideoView]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class VideoViewProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiVideoView(pigeonRegistrar) { + + override fun pigeon_defaultConstructor(): VideoView { + val instance = VideoView(pigeonRegistrar.context) + instance.setOnPreparedListener { player: MediaPlayer -> onPrepared(instance, player) {} } + instance.setOnErrorListener { player: MediaPlayer, what: Int, extra: Int -> + onError(instance, player, what.toLong(), extra.toLong()) {} + true + } + instance.setOnCompletionListener { player: MediaPlayer -> onCompletion(instance, player) {} } + return instance + } + + override fun setVideoUri(pigeon_instance: VideoView, uri: String) { + pigeon_instance.setVideoURI(Uri.parse(uri)) + } + + override fun getCurrentPosition(pigeon_instance: VideoView): Long { + return pigeon_instance.currentPosition.toLong() + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ViewGroupProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ViewGroupProxyApi.kt new file mode 100644 index 000000000000..5ba9fa8d58f4 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ViewGroupProxyApi.kt @@ -0,0 +1,21 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import android.view.View +import android.view.ViewGroup + +/** + * ProxyApi implementation for [ViewGroup]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class ViewGroupProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiViewGroup(pigeonRegistrar) { + override fun addView(pigeon_instance: ViewGroup, view: View) { + pigeon_instance.addView(view) + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ViewProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ViewProxyApi.kt new file mode 100644 index 000000000000..59934e882254 --- /dev/null +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ViewProxyApi.kt @@ -0,0 +1,14 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +/** + * ProxyApi implementation for [android.view.View]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class ViewProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiView(pigeonRegistrar) diff --git a/packages/interactive_media_ads/android/src/test/kotlin/android/net/Uri.kt b/packages/interactive_media_ads/android/src/test/kotlin/android/net/Uri.kt new file mode 100644 index 000000000000..107eef275d93 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/android/net/Uri.kt @@ -0,0 +1,22 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package android.net + +/** + * Redeclaration of Uri that works for tests. + * + * Without this redeclaration, `Uri.parse` always returns null. + */ +class Uri { + companion object { + @JvmStatic var lastValue: String? = null + + @JvmStatic + fun parse(value: String): Uri { + lastValue = value + return Uri() + } + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorEventProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorEventProxyApiTest.kt new file mode 100644 index 000000000000..e51f4f66894e --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorEventProxyApiTest.kt @@ -0,0 +1,25 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdError +import com.google.ads.interactivemedia.v3.api.AdErrorEvent +import kotlin.test.Test +import kotlin.test.assertEquals +import org.mockito.Mockito.mock +import org.mockito.kotlin.whenever + +internal class AdErrorEventProxyApiTest { + @Test + fun error() { + val api = TestProxyApiRegistrar().getPigeonApiAdErrorEvent() + + val instance = mock() + val mockError = mock() + whenever(instance.error).thenReturn(mockError) + + assertEquals(mockError, api.error(instance)) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorListenerProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorListenerProxyApiTest.kt new file mode 100644 index 000000000000..10890f84d613 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorListenerProxyApiTest.kt @@ -0,0 +1,35 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdErrorEvent +import kotlin.test.Test +import kotlin.test.assertTrue +import org.mockito.Mockito.mock +import org.mockito.Mockito.verify +import org.mockito.kotlin.any +import org.mockito.kotlin.eq +import org.mockito.kotlin.whenever + +internal class AdErrorListenerProxyApiTest { + @Test + fun pigeon_defaultConstructor() { + val api = TestProxyApiRegistrar().getPigeonApiAdErrorListener() + + assertTrue(api.pigeon_defaultConstructor() is AdErrorListenerProxyApi.AdErrorListenerImpl) + } + + @Test + fun onAdError() { + val mockApi = mock() + whenever(mockApi.pigeonRegistrar).thenReturn(TestProxyApiRegistrar()) + + val instance = AdErrorListenerProxyApi.AdErrorListenerImpl(mockApi) + val mockEvent = mock() + instance.onAdError(mockEvent) + + verify(mockApi).onAdError(eq(instance), eq(mockEvent), any()) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorProxyApiTest.kt new file mode 100644 index 000000000000..62e8efe927f9 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdErrorProxyApiTest.kt @@ -0,0 +1,53 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdError +import kotlin.test.Test +import kotlin.test.assertEquals +import org.mockito.Mockito +import org.mockito.kotlin.whenever + +class AdErrorProxyApiTest { + @Test + fun errorCode() { + val api = TestProxyApiRegistrar().getPigeonApiAdError() + + val instance = Mockito.mock() + whenever(instance.errorCode).thenReturn(AdError.AdErrorCode.VIDEO_PLAY_ERROR) + + assertEquals(AdErrorCode.VIDEO_PLAY_ERROR, api.errorCode(instance)) + } + + @Test + fun errorCodeNumber() { + val api = TestProxyApiRegistrar().getPigeonApiAdError() + + val instance = Mockito.mock() + whenever(instance.errorCodeNumber).thenReturn(0) + + assertEquals(0, api.errorCodeNumber(instance)) + } + + @Test + fun errorType() { + val api = TestProxyApiRegistrar().getPigeonApiAdError() + + val instance = Mockito.mock() + whenever(instance.errorType).thenReturn(AdError.AdErrorType.LOAD) + + assertEquals(AdErrorType.LOAD, api.errorType(instance)) + } + + @Test + fun message() { + val api = TestProxyApiRegistrar().getPigeonApiAdError() + + val instance = Mockito.mock() + whenever(instance.message).thenReturn("message") + + assertEquals("message", api.message(instance)) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventListenerProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventListenerProxyApiTest.kt new file mode 100644 index 000000000000..02904a9005b0 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventListenerProxyApiTest.kt @@ -0,0 +1,34 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdEvent +import kotlin.test.Test +import kotlin.test.assertTrue +import org.mockito.Mockito +import org.mockito.kotlin.any +import org.mockito.kotlin.eq +import org.mockito.kotlin.whenever + +class AdEventListenerProxyApiTest { + @Test + fun pigeon_defaultConstructor() { + val api = TestProxyApiRegistrar().getPigeonApiAdEventListener() + + assertTrue(api.pigeon_defaultConstructor() is AdEventListenerProxyApi.AdEventListenerImpl) + } + + @Test + fun onAdEvent() { + val mockApi = Mockito.mock() + whenever(mockApi.pigeonRegistrar).thenReturn(TestProxyApiRegistrar()) + + val instance = AdEventListenerProxyApi.AdEventListenerImpl(mockApi) + val mockEvent = Mockito.mock() + instance.onAdEvent(mockEvent) + + Mockito.verify(mockApi).onAdEvent(eq(instance), eq(mockEvent), any()) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApiTest.kt new file mode 100644 index 000000000000..fbab52be0080 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApiTest.kt @@ -0,0 +1,23 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdEvent +import kotlin.test.Test +import kotlin.test.assertEquals +import org.mockito.Mockito +import org.mockito.kotlin.whenever + +class AdEventProxyApiTest { + @Test + fun type() { + val api = TestProxyApiRegistrar().getPigeonApiAdEvent() + + val instance = Mockito.mock() + whenever(instance.type).thenReturn(AdEvent.AdEventType.PAUSED) + + assertEquals(AdEventType.PAUSED, api.type(instance)) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdMediaInfoProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdMediaInfoProxyApiTest.kt new file mode 100644 index 000000000000..37602d5ab9ee --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdMediaInfoProxyApiTest.kt @@ -0,0 +1,23 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.player.AdMediaInfo +import kotlin.test.Test +import kotlin.test.assertEquals +import org.mockito.Mockito +import org.mockito.kotlin.whenever + +class AdMediaInfoProxyApiTest { + @Test + fun url() { + val api = TestProxyApiRegistrar().getPigeonApiAdMediaInfo() + + val instance = Mockito.mock() + whenever(instance.url).thenReturn("url") + + assertEquals("url", api.url(instance)) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdPodInfoProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdPodInfoProxyApiTest.kt new file mode 100644 index 000000000000..b1610f25108d --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdPodInfoProxyApiTest.kt @@ -0,0 +1,73 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdPodInfo +import kotlin.test.Test +import kotlin.test.assertEquals +import org.mockito.Mockito +import org.mockito.kotlin.whenever + +class AdPodInfoProxyApiTest { + @Test + fun adPosition() { + val api = TestProxyApiRegistrar().getPigeonApiAdPodInfo() + + val instance = Mockito.mock() + whenever(instance.adPosition).thenReturn(0) + + assertEquals(0, api.adPosition(instance)) + } + + @Test + fun maxDuration() { + val api = TestProxyApiRegistrar().getPigeonApiAdPodInfo() + + val instance = Mockito.mock() + whenever(instance.maxDuration).thenReturn(0.0) + + assertEquals(0.0, api.maxDuration(instance)) + } + + @Test + fun podIndex() { + val api = TestProxyApiRegistrar().getPigeonApiAdPodInfo() + + val instance = Mockito.mock() + whenever(instance.podIndex).thenReturn(0) + + assertEquals(0, api.podIndex(instance)) + } + + @Test + fun timeOffset() { + val api = TestProxyApiRegistrar().getPigeonApiAdPodInfo() + + val instance = Mockito.mock() + whenever(instance.timeOffset).thenReturn(0.0) + + assertEquals(0.0, api.timeOffset(instance)) + } + + @Test + fun totalAds() { + val api = TestProxyApiRegistrar().getPigeonApiAdPodInfo() + + val instance = Mockito.mock() + whenever(instance.totalAds).thenReturn(0) + + assertEquals(0, api.totalAds(instance)) + } + + @Test + fun isBumper() { + val api = TestProxyApiRegistrar().getPigeonApiAdPodInfo() + + val instance = Mockito.mock() + whenever(instance.isBumper).thenReturn(true) + + assertEquals(true, api.isBumper(instance)) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoadedListenerProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoadedListenerProxyApiTest.kt new file mode 100644 index 000000000000..5d89ba05da31 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoadedListenerProxyApiTest.kt @@ -0,0 +1,34 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent +import kotlin.test.Test +import kotlin.test.assertTrue +import org.mockito.Mockito +import org.mockito.kotlin.any +import org.mockito.kotlin.eq +import org.mockito.kotlin.whenever + +class AdsLoadedListenerProxyApiTest { + @Test + fun pigeon_defaultConstructor() { + val api = TestProxyApiRegistrar().getPigeonApiAdsLoadedListener() + + assertTrue(api.pigeon_defaultConstructor() is AdsLoadedListenerProxyApi.AdsLoadedListenerImpl) + } + + @Test + fun onAdsManagerLoaded() { + val mockApi = Mockito.mock() + whenever(mockApi.pigeonRegistrar).thenReturn(TestProxyApiRegistrar()) + + val instance = AdsLoadedListenerProxyApi.AdsLoadedListenerImpl(mockApi) + val mockEvent = Mockito.mock() + instance.onAdsManagerLoaded(mockEvent) + + Mockito.verify(mockApi).onAdsManagerLoaded(eq(instance), eq(mockEvent), any()) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoaderProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoaderProxyApiTest.kt new file mode 100644 index 000000000000..f70fb27f00be --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsLoaderProxyApiTest.kt @@ -0,0 +1,47 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdErrorEvent +import com.google.ads.interactivemedia.v3.api.AdsLoader +import com.google.ads.interactivemedia.v3.api.AdsRequest +import kotlin.test.Test +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify + +class AdsLoaderProxyApiTest { + @Test + fun addAdErrorListener() { + val api = TestProxyApiRegistrar().getPigeonApiAdsLoader() + + val instance = mock() + val mockListener = mock() + api.addAdErrorListener(instance, mockListener) + + verify(instance).addAdErrorListener(mockListener) + } + + @Test + fun addAdsLoadedListener() { + val api = TestProxyApiRegistrar().getPigeonApiAdsLoader() + + val instance = mock() + val mockListener = mock() + api.addAdsLoadedListener(instance, mockListener) + + verify(instance).addAdsLoadedListener(mockListener) + } + + @Test + fun requestAds() { + val api = TestProxyApiRegistrar().getPigeonApiAdsLoader() + + val instance = mock() + val mockRequest = mock() + api.requestAds(instance, mockRequest) + + verify(instance).requestAds(mockRequest) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerLoadedEventProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerLoadedEventProxyApiTest.kt new file mode 100644 index 000000000000..ff3f3f51dce0 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerLoadedEventProxyApiTest.kt @@ -0,0 +1,25 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdsManager +import com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent +import kotlin.test.Test +import kotlin.test.assertEquals +import org.mockito.Mockito +import org.mockito.kotlin.whenever + +class AdsManagerLoadedEventProxyApiTest { + @Test + fun manager() { + val api = TestProxyApiRegistrar().getPigeonApiAdsManagerLoadedEvent() + + val instance = Mockito.mock() + val mockManager = Mockito.mock() + whenever(instance.adsManager).thenReturn(mockManager) + + assertEquals(mockManager, api.manager(instance)) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerProxyApiTest.kt new file mode 100644 index 000000000000..8dc78843ef75 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsManagerProxyApiTest.kt @@ -0,0 +1,42 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdsManager +import kotlin.test.Test +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify + +class AdsManagerProxyApiTest { + @Test + fun discardAdBreak() { + val api = TestProxyApiRegistrar().getPigeonApiAdsManager() + + val instance = mock() + api.discardAdBreak(instance) + + verify(instance).discardAdBreak() + } + + @Test + fun pause() { + val api = TestProxyApiRegistrar().getPigeonApiAdsManager() + + val instance = mock() + api.pause(instance) + + verify(instance).pause() + } + + @Test + fun start() { + val api = TestProxyApiRegistrar().getPigeonApiAdsManager() + + val instance = mock() + api.start(instance) + + verify(instance).start() + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt new file mode 100644 index 000000000000..66c3d35ee555 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt @@ -0,0 +1,35 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdsRequest +import com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider +import kotlin.test.Test +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify + +class AdsRequestProxyApiTest { + @Test + fun setAdTagUrl() { + val api = TestProxyApiRegistrar().getPigeonApiAdsRequest() + + val instance = mock() + api.setAdTagUrl(instance, "adTag") + + verify(instance).adTagUrl = + "adTag&request_agent=Flutter-IMA-${AdsRequestProxyApi.pluginVersion}" + } + + @Test + fun setContentProgressProvider() { + val api = TestProxyApiRegistrar().getPigeonApiAdsRequest() + + val instance = mock() + val mockProvider = mock() + api.setContentProgressProvider(instance, mockProvider) + + verify(instance).contentProgressProvider = mockProvider + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApiTest.kt new file mode 100644 index 000000000000..0c9293d8d712 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApiTest.kt @@ -0,0 +1,56 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdErrorEvent +import com.google.ads.interactivemedia.v3.api.AdEvent +import com.google.ads.interactivemedia.v3.api.BaseManager +import kotlin.test.Test +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify + +class BaseManagerProxyApiTest { + @Test + fun addAdErrorListener() { + val api = TestProxyApiRegistrar().getPigeonApiBaseManager() + + val instance = mock() + val mockListener = mock() + api.addAdErrorListener(instance, mockListener) + + verify(instance).addAdErrorListener(mockListener) + } + + @Test + fun addAdEventListener() { + val api = TestProxyApiRegistrar().getPigeonApiBaseManager() + + val instance = mock() + val mockListener = mock() + api.addAdEventListener(instance, mockListener) + + verify(instance).addAdEventListener(mockListener) + } + + @Test + fun destroy() { + val api = TestProxyApiRegistrar().getPigeonApiBaseManager() + + val instance = mock() + api.destroy(instance) + + verify(instance).destroy() + } + + @Test + fun init() { + val api = TestProxyApiRegistrar().getPigeonApiBaseManager() + + val instance = mock() + api.init(instance) + + verify(instance).init() + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkFactoryProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkFactoryProxyApiTest.kt new file mode 100644 index 000000000000..600e5e41a09e --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ImaSdkFactoryProxyApiTest.kt @@ -0,0 +1,54 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdDisplayContainer +import com.google.ads.interactivemedia.v3.api.AdsLoader +import com.google.ads.interactivemedia.v3.api.AdsRequest +import com.google.ads.interactivemedia.v3.api.ImaSdkFactory +import com.google.ads.interactivemedia.v3.api.ImaSdkSettings +import kotlin.test.Test +import kotlin.test.assertEquals +import org.mockito.kotlin.mock +import org.mockito.kotlin.whenever + +class ImaSdkFactoryProxyApiTest { + @Test + fun createImaSdkSettings() { + val api = TestProxyApiRegistrar().getPigeonApiImaSdkFactory() + + val instance = mock() + val mockSettings = mock() + whenever(instance.createImaSdkSettings()).thenReturn(mockSettings) + + assertEquals(mockSettings, api.createImaSdkSettings(instance)) + } + + @Test + fun createAdsLoader() { + val registrar = TestProxyApiRegistrar() + val api = registrar.getPigeonApiImaSdkFactory() + + val instance = mock() + val mockAdsLoader = mock() + val mockSettings = mock() + val mockContainer = mock() + whenever(instance.createAdsLoader(registrar.context, mockSettings, mockContainer)) + .thenReturn(mockAdsLoader) + + assertEquals(mockAdsLoader, api.createAdsLoader(instance, mockSettings, mockContainer)) + } + + @Test + fun createAdsRequest() { + val api = TestProxyApiRegistrar().getPigeonApiImaSdkFactory() + + val instance = mock() + val mockRequest = mock() + whenever(instance.createAdsRequest()).thenReturn(mockRequest) + + assertEquals(mockRequest, api.createAdsRequest(instance)) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPluginTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPluginTest.kt deleted file mode 100644 index 3adc0d0a56b4..000000000000 --- a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPluginTest.kt +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package dev.flutter.packages.interactive_media_ads - -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel -import kotlin.test.Test -import org.mockito.Mockito - -/* - * This demonstrates a simple unit test of the Kotlin portion of this plugin's implementation. - * - * Once you have built the plugin's example app, you can run these tests from the command - * line by running `./gradlew testDebugUnitTest` in the `example/android/` directory, or - * you can run them directly from IDEs that support JUnit such as Android Studio. - */ - -internal class InteractiveMediaAdsPluginTest { - @Test - fun onMethodCall_getPlatformVersion_returnsExpectedValue() { - val plugin = InteractiveMediaAdsPlugin() - - val call = MethodCall("getPlatformVersion", null) - val mockResult: MethodChannel.Result = Mockito.mock(MethodChannel.Result::class.java) - plugin.onMethodCall(call, mockResult) - - Mockito.verify(mockResult).success("Android " + android.os.Build.VERSION.RELEASE) - } -} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/MediaPlayerProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/MediaPlayerProxyApiTest.kt new file mode 100644 index 000000000000..cee45eb3d905 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/MediaPlayerProxyApiTest.kt @@ -0,0 +1,64 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import android.media.MediaPlayer +import kotlin.test.Test +import kotlin.test.assertEquals +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever + +class MediaPlayerProxyApiTest { + @Test + fun getDuration() { + val api = TestProxyApiRegistrar().getPigeonApiMediaPlayer() + + val instance = mock() + whenever(instance.duration).thenReturn(0) + + assertEquals(0, api.getDuration(instance)) + } + + @Test + fun seekTo() { + val api = TestProxyApiRegistrar().getPigeonApiMediaPlayer() + + val instance = mock() + api.seekTo(instance, 0) + + verify(instance).seekTo(0) + } + + @Test + fun start() { + val api = TestProxyApiRegistrar().getPigeonApiMediaPlayer() + + val instance = mock() + api.start(instance) + + verify(instance).start() + } + + @Test + fun pause() { + val api = TestProxyApiRegistrar().getPigeonApiMediaPlayer() + + val instance = mock() + api.pause(instance) + + verify(instance).pause() + } + + @Test + fun stop() { + val api = TestProxyApiRegistrar().getPigeonApiMediaPlayer() + + val instance = mock() + api.stop(instance) + + verify(instance).stop() + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/TestProxyApiRegistrar.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/TestProxyApiRegistrar.kt new file mode 100644 index 000000000000..0aba7066a28a --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/TestProxyApiRegistrar.kt @@ -0,0 +1,17 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import org.mockito.kotlin.mock + +/** + * Test implementation of `ProxyApiRegistrar` that provides mocks and instantly runs callbacks + * instead of posting them. + */ +class TestProxyApiRegistrar : ProxyApiRegistrar(mock(), mock()) { + override fun runOnMainThread(callback: Runnable) { + callback.run() + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerCallbackProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerCallbackProxyApiTest.kt new file mode 100644 index 000000000000..125fd16f951e --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerCallbackProxyApiTest.kt @@ -0,0 +1,124 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.player.AdMediaInfo +import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback +import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate +import kotlin.test.Test +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify + +class VideoAdPlayerCallbackProxyApiTest { + @Test + fun onAdProgress() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayerCallback() + + val instance = mock() + val mockInfo = mock() + val mockUpdate = mock() + api.onAdProgress(instance, mockInfo, mockUpdate) + + verify(instance).onAdProgress(mockInfo, mockUpdate) + } + + @Test + fun onBuffering() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayerCallback() + + val instance = mock() + val mockInfo = mock() + api.onBuffering(instance, mockInfo) + + verify(instance).onBuffering(mockInfo) + } + + @Test + fun onContentComplete() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayerCallback() + + val instance = mock() + api.onContentComplete(instance) + + verify(instance).onContentComplete() + } + + @Test + fun onEnded() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayerCallback() + + val instance = mock() + val mockInfo = mock() + api.onEnded(instance, mockInfo) + + verify(instance).onEnded(mockInfo) + } + + @Test + fun onError() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayerCallback() + + val instance = mock() + val mockInfo = mock() + api.onError(instance, mockInfo) + + verify(instance).onError(mockInfo) + } + + @Test + fun onLoaded() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayerCallback() + + val instance = mock() + val mockInfo = mock() + api.onLoaded(instance, mockInfo) + + verify(instance).onLoaded(mockInfo) + } + + @Test + fun onPause() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayerCallback() + + val instance = mock() + val mockInfo = mock() + api.onPause(instance, mockInfo) + + verify(instance).onPause(mockInfo) + } + + @Test + fun onPlay() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayerCallback() + + val instance = mock() + val mockInfo = mock() + api.onPlay(instance, mockInfo) + + verify(instance).onPlay(mockInfo) + } + + @Test + fun onResume() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayerCallback() + + val instance = mock() + val mockInfo = mock() + api.onResume(instance, mockInfo) + + verify(instance).onResume(mockInfo) + } + + @Test + fun onVolumeChanged() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayerCallback() + + val instance = mock() + val mockInfo = mock() + api.onVolumeChanged(instance, mockInfo, 0) + + verify(instance).onVolumeChanged(mockInfo, 0) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerProxyApiTest.kt new file mode 100644 index 000000000000..01eb2b1f6dd9 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoAdPlayerProxyApiTest.kt @@ -0,0 +1,132 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.AdPodInfo +import com.google.ads.interactivemedia.v3.api.player.AdMediaInfo +import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer +import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue +import org.mockito.Mockito +import org.mockito.kotlin.any +import org.mockito.kotlin.eq +import org.mockito.kotlin.mock +import org.mockito.kotlin.whenever + +class VideoAdPlayerProxyApiTest { + @Test + fun pigeon_defaultConstructor() { + val api = ProxyApiRegistrar(Mockito.mock(), Mockito.mock()).getPigeonApiVideoAdPlayer() + + assertTrue(api.pigeon_defaultConstructor() is VideoAdPlayerProxyApi.VideoAdPlayerImpl) + } + + @Test + fun setVolume() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayer() + + val instance = VideoAdPlayerProxyApi.VideoAdPlayerImpl(api as VideoAdPlayerProxyApi) + api.setVolume(instance, 0) + + assertEquals(0, instance.volume) + } + + @Test + fun setAdProgress() { + val api = TestProxyApiRegistrar().getPigeonApiVideoAdPlayer() + + val instance = VideoAdPlayerProxyApi.VideoAdPlayerImpl(api as VideoAdPlayerProxyApi) + val mockProgressUpdate = mock() + api.setAdProgress(instance, mockProgressUpdate) + + assertEquals(mockProgressUpdate, instance.adProgress) + } + + @Test + fun addCallback() { + val mockApi = Mockito.mock() + whenever(mockApi.pigeonRegistrar).thenReturn(TestProxyApiRegistrar()) + + val instance = VideoAdPlayerProxyApi.VideoAdPlayerImpl(mockApi) + val mockCallback = Mockito.mock() + instance.addCallback(mockCallback) + + Mockito.verify(mockApi).addCallback(eq(instance), eq(mockCallback), any()) + } + + @Test + fun loadAd() { + val mockApi = Mockito.mock() + whenever(mockApi.pigeonRegistrar).thenReturn(TestProxyApiRegistrar()) + + val instance = VideoAdPlayerProxyApi.VideoAdPlayerImpl(mockApi) + val mockMediaInfo = mock() + val mockPodInfo = mock() + instance.loadAd(mockMediaInfo, mockPodInfo) + + Mockito.verify(mockApi).loadAd(eq(instance), eq(mockMediaInfo), eq(mockPodInfo), any()) + } + + @Test + fun pauseAd() { + val mockApi = Mockito.mock() + whenever(mockApi.pigeonRegistrar).thenReturn(TestProxyApiRegistrar()) + + val instance = VideoAdPlayerProxyApi.VideoAdPlayerImpl(mockApi) + val mockMediaInfo = mock() + instance.pauseAd(mockMediaInfo) + + Mockito.verify(mockApi).pauseAd(eq(instance), eq(mockMediaInfo), any()) + } + + @Test + fun playAd() { + val mockApi = Mockito.mock() + whenever(mockApi.pigeonRegistrar).thenReturn(TestProxyApiRegistrar()) + + val instance = VideoAdPlayerProxyApi.VideoAdPlayerImpl(mockApi) + val mockMediaInfo = mock() + instance.playAd(mockMediaInfo) + + Mockito.verify(mockApi).playAd(eq(instance), eq(mockMediaInfo), any()) + } + + @Test + fun release() { + val mockApi = Mockito.mock() + whenever(mockApi.pigeonRegistrar).thenReturn(TestProxyApiRegistrar()) + + val instance = VideoAdPlayerProxyApi.VideoAdPlayerImpl(mockApi) + instance.release() + + Mockito.verify(mockApi).release(eq(instance), any()) + } + + @Test + fun removeCallback() { + val mockApi = Mockito.mock() + whenever(mockApi.pigeonRegistrar).thenReturn(TestProxyApiRegistrar()) + + val instance = VideoAdPlayerProxyApi.VideoAdPlayerImpl(mockApi) + val mockCallback = Mockito.mock() + instance.removeCallback(mockCallback) + + Mockito.verify(mockApi).removeCallback(eq(instance), eq(mockCallback), any()) + } + + @Test + fun stopAd() { + val mockApi = Mockito.mock() + whenever(mockApi.pigeonRegistrar).thenReturn(TestProxyApiRegistrar()) + + val instance = VideoAdPlayerProxyApi.VideoAdPlayerImpl(mockApi) + val mockMediaInfo = mock() + instance.stopAd(mockMediaInfo) + + Mockito.verify(mockApi).stopAd(eq(instance), eq(mockMediaInfo), any()) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoViewProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoViewProxyApiTest.kt new file mode 100644 index 000000000000..f43af0aa4287 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/VideoViewProxyApiTest.kt @@ -0,0 +1,38 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import android.net.Uri +import android.widget.VideoView +import kotlin.test.Test +import kotlin.test.assertEquals +import org.mockito.kotlin.isNotNull +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever + +class VideoViewProxyApiTest { + @Test + fun setVideoURI() { + val api = TestProxyApiRegistrar().getPigeonApiVideoView() + + val instance = mock() + api.setVideoUri(instance, "adTag") + + verify(instance).setVideoURI(isNotNull()) + assertEquals("adTag", Uri.lastValue) + } + + @Test + fun getCurrentPosition() { + val api = TestProxyApiRegistrar().getPigeonApiVideoView() + + val instance = mock() + whenever(instance.currentPosition).thenReturn(0) + api.getCurrentPosition(instance) + + assertEquals(0, api.getCurrentPosition(instance)) + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ViewGroupProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ViewGroupProxyApiTest.kt new file mode 100644 index 000000000000..e73e29ed8ea8 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ViewGroupProxyApiTest.kt @@ -0,0 +1,24 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.packages.interactive_media_ads + +import android.view.View +import android.view.ViewGroup +import kotlin.test.Test +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify + +class ViewGroupProxyApiTest { + @Test + fun addView() { + val api = TestProxyApiRegistrar().getPigeonApiViewGroup() + + val instance = mock() + val mockView = mock() + api.addView(instance, mockView) + + verify(instance).addView(mockView) + } +} diff --git a/packages/interactive_media_ads/example/android/app/src/main/AndroidManifest.xml b/packages/interactive_media_ads/example/android/app/src/main/AndroidManifest.xml index 8733f2b862ab..73dc642f81e3 100644 --- a/packages/interactive_media_ads/example/android/app/src/main/AndroidManifest.xml +++ b/packages/interactive_media_ads/example/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,8 @@ + + + + createState() => _MyAppState(); + State createState() => _AdExampleWidgetState(); } -class _MyAppState extends State { +class _AdExampleWidgetState extends State { + late final AdsLoader _adsLoader; + AdsManager? _adsManager; + bool _shouldShowContentVideo = true; + + late final VideoPlayerController _contentVideoController; + + late final AdDisplayContainer _adDisplayContainer = AdDisplayContainer( + onContainerAdded: (AdDisplayContainer container) { + _requestAds(container); + }, + ); + + @override + void initState() { + super.initState(); + _contentVideoController = VideoPlayerController.networkUrl( + Uri.parse( + 'https://storage.googleapis.com/gvabox/media/samples/stock.mp4', + ), + ) + ..addListener(() { + if (_contentVideoController.value.isCompleted) { + _adsLoader.contentComplete(); + setState(() {}); + } + }) + ..initialize().then((_) { + // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed. + setState(() {}); + }); + } + + Future _resumeContent() { + setState(() { + _shouldShowContentVideo = true; + }); + return _contentVideoController.play(); + } + + Future _pauseContent() { + setState(() { + _shouldShowContentVideo = false; + }); + return _contentVideoController.pause(); + } + + Future _requestAds(AdDisplayContainer container) { + _adsLoader = AdsLoader( + container: container, + onAdsLoaded: (OnAdsLoadedData data) { + final AdsManager manager = data.manager; + _adsManager = data.manager; + + manager.setAdsManagerDelegate(AdsManagerDelegate( + onAdEvent: (AdEvent event) { + debugPrint('OnAdEvent: ${event.type}'); + switch (event.type) { + case AdEventType.loaded: + manager.start(); + case AdEventType.contentPauseRequested: + _pauseContent(); + case AdEventType.contentResumeRequested: + _resumeContent(); + case AdEventType.allAdsCompleted: + manager.destroy(); + _adsManager = null; + case AdEventType.clicked: + case AdEventType.complete: + } + }, + onAdErrorEvent: (AdErrorEvent event) { + debugPrint('AdErrorEvent: ${event.error.message}'); + _resumeContent(); + }, + )); + + manager.init(); + }, + onAdsLoadError: (AdsLoadErrorData data) { + debugPrint('OnAdsLoadError: ${data.error.message}'); + _resumeContent(); + }, + ); + + return _adsLoader.requestAds(AdsRequest(adTagUrl: _adTagUrl)); + } + + @override + void dispose() { + super.dispose(); + _contentVideoController.dispose(); + _adsManager?.destroy(); + } + @override Widget build(BuildContext context) { - debugPrint('THEAPP'); - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Plugin example app'), - ), - body: Center( - child: Text('Running on: $defaultTargetPlatform'), + return Scaffold( + body: Center( + child: SizedBox( + width: 300, + child: !_contentVideoController.value.isInitialized + ? Container() + : AspectRatio( + aspectRatio: _contentVideoController.value.aspectRatio, + child: Stack( + children: [ + // The display container must be on screen before any Ads can be + // loaded and can't be removed between ads. This handles clicks for + // ads. + _adDisplayContainer, + if (_shouldShowContentVideo) + VideoPlayer(_contentVideoController) + ], + ), + ), ), ), + floatingActionButton: + _contentVideoController.value.isInitialized && _shouldShowContentVideo + ? FloatingActionButton( + onPressed: () { + setState(() { + _contentVideoController.value.isPlaying + ? _contentVideoController.pause() + : _contentVideoController.play(); + }); + }, + child: Icon( + _contentVideoController.value.isPlaying + ? Icons.pause + : Icons.play_arrow, + ), + ) + : null, ); } } diff --git a/packages/interactive_media_ads/example/pubspec.yaml b/packages/interactive_media_ads/example/pubspec.yaml index fde3e7a8b2ec..16175a864b6f 100644 --- a/packages/interactive_media_ads/example/pubspec.yaml +++ b/packages/interactive_media_ads/example/pubspec.yaml @@ -13,6 +13,7 @@ dependencies: sdk: flutter interactive_media_ads: path: ../ + video_player: ^2.8.6 dev_dependencies: espresso: ^0.2.0 diff --git a/packages/interactive_media_ads/lib/interactive_media_ads.dart b/packages/interactive_media_ads/lib/interactive_media_ads.dart index 185d304cf5bc..b9e2aee98a3c 100644 --- a/packages/interactive_media_ads/lib/interactive_media_ads.dart +++ b/packages/interactive_media_ads/lib/interactive_media_ads.dart @@ -5,6 +5,15 @@ export 'src/ad_display_container.dart'; export 'src/ads_loader.dart'; export 'src/ads_manager_delegate.dart'; -export 'src/platform_interface/ad_error.dart'; -export 'src/platform_interface/ad_event.dart'; -export 'src/platform_interface/ads_request.dart'; +export 'src/android/android_interactive_media_ads.dart' + show AndroidInteractiveMediaAds; +export 'src/platform_interface/platform_interface.dart' + show + AdError, + AdErrorCode, + AdErrorEvent, + AdErrorType, + AdEvent, + AdEventType, + AdsLoadErrorData, + AdsRequest; diff --git a/packages/interactive_media_ads/lib/src/android/android_ad_display_container.dart b/packages/interactive_media_ads/lib/src/android/android_ad_display_container.dart new file mode 100644 index 000000000000..9822a78f7c39 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/android_ad_display_container.dart @@ -0,0 +1,279 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/widgets.dart'; +import 'package:meta/meta.dart'; + +import '../platform_interface/platform_interface.dart'; +import 'android_view_widget.dart'; +import 'interactive_media_ads.g.dart' as ima; +import 'interactive_media_ads_proxy.dart'; +import 'platform_views_service_proxy.dart'; + +/// Android implementation of [PlatformAdDisplayContainerCreationParams]. +final class AndroidAdDisplayContainerCreationParams + extends PlatformAdDisplayContainerCreationParams { + /// Constructs a [AndroidAdDisplayContainerCreationParams]. + const AndroidAdDisplayContainerCreationParams({ + super.key, + required super.onContainerAdded, + @visibleForTesting InteractiveMediaAdsProxy? imaProxy, + @visibleForTesting PlatformViewsServiceProxy? platformViewsProxy, + }) : _imaProxy = imaProxy ?? const InteractiveMediaAdsProxy(), + _platformViewsProxy = + platformViewsProxy ?? const PlatformViewsServiceProxy(), + super(); + + /// Creates a [AndroidAdDisplayContainerCreationParams] from an instance of + /// [PlatformAdDisplayContainerCreationParams]. + factory AndroidAdDisplayContainerCreationParams.fromPlatformAdDisplayContainerCreationParams( + PlatformAdDisplayContainerCreationParams params, { + @visibleForTesting InteractiveMediaAdsProxy? imaProxy, + @visibleForTesting PlatformViewsServiceProxy? platformViewsProxy, + }) { + return AndroidAdDisplayContainerCreationParams( + key: params.key, + onContainerAdded: params.onContainerAdded, + imaProxy: imaProxy, + platformViewsProxy: platformViewsProxy, + ); + } + + final InteractiveMediaAdsProxy _imaProxy; + final PlatformViewsServiceProxy _platformViewsProxy; +} + +/// Android implementation of [PlatformAdDisplayContainer]. +/// +/// This acts as the video player for an ad. To be a player for an ad from the +/// IMA SDK: +/// 1. The [ima.VideoView] must be in the View hierarchy until all ads have +/// finished. +/// 2. Must respond to callbacks from the [ima.VideoAdPlayer]. +/// 3. Must trigger methods for [ima.VideoAdPlayerCallback]s that provide ad +/// playback information to the IMA SDK. [ima.VideoAdPlayerCallback]s are +/// provided by [ima.VideoAdPlayer.addCallback]. +/// 4. Must create an [ima.AdDisplayContainer] with the `ViewGroup` that +/// contains the `VideoView`. +base class AndroidAdDisplayContainer extends PlatformAdDisplayContainer { + /// Constructs an [AndroidAdDisplayContainer]. + AndroidAdDisplayContainer(super.params) : super.implementation() { + final WeakReference weakThis = + WeakReference(this); + _videoView = _setUpVideoView(weakThis); + _frameLayout.addView(_videoView); + _videoAdPlayer = _setUpVideoAdPlayer(weakThis); + } + + // The duration between each update to the IMA SDK of the progress of the + // currently playing ad. This value matches the one used in the Android + // example. + // See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side#6.-create-the-videoadplayeradapter-class + static const int _progressPollingMs = 250; + + // The `ViewGroup` used to create the native `ima.AdDisplayContainer`. The + // `View` that handles playing an ad is added as a child to this `ViewGroup`. + late final ima.FrameLayout _frameLayout = + _androidParams._imaProxy.newFrameLayout(); + + // Handles loading and displaying an ad. + late final ima.VideoView _videoView; + + // After an ad is loaded in the `VideoView`, this is used to control + // playback. + ima.MediaPlayer? _mediaPlayer; + + /// Methods that must be triggered to update the IMA SDK of the state of + /// playback of an ad. + @internal + final Set videoAdPlayerCallbacks = + {}; + + // Handles ad playback callbacks from the IMA SDK. For a player to be used for + // ad playback, the callbacks in this class must be implemented. This also + // provides `VideoAdPlayerCallback`s that contain methods that must be + // triggered by the player. + late final ima.VideoAdPlayer _videoAdPlayer; + + /// The native Android AdDisplayContainer. + /// + /// This holds the player for video ads. + /// + /// Created with the `ViewGroup` that contains the `View` that handles playing + /// an ad. + @internal + ima.AdDisplayContainer? adDisplayContainer; + + // Currently loaded ad. + ima.AdMediaInfo? _loadedAdMediaInfo; + + // The saved ad position, used to resume ad playback following an ad + // click-through. + int _savedAdPosition = 0; + + // Timer used to periodically update the IMA SDK of the progress of the + // currently playing ad. + Timer? _adProgressTimer; + + int? _adDuration; + + late final AndroidAdDisplayContainerCreationParams _androidParams = + params is AndroidAdDisplayContainerCreationParams + ? params as AndroidAdDisplayContainerCreationParams + : AndroidAdDisplayContainerCreationParams + .fromPlatformAdDisplayContainerCreationParams(params); + + @override + Widget build(BuildContext context) { + return AndroidViewWidget( + key: params.key, + view: _frameLayout, + platformViewsServiceProxy: _androidParams._platformViewsProxy, + onPlatformViewCreated: () async { + adDisplayContainer = await _androidParams._imaProxy + .createAdDisplayContainerImaSdkFactory( + _frameLayout, + _videoAdPlayer, + ); + params.onContainerAdded(this); + }, + ); + } + + // Clears the current `MediaPlayer` and resets any saved position of an ad. + // This should be used when current ad that is loaded in the `VideoView` is + // complete, failed to load/play, or has been stopped. + void _clearMediaPlayer() { + _mediaPlayer = null; + _savedAdPosition = 0; + } + + // Starts periodically updating the IMA SDK the progress of the currently + // playing ad. + // + // Setting a timer to periodically update the IMA SDK is also done in the + // official Android example: https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side#8.-set-up-ad-tracking. + void _startAdProgressTracking() { + // Stop any previous ad tracking. + _stopAdProgressTracking(); + _adProgressTimer = Timer.periodic( + const Duration(milliseconds: _progressPollingMs), + (Timer timer) async { + final ima.VideoProgressUpdate currentProgress = + _androidParams._imaProxy.newVideoProgressUpdate( + currentTimeMs: await _videoView.getCurrentPosition(), + durationMs: _adDuration!, + ); + await Future.wait( + >[ + _videoAdPlayer.setAdProgress(currentProgress), + ...videoAdPlayerCallbacks.map( + (ima.VideoAdPlayerCallback callback) async { + await callback.onAdProgress( + _loadedAdMediaInfo!, + currentProgress, + ); + }, + ), + ], + ); + }, + ); + } + + // Stops updating the IMA SDK the progress of the currently playing ad. + void _stopAdProgressTracking() { + _adProgressTimer?.cancel(); + _adProgressTimer = null; + } + + // This value is created in a static method because the callback methods for + // any wrapped classes must not reference the encapsulating object. This is to + // prevent a circular reference that prevents garbage collection. + static ima.VideoView _setUpVideoView( + WeakReference weakThis, + ) { + return weakThis.target!._androidParams._imaProxy.newVideoView( + onCompletion: (_, __) { + final AndroidAdDisplayContainer? container = weakThis.target; + if (container != null) { + container._clearMediaPlayer(); + container._stopAdProgressTracking(); + for (final ima.VideoAdPlayerCallback callback + in container.videoAdPlayerCallbacks) { + callback.onEnded(container._loadedAdMediaInfo!); + } + } + }, + onPrepared: (_, ima.MediaPlayer player) async { + final AndroidAdDisplayContainer? container = weakThis.target; + if (container != null) { + container._adDuration = await player.getDuration(); + container._mediaPlayer = player; + if (container._savedAdPosition > 0) { + await player.seekTo(container._savedAdPosition); + } + } + + await player.start(); + container?._startAdProgressTracking(); + }, + onError: (_, __, ___, ____) { + final AndroidAdDisplayContainer? container = weakThis.target; + if (container != null) { + container._clearMediaPlayer(); + for (final ima.VideoAdPlayerCallback callback + in container.videoAdPlayerCallbacks) { + callback.onError(container._loadedAdMediaInfo!); + } + container._loadedAdMediaInfo = null; + container._adDuration = null; + } + }, + ); + } + + // This value is created in a static method because the callback methods for + // any wrapped classes must not reference the encapsulating object. This is to + // prevent a circular reference that prevents garbage collection. + static ima.VideoAdPlayer _setUpVideoAdPlayer( + WeakReference weakThis, + ) { + return weakThis.target!._androidParams._imaProxy.newVideoAdPlayer( + addCallback: (_, ima.VideoAdPlayerCallback callback) { + weakThis.target?.videoAdPlayerCallbacks.add(callback); + }, + removeCallback: (_, ima.VideoAdPlayerCallback callback) { + weakThis.target?.videoAdPlayerCallbacks.remove(callback); + }, + loadAd: (_, ima.AdMediaInfo adMediaInfo, __) { + weakThis.target?._loadedAdMediaInfo = adMediaInfo; + }, + pauseAd: (_, __) async { + final AndroidAdDisplayContainer? container = weakThis.target; + if (container != null) { + await container._mediaPlayer!.pause(); + container._savedAdPosition = + await container._videoView.getCurrentPosition(); + container._stopAdProgressTracking(); + } + }, + playAd: (_, ima.AdMediaInfo adMediaInfo) { + weakThis.target?._videoView.setVideoUri(adMediaInfo.url); + }, + release: (_) {}, + stopAd: (_, __) { + final AndroidAdDisplayContainer? container = weakThis.target; + if (container != null) { + container._stopAdProgressTracking(); + container._clearMediaPlayer(); + container._loadedAdMediaInfo = null; + container._adDuration = null; + } + }, + ); + } +} diff --git a/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart b/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart new file mode 100644 index 000000000000..03fde8d22f22 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart @@ -0,0 +1,143 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/widgets.dart'; + +import '../platform_interface/platform_interface.dart'; +import 'android_ad_display_container.dart'; +import 'android_ads_manager.dart'; +import 'enum_converter_extensions.dart'; +import 'interactive_media_ads.g.dart' as ima; +import 'interactive_media_ads_proxy.dart'; + +/// Android implementation of [PlatformAdsLoaderCreationParams]. +final class AndroidAdsLoaderCreationParams + extends PlatformAdsLoaderCreationParams { + /// Constructs a [AndroidAdsLoaderCreationParams]. + const AndroidAdsLoaderCreationParams({ + required super.container, + required super.onAdsLoaded, + required super.onAdsLoadError, + @visibleForTesting InteractiveMediaAdsProxy? proxy, + }) : _proxy = proxy ?? const InteractiveMediaAdsProxy(), + super(); + + /// Creates a [AndroidAdsLoaderCreationParams] from an instance of + /// [PlatformAdsLoaderCreationParams]. + factory AndroidAdsLoaderCreationParams.fromPlatformAdsLoaderCreationParams( + PlatformAdsLoaderCreationParams params, { + @visibleForTesting InteractiveMediaAdsProxy? proxy, + }) { + return AndroidAdsLoaderCreationParams( + container: params.container, + onAdsLoaded: params.onAdsLoaded, + onAdsLoadError: params.onAdsLoadError, + proxy: proxy, + ); + } + + final InteractiveMediaAdsProxy _proxy; +} + +/// Android implementation of [PlatformAdsLoader]. +base class AndroidAdsLoader extends PlatformAdsLoader { + /// Constructs an [AndroidAdsLoader]. + AndroidAdsLoader(super.params) + : assert(params.container is AndroidAdDisplayContainer), + assert( + (params.container as AndroidAdDisplayContainer).adDisplayContainer != + null, + 'Ensure the AdDisplayContainer has been added to the Widget tree before creating an AdsLoader.', + ), + super.implementation() { + _adsLoaderFuture = _createAdsLoader(); + } + + late final ima.ImaSdkFactory _sdkFactory = + _androidParams._proxy.instanceImaSdkFactory(); + late Future _adsLoaderFuture; + + late final AndroidAdsLoaderCreationParams _androidParams = + params is AndroidAdsLoaderCreationParams + ? params as AndroidAdsLoaderCreationParams + : AndroidAdsLoaderCreationParams.fromPlatformAdsLoaderCreationParams( + params, + ); + + @override + Future contentComplete() async { + final Set callbacks = + (params.container as AndroidAdDisplayContainer).videoAdPlayerCallbacks; + await Future.wait( + callbacks.map( + (ima.VideoAdPlayerCallback callback) => callback.onContentComplete(), + ), + ); + } + + @override + Future requestAds(AdsRequest request) async { + final ima.AdsLoader adsLoader = await _adsLoaderFuture; + + final ima.AdsRequest androidRequest = await _sdkFactory.createAdsRequest(); + + await Future.wait(>[ + androidRequest.setAdTagUrl(request.adTagUrl), + adsLoader.requestAds(androidRequest), + ]); + } + + Future _createAdsLoader() async { + final ima.ImaSdkSettings settings = + await _sdkFactory.createImaSdkSettings(); + + final ima.AdsLoader adsLoader = await _sdkFactory.createAdsLoader( + settings, + (params.container as AndroidAdDisplayContainer).adDisplayContainer!, + ); + + _addListeners(WeakReference(this), adsLoader); + + return adsLoader; + } + + // This value is created in a static method because the callback methods for + // any wrapped classes must not reference the encapsulating object. This is to + // prevent a circular reference that prevents garbage collection. + static void _addListeners( + WeakReference weakThis, + ima.AdsLoader adsLoader, + ) { + final InteractiveMediaAdsProxy proxy = + weakThis.target!._androidParams._proxy; + adsLoader + ..addAdsLoadedListener(proxy.newAdsLoadedListener( + onAdsManagerLoaded: (_, ima.AdsManagerLoadedEvent event) { + weakThis.target?.params.onAdsLoaded( + PlatformOnAdsLoadedData( + manager: AndroidAdsManager( + event.manager, + proxy: weakThis.target?._androidParams._proxy, + ), + ), + ); + }, + )) + ..addAdErrorListener(proxy.newAdErrorListener( + onAdError: (_, ima.AdErrorEvent event) { + weakThis.target?.params.onAdsLoadError( + AdsLoadErrorData( + error: AdError( + type: event.error.errorType.asInterfaceErrorType(), + code: event.error.errorCode.asInterfaceErrorCode(), + message: event.error.message, + ), + ), + ); + }, + )); + } +} diff --git a/packages/interactive_media_ads/lib/src/android/android_ads_manager.dart b/packages/interactive_media_ads/lib/src/android/android_ads_manager.dart new file mode 100644 index 000000000000..7bf158ff52ad --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/android_ads_manager.dart @@ -0,0 +1,88 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:meta/meta.dart'; + +import '../platform_interface/platform_interface.dart'; +import 'enum_converter_extensions.dart'; +import 'interactive_media_ads.g.dart' as ima; +import 'interactive_media_ads_proxy.dart'; + +/// Android implementation of [PlatformAdsManager]. +class AndroidAdsManager extends PlatformAdsManager { + /// Constructs an [AndroidAdsManager]. + @internal + AndroidAdsManager( + ima.AdsManager manager, { + InteractiveMediaAdsProxy? proxy, + }) : _manager = manager, + _proxy = proxy ?? const InteractiveMediaAdsProxy(); + + final ima.AdsManager _manager; + final InteractiveMediaAdsProxy _proxy; + + PlatformAdsManagerDelegate? _managerDelegate; + + @override + Future destroy() { + return _manager.destroy(); + } + + @override + Future init(AdsManagerInitParams params) { + return _manager.init(); + } + + @override + Future setAdsManagerDelegate( + PlatformAdsManagerDelegate delegate, + ) async { + _managerDelegate = delegate; + _addListeners(WeakReference(this)); + } + + @override + Future start(AdsManagerStartParams params) { + return _manager.start(); + } + + // This value is created in a static method because the callback methods for + // any wrapped classes must not reference the encapsulating object. This is to + // prevent a circular reference that prevents garbage collection. + static void _addListeners(WeakReference weakThis) { + final InteractiveMediaAdsProxy proxy = weakThis.target!._proxy; + weakThis.target?._manager.addAdEventListener( + proxy.newAdEventListener( + onAdEvent: (_, ima.AdEvent event) { + late final AdEventType? eventType = + event.type.asInterfaceAdEventType(); + if (eventType == null) { + return; + } + + weakThis.target?._managerDelegate?.params.onAdEvent + ?.call(AdEvent(type: eventType)); + }, + ), + ); + weakThis.target?._manager.addAdErrorListener( + proxy.newAdErrorListener( + onAdError: (_, ima.AdErrorEvent event) { + weakThis.target?._managerDelegate?.params.onAdErrorEvent?.call( + AdErrorEvent( + error: AdError( + type: event.error.errorType.asInterfaceErrorType(), + code: event.error.errorCode.asInterfaceErrorCode(), + message: event.error.message, + ), + ), + ); + weakThis.target?._manager.discardAdBreak(); + }, + ), + ); + } +} diff --git a/packages/interactive_media_ads/lib/src/android/android_ads_manager_delegate.dart b/packages/interactive_media_ads/lib/src/android/android_ads_manager_delegate.dart new file mode 100644 index 000000000000..24ab7eca9267 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/android_ads_manager_delegate.dart @@ -0,0 +1,11 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import '../platform_interface/platform_interface.dart'; + +/// Android implementation of [PlatformAdsManagerDelegate]. +final class AndroidAdsManagerDelegate extends PlatformAdsManagerDelegate { + /// Constructs an [AndroidAdsManagerDelegate]. + AndroidAdsManagerDelegate(super.params) : super.implementation(); +} diff --git a/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart b/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart new file mode 100644 index 000000000000..2406520d5531 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart @@ -0,0 +1,40 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import '../platform_interface/interactive_media_ads_platform.dart'; +import '../platform_interface/platform_ad_display_container.dart'; +import '../platform_interface/platform_ads_loader.dart'; +import '../platform_interface/platform_ads_manager_delegate.dart'; +import 'android_ad_display_container.dart'; +import 'android_ads_loader.dart'; +import 'android_ads_manager_delegate.dart'; + +/// Android implementation of [InteractiveMediaAdsPlatform]. +final class AndroidInteractiveMediaAds extends InteractiveMediaAdsPlatform { + /// Registers this class as the default instance of [InteractiveMediaAdsPlatform]. + static void registerWith() { + InteractiveMediaAdsPlatform.instance = AndroidInteractiveMediaAds(); + } + + @override + PlatformAdDisplayContainer createPlatformAdDisplayContainer( + PlatformAdDisplayContainerCreationParams params, + ) { + return AndroidAdDisplayContainer(params); + } + + @override + PlatformAdsLoader createPlatformAdsLoader( + PlatformAdsLoaderCreationParams params, + ) { + return AndroidAdsLoader(params); + } + + @override + PlatformAdsManagerDelegate createPlatformAdsManagerDelegate( + PlatformAdsManagerDelegateCreationParams params, + ) { + return AndroidAdsManagerDelegate(params); + } +} diff --git a/packages/interactive_media_ads/lib/src/android/android_view_widget.dart b/packages/interactive_media_ads/lib/src/android/android_view_widget.dart new file mode 100644 index 000000000000..a4c0b662e987 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/android_view_widget.dart @@ -0,0 +1,103 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; + +import 'interactive_media_ads.g.dart' as ima; +import 'platform_views_service_proxy.dart'; + +/// Represents a Flutter implementation of the Android [View](https://developer.android.com/reference/android/view/View) +/// that is created by the Android platform. +class AndroidViewWidget extends StatelessWidget { + /// Creates a [AndroidViewWidget]. + /// + /// The [AndroidViewWidget] should only be instantiated internally. + /// This constructor is visible for testing purposes only and should + /// never be called externally. + AndroidViewWidget({ + super.key, + required this.view, + this.layoutDirection = TextDirection.ltr, + this.onPlatformViewCreated, + this.displayWithHybridComposition = false, + ima.PigeonInstanceManager? instanceManager, + this.platformViewsServiceProxy = const PlatformViewsServiceProxy(), + }) : instanceManager = instanceManager ?? ima.PigeonInstanceManager.instance; + + /// The reference to the Android native view that should be shown. + final ima.View view; + + /// Maintains instances used to communicate with the native objects they + /// represent. + /// + /// This field is exposed for testing purposes only and should not be used + /// outside of tests. + final ima.PigeonInstanceManager instanceManager; + + /// Proxy that provides access to the platform views service. + /// + /// This service allows creating and controlling platform-specific views. + final PlatformViewsServiceProxy platformViewsServiceProxy; + + /// Whether to use Hybrid Composition to display the Android View. + final bool displayWithHybridComposition; + + /// Layout direction used by the Android View. + final TextDirection layoutDirection; + + /// Callback that will get invoke after the platform view has been created. + final VoidCallback? onPlatformViewCreated; + + @override + Widget build(BuildContext context) { + return PlatformViewLink( + viewType: 'plugins.flutter.io/webview', + surfaceFactory: ( + BuildContext context, + PlatformViewController controller, + ) { + return AndroidViewSurface( + controller: controller as AndroidViewController, + hitTestBehavior: PlatformViewHitTestBehavior.opaque, + gestureRecognizers: const >{}, + ); + }, + onCreatePlatformView: (PlatformViewCreationParams params) { + return _initAndroidView(params) + ..addOnPlatformViewCreatedListener((int id) { + params.onPlatformViewCreated(id); + onPlatformViewCreated?.call(); + }) + ..create(); + }, + ); + } + + AndroidViewController _initAndroidView(PlatformViewCreationParams params) { + const String viewType = 'interactive_media_ads.packages.flutter.dev/view'; + final int? identifier = instanceManager.getIdentifier(view); + + if (displayWithHybridComposition) { + return platformViewsServiceProxy.initExpensiveAndroidView( + id: params.id, + viewType: viewType, + layoutDirection: layoutDirection, + creationParams: identifier, + creationParamsCodec: const StandardMessageCodec(), + ); + } else { + return platformViewsServiceProxy.initSurfaceAndroidView( + id: params.id, + viewType: viewType, + layoutDirection: layoutDirection, + creationParams: identifier, + creationParamsCodec: const StandardMessageCodec(), + ); + } + } +} diff --git a/packages/interactive_media_ads/lib/src/android/enum_converter_extensions.dart b/packages/interactive_media_ads/lib/src/android/enum_converter_extensions.dart new file mode 100644 index 000000000000..4d7293df4293 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/enum_converter_extensions.dart @@ -0,0 +1,85 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import '../platform_interface/platform_interface.dart'; +import 'interactive_media_ads.g.dart' as ima; + +/// Adds a method to convert native AdErrorType to platform interface +/// AdErrorType. +extension NativeAdErrorTypeConverter on ima.AdErrorType { + /// Converts [ima.AdErrorType] to [AdErrorType]. + AdErrorType asInterfaceErrorType() { + return switch (this) { + ima.AdErrorType.load => AdErrorType.loading, + ima.AdErrorType.play => AdErrorType.playing, + ima.AdErrorType.unknown => AdErrorType.unknown, + }; + } +} + +/// Adds a method to convert native AdEventType to platform interface +/// AdEventType. +extension NativeAdEventTypeConverter on ima.AdEventType { + /// Attempts to convert an [ima.AdEventType] to [AdEventType]. + /// + /// Returns null is the type is not supported by the platform interface. + AdEventType? asInterfaceAdEventType() { + return switch (this) { + ima.AdEventType.allAdsCompleted => AdEventType.allAdsCompleted, + ima.AdEventType.completed => AdEventType.complete, + ima.AdEventType.contentPauseRequested => + AdEventType.contentPauseRequested, + ima.AdEventType.contentResumeRequested => + AdEventType.contentResumeRequested, + ima.AdEventType.loaded => AdEventType.loaded, + ima.AdEventType.clicked => AdEventType.clicked, + _ => null, + }; + } +} + +/// Adds a method to convert native AdErrorCode to platform interface +/// AdErrorCode. +extension NativeAdErrorCodeConverter on ima.AdErrorCode { + /// Converts [ima.AdErrorCode] to [AdErrorCode]. + AdErrorCode asInterfaceErrorCode() { + return switch (this) { + ima.AdErrorCode.adsPlayerWasNotProvided => + AdErrorCode.adsPlayerNotProvided, + ima.AdErrorCode.adsRequestNetworkError => + AdErrorCode.adsRequestNetworkError, + ima.AdErrorCode.companionAdLoadingFailed => + AdErrorCode.companionAdLoadingFailed, + ima.AdErrorCode.failedToRequestAds => AdErrorCode.failedToRequestAds, + ima.AdErrorCode.internalError => AdErrorCode.internalError, + ima.AdErrorCode.invalidArguments => AdErrorCode.invalidArguments, + ima.AdErrorCode.overlayAdLoadingFailed => + AdErrorCode.overlayAdLoadingFailed, + ima.AdErrorCode.overlayAdPlayingFailed => + AdErrorCode.overlayAdPlayingFailed, + ima.AdErrorCode.playlistNoContentTracking => + AdErrorCode.playlistNoContentTracking, + ima.AdErrorCode.unexpectedAdsLoadedEvent => + AdErrorCode.unexpectedAdsLoadedEvent, + ima.AdErrorCode.unknownAdResponse => AdErrorCode.unknownAdResponse, + ima.AdErrorCode.unknownError => AdErrorCode.unknownError, + ima.AdErrorCode.vastAssetNotFound => AdErrorCode.vastAssetNotFound, + ima.AdErrorCode.vastEmptyResponse => AdErrorCode.vastEmptyResponse, + ima.AdErrorCode.vastLinearAssetMismatch => + AdErrorCode.vastLinearAssetMismatch, + ima.AdErrorCode.vastLoadTimeout => AdErrorCode.vastLoadTimeout, + ima.AdErrorCode.vastMalformedResponse => + AdErrorCode.vastMalformedResponse, + ima.AdErrorCode.vastMediaLoadTimeout => AdErrorCode.vastMediaLoadTimeout, + ima.AdErrorCode.vastNonlinearAssetMismatch => + AdErrorCode.vastNonlinearAssetMismatch, + ima.AdErrorCode.vastNoAdsAfterWrapper => + AdErrorCode.vastNoAdsAfterWrapper, + ima.AdErrorCode.vastTooManyRedirects => AdErrorCode.vastTooManyRedirects, + ima.AdErrorCode.vastTraffickingError => AdErrorCode.vastTraffickingError, + ima.AdErrorCode.videoPlayError => AdErrorCode.videoPlayError, + ima.AdErrorCode.unknown => AdErrorCode.unknownError, + }; + } +} diff --git a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart new file mode 100644 index 000000000000..5ba85481c3bf --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart @@ -0,0 +1,4726 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// Autogenerated from Pigeon (v19.1.0), do not edit directly. +// See also: https://pub.dev/packages/pigeon +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers + +import 'dart:async'; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; + +import 'package:flutter/foundation.dart' + show ReadBuffer, WriteBuffer, immutable, protected; +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart' show WidgetsFlutterBinding; + +PlatformException _createConnectionError(String channelName) { + return PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel: "$channelName".', + ); +} + +List wrapResponse( + {Object? result, PlatformException? error, bool empty = false}) { + if (empty) { + return []; + } + if (error == null) { + return [result]; + } + return [error.code, error.message, error.details]; +} + +/// An immutable object that serves as the base class for all ProxyApis and +/// can provide functional copies of itself. +/// +/// All implementers are expected to be [immutable] as defined by the annotation +/// and override [pigeon_copy] returning an instance of itself. +@immutable +abstract class PigeonProxyApiBaseClass { + /// Construct a [PigeonProxyApiBaseClass]. + PigeonProxyApiBaseClass({ + this.pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + }) : pigeon_instanceManager = + pigeon_instanceManager ?? PigeonInstanceManager.instance; + + /// Sends and receives binary data across the Flutter platform barrier. + /// + /// If it is null, the default BinaryMessenger will be used, which routes to + /// the host platform. + @protected + final BinaryMessenger? pigeon_binaryMessenger; + + /// Maintains instances stored to communicate with native language objects. + @protected + final PigeonInstanceManager pigeon_instanceManager; + + /// Instantiates and returns a functionally identical object to oneself. + /// + /// Outside of tests, this method should only ever be called by + /// [PigeonInstanceManager]. + /// + /// Subclasses should always override their parent's implementation of this + /// method. + @protected + PigeonProxyApiBaseClass pigeon_copy(); +} + +/// Maintains instances used to communicate with the native objects they +/// represent. +/// +/// Added instances are stored as weak references and their copies are stored +/// as strong references to maintain access to their variables and callback +/// methods. Both are stored with the same identifier. +/// +/// When a weak referenced instance becomes inaccessible, +/// [onWeakReferenceRemoved] is called with its associated identifier. +/// +/// If an instance is retrieved and has the possibility to be used, +/// (e.g. calling [getInstanceWithWeakReference]) a copy of the strong reference +/// is added as a weak reference with the same identifier. This prevents a +/// scenario where the weak referenced instance was released and then later +/// returned by the host platform. +class PigeonInstanceManager { + /// Constructs a [PigeonInstanceManager]. + PigeonInstanceManager({required void Function(int) onWeakReferenceRemoved}) { + this.onWeakReferenceRemoved = (int identifier) { + _weakInstances.remove(identifier); + onWeakReferenceRemoved(identifier); + }; + _finalizer = Finalizer(this.onWeakReferenceRemoved); + } + + // Identifiers are locked to a specific range to avoid collisions with objects + // created simultaneously by the host platform. + // Host uses identifiers >= 2^16 and Dart is expected to use values n where, + // 0 <= n < 2^16. + static const int _maxDartCreatedIdentifier = 65536; + + /// The default [PigeonInstanceManager] used by ProxyApis. + /// + /// On creation, this manager makes a call to clear the native + /// InstanceManager. This is to prevent identifier conflicts after a host + /// restart. + static final PigeonInstanceManager instance = _initInstance(); + + // Expando is used because it doesn't prevent its keys from becoming + // inaccessible. This allows the manager to efficiently retrieve an identifier + // of an instance without holding a strong reference to that instance. + // + // It also doesn't use `==` to search for identifiers, which would lead to an + // infinite loop when comparing an object to its copy. (i.e. which was caused + // by calling instanceManager.getIdentifier() inside of `==` while this was a + // HashMap). + final Expando _identifiers = Expando(); + final Map> _weakInstances = + >{}; + final Map _strongInstances = + {}; + late final Finalizer _finalizer; + int _nextIdentifier = 0; + + /// Called when a weak referenced instance is removed by [removeWeakReference] + /// or becomes inaccessible. + late final void Function(int) onWeakReferenceRemoved; + + static PigeonInstanceManager _initInstance() { + WidgetsFlutterBinding.ensureInitialized(); + final _PigeonInstanceManagerApi api = _PigeonInstanceManagerApi(); + // Clears the native `PigeonInstanceManager` on the initial use of the Dart one. + api.clear(); + final PigeonInstanceManager instanceManager = PigeonInstanceManager( + onWeakReferenceRemoved: (int identifier) { + api.removeStrongReference(identifier); + }, + ); + _PigeonInstanceManagerApi.setUpMessageHandlers( + instanceManager: instanceManager); + BaseDisplayContainer.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdDisplayContainer.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdsLoader.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdsManagerLoadedEvent.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdErrorEvent.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdError.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdsRequest.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + ContentProgressProvider.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdsManager.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + BaseManager.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdEvent.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + ImaSdkFactory.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + ImaSdkSettings.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + VideoProgressUpdate.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdMediaInfo.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdPodInfo.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + FrameLayout.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + ViewGroup.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + VideoView.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + View.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager); + MediaPlayer.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + VideoAdPlayerCallback.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + VideoAdPlayer.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdsLoadedListener.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdErrorListener.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + AdEventListener.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + return instanceManager; + } + + /// Adds a new instance that was instantiated by Dart. + /// + /// In other words, Dart wants to add a new instance that will represent + /// an object that will be instantiated on the host platform. + /// + /// Throws assertion error if the instance has already been added. + /// + /// Returns the randomly generated id of the [instance] added. + int addDartCreatedInstance(PigeonProxyApiBaseClass instance) { + final int identifier = _nextUniqueIdentifier(); + _addInstanceWithIdentifier(instance, identifier); + return identifier; + } + + /// Removes the instance, if present, and call [onWeakReferenceRemoved] with + /// its identifier. + /// + /// Returns the identifier associated with the removed instance. Otherwise, + /// `null` if the instance was not found in this manager. + /// + /// This does not remove the strong referenced instance associated with + /// [instance]. This can be done with [remove]. + int? removeWeakReference(PigeonProxyApiBaseClass instance) { + final int? identifier = getIdentifier(instance); + if (identifier == null) { + return null; + } + + _identifiers[instance] = null; + _finalizer.detach(instance); + onWeakReferenceRemoved(identifier); + + return identifier; + } + + /// Removes [identifier] and its associated strongly referenced instance, if + /// present, from the manager. + /// + /// Returns the strong referenced instance associated with [identifier] before + /// it was removed. Returns `null` if [identifier] was not associated with + /// any strong reference. + /// + /// This does not remove the weak referenced instance associated with + /// [identifier]. This can be done with [removeWeakReference]. + T? remove(int identifier) { + return _strongInstances.remove(identifier) as T?; + } + + /// Retrieves the instance associated with identifier. + /// + /// The value returned is chosen from the following order: + /// + /// 1. A weakly referenced instance associated with identifier. + /// 2. If the only instance associated with identifier is a strongly + /// referenced instance, a copy of the instance is added as a weak reference + /// with the same identifier. Returning the newly created copy. + /// 3. If no instance is associated with identifier, returns null. + /// + /// This method also expects the host `InstanceManager` to have a strong + /// reference to the instance the identifier is associated with. + T? getInstanceWithWeakReference( + int identifier) { + final PigeonProxyApiBaseClass? weakInstance = + _weakInstances[identifier]?.target; + + if (weakInstance == null) { + final PigeonProxyApiBaseClass? strongInstance = + _strongInstances[identifier]; + if (strongInstance != null) { + final PigeonProxyApiBaseClass copy = strongInstance.pigeon_copy(); + _identifiers[copy] = identifier; + _weakInstances[identifier] = + WeakReference(copy); + _finalizer.attach(copy, identifier, detach: copy); + return copy as T; + } + return strongInstance as T?; + } + + return weakInstance as T; + } + + /// Retrieves the identifier associated with instance. + int? getIdentifier(PigeonProxyApiBaseClass instance) { + return _identifiers[instance]; + } + + /// Adds a new instance that was instantiated by the host platform. + /// + /// In other words, the host platform wants to add a new instance that + /// represents an object on the host platform. Stored with [identifier]. + /// + /// Throws assertion error if the instance or its identifier has already been + /// added. + /// + /// Returns unique identifier of the [instance] added. + void addHostCreatedInstance( + PigeonProxyApiBaseClass instance, int identifier) { + _addInstanceWithIdentifier(instance, identifier); + } + + void _addInstanceWithIdentifier( + PigeonProxyApiBaseClass instance, int identifier) { + assert(!containsIdentifier(identifier)); + assert(getIdentifier(instance) == null); + assert(identifier >= 0); + + _identifiers[instance] = identifier; + _weakInstances[identifier] = + WeakReference(instance); + _finalizer.attach(instance, identifier, detach: instance); + + final PigeonProxyApiBaseClass copy = instance.pigeon_copy(); + _identifiers[copy] = identifier; + _strongInstances[identifier] = copy; + } + + /// Whether this manager contains the given [identifier]. + bool containsIdentifier(int identifier) { + return _weakInstances.containsKey(identifier) || + _strongInstances.containsKey(identifier); + } + + int _nextUniqueIdentifier() { + late int identifier; + do { + identifier = _nextIdentifier; + _nextIdentifier = (_nextIdentifier + 1) % _maxDartCreatedIdentifier; + } while (containsIdentifier(identifier)); + return identifier; + } +} + +/// Generated API for managing the Dart and native `PigeonInstanceManager`s. +class _PigeonInstanceManagerApi { + /// Constructor for [_PigeonInstanceManagerApi]. + _PigeonInstanceManagerApi({BinaryMessenger? binaryMessenger}) + : __pigeon_binaryMessenger = binaryMessenger; + + final BinaryMessenger? __pigeon_binaryMessenger; + + static const MessageCodec pigeonChannelCodec = + StandardMessageCodec(); + + static void setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? binaryMessenger, + PigeonInstanceManager? instanceManager, + }) { + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference was null.'); + final List args = (message as List?)!; + final int? arg_identifier = (args[0] as int?); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference was null, expected non-null int.'); + try { + (instanceManager ?? PigeonInstanceManager.instance) + .remove(arg_identifier!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + Future removeStrongReference(int identifier) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([identifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Clear the native `PigeonInstanceManager`. + /// + /// This is typically called after a hot restart. + Future clear() async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.clear'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send(null) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } +} + +class _PigeonProxyApiBaseCodec extends StandardMessageCodec { + const _PigeonProxyApiBaseCodec(this.instanceManager); + final PigeonInstanceManager instanceManager; + @override + void writeValue(WriteBuffer buffer, Object? value) { + if (value is PigeonProxyApiBaseClass) { + buffer.putUint8(128); + writeValue(buffer, instanceManager.getIdentifier(value)); + } else { + super.writeValue(buffer, value); + } + } + + @override + Object? readValueOfType(int type, ReadBuffer buffer) { + switch (type) { + case 128: + return instanceManager + .getInstanceWithWeakReference(readValue(buffer)! as int); + default: + return super.readValueOfType(type, buffer); + } + } +} + +/// The types of error that can be encountered. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.AdErrorCode.html. +enum AdErrorCode { + /// Ads player was not provided. + adsPlayerWasNotProvided, + + /// There was a problem requesting ads from the server. + adsRequestNetworkError, + + /// A companion ad failed to load or render. + companionAdLoadingFailed, + + /// There was a problem requesting ads from the server. + failedToRequestAds, + + /// An error internal to the SDK occurred. + internalError, + + /// Invalid arguments were provided to SDK methods. + invalidArguments, + + /// An overlay ad failed to load. + overlayAdLoadingFailed, + + /// An overlay ad failed to render. + overlayAdPlayingFailed, + + /// Ads list was returned but ContentProgressProvider was not configured. + playlistNoContentTracking, + + /// Ads loader sent ads loaded event when it was not expected. + unexpectedAdsLoadedEvent, + + /// The ad response was not understood and cannot be parsed. + unknownAdResponse, + + /// An unexpected error occurred and the cause is not known. + unknownError, + + /// No assets were found in the VAST ad response. + vastAssetNotFound, + + /// A VAST response containing a single `` tag with no child tags. + vastEmptyResponse, + + /// Assets were found in the VAST ad response for a linear ad, but none of + /// them matched the video player's capabilities. + vastLinearAssetMismatch, + + /// At least one VAST wrapper ad loaded successfully and a subsequent wrapper + /// or inline ad load has timed out. + vastLoadTimeout, + + /// The ad response was not recognized as a valid VAST ad. + vastMalformedResponse, + + /// Failed to load media assets from a VAST response. + vastMediaLoadTimeout, + + /// Assets were found in the VAST ad response for a nonlinear ad, but none of + /// them matched the video player's capabilities. + vastNonlinearAssetMismatch, + + /// No Ads VAST response after one or more wrappers. + vastNoAdsAfterWrapper, + + /// The maximum number of VAST wrapper redirects has been reached. + vastTooManyRedirects, + + /// Trafficking error. + /// + /// Video player received an ad type that it was not expecting and/or cannot + /// display. + vastTraffickingError, + + /// There was an error playing the video ad. + videoPlayError, + + /// The error code is not recognized by this wrapper. + unknown, +} + +/// Specifies when the error was encountered, during either ad loading or playback. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.AdErrorType.html. +enum AdErrorType { + /// Indicates that the error was encountered when the ad was being loaded. + load, + + /// Indicates that the error was encountered after the ad loaded, during ad play. + play, + + /// The error is not recognized by this wrapper. + unknown, +} + +/// Types of events that can occur during ad playback. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventType.html. +enum AdEventType { + /// Fired when an ad break in a stream ends. + adBreakEnded, + + /// Fired when an ad break will not play back any ads. + adBreakFetchError, + + /// Fired when an ad break is ready from VMAP or ad rule ads. + adBreakReady, + + /// Fired when an ad break in a stream starts. + adBreakStarted, + + /// Fired when playback stalls while the ad buffers. + adBuffering, + + /// Fired when an ad period in a stream ends. + adPeriodEnded, + + /// Fired when an ad period in a stream starts. + adPeriodStarted, + + /// Fired to inform of ad progress and can be used by publisher to display a + /// countdown timer. + adProgress, + + /// Fired when the ads manager is done playing all the valid ads in the ads + /// response, or when the response doesn't return any valid ads. + allAdsCompleted, + + /// Fired when an ad is clicked. + clicked, + + /// Fired when an ad completes playing. + completed, + + /// Fired when content should be paused. + contentPauseRequested, + + /// Fired when content should be resumed. + contentResumeRequested, + + /// Fired when VOD stream cuepoints have changed. + cuepointsChanged, + + /// Fired when the ad playhead crosses first quartile. + firstQuartile, + + /// The user has closed the icon fallback image dialog. + iconFallbackImageClosed, + + /// The user has tapped an ad icon. + iconTapped, + + /// Fired when the VAST response has been received. + loaded, + + /// Fired to enable the SDK to communicate a message to be logged, which is + /// stored in adData. + log, + + /// Fired when the ad playhead crosses midpoint. + midpoint, + + /// Fired when an ad is paused. + paused, + + /// Fired when an ad is resumed. + resumed, + + /// Fired when an ad changes its skippable state. + skippableStateChanged, + + /// Fired when an ad was skipped. + skipped, + + /// Fired when an ad starts playing. + started, + + /// Fired when a non-clickthrough portion of a video ad is clicked. + tapped, + + /// Fired when the ad playhead crosses third quartile. + thirdQuartile, + + /// The event type is not recognized by this wrapper. + unknown, +} + +/// A base class for more specialized container interfaces. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseDisplayContainer.html. +class BaseDisplayContainer extends PigeonProxyApiBaseClass { + /// Constructs [BaseDisplayContainer] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + BaseDisplayContainer.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + BaseDisplayContainer Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.BaseDisplayContainer.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.BaseDisplayContainer.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.BaseDisplayContainer.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + BaseDisplayContainer.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + BaseDisplayContainer pigeon_copy() { + return BaseDisplayContainer.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// A container in which to display the ads. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdDisplayContainer. +class AdDisplayContainer extends PigeonProxyApiBaseClass + implements BaseDisplayContainer { + /// Constructs [AdDisplayContainer] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdDisplayContainer.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + AdDisplayContainer Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdDisplayContainer.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdDisplayContainer.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdDisplayContainer.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + AdDisplayContainer.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + AdDisplayContainer pigeon_copy() { + return AdDisplayContainer.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// An object which allows publishers to request ads from ad servers or a +/// dynamic ad insertion stream. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader. +class AdsLoader extends PigeonProxyApiBaseClass { + /// Constructs [AdsLoader] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdsLoader.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecAdsLoader = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + AdsLoader Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdsLoader.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsLoader.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsLoader.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + AdsLoader.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + /// Registers a listener for errors that occur during the ads request. + Future addAdErrorListener(AdErrorListener listener) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecAdsLoader; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdsLoader.addAdErrorListener'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, listener]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Registers a listener for the ads manager loaded event. + Future addAdsLoadedListener(AdsLoadedListener listener) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecAdsLoader; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdsLoader.addAdsLoadedListener'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, listener]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Requests ads from a server. + Future requestAds(AdsRequest request) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecAdsLoader; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdsLoader.requestAds'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, request]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + @override + AdsLoader pigeon_copy() { + return AdsLoader.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// An event raised when ads are successfully loaded from the ad server through an AdsLoader. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManagerLoadedEvent.html. +class AdsManagerLoadedEvent extends PigeonProxyApiBaseClass { + /// Constructs [AdsManagerLoadedEvent] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdsManagerLoadedEvent.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.manager, + }); + + /// The ads manager that will control playback of the loaded ads, or null when + /// using dynamic ad insertion. + final AdsManager manager; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + AdsManagerLoadedEvent Function(AdsManager manager)? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdsManagerLoadedEvent.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsManagerLoadedEvent.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsManagerLoadedEvent.pigeon_newInstance was null, expected non-null int.'); + final AdsManager? arg_manager = (args[1] as AdsManager?); + assert(arg_manager != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsManagerLoadedEvent.pigeon_newInstance was null, expected non-null AdsManager.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call(arg_manager!) ?? + AdsManagerLoadedEvent.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + manager: arg_manager!, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + AdsManagerLoadedEvent pigeon_copy() { + return AdsManagerLoadedEvent.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + manager: manager, + ); + } +} + +/// An event raised when there is an error loading or playing ads. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.html. +class AdErrorEvent extends PigeonProxyApiBaseClass { + /// Constructs [AdErrorEvent] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdErrorEvent.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.error, + }); + + /// The AdError that caused this event. + final AdError error; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + AdErrorEvent Function(AdError error)? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdErrorEvent.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdErrorEvent.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdErrorEvent.pigeon_newInstance was null, expected non-null int.'); + final AdError? arg_error = (args[1] as AdError?); + assert(arg_error != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdErrorEvent.pigeon_newInstance was null, expected non-null AdError.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call(arg_error!) ?? + AdErrorEvent.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + error: arg_error!, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + AdErrorEvent pigeon_copy() { + return AdErrorEvent.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + error: error, + ); + } +} + +/// An error that occurred in the SDK. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.html. +class AdError extends PigeonProxyApiBaseClass { + /// Constructs [AdError] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdError.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.errorCode, + required this.errorCodeNumber, + required this.errorType, + required this.message, + }); + + /// The error's code. + final AdErrorCode errorCode; + + /// The error code's number. + final int errorCodeNumber; + + /// The error's type. + final AdErrorType errorType; + + /// A human-readable summary of the error. + final String message; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + AdError Function( + AdErrorCode errorCode, + int errorCodeNumber, + AdErrorType errorType, + String message, + )? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null, expected non-null int.'); + final AdErrorCode? arg_errorCode = + args[1] == null ? null : AdErrorCode.values[args[1]! as int]; + assert(arg_errorCode != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null, expected non-null AdErrorCode.'); + final int? arg_errorCodeNumber = (args[2] as int?); + assert(arg_errorCodeNumber != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null, expected non-null int.'); + final AdErrorType? arg_errorType = + args[3] == null ? null : AdErrorType.values[args[3]! as int]; + assert(arg_errorType != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null, expected non-null AdErrorType.'); + final String? arg_message = (args[4] as String?); + assert(arg_message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null, expected non-null String.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call(arg_errorCode!, arg_errorCodeNumber!, + arg_errorType!, arg_message!) ?? + AdError.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + errorCode: arg_errorCode!, + errorCodeNumber: arg_errorCodeNumber!, + errorType: arg_errorType!, + message: arg_message!, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + AdError pigeon_copy() { + return AdError.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + errorCode: errorCode, + errorCodeNumber: errorCodeNumber, + errorType: errorType, + message: message, + ); + } +} + +/// An object containing the data used to request ads from the server. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest. +class AdsRequest extends PigeonProxyApiBaseClass { + /// Constructs [AdsRequest] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdsRequest.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecAdsRequest = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + AdsRequest Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdsRequest.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsRequest.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsRequest.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + AdsRequest.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + /// Sets the URL from which ads will be requested. + Future setAdTagUrl(String adTagUrl) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecAdsRequest; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdsRequest.setAdTagUrl'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adTagUrl]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Attaches a ContentProgressProvider instance to allow scheduling ad breaks + /// based on content progress (cue points). + Future setContentProgressProvider( + ContentProgressProvider provider) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecAdsRequest; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentProgressProvider'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, provider]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + @override + AdsRequest pigeon_copy() { + return AdsRequest.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// Defines an interface to allow SDK to track progress of the content video. +/// +/// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. +class ContentProgressProvider extends PigeonProxyApiBaseClass { + /// Constructs [ContentProgressProvider] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + ContentProgressProvider.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + ContentProgressProvider Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + ContentProgressProvider.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + ContentProgressProvider pigeon_copy() { + return ContentProgressProvider.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// An object which handles playing ads after they've been received from the +/// server. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManager. +class AdsManager extends BaseManager { + /// Constructs [AdsManager] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdsManager.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }) : super.pigeon_detached(); + + late final _PigeonProxyApiBaseCodec __pigeon_codecAdsManager = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + AdsManager Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdsManager.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsManager.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsManager.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + AdsManager.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + /// Discards current ad break and resumes content. + Future discardAdBreak() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecAdsManager; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdsManager.discardAdBreak'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Pauses the current ad. + Future pause() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecAdsManager; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdsManager.pause'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Starts playing the ads. + Future start() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecAdsManager; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdsManager.start'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + @override + AdsManager pigeon_copy() { + return AdsManager.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// Base interface for managing ads.. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager.html. +class BaseManager extends PigeonProxyApiBaseClass { + /// Constructs [BaseManager] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + BaseManager.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecBaseManager = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + BaseManager Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.BaseManager.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.BaseManager.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.BaseManager.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + BaseManager.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + /// Registers a listener for errors that occur during the ad or stream + /// initialization and playback. + Future addAdErrorListener(AdErrorListener errorListener) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecBaseManager; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.BaseManager.addAdErrorListener'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, errorListener]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Registers a listener for ad events that occur during ad or stream + /// initialization and playback. + Future addAdEventListener(AdEventListener adEventListener) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecBaseManager; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.BaseManager.addAdEventListener'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adEventListener]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Stops the ad and all tracking, then releases all assets that were loaded + /// to play the ad. + Future destroy() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecBaseManager; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.BaseManager.destroy'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Initializes the ad experience using default rendering settings + Future init() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecBaseManager; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.BaseManager.init'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + @override + BaseManager pigeon_copy() { + return BaseManager.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// Event to notify publisher that an event occurred with an Ad. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. +class AdEvent extends PigeonProxyApiBaseClass { + /// Constructs [AdEvent] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdEvent.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.type, + }); + + /// The type of event that occurred. + final AdEventType type; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + AdEvent Function(AdEventType type)? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance was null, expected non-null int.'); + final AdEventType? arg_type = + args[1] == null ? null : AdEventType.values[args[1]! as int]; + assert(arg_type != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance was null, expected non-null AdEventType.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call(arg_type!) ?? + AdEvent.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + type: arg_type!, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + AdEvent pigeon_copy() { + return AdEvent.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + type: type, + ); + } +} + +/// Factory class for creating SDK objects. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory. +class ImaSdkFactory extends PigeonProxyApiBaseClass { + /// Constructs [ImaSdkFactory] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + ImaSdkFactory.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecImaSdkFactory = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + static final ImaSdkFactory instance = __pigeon_instance(); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + ImaSdkFactory Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + ImaSdkFactory.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + static ImaSdkFactory __pigeon_instance() { + final ImaSdkFactory __pigeon_instance = ImaSdkFactory.pigeon_detached(); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec(PigeonInstanceManager.instance); + final BinaryMessenger __pigeon_binaryMessenger = + ServicesBinding.instance.defaultBinaryMessenger; + final int __pigeon_instanceIdentifier = PigeonInstanceManager.instance + .addDartCreatedInstance(__pigeon_instance); + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.instance'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + return __pigeon_instance; + } + + static Future createAdDisplayContainer( + ViewGroup container, + VideoAdPlayer player, { + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + }) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdDisplayContainer'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([container, player]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as AdDisplayContainer?)!; + } + } + + /// Creates an `ImaSdkSettings` object for configuring the IMA SDK. + Future createImaSdkSettings() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecImaSdkFactory; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createImaSdkSettings'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as ImaSdkSettings?)!; + } + } + + /// Creates an `AdsLoader` for requesting ads using the specified settings + /// object. + Future createAdsLoader( + ImaSdkSettings settings, + AdDisplayContainer container, + ) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecImaSdkFactory; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdsLoader'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, settings, container]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as AdsLoader?)!; + } + } + + /// Creates an AdsRequest object to contain the data used to request ads. + Future createAdsRequest() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecImaSdkFactory; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdsRequest'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as AdsRequest?)!; + } + } + + @override + ImaSdkFactory pigeon_copy() { + return ImaSdkFactory.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// Defines general SDK settings that are used when creating an `AdsLoader`. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkSettings.html. +class ImaSdkSettings extends PigeonProxyApiBaseClass { + /// Constructs [ImaSdkSettings] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + ImaSdkSettings.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + ImaSdkSettings Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.ImaSdkSettings.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.ImaSdkSettings.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.ImaSdkSettings.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + ImaSdkSettings.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + ImaSdkSettings pigeon_copy() { + return ImaSdkSettings.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// Defines an update to the video's progress. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoProgressUpdate.html. +class VideoProgressUpdate extends PigeonProxyApiBaseClass { + VideoProgressUpdate({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required int currentTimeMs, + required int durationMs, + }) { + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoProgressUpdate; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.pigeon_defaultConstructor'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel.send( + [__pigeon_instanceIdentifier, currentTimeMs, durationMs]) + as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + } + + /// Constructs [VideoProgressUpdate] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + VideoProgressUpdate.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecVideoProgressUpdate = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + /// Value to use for cases when progress is not yet defined, such as video + /// initialization. + static final VideoProgressUpdate videoTimeNotReady = + __pigeon_videoTimeNotReady(); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + VideoProgressUpdate Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + VideoProgressUpdate.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + static VideoProgressUpdate __pigeon_videoTimeNotReady() { + final VideoProgressUpdate __pigeon_instance = + VideoProgressUpdate.pigeon_detached(); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec(PigeonInstanceManager.instance); + final BinaryMessenger __pigeon_binaryMessenger = + ServicesBinding.instance.defaultBinaryMessenger; + final int __pigeon_instanceIdentifier = PigeonInstanceManager.instance + .addDartCreatedInstance(__pigeon_instance); + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.videoTimeNotReady'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + return __pigeon_instance; + } + + @override + VideoProgressUpdate pigeon_copy() { + return VideoProgressUpdate.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// The minimal information required to play an ad. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/AdMediaInfo.html. +class AdMediaInfo extends PigeonProxyApiBaseClass { + /// Constructs [AdMediaInfo] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdMediaInfo.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.url, + }); + + final String url; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + AdMediaInfo Function(String url)? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdMediaInfo.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdMediaInfo.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdMediaInfo.pigeon_newInstance was null, expected non-null int.'); + final String? arg_url = (args[1] as String?); + assert(arg_url != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdMediaInfo.pigeon_newInstance was null, expected non-null String.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call(arg_url!) ?? + AdMediaInfo.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + url: arg_url!, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + AdMediaInfo pigeon_copy() { + return AdMediaInfo.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + url: url, + ); + } +} + +/// An ad may be part of a pod of ads. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdPodInfo.html. +class AdPodInfo extends PigeonProxyApiBaseClass { + /// Constructs [AdPodInfo] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdPodInfo.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.adPosition, + required this.maxDuration, + required this.podIndex, + required this.timeOffset, + required this.totalAds, + required this.isBumper, + }); + + /// The position of the ad within the pod. + /// + /// The value returned is one-based, for example, 1 of 2, 2 of 2, etc. If the + /// ad is not part of a pod, this will return 1. + final int adPosition; + + /// The maximum duration of the pod in seconds. + /// + /// For unknown duration, -1 is returned. + final double maxDuration; + + /// Client side and DAI VOD: Returns the index of the ad pod. + final int podIndex; + + /// The content time offset at which the current ad pod was scheduled. + /// + /// For preroll pod, 0 is returned. For midrolls, the scheduled time is + /// returned in seconds. For postroll, -1 is returned. Defaults to 0 if this + /// ad is not part of a pod, or the pod is not part of an ad playlist. + final double timeOffset; + + /// The total number of ads contained within this pod, including bumpers. + final int totalAds; + + /// Returns true if the ad is a bumper ad. + final bool isBumper; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + AdPodInfo Function( + int adPosition, + double maxDuration, + int podIndex, + double timeOffset, + int totalAds, + bool isBumper, + )? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance was null, expected non-null int.'); + final int? arg_adPosition = (args[1] as int?); + assert(arg_adPosition != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance was null, expected non-null int.'); + final double? arg_maxDuration = (args[2] as double?); + assert(arg_maxDuration != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance was null, expected non-null double.'); + final int? arg_podIndex = (args[3] as int?); + assert(arg_podIndex != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance was null, expected non-null int.'); + final double? arg_timeOffset = (args[4] as double?); + assert(arg_timeOffset != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance was null, expected non-null double.'); + final int? arg_totalAds = (args[5] as int?); + assert(arg_totalAds != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance was null, expected non-null int.'); + final bool? arg_isBumper = (args[6] as bool?); + assert(arg_isBumper != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance was null, expected non-null bool.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call( + arg_adPosition!, + arg_maxDuration!, + arg_podIndex!, + arg_timeOffset!, + arg_totalAds!, + arg_isBumper!) ?? + AdPodInfo.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + adPosition: arg_adPosition!, + maxDuration: arg_maxDuration!, + podIndex: arg_podIndex!, + timeOffset: arg_timeOffset!, + totalAds: arg_totalAds!, + isBumper: arg_isBumper!, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + AdPodInfo pigeon_copy() { + return AdPodInfo.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + adPosition: adPosition, + maxDuration: maxDuration, + podIndex: podIndex, + timeOffset: timeOffset, + totalAds: totalAds, + isBumper: isBumper, + ); + } +} + +/// FrameLayout is designed to block out an area on the screen to display a +/// single item. +/// +/// See https://developer.android.com/reference/android/widget/FrameLayout. +class FrameLayout extends ViewGroup { + FrameLayout({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }) : super.pigeon_detached() { + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecFrameLayout; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.FrameLayout.pigeon_defaultConstructor'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + } + + /// Constructs [FrameLayout] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + FrameLayout.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }) : super.pigeon_detached(); + + late final _PigeonProxyApiBaseCodec __pigeon_codecFrameLayout = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + FrameLayout Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.FrameLayout.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.FrameLayout.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.FrameLayout.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + FrameLayout.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + FrameLayout pigeon_copy() { + return FrameLayout.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// A special view that can contain other views (called children.) +/// +/// See https://developer.android.com/reference/android/view/ViewGroup. +class ViewGroup extends View { + /// Constructs [ViewGroup] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + ViewGroup.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }) : super.pigeon_detached(); + + late final _PigeonProxyApiBaseCodec __pigeon_codecViewGroup = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + ViewGroup Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.ViewGroup.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.ViewGroup.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.ViewGroup.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + ViewGroup.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + Future addView(View view) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecViewGroup; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.ViewGroup.addView'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, view]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + @override + ViewGroup pigeon_copy() { + return ViewGroup.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// Displays a video file. +/// +/// See https://developer.android.com/reference/android/widget/VideoView. +class VideoView extends View { + VideoView({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + this.onPrepared, + this.onCompletion, + required this.onError, + }) : super.pigeon_detached() { + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecVideoView; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoView.pigeon_defaultConstructor'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + } + + /// Constructs [VideoView] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + VideoView.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + this.onPrepared, + this.onCompletion, + required this.onError, + }) : super.pigeon_detached(); + + late final _PigeonProxyApiBaseCodec __pigeon_codecVideoView = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + /// Callback to be invoked when the media source is ready for playback. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final VideoView instance = VideoView( + /// onPrepared: (VideoView pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + VideoView pigeon_instance, + MediaPlayer player, + )? onPrepared; + + /// Callback to be invoked when playback of a media source has completed. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final VideoView instance = VideoView( + /// onCompletion: (VideoView pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + VideoView pigeon_instance, + MediaPlayer player, + )? onCompletion; + + /// Callback to be invoked when there has been an error during an asynchronous + /// operation. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final VideoView instance = VideoView( + /// onError: (VideoView pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + VideoView pigeon_instance, + MediaPlayer player, + int what, + int extra, + ) onError; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + void Function( + VideoView pigeon_instance, + MediaPlayer player, + )? onPrepared, + void Function( + VideoView pigeon_instance, + MediaPlayer player, + )? onCompletion, + void Function( + VideoView pigeon_instance, + MediaPlayer player, + int what, + int extra, + )? onError, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + 'dev.flutter.pigeon.interactive_media_ads.VideoView.onPrepared', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onPrepared was null.'); + final List args = (message as List?)!; + final VideoView? arg_pigeon_instance = (args[0] as VideoView?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onPrepared was null, expected non-null VideoView.'); + final MediaPlayer? arg_player = (args[1] as MediaPlayer?); + assert(arg_player != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onPrepared was null, expected non-null MediaPlayer.'); + try { + (onPrepared ?? arg_pigeon_instance!.onPrepared) + ?.call(arg_pigeon_instance!, arg_player!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + 'dev.flutter.pigeon.interactive_media_ads.VideoView.onCompletion', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onCompletion was null.'); + final List args = (message as List?)!; + final VideoView? arg_pigeon_instance = (args[0] as VideoView?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onCompletion was null, expected non-null VideoView.'); + final MediaPlayer? arg_player = (args[1] as MediaPlayer?); + assert(arg_player != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onCompletion was null, expected non-null MediaPlayer.'); + try { + (onCompletion ?? arg_pigeon_instance!.onCompletion) + ?.call(arg_pigeon_instance!, arg_player!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + 'dev.flutter.pigeon.interactive_media_ads.VideoView.onError', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onError was null.'); + final List args = (message as List?)!; + final VideoView? arg_pigeon_instance = (args[0] as VideoView?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onError was null, expected non-null VideoView.'); + final MediaPlayer? arg_player = (args[1] as MediaPlayer?); + assert(arg_player != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onError was null, expected non-null MediaPlayer.'); + final int? arg_what = (args[2] as int?); + assert(arg_what != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onError was null, expected non-null int.'); + final int? arg_extra = (args[3] as int?); + assert(arg_extra != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onError was null, expected non-null int.'); + try { + (onError ?? arg_pigeon_instance!.onError) + .call(arg_pigeon_instance!, arg_player!, arg_what!, arg_extra!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + /// Sets the URI of the video. + Future setVideoUri(String uri) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecVideoView; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoView.setVideoUri'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, uri]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// The current position of the playing video. + /// + /// In milliseconds. + Future getCurrentPosition() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecVideoView; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoView.getCurrentPosition'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as int?)!; + } + } + + @override + VideoView pigeon_copy() { + return VideoView.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + onPrepared: onPrepared, + onCompletion: onCompletion, + onError: onError, + ); + } +} + +/// This class represents the basic building block for user interface components. +/// +/// See https://developer.android.com/reference/android/view/View. +class View extends PigeonProxyApiBaseClass { + /// Constructs [View] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + View.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + View Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.View.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.View.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.View.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + View.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + View pigeon_copy() { + return View.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// MediaPlayer class can be used to control playback of audio/video files and +/// streams. +/// +/// See https://developer.android.com/reference/android/media/MediaPlayer. +class MediaPlayer extends PigeonProxyApiBaseClass { + /// Constructs [MediaPlayer] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + MediaPlayer.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecMediaPlayer = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + MediaPlayer Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.MediaPlayer.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.MediaPlayer.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + MediaPlayer.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + /// Gets the duration of the file. + Future getDuration() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecMediaPlayer; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.getDuration'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as int?)!; + } + } + + /// Seeks to specified time position. + Future seekTo(int mSec) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecMediaPlayer; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.seekTo'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, mSec]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Starts or resumes playback. + Future start() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecMediaPlayer; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.start'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Pauses playback. + Future pause() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecMediaPlayer; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.pause'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Stops playback after playback has been started or paused. + Future stop() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecMediaPlayer; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.stop'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + @override + MediaPlayer pigeon_copy() { + return MediaPlayer.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// Callbacks that the player must fire. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.VideoAdPlayerCallback.html +class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { + /// Constructs [VideoAdPlayerCallback] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + VideoAdPlayerCallback.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecVideoAdPlayerCallback = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + VideoAdPlayerCallback Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + VideoAdPlayerCallback.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + /// Fire this callback periodically as ad playback occurs. + Future onAdProgress( + AdMediaInfo adMediaInfo, + VideoProgressUpdate videoProgressUpdate, + ) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayerCallback; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onAdProgress'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adMediaInfo, videoProgressUpdate]) + as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Fire this callback when video playback stalls waiting for data. + Future onBuffering(AdMediaInfo adMediaInfo) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayerCallback; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onBuffering'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adMediaInfo]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Fire this callback when all content has finished playing. + Future onContentComplete() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayerCallback; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onContentComplete'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Fire this callback when the video finishes playing. + Future onEnded(AdMediaInfo adMediaInfo) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayerCallback; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onEnded'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adMediaInfo]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Fire this callback when the video has encountered an error. + Future onError(AdMediaInfo adMediaInfo) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayerCallback; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onError'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adMediaInfo]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Fire this callback when the video is ready to begin playback. + Future onLoaded(AdMediaInfo adMediaInfo) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayerCallback; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onLoaded'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adMediaInfo]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Fire this callback when the video is paused. + Future onPause(AdMediaInfo adMediaInfo) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayerCallback; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onPause'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adMediaInfo]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Fire this callback when the player begins playing a video. + Future onPlay(AdMediaInfo adMediaInfo) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayerCallback; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onPlay'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adMediaInfo]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Fire this callback when the video is unpaused. + Future onResume(AdMediaInfo adMediaInfo) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayerCallback; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onResume'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adMediaInfo]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Fire this callback when the playback volume changes. + Future onVolumeChanged( + AdMediaInfo adMediaInfo, + int percentage, + ) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayerCallback; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onVolumeChanged'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, adMediaInfo, percentage]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + @override + VideoAdPlayerCallback pigeon_copy() { + return VideoAdPlayerCallback.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// Defines the set of methods that a video player must implement to be used by +/// the IMA SDK, as well as a set of callbacks that it must fire. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.html. +class VideoAdPlayer extends PigeonProxyApiBaseClass { + VideoAdPlayer({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.addCallback, + required this.loadAd, + required this.pauseAd, + required this.playAd, + required this.release, + required this.removeCallback, + required this.stopAd, + }) { + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayer; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pigeon_defaultConstructor'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + } + + /// Constructs [VideoAdPlayer] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + VideoAdPlayer.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.addCallback, + required this.loadAd, + required this.pauseAd, + required this.playAd, + required this.release, + required this.removeCallback, + required this.stopAd, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecVideoAdPlayer = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + /// Adds a callback. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final VideoAdPlayer instance = VideoAdPlayer( + /// addCallback: (VideoAdPlayer pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + VideoAdPlayer pigeon_instance, + VideoAdPlayerCallback callback, + ) addCallback; + + /// Loads a video ad hosted at AdMediaInfo. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final VideoAdPlayer instance = VideoAdPlayer( + /// loadAd: (VideoAdPlayer pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + VideoAdPlayer pigeon_instance, + AdMediaInfo adMediaInfo, + AdPodInfo adPodInfo, + ) loadAd; + + /// Pauses playing the current ad. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final VideoAdPlayer instance = VideoAdPlayer( + /// pauseAd: (VideoAdPlayer pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + VideoAdPlayer pigeon_instance, + AdMediaInfo adMediaInfo, + ) pauseAd; + + /// Starts or resumes playing the video ad referenced by the AdMediaInfo, + /// provided loadAd has already been called for it. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final VideoAdPlayer instance = VideoAdPlayer( + /// playAd: (VideoAdPlayer pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + VideoAdPlayer pigeon_instance, + AdMediaInfo adMediaInfo, + ) playAd; + + /// Cleans up and releases all resources used by the `VideoAdPlayer`. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final VideoAdPlayer instance = VideoAdPlayer( + /// release: (VideoAdPlayer pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function(VideoAdPlayer pigeon_instance) release; + + /// Removes a callback. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final VideoAdPlayer instance = VideoAdPlayer( + /// removeCallback: (VideoAdPlayer pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + VideoAdPlayer pigeon_instance, + VideoAdPlayerCallback callback, + ) removeCallback; + + /// Stops playing the current ad. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final VideoAdPlayer instance = VideoAdPlayer( + /// stopAd: (VideoAdPlayer pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + VideoAdPlayer pigeon_instance, + AdMediaInfo adMediaInfo, + ) stopAd; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + void Function( + VideoAdPlayer pigeon_instance, + VideoAdPlayerCallback callback, + )? addCallback, + void Function( + VideoAdPlayer pigeon_instance, + AdMediaInfo adMediaInfo, + AdPodInfo adPodInfo, + )? loadAd, + void Function( + VideoAdPlayer pigeon_instance, + AdMediaInfo adMediaInfo, + )? pauseAd, + void Function( + VideoAdPlayer pigeon_instance, + AdMediaInfo adMediaInfo, + )? playAd, + void Function(VideoAdPlayer pigeon_instance)? release, + void Function( + VideoAdPlayer pigeon_instance, + VideoAdPlayerCallback callback, + )? removeCallback, + void Function( + VideoAdPlayer pigeon_instance, + AdMediaInfo adMediaInfo, + )? stopAd, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.addCallback', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.addCallback was null.'); + final List args = (message as List?)!; + final VideoAdPlayer? arg_pigeon_instance = + (args[0] as VideoAdPlayer?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.addCallback was null, expected non-null VideoAdPlayer.'); + final VideoAdPlayerCallback? arg_callback = + (args[1] as VideoAdPlayerCallback?); + assert(arg_callback != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.addCallback was null, expected non-null VideoAdPlayerCallback.'); + try { + (addCallback ?? arg_pigeon_instance!.addCallback) + .call(arg_pigeon_instance!, arg_callback!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.loadAd', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.loadAd was null.'); + final List args = (message as List?)!; + final VideoAdPlayer? arg_pigeon_instance = + (args[0] as VideoAdPlayer?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.loadAd was null, expected non-null VideoAdPlayer.'); + final AdMediaInfo? arg_adMediaInfo = (args[1] as AdMediaInfo?); + assert(arg_adMediaInfo != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.loadAd was null, expected non-null AdMediaInfo.'); + final AdPodInfo? arg_adPodInfo = (args[2] as AdPodInfo?); + assert(arg_adPodInfo != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.loadAd was null, expected non-null AdPodInfo.'); + try { + (loadAd ?? arg_pigeon_instance!.loadAd) + .call(arg_pigeon_instance!, arg_adMediaInfo!, arg_adPodInfo!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pauseAd', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pauseAd was null.'); + final List args = (message as List?)!; + final VideoAdPlayer? arg_pigeon_instance = + (args[0] as VideoAdPlayer?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pauseAd was null, expected non-null VideoAdPlayer.'); + final AdMediaInfo? arg_adMediaInfo = (args[1] as AdMediaInfo?); + assert(arg_adMediaInfo != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pauseAd was null, expected non-null AdMediaInfo.'); + try { + (pauseAd ?? arg_pigeon_instance!.pauseAd) + .call(arg_pigeon_instance!, arg_adMediaInfo!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.playAd', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.playAd was null.'); + final List args = (message as List?)!; + final VideoAdPlayer? arg_pigeon_instance = + (args[0] as VideoAdPlayer?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.playAd was null, expected non-null VideoAdPlayer.'); + final AdMediaInfo? arg_adMediaInfo = (args[1] as AdMediaInfo?); + assert(arg_adMediaInfo != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.playAd was null, expected non-null AdMediaInfo.'); + try { + (playAd ?? arg_pigeon_instance!.playAd) + .call(arg_pigeon_instance!, arg_adMediaInfo!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.release', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.release was null.'); + final List args = (message as List?)!; + final VideoAdPlayer? arg_pigeon_instance = + (args[0] as VideoAdPlayer?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.release was null, expected non-null VideoAdPlayer.'); + try { + (release ?? arg_pigeon_instance!.release) + .call(arg_pigeon_instance!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.removeCallback', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.removeCallback was null.'); + final List args = (message as List?)!; + final VideoAdPlayer? arg_pigeon_instance = + (args[0] as VideoAdPlayer?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.removeCallback was null, expected non-null VideoAdPlayer.'); + final VideoAdPlayerCallback? arg_callback = + (args[1] as VideoAdPlayerCallback?); + assert(arg_callback != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.removeCallback was null, expected non-null VideoAdPlayerCallback.'); + try { + (removeCallback ?? arg_pigeon_instance!.removeCallback) + .call(arg_pigeon_instance!, arg_callback!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.stopAd', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.stopAd was null.'); + final List args = (message as List?)!; + final VideoAdPlayer? arg_pigeon_instance = + (args[0] as VideoAdPlayer?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.stopAd was null, expected non-null VideoAdPlayer.'); + final AdMediaInfo? arg_adMediaInfo = (args[1] as AdMediaInfo?); + assert(arg_adMediaInfo != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.stopAd was null, expected non-null AdMediaInfo.'); + try { + (stopAd ?? arg_pigeon_instance!.stopAd) + .call(arg_pigeon_instance!, arg_adMediaInfo!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + /// The volume of the player as a percentage from 0 to 100. + Future setVolume(int value) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayer; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.setVolume'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, value]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// The `VideoProgressUpdate` describing playback progress of the current + /// video. + Future setAdProgress(VideoProgressUpdate progress) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecVideoAdPlayer; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.setAdProgress'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, progress]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + @override + VideoAdPlayer pigeon_copy() { + return VideoAdPlayer.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + addCallback: addCallback, + loadAd: loadAd, + pauseAd: pauseAd, + playAd: playAd, + release: release, + removeCallback: removeCallback, + stopAd: stopAd, + ); + } +} + +/// Listener interface for notification of ad load or stream load completion. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader.AdsLoadedListener.html. +class AdsLoadedListener extends PigeonProxyApiBaseClass { + AdsLoadedListener({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.onAdsManagerLoaded, + }) { + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecAdsLoadedListener; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdsLoadedListener.pigeon_defaultConstructor'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + } + + /// Constructs [AdsLoadedListener] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdsLoadedListener.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.onAdsManagerLoaded, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecAdsLoadedListener = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + /// Called once the AdsManager or StreamManager has been loaded. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final AdsLoadedListener instance = AdsLoadedListener( + /// onAdsManagerLoaded: (AdsLoadedListener pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + AdsLoadedListener pigeon_instance, + AdsManagerLoadedEvent event, + ) onAdsManagerLoaded; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + void Function( + AdsLoadedListener pigeon_instance, + AdsManagerLoadedEvent event, + )? onAdsManagerLoaded, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdsLoadedListener.onAdsManagerLoaded', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsLoadedListener.onAdsManagerLoaded was null.'); + final List args = (message as List?)!; + final AdsLoadedListener? arg_pigeon_instance = + (args[0] as AdsLoadedListener?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsLoadedListener.onAdsManagerLoaded was null, expected non-null AdsLoadedListener.'); + final AdsManagerLoadedEvent? arg_event = + (args[1] as AdsManagerLoadedEvent?); + assert(arg_event != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsLoadedListener.onAdsManagerLoaded was null, expected non-null AdsManagerLoadedEvent.'); + try { + (onAdsManagerLoaded ?? arg_pigeon_instance!.onAdsManagerLoaded) + .call(arg_pigeon_instance!, arg_event!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + AdsLoadedListener pigeon_copy() { + return AdsLoadedListener.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + onAdsManagerLoaded: onAdsManagerLoaded, + ); + } +} + +/// Interface for classes that will listen to AdErrorEvents. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.AdErrorListener.html. +class AdErrorListener extends PigeonProxyApiBaseClass { + AdErrorListener({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.onAdError, + }) { + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecAdErrorListener; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdErrorListener.pigeon_defaultConstructor'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + } + + /// Constructs [AdErrorListener] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdErrorListener.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.onAdError, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecAdErrorListener = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + /// Called when an error occurs. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final AdErrorListener instance = AdErrorListener( + /// onAdError: (AdErrorListener pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + AdErrorListener pigeon_instance, + AdErrorEvent event, + ) onAdError; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + void Function( + AdErrorListener pigeon_instance, + AdErrorEvent event, + )? onAdError, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdErrorListener.onAdError', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdErrorListener.onAdError was null.'); + final List args = (message as List?)!; + final AdErrorListener? arg_pigeon_instance = + (args[0] as AdErrorListener?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdErrorListener.onAdError was null, expected non-null AdErrorListener.'); + final AdErrorEvent? arg_event = (args[1] as AdErrorEvent?); + assert(arg_event != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdErrorListener.onAdError was null, expected non-null AdErrorEvent.'); + try { + (onAdError ?? arg_pigeon_instance!.onAdError) + .call(arg_pigeon_instance!, arg_event!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + AdErrorListener pigeon_copy() { + return AdErrorListener.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + onAdError: onAdError, + ); + } +} + +/// Listener interface for ad events. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventListener.html. +class AdEventListener extends PigeonProxyApiBaseClass { + AdEventListener({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.onAdEvent, + }) { + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecAdEventListener; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdEventListener.pigeon_defaultConstructor'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + } + + /// Constructs [AdEventListener] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + AdEventListener.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.onAdEvent, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecAdEventListener = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + /// Respond to an occurrence of an AdEvent. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final AdEventListener instance = AdEventListener( + /// onAdEvent: (AdEventListener pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + AdEventListener pigeon_instance, + AdEvent event, + ) onAdEvent; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + void Function( + AdEventListener pigeon_instance, + AdEvent event, + )? onAdEvent, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.AdEventListener.onAdEvent', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEventListener.onAdEvent was null.'); + final List args = (message as List?)!; + final AdEventListener? arg_pigeon_instance = + (args[0] as AdEventListener?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEventListener.onAdEvent was null, expected non-null AdEventListener.'); + final AdEvent? arg_event = (args[1] as AdEvent?); + assert(arg_event != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEventListener.onAdEvent was null, expected non-null AdEvent.'); + try { + (onAdEvent ?? arg_pigeon_instance!.onAdEvent) + .call(arg_pigeon_instance!, arg_event!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + AdEventListener pigeon_copy() { + return AdEventListener.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + onAdEvent: onAdEvent, + ); + } +} diff --git a/packages/interactive_media_ads/lib/src/android/interactive_media_ads_proxy.dart b/packages/interactive_media_ads/lib/src/android/interactive_media_ads_proxy.dart new file mode 100644 index 000000000000..eff593541369 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/interactive_media_ads_proxy.dart @@ -0,0 +1,90 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'interactive_media_ads.g.dart'; + +/// Handles constructing objects and calling static methods for the Android +/// Interactive Media Ads native library. +/// +/// This class provides dependency injection for the implementations of the +/// platform interface classes. Improving the ease of unit testing and/or +/// overriding the underlying Android classes. +/// +/// By default each function calls the default constructor of the class it +/// intends to return. +class InteractiveMediaAdsProxy { + /// Constructs an [InteractiveMediaAdsProxy]. + const InteractiveMediaAdsProxy({ + this.newVideoProgressUpdate = VideoProgressUpdate.new, + this.newFrameLayout = FrameLayout.new, + this.newVideoView = VideoView.new, + this.newVideoAdPlayer = VideoAdPlayer.new, + this.newAdsLoadedListener = AdsLoadedListener.new, + this.newAdErrorListener = AdErrorListener.new, + this.newAdEventListener = AdEventListener.new, + this.createAdDisplayContainerImaSdkFactory = + ImaSdkFactory.createAdDisplayContainer, + this.instanceImaSdkFactory = _instanceImaSdkFactory, + this.videoTimeNotReadyVideoProgressUpdate = + _videoTimeNotReadyVideoProgressUpdate, + }); + + /// Constructs [VideoProgressUpdate]. + final VideoProgressUpdate Function({ + required int currentTimeMs, + required int durationMs, + }) newVideoProgressUpdate; + + /// Constructs [FrameLayout]. + final FrameLayout Function() newFrameLayout; + + /// Constructs [VideoView]. + final VideoView Function({ + required void Function(VideoView, MediaPlayer, int, int) onError, + void Function(VideoView, MediaPlayer)? onPrepared, + void Function(VideoView, MediaPlayer)? onCompletion, + }) newVideoView; + + /// Constructs [VideoAdPlayer]. + final VideoAdPlayer Function({ + required void Function(VideoAdPlayer, VideoAdPlayerCallback) addCallback, + required void Function(VideoAdPlayer, AdMediaInfo, AdPodInfo) loadAd, + required void Function(VideoAdPlayer, AdMediaInfo) pauseAd, + required void Function(VideoAdPlayer, AdMediaInfo) playAd, + required void Function(VideoAdPlayer) release, + required void Function(VideoAdPlayer, VideoAdPlayerCallback) removeCallback, + required void Function(VideoAdPlayer, AdMediaInfo) stopAd, + }) newVideoAdPlayer; + + /// Constructs [AdsLoadedListener]. + final AdsLoadedListener Function({ + required void Function(AdsLoadedListener, AdsManagerLoadedEvent) + onAdsManagerLoaded, + }) newAdsLoadedListener; + + /// Constructs [AdErrorListener]. + final AdErrorListener Function({ + required void Function(AdErrorListener, AdErrorEvent) onAdError, + }) newAdErrorListener; + + /// Constructs [AdEventListener]. + final AdEventListener Function({ + required void Function(AdEventListener, AdEvent) onAdEvent, + }) newAdEventListener; + + /// Calls to [ImaSdkFactory.createAdDisplayContainer]. + final Future Function(ViewGroup, VideoAdPlayer) + createAdDisplayContainerImaSdkFactory; + + /// Calls to [ImaSdkFactory.instance]. + final ImaSdkFactory Function() instanceImaSdkFactory; + + /// Calls to [VideoProgressUpdate.videoTimeNotReady]. + final VideoProgressUpdate Function() videoTimeNotReadyVideoProgressUpdate; + + static ImaSdkFactory _instanceImaSdkFactory() => ImaSdkFactory.instance; + + static VideoProgressUpdate _videoTimeNotReadyVideoProgressUpdate() => + VideoProgressUpdate.videoTimeNotReady; +} diff --git a/packages/interactive_media_ads/lib/src/android/platform_views_service_proxy.dart b/packages/interactive_media_ads/lib/src/android/platform_views_service_proxy.dart new file mode 100644 index 000000000000..6e0501cb8093 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/platform_views_service_proxy.dart @@ -0,0 +1,53 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; + +/// Proxy that provides access to the platform views service. +/// +/// This service allows creating and controlling platform-specific views. +@immutable +class PlatformViewsServiceProxy { + /// Constructs a [PlatformViewsServiceProxy]. + const PlatformViewsServiceProxy(); + + /// Proxy method for [PlatformViewsService.initExpensiveAndroidView]. + ExpensiveAndroidViewController initExpensiveAndroidView({ + required int id, + required String viewType, + required TextDirection layoutDirection, + dynamic creationParams, + MessageCodec? creationParamsCodec, + VoidCallback? onFocus, + }) { + return PlatformViewsService.initExpensiveAndroidView( + id: id, + viewType: viewType, + layoutDirection: layoutDirection, + creationParams: creationParams, + creationParamsCodec: creationParamsCodec, + onFocus: onFocus, + ); + } + + /// Proxy method for [PlatformViewsService.initSurfaceAndroidView]. + SurfaceAndroidViewController initSurfaceAndroidView({ + required int id, + required String viewType, + required TextDirection layoutDirection, + dynamic creationParams, + MessageCodec? creationParamsCodec, + VoidCallback? onFocus, + }) { + return PlatformViewsService.initSurfaceAndroidView( + id: id, + viewType: viewType, + layoutDirection: layoutDirection, + creationParams: creationParams, + creationParamsCodec: creationParamsCodec, + onFocus: onFocus, + ); + } +} diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart index d80a17a6a730..85488aaa2512 100644 --- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart +++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart @@ -13,7 +13,7 @@ base class AdsManagerInitParams {} /// ads. base class AdsManagerStartParams {} -/// Interface for a platform implementation of a `AdsManager`. +/// Interface for a platform implementation of an `AdsManager`. abstract class PlatformAdsManager { /// Creates a [PlatformAdsManager]. @protected diff --git a/packages/interactive_media_ads/pigeons/copyright.txt b/packages/interactive_media_ads/pigeons/copyright.txt new file mode 100644 index 000000000000..fb682b1ab965 --- /dev/null +++ b/packages/interactive_media_ads/pigeons/copyright.txt @@ -0,0 +1,3 @@ +Copyright 2013 The Flutter Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. \ No newline at end of file diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart new file mode 100644 index 000000000000..972a1e6818c4 --- /dev/null +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart @@ -0,0 +1,723 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// TODO(bparrishMines): Uncomment this file once +// https://github.com/flutter/packages/pull/6371 lands. This file uses the +// Kotlin ProxyApi feature from pigeon. +// ignore_for_file: avoid_unused_constructor_parameters +// +// import 'package:pigeon/pigeon.dart'; +// +// @ConfigurePigeon( +// PigeonOptions( +// copyrightHeader: 'pigeons/copyright.txt', +// dartOut: 'lib/src/android/interactive_media_ads.g.dart', +// kotlinOut: +// 'android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt', +// kotlinOptions: KotlinOptions( +// package: 'dev.flutter.packages.interactive_media_ads', +// ), +// ), +// ) +// +// /// The types of error that can be encountered. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.AdErrorCode.html. +// enum AdErrorCode { +// /// Ads player was not provided. +// adsPlayerWasNotProvided, +// +// /// There was a problem requesting ads from the server. +// adsRequestNetworkError, +// +// /// A companion ad failed to load or render. +// companionAdLoadingFailed, +// +// /// There was a problem requesting ads from the server. +// failedToRequestAds, +// +// /// An error internal to the SDK occurred. +// internalError, +// +// /// Invalid arguments were provided to SDK methods. +// invalidArguments, +// +// /// An overlay ad failed to load. +// overlayAdLoadingFailed, +// +// /// An overlay ad failed to render. +// overlayAdPlayingFailed, +// +// /// Ads list was returned but ContentProgressProvider was not configured. +// playlistNoContentTracking, +// +// /// Ads loader sent ads loaded event when it was not expected. +// unexpectedAdsLoadedEvent, +// +// /// The ad response was not understood and cannot be parsed. +// unknownAdResponse, +// +// /// An unexpected error occurred and the cause is not known. +// unknownError, +// +// /// No assets were found in the VAST ad response. +// vastAssetNotFound, +// +// /// A VAST response containing a single `` tag with no child tags. +// vastEmptyResponse, +// +// /// Assets were found in the VAST ad response for a linear ad, but none of +// /// them matched the video player's capabilities. +// vastLinearAssetMismatch, +// +// /// At least one VAST wrapper ad loaded successfully and a subsequent wrapper +// /// or inline ad load has timed out. +// vastLoadTimeout, +// +// /// The ad response was not recognized as a valid VAST ad. +// vastMalformedResponse, +// +// /// Failed to load media assets from a VAST response. +// vastMediaLoadTimeout, +// +// /// Assets were found in the VAST ad response for a nonlinear ad, but none of +// /// them matched the video player's capabilities. +// vastNonlinearAssetMismatch, +// +// /// No Ads VAST response after one or more wrappers. +// vastNoAdsAfterWrapper, +// +// /// The maximum number of VAST wrapper redirects has been reached. +// vastTooManyRedirects, +// +// /// Trafficking error. +// /// +// /// Video player received an ad type that it was not expecting and/or cannot +// /// display. +// vastTraffickingError, +// +// /// There was an error playing the video ad. +// videoPlayError, +// +// /// The error code is not recognized by this wrapper. +// unknown, +// } +// +// /// Specifies when the error was encountered, during either ad loading or playback. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.AdErrorType.html. +// enum AdErrorType { +// /// Indicates that the error was encountered when the ad was being loaded. +// load, +// +// /// Indicates that the error was encountered after the ad loaded, during ad play. +// play, +// +// /// The error is not recognized by this wrapper. +// unknown, +// } +// +// /// Types of events that can occur during ad playback. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventType.html. +// enum AdEventType { +// /// Fired when an ad break in a stream ends. +// adBreakEnded, +// +// /// Fired when an ad break will not play back any ads. +// adBreakFetchError, +// +// /// Fired when an ad break is ready from VMAP or ad rule ads. +// adBreakReady, +// +// /// Fired when an ad break in a stream starts. +// adBreakStarted, +// +// /// Fired when playback stalls while the ad buffers. +// adBuffering, +// +// /// Fired when an ad period in a stream ends. +// adPeriodEnded, +// +// /// Fired when an ad period in a stream starts. +// adPeriodStarted, +// +// /// Fired to inform of ad progress and can be used by publisher to display a +// /// countdown timer. +// adProgress, +// +// /// Fired when the ads manager is done playing all the valid ads in the ads +// /// response, or when the response doesn't return any valid ads. +// allAdsCompleted, +// +// /// Fired when an ad is clicked. +// clicked, +// +// /// Fired when an ad completes playing. +// completed, +// +// /// Fired when content should be paused. +// contentPauseRequested, +// +// /// Fired when content should be resumed. +// contentResumeRequested, +// +// /// Fired when VOD stream cuepoints have changed. +// cuepointsChanged, +// +// /// Fired when the ad playhead crosses first quartile. +// firstQuartile, +// +// /// The user has closed the icon fallback image dialog. +// iconFallbackImageClosed, +// +// /// The user has tapped an ad icon. +// iconTapped, +// +// /// Fired when the VAST response has been received. +// loaded, +// +// /// Fired to enable the SDK to communicate a message to be logged, which is +// /// stored in adData. +// log, +// +// /// Fired when the ad playhead crosses midpoint. +// midpoint, +// +// /// Fired when an ad is paused. +// paused, +// +// /// Fired when an ad is resumed. +// resumed, +// +// /// Fired when an ad changes its skippable state. +// skippableStateChanged, +// +// /// Fired when an ad was skipped. +// skipped, +// +// /// Fired when an ad starts playing. +// started, +// +// /// Fired when a non-clickthrough portion of a video ad is clicked. +// tapped, +// +// /// Fired when the ad playhead crosses third quartile. +// thirdQuartile, +// +// /// The event type is not recognized by this wrapper. +// unknown, +// } +// +// /// A base class for more specialized container interfaces. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseDisplayContainer.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.BaseDisplayContainer', +// ), +// ) +// abstract class BaseDisplayContainer {} +// +// /// A container in which to display the ads. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdDisplayContainer. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdDisplayContainer', +// ), +// ) +// abstract class AdDisplayContainer implements BaseDisplayContainer {} +// +// /// An object which allows publishers to request ads from ad servers or a +// /// dynamic ad insertion stream. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsLoader', +// ), +// ) +// abstract class AdsLoader { +// /// Registers a listener for errors that occur during the ads request. +// void addAdErrorListener(AdErrorListener listener); +// +// /// Registers a listener for the ads manager loaded event. +// void addAdsLoadedListener(AdsLoadedListener listener); +// +// /// Requests ads from a server. +// void requestAds(AdsRequest request); +// } +// +// /// An event raised when ads are successfully loaded from the ad server through an AdsLoader. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManagerLoadedEvent.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent', +// ), +// ) +// abstract class AdsManagerLoadedEvent { +// /// The ads manager that will control playback of the loaded ads, or null when +// /// using dynamic ad insertion. +// late final AdsManager manager; +// } +// +// /// An event raised when there is an error loading or playing ads. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdErrorEvent', +// ), +// ) +// abstract class AdErrorEvent { +// /// The AdError that caused this event. +// late final AdError error; +// } +// +// /// An error that occurred in the SDK. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdError', +// ), +// ) +// abstract class AdError { +// /// The error's code. +// late final AdErrorCode errorCode; +// +// /// The error code's number. +// late final int errorCodeNumber; +// +// /// The error's type. +// late final AdErrorType errorType; +// +// /// A human-readable summary of the error. +// late final String message; +// } +// +// /// An object containing the data used to request ads from the server. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsRequest', +// ), +// ) +// abstract class AdsRequest { +// /// Sets the URL from which ads will be requested. +// void setAdTagUrl(String adTagUrl); +// +// /// Attaches a ContentProgressProvider instance to allow scheduling ad breaks +// /// based on content progress (cue points). +// void setContentProgressProvider(ContentProgressProvider provider); +// } +// +// /// Defines an interface to allow SDK to track progress of the content video. +// /// +// /// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider', +// ), +// ) +// abstract class ContentProgressProvider {} +// +// /// An object which handles playing ads after they've been received from the +// /// server. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManager. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsManager', +// ), +// ) +// abstract class AdsManager extends BaseManager { +// /// Discards current ad break and resumes content. +// void discardAdBreak(); +// +// /// Pauses the current ad. +// void pause(); +// +// /// Starts playing the ads. +// void start(); +// } +// +// /// Base interface for managing ads.. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.BaseManager', +// ), +// ) +// abstract class BaseManager { +// /// Registers a listener for errors that occur during the ad or stream +// /// initialization and playback. +// void addAdErrorListener(AdErrorListener errorListener); +// +// /// Registers a listener for ad events that occur during ad or stream +// /// initialization and playback. +// void addAdEventListener(AdEventListener adEventListener); +// +// /// Stops the ad and all tracking, then releases all assets that were loaded +// /// to play the ad. +// void destroy(); +// +// /// Initializes the ad experience using default rendering settings +// void init(); +// } +// +// /// Event to notify publisher that an event occurred with an Ad. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdEvent', +// ), +// ) +// abstract class AdEvent { +// /// The type of event that occurred. +// late final AdEventType type; +// } +// +// /// Factory class for creating SDK objects. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.ImaSdkFactory', +// ), +// ) +// abstract class ImaSdkFactory { +// @static +// @attached +// late final ImaSdkFactory instance; +// +// @static +// AdDisplayContainer createAdDisplayContainer( +// ViewGroup container, +// VideoAdPlayer player, +// ); +// +// /// Creates an `ImaSdkSettings` object for configuring the IMA SDK. +// ImaSdkSettings createImaSdkSettings(); +// +// /// Creates an `AdsLoader` for requesting ads using the specified settings +// /// object. +// AdsLoader createAdsLoader( +// ImaSdkSettings settings, +// AdDisplayContainer container, +// ); +// +// /// Creates an AdsRequest object to contain the data used to request ads. +// AdsRequest createAdsRequest(); +// } +// +// /// Defines general SDK settings that are used when creating an `AdsLoader`. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkSettings.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.ImaSdkSettings', +// ), +// ) +// abstract class ImaSdkSettings {} +// +// /// Defines an update to the video's progress. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoProgressUpdate.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate', +// ), +// ) +// abstract class VideoProgressUpdate { +// VideoProgressUpdate(int currentTimeMs, int durationMs); +// +// /// Value to use for cases when progress is not yet defined, such as video +// /// initialization. +// @static +// @attached +// late final VideoProgressUpdate videoTimeNotReady; +// } +// +// /// The minimal information required to play an ad. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/AdMediaInfo.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.player.AdMediaInfo', +// ), +// ) +// abstract class AdMediaInfo { +// late final String url; +// } +// +// /// An ad may be part of a pod of ads. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdPodInfo.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdPodInfo', +// ), +// ) +// abstract class AdPodInfo { +// /// The position of the ad within the pod. +// /// +// /// The value returned is one-based, for example, 1 of 2, 2 of 2, etc. If the +// /// ad is not part of a pod, this will return 1. +// late final int adPosition; +// +// /// The maximum duration of the pod in seconds. +// /// +// /// For unknown duration, -1 is returned. +// late final double maxDuration; +// +// /// Client side and DAI VOD: Returns the index of the ad pod. +// late final int podIndex; +// +// /// The content time offset at which the current ad pod was scheduled. +// /// +// /// For preroll pod, 0 is returned. For midrolls, the scheduled time is +// /// returned in seconds. For postroll, -1 is returned. Defaults to 0 if this +// /// ad is not part of a pod, or the pod is not part of an ad playlist. +// late final double timeOffset; +// +// /// The total number of ads contained within this pod, including bumpers. +// late final int totalAds; +// +// /// Returns true if the ad is a bumper ad. +// late final bool isBumper; +// } +// +// /// FrameLayout is designed to block out an area on the screen to display a +// /// single item. +// /// +// /// See https://developer.android.com/reference/android/widget/FrameLayout. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'android.widget.FrameLayout', +// ), +// ) +// abstract class FrameLayout extends ViewGroup { +// FrameLayout(); +// } +// +// /// A special view that can contain other views (called children.) +// /// +// /// See https://developer.android.com/reference/android/view/ViewGroup. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'android.view.ViewGroup', +// ), +// ) +// abstract class ViewGroup extends View { +// void addView(View view); +// } +// +// /// Displays a video file. +// /// +// /// See https://developer.android.com/reference/android/widget/VideoView. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'android.widget.VideoView', +// ), +// ) +// abstract class VideoView extends View { +// VideoView(); +// +// /// Callback to be invoked when the media source is ready for playback. +// late final void Function(MediaPlayer player)? onPrepared; +// +// /// Callback to be invoked when playback of a media source has completed. +// late final void Function(MediaPlayer player)? onCompletion; +// +// /// Callback to be invoked when there has been an error during an asynchronous +// /// operation. +// late final void Function(MediaPlayer player, int what, int extra) onError; +// +// /// Sets the URI of the video. +// void setVideoUri(String uri); +// +// /// The current position of the playing video. +// /// +// /// In milliseconds. +// int getCurrentPosition(); +// } +// +// /// This class represents the basic building block for user interface components. +// /// +// /// See https://developer.android.com/reference/android/view/View. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions(fullClassName: 'android.view.View'), +// ) +// abstract class View {} +// +// /// MediaPlayer class can be used to control playback of audio/video files and +// /// streams. +// /// +// /// See https://developer.android.com/reference/android/media/MediaPlayer. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'android.media.MediaPlayer', +// ), +// ) +// abstract class MediaPlayer { +// /// Gets the duration of the file. +// int getDuration(); +// +// /// Seeks to specified time position. +// void seekTo(int mSec); +// +// /// Starts or resumes playback. +// void start(); +// +// /// Pauses playback. +// void pause(); +// +// /// Stops playback after playback has been started or paused. +// void stop(); +// } +// +// /// Callbacks that the player must fire. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.VideoAdPlayerCallback.html +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback', +// ), +// ) +// abstract class VideoAdPlayerCallback { +// /// Fire this callback periodically as ad playback occurs. +// void onAdProgress( +// AdMediaInfo adMediaInfo, +// VideoProgressUpdate videoProgressUpdate, +// ); +// +// /// Fire this callback when video playback stalls waiting for data. +// void onBuffering(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when all content has finished playing. +// void onContentComplete(); +// +// /// Fire this callback when the video finishes playing. +// void onEnded(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the video has encountered an error. +// void onError(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the video is ready to begin playback. +// void onLoaded(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the video is paused. +// void onPause(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the player begins playing a video. +// void onPlay(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the video is unpaused. +// void onResume(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the playback volume changes. +// void onVolumeChanged(AdMediaInfo adMediaInfo, int percentage); +// } +// +// /// Defines the set of methods that a video player must implement to be used by +// /// the IMA SDK, as well as a set of callbacks that it must fire. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer', +// ), +// ) +// abstract class VideoAdPlayer { +// VideoAdPlayer(); +// +// /// Adds a callback. +// late final void Function(VideoAdPlayerCallback callback) addCallback; +// +// /// Loads a video ad hosted at AdMediaInfo. +// late final void Function(AdMediaInfo adMediaInfo, AdPodInfo adPodInfo) loadAd; +// +// /// Pauses playing the current ad. +// late final void Function(AdMediaInfo adMediaInfo) pauseAd; +// +// /// Starts or resumes playing the video ad referenced by the AdMediaInfo, +// /// provided loadAd has already been called for it. +// late final void Function(AdMediaInfo adMediaInfo) playAd; +// +// /// Cleans up and releases all resources used by the `VideoAdPlayer`. +// late final void Function() release; +// +// /// Removes a callback. +// late final void Function(VideoAdPlayerCallback callback) removeCallback; +// +// /// Stops playing the current ad. +// late final void Function(AdMediaInfo adMediaInfo) stopAd; +// +// /// The volume of the player as a percentage from 0 to 100. +// void setVolume(int value); +// +// /// The `VideoProgressUpdate` describing playback progress of the current +// /// video. +// void setAdProgress(VideoProgressUpdate progress); +// } +// +// /// Listener interface for notification of ad load or stream load completion. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader.AdsLoadedListener.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener', +// ), +// ) +// abstract class AdsLoadedListener { +// AdsLoadedListener(); +// +// /// Called once the AdsManager or StreamManager has been loaded. +// late final void Function(AdsManagerLoadedEvent event) onAdsManagerLoaded; +// } +// +// /// Interface for classes that will listen to AdErrorEvents. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.AdErrorListener.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener', +// ), +// ) +// abstract class AdErrorListener { +// AdErrorListener(); +// +// /// Called when an error occurs. +// late final void Function(AdErrorEvent event) onAdError; +// } +// +// /// Listener interface for ad events. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventListener.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener', +// ), +// ) +// abstract class AdEventListener { +// AdEventListener(); +// +// /// Respond to an occurrence of an AdEvent. +// late final void Function(AdEvent event) onAdEvent; +// } diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml index b1c5cf0b1f18..c3bc1e75b17e 100644 --- a/packages/interactive_media_ads/pubspec.yaml +++ b/packages/interactive_media_ads/pubspec.yaml @@ -2,7 +2,7 @@ name: interactive_media_ads description: A Flutter plugin for using the Interactive Media Ads SDKs on Android and iOS. repository: https://github.com/flutter/packages/tree/main/packages/interactive_media_ads issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+interactive_media_ads%22 -version: 0.0.1+3 +version: 0.0.2 # This must match the version in `android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt` environment: sdk: ^3.2.3 @@ -14,12 +14,14 @@ flutter: android: package: dev.flutter.packages.interactive_media_ads pluginClass: InteractiveMediaAdsPlugin + dartPluginClass: AndroidInteractiveMediaAds ios: pluginClass: InteractiveMediaAdsPlugin dependencies: flutter: sdk: flutter + meta: ^1.10.0 dev_dependencies: build_runner: ^2.1.4 diff --git a/packages/interactive_media_ads/test/android/ad_display_container_test.dart b/packages/interactive_media_ads/test/android/ad_display_container_test.dart new file mode 100644 index 000000000000..83694918bf3f --- /dev/null +++ b/packages/interactive_media_ads/test/android/ad_display_container_test.dart @@ -0,0 +1,518 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:interactive_media_ads/src/android/android_ad_display_container.dart'; +import 'package:interactive_media_ads/src/android/interactive_media_ads.g.dart' + as ima; +import 'package:interactive_media_ads/src/android/interactive_media_ads_proxy.dart'; +import 'package:interactive_media_ads/src/android/platform_views_service_proxy.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; + +import 'ad_display_container_test.mocks.dart'; + +@GenerateNiceMocks(>[ + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), +]) +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('AndroidAdDisplayContainer', () { + testWidgets('build with key', (WidgetTester tester) async { + final AndroidAdDisplayContainer container = AndroidAdDisplayContainer( + AndroidAdDisplayContainerCreationParams( + key: const Key('testKey'), + onContainerAdded: (_) {}, + ), + ); + + await tester.pumpWidget(Builder( + builder: (BuildContext context) => container.build(context), + )); + + expect(find.byType(PlatformViewLink), findsOneWidget); + expect(find.byKey(const Key('testKey')), findsOneWidget); + }); + + testWidgets('onContainerAdded is called', (WidgetTester tester) async { + final InteractiveMediaAdsProxy imaProxy = InteractiveMediaAdsProxy( + newFrameLayout: () => MockFrameLayout(), + newVideoView: ({ + required dynamic onError, + dynamic onPrepared, + dynamic onCompletion, + }) => + MockVideoView(), + createAdDisplayContainerImaSdkFactory: ( + _, + __, + ) async { + return MockAdDisplayContainer(); + }, + newVideoAdPlayer: ({ + required dynamic addCallback, + required dynamic loadAd, + required dynamic pauseAd, + required dynamic playAd, + required dynamic release, + required dynamic removeCallback, + required dynamic stopAd, + }) => + MockVideoAdPlayer(), + ); + + final MockPlatformViewsServiceProxy mockPlatformViewsProxy = + MockPlatformViewsServiceProxy(); + final MockSurfaceAndroidViewController mockAndroidViewController = + MockSurfaceAndroidViewController(); + + late final int platformViewId; + when( + mockPlatformViewsProxy.initSurfaceAndroidView( + id: anyNamed('id'), + viewType: anyNamed('viewType'), + layoutDirection: anyNamed('layoutDirection'), + creationParams: anyNamed('creationParams'), + creationParamsCodec: anyNamed('creationParamsCodec'), + onFocus: anyNamed('onFocus'), + ), + ).thenAnswer((Invocation invocation) { + platformViewId = invocation.namedArguments[const Symbol('id')] as int; + return mockAndroidViewController; + }); + + final AndroidAdDisplayContainer container = AndroidAdDisplayContainer( + AndroidAdDisplayContainerCreationParams( + onContainerAdded: expectAsync1((_) {}), + platformViewsProxy: mockPlatformViewsProxy, + imaProxy: imaProxy, + ), + ); + + await tester.pumpWidget(Builder( + builder: (BuildContext context) => container.build(context), + )); + + final void Function(int) onPlatformCreatedCallback = verify( + mockAndroidViewController + .addOnPlatformViewCreatedListener(captureAny)) + .captured[0] as void Function(int); + + onPlatformCreatedCallback(platformViewId); + + await tester.pumpAndSettle(); + }); + + test('completing the ad notifies IMA SDK the ad has ended', () { + late final void Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ima.AdPodInfo, + ) loadAdCallback; + + late final void Function( + ima.VideoAdPlayer, + ima.VideoAdPlayerCallback, + ) addCallbackCallback; + + late final void Function( + ima.VideoView, + ima.MediaPlayer, + ) onCompletionCallback; + + final InteractiveMediaAdsProxy imaProxy = InteractiveMediaAdsProxy( + newFrameLayout: () => MockFrameLayout(), + newVideoView: ({ + required dynamic onError, + dynamic onPrepared, + void Function( + ima.VideoView, + ima.MediaPlayer, + )? onCompletion, + }) { + onCompletionCallback = onCompletion!; + return MockVideoView(); + }, + createAdDisplayContainerImaSdkFactory: ( + _, + __, + ) async { + return MockAdDisplayContainer(); + }, + newVideoAdPlayer: ({ + required void Function( + ima.VideoAdPlayer, + ima.VideoAdPlayerCallback, + ) addCallback, + required void Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ima.AdPodInfo, + ) loadAd, + required dynamic pauseAd, + required dynamic playAd, + required dynamic release, + required dynamic removeCallback, + required dynamic stopAd, + }) { + loadAdCallback = loadAd; + addCallbackCallback = addCallback; + return MockVideoAdPlayer(); + }, + ); + + AndroidAdDisplayContainer( + AndroidAdDisplayContainerCreationParams( + onContainerAdded: (_) {}, + imaProxy: imaProxy, + ), + ); + + final ima.AdMediaInfo mockAdMediaInfo = MockAdMediaInfo(); + loadAdCallback(MockVideoAdPlayer(), mockAdMediaInfo, MockAdPodInfo()); + + final MockVideoAdPlayerCallback mockPlayerCallback = + MockVideoAdPlayerCallback(); + addCallbackCallback(MockVideoAdPlayer(), mockPlayerCallback); + + onCompletionCallback(MockVideoView(), MockMediaPlayer()); + + verify(mockPlayerCallback.onEnded(mockAdMediaInfo)); + }); + + test('error loading the ad notifies IMA SDK of error', () { + late final void Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ima.AdPodInfo, + ) loadAdCallback; + + late final void Function( + ima.VideoAdPlayer, + ima.VideoAdPlayerCallback, + ) addCallbackCallback; + + late final void Function( + ima.VideoView, + ima.MediaPlayer, + int, + int, + ) onErrorCallback; + + final InteractiveMediaAdsProxy imaProxy = InteractiveMediaAdsProxy( + newFrameLayout: () => MockFrameLayout(), + newVideoView: ({ + required void Function( + ima.VideoView, + ima.MediaPlayer, + int, + int, + ) onError, + dynamic onPrepared, + dynamic onCompletion, + }) { + onErrorCallback = onError; + return MockVideoView(); + }, + createAdDisplayContainerImaSdkFactory: ( + _, + __, + ) async { + return MockAdDisplayContainer(); + }, + newVideoAdPlayer: ({ + required void Function( + ima.VideoAdPlayer, + ima.VideoAdPlayerCallback, + ) addCallback, + required void Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ima.AdPodInfo, + ) loadAd, + required dynamic pauseAd, + required dynamic playAd, + required dynamic release, + required dynamic removeCallback, + required dynamic stopAd, + }) { + loadAdCallback = loadAd; + addCallbackCallback = addCallback; + return MockVideoAdPlayer(); + }, + ); + + AndroidAdDisplayContainer( + AndroidAdDisplayContainerCreationParams( + onContainerAdded: (_) {}, + imaProxy: imaProxy, + ), + ); + + final ima.AdMediaInfo mockAdMediaInfo = MockAdMediaInfo(); + loadAdCallback(MockVideoAdPlayer(), mockAdMediaInfo, MockAdPodInfo()); + + final MockVideoAdPlayerCallback mockPlayerCallback = + MockVideoAdPlayerCallback(); + addCallbackCallback(MockVideoAdPlayer(), mockPlayerCallback); + + onErrorCallback(MockVideoView(), MockMediaPlayer(), 0, 0); + + verify(mockPlayerCallback.onError(mockAdMediaInfo)); + }); + + test('play ad once when it is prepared', () async { + late final void Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ima.AdPodInfo, + ) loadAdCallback; + + late final void Function( + ima.VideoAdPlayer, + ima.VideoAdPlayerCallback, + ) addCallbackCallback; + + late final Future Function( + ima.VideoView, + ima.MediaPlayer, + ) onPreparedCallback; + + const int adDuration = 100; + const int adProgress = 10; + + final InteractiveMediaAdsProxy imaProxy = InteractiveMediaAdsProxy( + newFrameLayout: () => MockFrameLayout(), + newVideoView: ({ + dynamic onError, + dynamic onPrepared, + dynamic onCompletion, + }) { + // VideoView.onPrepared returns void, but the implementation uses an + // async callback method. + onPreparedCallback = onPrepared! as Future Function( + ima.VideoView, + ima.MediaPlayer, + ); + final MockVideoView mockVideoView = MockVideoView(); + when(mockVideoView.getCurrentPosition()).thenAnswer( + (_) async => adProgress, + ); + return mockVideoView; + }, + createAdDisplayContainerImaSdkFactory: (_, __) async { + return MockAdDisplayContainer(); + }, + newVideoAdPlayer: ({ + required void Function( + ima.VideoAdPlayer, + ima.VideoAdPlayerCallback, + ) addCallback, + required void Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ima.AdPodInfo, + ) loadAd, + required dynamic pauseAd, + required dynamic playAd, + required dynamic release, + required dynamic removeCallback, + required dynamic stopAd, + }) { + loadAdCallback = loadAd; + addCallbackCallback = addCallback; + return MockVideoAdPlayer(); + }, + newVideoProgressUpdate: ({ + required int currentTimeMs, + required int durationMs, + }) { + expect(currentTimeMs, adProgress); + expect(durationMs, adDuration); + return MockVideoProgressUpdate(); + }, + ); + + AndroidAdDisplayContainer( + AndroidAdDisplayContainerCreationParams( + onContainerAdded: (_) {}, + imaProxy: imaProxy, + ), + ); + + final ima.AdMediaInfo mockAdMediaInfo = MockAdMediaInfo(); + loadAdCallback(MockVideoAdPlayer(), mockAdMediaInfo, MockAdPodInfo()); + + final MockVideoAdPlayerCallback mockPlayerCallback = + MockVideoAdPlayerCallback(); + addCallbackCallback(MockVideoAdPlayer(), mockPlayerCallback); + + final MockMediaPlayer mockMediaPlayer = MockMediaPlayer(); + when(mockMediaPlayer.getDuration()).thenAnswer((_) async => adDuration); + + await onPreparedCallback(MockVideoView(), mockMediaPlayer); + + verify(mockMediaPlayer.start()); + + // Ad progress is updated with a reoccurring timer, so this waits for + // at least one update. + await Future.delayed(const Duration(milliseconds: 300)); + verify(mockPlayerCallback.onAdProgress(mockAdMediaInfo, any)); + }); + + test('pause ad', () async { + late final void Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ima.AdPodInfo, + ) loadAdCallback; + + late final Future Function( + ima.VideoView, + ima.MediaPlayer, + ) onPreparedCallback; + + late final Future Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ) pauseAdCallback; + + final InteractiveMediaAdsProxy imaProxy = InteractiveMediaAdsProxy( + newFrameLayout: () => MockFrameLayout(), + newVideoView: ({ + dynamic onError, + void Function( + ima.VideoView, + ima.MediaPlayer, + )? onPrepared, + dynamic onCompletion, + }) { + // VideoView.onPrepared returns void, but the implementation uses an + // async callback method. + onPreparedCallback = onPrepared! as Future Function( + ima.VideoView, + ima.MediaPlayer, + ); + final MockVideoView mockVideoView = MockVideoView(); + when(mockVideoView.getCurrentPosition()).thenAnswer((_) async => 10); + return mockVideoView; + }, + createAdDisplayContainerImaSdkFactory: (_, __) async { + return MockAdDisplayContainer(); + }, + newVideoAdPlayer: ({ + required dynamic addCallback, + required void Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ima.AdPodInfo, + ) loadAd, + required dynamic pauseAd, + required dynamic playAd, + required dynamic release, + required dynamic removeCallback, + required dynamic stopAd, + }) { + loadAdCallback = loadAd; + // VideoAdPlayer.pauseAd returns void, but the implementation uses an + // async callback method. + pauseAdCallback = pauseAd as Future Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ); + return MockVideoAdPlayer(); + }, + newVideoProgressUpdate: ({ + required int currentTimeMs, + required int durationMs, + }) { + return MockVideoProgressUpdate(); + }, + ); + + AndroidAdDisplayContainer( + AndroidAdDisplayContainerCreationParams( + onContainerAdded: (_) {}, + imaProxy: imaProxy, + ), + ); + + final ima.AdMediaInfo mockAdMediaInfo = MockAdMediaInfo(); + loadAdCallback(MockVideoAdPlayer(), mockAdMediaInfo, MockAdPodInfo()); + + final MockMediaPlayer mockMediaPlayer = MockMediaPlayer(); + when(mockMediaPlayer.getDuration()).thenAnswer((_) async => 100); + + await onPreparedCallback(MockVideoView(), mockMediaPlayer); + + await pauseAdCallback(MockVideoAdPlayer(), mockAdMediaInfo); + + verify(mockMediaPlayer.pause()); + }); + + test('play ad', () async { + late final void Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ) playAdCallback; + + final MockVideoView mockVideoView = MockVideoView(); + final InteractiveMediaAdsProxy imaProxy = InteractiveMediaAdsProxy( + newFrameLayout: () => MockFrameLayout(), + newVideoView: ({ + dynamic onError, + dynamic onPrepared, + dynamic onCompletion, + }) { + return mockVideoView; + }, + createAdDisplayContainerImaSdkFactory: (_, __) async { + return MockAdDisplayContainer(); + }, + newVideoAdPlayer: ({ + required dynamic addCallback, + required dynamic loadAd, + required dynamic pauseAd, + required void Function( + ima.VideoAdPlayer, + ima.AdMediaInfo, + ) playAd, + required dynamic release, + required dynamic removeCallback, + required dynamic stopAd, + }) { + playAdCallback = playAd; + return MockVideoAdPlayer(); + }, + ); + + AndroidAdDisplayContainer( + AndroidAdDisplayContainerCreationParams( + onContainerAdded: (_) {}, + imaProxy: imaProxy, + ), + ); + + const String videoUrl = 'url'; + final ima.AdMediaInfo mockAdMediaInfo = MockAdMediaInfo(); + when(mockAdMediaInfo.url).thenReturn(videoUrl); + playAdCallback(MockVideoAdPlayer(), mockAdMediaInfo); + + verify(mockVideoView.setVideoUri(videoUrl)); + }); + }); +} diff --git a/packages/interactive_media_ads/test/android/ad_display_container_test.mocks.dart b/packages/interactive_media_ads/test/android/ad_display_container_test.mocks.dart new file mode 100644 index 000000000000..ef3f12b50b01 --- /dev/null +++ b/packages/interactive_media_ads/test/android/ad_display_container_test.mocks.dart @@ -0,0 +1,1266 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in interactive_media_ads/test/android/ad_display_container_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i6; +import 'dart:ui' as _i3; + +import 'package:flutter/services.dart' as _i4; +import 'package:interactive_media_ads/src/android/interactive_media_ads.g.dart' + as _i2; +import 'package:interactive_media_ads/src/android/platform_views_service_proxy.dart' + as _i7; +import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i5; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakePigeonInstanceManager_0 extends _i1.SmartFake + implements _i2.PigeonInstanceManager { + _FakePigeonInstanceManager_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdDisplayContainer_1 extends _i1.SmartFake + implements _i2.AdDisplayContainer { + _FakeAdDisplayContainer_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdMediaInfo_2 extends _i1.SmartFake implements _i2.AdMediaInfo { + _FakeAdMediaInfo_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdPodInfo_3 extends _i1.SmartFake implements _i2.AdPodInfo { + _FakeAdPodInfo_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeFrameLayout_4 extends _i1.SmartFake implements _i2.FrameLayout { + _FakeFrameLayout_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeMediaPlayer_5 extends _i1.SmartFake implements _i2.MediaPlayer { + _FakeMediaPlayer_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeVideoAdPlayer_6 extends _i1.SmartFake implements _i2.VideoAdPlayer { + _FakeVideoAdPlayer_6( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeVideoAdPlayerCallback_7 extends _i1.SmartFake + implements _i2.VideoAdPlayerCallback { + _FakeVideoAdPlayerCallback_7( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeVideoProgressUpdate_8 extends _i1.SmartFake + implements _i2.VideoProgressUpdate { + _FakeVideoProgressUpdate_8( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeVideoView_9 extends _i1.SmartFake implements _i2.VideoView { + _FakeVideoView_9( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeOffset_10 extends _i1.SmartFake implements _i3.Offset { + _FakeOffset_10( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeSize_11 extends _i1.SmartFake implements _i3.Size { + _FakeSize_11( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeExpensiveAndroidViewController_12 extends _i1.SmartFake + implements _i4.ExpensiveAndroidViewController { + _FakeExpensiveAndroidViewController_12( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeSurfaceAndroidViewController_13 extends _i1.SmartFake + implements _i4.SurfaceAndroidViewController { + _FakeSurfaceAndroidViewController_13( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [AdDisplayContainer]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdDisplayContainer extends _i1.Mock + implements _i2.AdDisplayContainer { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdDisplayContainer pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdDisplayContainer_1( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdDisplayContainer_1( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdDisplayContainer); +} + +/// A class which mocks [AdMediaInfo]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdMediaInfo extends _i1.Mock implements _i2.AdMediaInfo { + @override + String get url => (super.noSuchMethod( + Invocation.getter(#url), + returnValue: _i5.dummyValue( + this, + Invocation.getter(#url), + ), + returnValueForMissingStub: _i5.dummyValue( + this, + Invocation.getter(#url), + ), + ) as String); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdMediaInfo pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdMediaInfo_2( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdMediaInfo_2( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdMediaInfo); +} + +/// A class which mocks [AdPodInfo]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdPodInfo extends _i1.Mock implements _i2.AdPodInfo { + @override + int get adPosition => (super.noSuchMethod( + Invocation.getter(#adPosition), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + double get maxDuration => (super.noSuchMethod( + Invocation.getter(#maxDuration), + returnValue: 0.0, + returnValueForMissingStub: 0.0, + ) as double); + + @override + int get podIndex => (super.noSuchMethod( + Invocation.getter(#podIndex), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + double get timeOffset => (super.noSuchMethod( + Invocation.getter(#timeOffset), + returnValue: 0.0, + returnValueForMissingStub: 0.0, + ) as double); + + @override + int get totalAds => (super.noSuchMethod( + Invocation.getter(#totalAds), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + bool get isBumper => (super.noSuchMethod( + Invocation.getter(#isBumper), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdPodInfo pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdPodInfo_3( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdPodInfo_3( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdPodInfo); +} + +/// A class which mocks [FrameLayout]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockFrameLayout extends _i1.Mock implements _i2.FrameLayout { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.FrameLayout pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeFrameLayout_4( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeFrameLayout_4( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.FrameLayout); + + @override + _i6.Future addView(_i2.View? view) => (super.noSuchMethod( + Invocation.method( + #addView, + [view], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [MediaPlayer]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMediaPlayer extends _i1.Mock implements _i2.MediaPlayer { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future getDuration() => (super.noSuchMethod( + Invocation.method( + #getDuration, + [], + ), + returnValue: _i6.Future.value(0), + returnValueForMissingStub: _i6.Future.value(0), + ) as _i6.Future); + + @override + _i6.Future seekTo(int? mSec) => (super.noSuchMethod( + Invocation.method( + #seekTo, + [mSec], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future start() => (super.noSuchMethod( + Invocation.method( + #start, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future pause() => (super.noSuchMethod( + Invocation.method( + #pause, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future stop() => (super.noSuchMethod( + Invocation.method( + #stop, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i2.MediaPlayer pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeMediaPlayer_5( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeMediaPlayer_5( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.MediaPlayer); +} + +/// A class which mocks [VideoAdPlayer]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockVideoAdPlayer extends _i1.Mock implements _i2.VideoAdPlayer { + @override + void Function( + _i2.VideoAdPlayer, + _i2.VideoAdPlayerCallback, + ) get addCallback => (super.noSuchMethod( + Invocation.getter(#addCallback), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.VideoAdPlayerCallback callback, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.VideoAdPlayerCallback callback, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.VideoAdPlayerCallback, + )); + + @override + void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + _i2.AdPodInfo, + ) get loadAd => (super.noSuchMethod( + Invocation.getter(#loadAd), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + _i2.AdPodInfo adPodInfo, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + _i2.AdPodInfo adPodInfo, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + _i2.AdPodInfo, + )); + + @override + void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + ) get pauseAd => (super.noSuchMethod( + Invocation.getter(#pauseAd), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + )); + + @override + void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + ) get playAd => (super.noSuchMethod( + Invocation.getter(#playAd), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + )); + + @override + void Function(_i2.VideoAdPlayer) get release => (super.noSuchMethod( + Invocation.getter(#release), + returnValue: (_i2.VideoAdPlayer pigeon_instance) {}, + returnValueForMissingStub: (_i2.VideoAdPlayer pigeon_instance) {}, + ) as void Function(_i2.VideoAdPlayer)); + + @override + void Function( + _i2.VideoAdPlayer, + _i2.VideoAdPlayerCallback, + ) get removeCallback => (super.noSuchMethod( + Invocation.getter(#removeCallback), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.VideoAdPlayerCallback callback, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.VideoAdPlayerCallback callback, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.VideoAdPlayerCallback, + )); + + @override + void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + ) get stopAd => (super.noSuchMethod( + Invocation.getter(#stopAd), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + )); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future setVolume(int? value) => (super.noSuchMethod( + Invocation.method( + #setVolume, + [value], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future setAdProgress(_i2.VideoProgressUpdate? progress) => + (super.noSuchMethod( + Invocation.method( + #setAdProgress, + [progress], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i2.VideoAdPlayer pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeVideoAdPlayer_6( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeVideoAdPlayer_6( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.VideoAdPlayer); +} + +/// A class which mocks [VideoAdPlayerCallback]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockVideoAdPlayerCallback extends _i1.Mock + implements _i2.VideoAdPlayerCallback { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future onAdProgress( + _i2.AdMediaInfo? adMediaInfo, + _i2.VideoProgressUpdate? videoProgressUpdate, + ) => + (super.noSuchMethod( + Invocation.method( + #onAdProgress, + [ + adMediaInfo, + videoProgressUpdate, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onBuffering(_i2.AdMediaInfo? adMediaInfo) => + (super.noSuchMethod( + Invocation.method( + #onBuffering, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onContentComplete() => (super.noSuchMethod( + Invocation.method( + #onContentComplete, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onEnded(_i2.AdMediaInfo? adMediaInfo) => (super.noSuchMethod( + Invocation.method( + #onEnded, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onError(_i2.AdMediaInfo? adMediaInfo) => (super.noSuchMethod( + Invocation.method( + #onError, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onLoaded(_i2.AdMediaInfo? adMediaInfo) => + (super.noSuchMethod( + Invocation.method( + #onLoaded, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onPause(_i2.AdMediaInfo? adMediaInfo) => (super.noSuchMethod( + Invocation.method( + #onPause, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onPlay(_i2.AdMediaInfo? adMediaInfo) => (super.noSuchMethod( + Invocation.method( + #onPlay, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onResume(_i2.AdMediaInfo? adMediaInfo) => + (super.noSuchMethod( + Invocation.method( + #onResume, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onVolumeChanged( + _i2.AdMediaInfo? adMediaInfo, + int? percentage, + ) => + (super.noSuchMethod( + Invocation.method( + #onVolumeChanged, + [ + adMediaInfo, + percentage, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i2.VideoAdPlayerCallback pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeVideoAdPlayerCallback_7( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeVideoAdPlayerCallback_7( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.VideoAdPlayerCallback); +} + +/// A class which mocks [VideoProgressUpdate]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockVideoProgressUpdate extends _i1.Mock + implements _i2.VideoProgressUpdate { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.VideoProgressUpdate pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeVideoProgressUpdate_8( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeVideoProgressUpdate_8( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.VideoProgressUpdate); +} + +/// A class which mocks [VideoView]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockVideoView extends _i1.Mock implements _i2.VideoView { + @override + void Function( + _i2.VideoView, + _i2.MediaPlayer, + int, + int, + ) get onError => (super.noSuchMethod( + Invocation.getter(#onError), + returnValue: ( + _i2.VideoView pigeon_instance, + _i2.MediaPlayer player, + int what, + int extra, + ) {}, + returnValueForMissingStub: ( + _i2.VideoView pigeon_instance, + _i2.MediaPlayer player, + int what, + int extra, + ) {}, + ) as void Function( + _i2.VideoView, + _i2.MediaPlayer, + int, + int, + )); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future setVideoUri(String? uri) => (super.noSuchMethod( + Invocation.method( + #setVideoUri, + [uri], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future getCurrentPosition() => (super.noSuchMethod( + Invocation.method( + #getCurrentPosition, + [], + ), + returnValue: _i6.Future.value(0), + returnValueForMissingStub: _i6.Future.value(0), + ) as _i6.Future); + + @override + _i2.VideoView pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeVideoView_9( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeVideoView_9( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.VideoView); +} + +/// A class which mocks [SurfaceAndroidViewController]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockSurfaceAndroidViewController extends _i1.Mock + implements _i4.SurfaceAndroidViewController { + @override + bool get requiresViewComposition => (super.noSuchMethod( + Invocation.getter(#requiresViewComposition), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + int get viewId => (super.noSuchMethod( + Invocation.getter(#viewId), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + bool get awaitingCreation => (super.noSuchMethod( + Invocation.getter(#awaitingCreation), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + _i4.PointTransformer get pointTransformer => (super.noSuchMethod( + Invocation.getter(#pointTransformer), + returnValue: (_i3.Offset position) => _FakeOffset_10( + this, + Invocation.getter(#pointTransformer), + ), + returnValueForMissingStub: (_i3.Offset position) => _FakeOffset_10( + this, + Invocation.getter(#pointTransformer), + ), + ) as _i4.PointTransformer); + + @override + set pointTransformer(_i4.PointTransformer? transformer) => super.noSuchMethod( + Invocation.setter( + #pointTransformer, + transformer, + ), + returnValueForMissingStub: null, + ); + + @override + bool get isCreated => (super.noSuchMethod( + Invocation.getter(#isCreated), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + List<_i4.PlatformViewCreatedCallback> get createdCallbacks => + (super.noSuchMethod( + Invocation.getter(#createdCallbacks), + returnValue: <_i4.PlatformViewCreatedCallback>[], + returnValueForMissingStub: <_i4.PlatformViewCreatedCallback>[], + ) as List<_i4.PlatformViewCreatedCallback>); + + @override + _i6.Future setOffset(_i3.Offset? off) => (super.noSuchMethod( + Invocation.method( + #setOffset, + [off], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future create({ + _i3.Size? size, + _i3.Offset? position, + }) => + (super.noSuchMethod( + Invocation.method( + #create, + [], + { + #size: size, + #position: position, + }, + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future<_i3.Size> setSize(_i3.Size? size) => (super.noSuchMethod( + Invocation.method( + #setSize, + [size], + ), + returnValue: _i6.Future<_i3.Size>.value(_FakeSize_11( + this, + Invocation.method( + #setSize, + [size], + ), + )), + returnValueForMissingStub: _i6.Future<_i3.Size>.value(_FakeSize_11( + this, + Invocation.method( + #setSize, + [size], + ), + )), + ) as _i6.Future<_i3.Size>); + + @override + _i6.Future sendMotionEvent(_i4.AndroidMotionEvent? event) => + (super.noSuchMethod( + Invocation.method( + #sendMotionEvent, + [event], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + void addOnPlatformViewCreatedListener( + _i4.PlatformViewCreatedCallback? listener) => + super.noSuchMethod( + Invocation.method( + #addOnPlatformViewCreatedListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + void removeOnPlatformViewCreatedListener( + _i4.PlatformViewCreatedCallback? listener) => + super.noSuchMethod( + Invocation.method( + #removeOnPlatformViewCreatedListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + _i6.Future setLayoutDirection(_i3.TextDirection? layoutDirection) => + (super.noSuchMethod( + Invocation.method( + #setLayoutDirection, + [layoutDirection], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future dispatchPointerEvent(_i4.PointerEvent? event) => + (super.noSuchMethod( + Invocation.method( + #dispatchPointerEvent, + [event], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future clearFocus() => (super.noSuchMethod( + Invocation.method( + #clearFocus, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future dispose() => (super.noSuchMethod( + Invocation.method( + #dispose, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [PlatformViewsServiceProxy]. +/// +/// See the documentation for Mockito's code generation for more information. +// ignore: must_be_immutable +class MockPlatformViewsServiceProxy extends _i1.Mock + implements _i7.PlatformViewsServiceProxy { + @override + _i4.ExpensiveAndroidViewController initExpensiveAndroidView({ + required int? id, + required String? viewType, + required _i3.TextDirection? layoutDirection, + dynamic creationParams, + _i4.MessageCodec? creationParamsCodec, + _i3.VoidCallback? onFocus, + }) => + (super.noSuchMethod( + Invocation.method( + #initExpensiveAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + returnValue: _FakeExpensiveAndroidViewController_12( + this, + Invocation.method( + #initExpensiveAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + ), + returnValueForMissingStub: _FakeExpensiveAndroidViewController_12( + this, + Invocation.method( + #initExpensiveAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + ), + ) as _i4.ExpensiveAndroidViewController); + + @override + _i4.SurfaceAndroidViewController initSurfaceAndroidView({ + required int? id, + required String? viewType, + required _i3.TextDirection? layoutDirection, + dynamic creationParams, + _i4.MessageCodec? creationParamsCodec, + _i3.VoidCallback? onFocus, + }) => + (super.noSuchMethod( + Invocation.method( + #initSurfaceAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + returnValue: _FakeSurfaceAndroidViewController_13( + this, + Invocation.method( + #initSurfaceAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + ), + returnValueForMissingStub: _FakeSurfaceAndroidViewController_13( + this, + Invocation.method( + #initSurfaceAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + ), + ) as _i4.SurfaceAndroidViewController); +} diff --git a/packages/interactive_media_ads/test/android/ads_loader_test.dart b/packages/interactive_media_ads/test/android/ads_loader_test.dart new file mode 100644 index 000000000000..3446c4e899ad --- /dev/null +++ b/packages/interactive_media_ads/test/android/ads_loader_test.dart @@ -0,0 +1,322 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:interactive_media_ads/src/android/android_ad_display_container.dart'; +import 'package:interactive_media_ads/src/android/android_ads_loader.dart'; +import 'package:interactive_media_ads/src/android/interactive_media_ads.g.dart' + as ima; +import 'package:interactive_media_ads/src/android/interactive_media_ads_proxy.dart'; +import 'package:interactive_media_ads/src/android/platform_views_service_proxy.dart'; +import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; + +import 'ads_loader_test.mocks.dart'; + +@GenerateNiceMocks(>[ + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), +]) +void main() { + group('AndroidAdsLoader', () { + testWidgets('instantiate AndroidAdsLoader', (WidgetTester tester) async { + final AndroidAdDisplayContainer container = + await _pumpAdDisplayContainer(tester); + + AndroidAdsLoader( + AndroidAdsLoaderCreationParams( + container: container, + onAdsLoaded: (PlatformOnAdsLoadedData data) {}, + onAdsLoadError: (AdsLoadErrorData data) {}, + ), + ); + }); + + testWidgets('contentComplete', (WidgetTester tester) async { + final MockVideoAdPlayerCallback mockAdPlayerCallback = + MockVideoAdPlayerCallback(); + final AndroidAdDisplayContainer container = await _pumpAdDisplayContainer( + tester, + mockAdPlayerCallback: mockAdPlayerCallback, + ); + + final AndroidAdsLoader loader = AndroidAdsLoader( + AndroidAdsLoaderCreationParams( + container: container, + onAdsLoaded: (PlatformOnAdsLoadedData data) {}, + onAdsLoadError: (AdsLoadErrorData data) {}, + ), + ); + + await loader.contentComplete(); + verify(mockAdPlayerCallback.onContentComplete()); + }); + + testWidgets('requestAds', (WidgetTester tester) async { + final AndroidAdDisplayContainer container = + await _pumpAdDisplayContainer(tester); + + final MockImaSdkFactory mockSdkFactory = MockImaSdkFactory(); + when(mockSdkFactory.createImaSdkSettings()).thenAnswer((_) async { + return MockImaSdkSettings(); + }); + + final MockAdsLoader mockAdsLoader = MockAdsLoader(); + when(mockSdkFactory.createAdsLoader(any, any)).thenAnswer((_) async { + return mockAdsLoader; + }); + + final MockAdsRequest mockAdsRequest = MockAdsRequest(); + when(mockSdkFactory.createAdsRequest()).thenAnswer((_) async { + return mockAdsRequest; + }); + + final InteractiveMediaAdsProxy proxy = InteractiveMediaAdsProxy( + instanceImaSdkFactory: () => mockSdkFactory, + ); + + final AndroidAdsLoader adsLoader = AndroidAdsLoader( + AndroidAdsLoaderCreationParams( + container: container, + onAdsLoaded: (PlatformOnAdsLoadedData data) {}, + onAdsLoadError: (AdsLoadErrorData data) {}, + proxy: proxy, + ), + ); + + await adsLoader.requestAds(AdsRequest(adTagUrl: 'url')); + + verifyInOrder(>[ + mockAdsRequest.setAdTagUrl('url'), + mockAdsLoader.requestAds(mockAdsRequest), + ]); + }); + + testWidgets('onAdsLoaded', (WidgetTester tester) async { + final AndroidAdDisplayContainer container = + await _pumpAdDisplayContainer(tester); + + final MockImaSdkFactory mockSdkFactory = MockImaSdkFactory(); + when(mockSdkFactory.createImaSdkSettings()).thenAnswer((_) async { + return MockImaSdkSettings(); + }); + + final MockAdsLoader mockAdsLoader = MockAdsLoader(); + final Completer addEventListenerCompleter = Completer(); + when(mockAdsLoader.addAdsLoadedListener(any)).thenAnswer((_) async { + addEventListenerCompleter.complete(); + }); + + when(mockSdkFactory.createAdsLoader(any, any)).thenAnswer((_) async { + return mockAdsLoader; + }); + + late final void Function( + ima.AdsLoadedListener, + ima.AdsManagerLoadedEvent, + ) onAdsManagerLoadedCallback; + + final InteractiveMediaAdsProxy proxy = InteractiveMediaAdsProxy( + instanceImaSdkFactory: () => mockSdkFactory, + newAdsLoadedListener: ({ + required void Function( + ima.AdsLoadedListener, + ima.AdsManagerLoadedEvent, + ) onAdsManagerLoaded, + }) { + onAdsManagerLoadedCallback = onAdsManagerLoaded; + return MockAdsLoadedListener(); + }, + newAdErrorListener: ({required dynamic onAdError}) { + return MockAdErrorListener(); + }, + ); + + AndroidAdsLoader( + AndroidAdsLoaderCreationParams( + container: container, + onAdsLoaded: expectAsync1((_) {}), + onAdsLoadError: (_) {}, + proxy: proxy, + ), + ); + + final MockAdsManagerLoadedEvent mockLoadedEvent = + MockAdsManagerLoadedEvent(); + when(mockLoadedEvent.manager).thenReturn(MockAdsManager()); + + await addEventListenerCompleter.future; + + onAdsManagerLoadedCallback(MockAdsLoadedListener(), mockLoadedEvent); + }); + + testWidgets('onAdError', (WidgetTester tester) async { + final AndroidAdDisplayContainer container = + await _pumpAdDisplayContainer(tester); + + final MockImaSdkFactory mockSdkFactory = MockImaSdkFactory(); + when(mockSdkFactory.createImaSdkSettings()).thenAnswer((_) async { + return MockImaSdkSettings(); + }); + + final MockAdsLoader mockAdsLoader = MockAdsLoader(); + final Completer addErrorListenerCompleter = Completer(); + when(mockAdsLoader.addAdErrorListener(any)).thenAnswer((_) async { + addErrorListenerCompleter.complete(); + }); + + when(mockSdkFactory.createAdsLoader(any, any)).thenAnswer((_) async { + return mockAdsLoader; + }); + + late final void Function( + ima.AdErrorListener, + ima.AdErrorEvent, + ) onAdErrorCallback; + + final InteractiveMediaAdsProxy proxy = InteractiveMediaAdsProxy( + instanceImaSdkFactory: () => mockSdkFactory, + newAdsLoadedListener: ({required dynamic onAdsManagerLoaded}) { + return MockAdsLoadedListener(); + }, + newAdErrorListener: ({ + required void Function( + ima.AdErrorListener, + ima.AdErrorEvent, + ) onAdError, + }) { + onAdErrorCallback = onAdError; + return MockAdErrorListener(); + }, + ); + + AndroidAdsLoader( + AndroidAdsLoaderCreationParams( + container: container, + onAdsLoaded: (_) {}, + onAdsLoadError: expectAsync1((_) {}), + proxy: proxy, + ), + ); + + final MockAdErrorEvent mockErrorEvent = MockAdErrorEvent(); + final MockAdError mockError = MockAdError(); + when(mockError.errorType).thenReturn(ima.AdErrorType.load); + when(mockError.errorCode) + .thenReturn(ima.AdErrorCode.adsRequestNetworkError); + when(mockError.message).thenReturn('error message'); + when(mockErrorEvent.error).thenReturn(mockError); + + await addErrorListenerCompleter.future; + + onAdErrorCallback(MockAdErrorListener(), mockErrorEvent); + }); + }); +} + +Future _pumpAdDisplayContainer( + WidgetTester tester, { + MockVideoAdPlayerCallback? mockAdPlayerCallback, +}) async { + final InteractiveMediaAdsProxy imaProxy = InteractiveMediaAdsProxy( + newFrameLayout: () => MockFrameLayout(), + newVideoView: ({ + required dynamic onError, + dynamic onPrepared, + dynamic onCompletion, + }) => + MockVideoView(), + createAdDisplayContainerImaSdkFactory: ( + _, + __, + ) async { + return MockAdDisplayContainer(); + }, + newVideoAdPlayer: ({ + required void Function( + ima.VideoAdPlayer, + ima.VideoAdPlayerCallback, + ) addCallback, + required dynamic loadAd, + required dynamic pauseAd, + required dynamic playAd, + required dynamic release, + required dynamic removeCallback, + required dynamic stopAd, + }) { + if (mockAdPlayerCallback != null) { + addCallback(MockVideoAdPlayer(), mockAdPlayerCallback); + } + return MockVideoAdPlayer(); + }, + ); + + final MockPlatformViewsServiceProxy mockPlatformViewsProxy = + MockPlatformViewsServiceProxy(); + final MockSurfaceAndroidViewController mockAndroidViewController = + MockSurfaceAndroidViewController(); + + late final int platformViewId; + when( + mockPlatformViewsProxy.initSurfaceAndroidView( + id: anyNamed('id'), + viewType: anyNamed('viewType'), + layoutDirection: anyNamed('layoutDirection'), + creationParams: anyNamed('creationParams'), + creationParamsCodec: anyNamed('creationParamsCodec'), + onFocus: anyNamed('onFocus'), + ), + ).thenAnswer((Invocation invocation) { + platformViewId = invocation.namedArguments[const Symbol('id')] as int; + return mockAndroidViewController; + }); + + final Completer adDisplayContainerCompleter = + Completer(); + + final AndroidAdDisplayContainer container = AndroidAdDisplayContainer( + AndroidAdDisplayContainerCreationParams( + onContainerAdded: (PlatformAdDisplayContainer container) { + adDisplayContainerCompleter.complete( + container as AndroidAdDisplayContainer, + ); + }, + platformViewsProxy: mockPlatformViewsProxy, + imaProxy: imaProxy, + ), + ); + + await tester.pumpWidget(Builder( + builder: (BuildContext context) => container.build(context), + )); + + final void Function(int) onPlatformCreatedCallback = verify( + mockAndroidViewController + .addOnPlatformViewCreatedListener(captureAny)) + .captured[0] as void Function(int); + + onPlatformCreatedCallback(platformViewId); + + return adDisplayContainerCompleter.future; +} diff --git a/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart b/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart new file mode 100644 index 000000000000..bdcfc1f4d54c --- /dev/null +++ b/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart @@ -0,0 +1,1771 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in interactive_media_ads/test/android/ads_loader_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i6; +import 'dart:ui' as _i3; + +import 'package:flutter/services.dart' as _i4; +import 'package:interactive_media_ads/src/android/interactive_media_ads.g.dart' + as _i2; +import 'package:interactive_media_ads/src/android/platform_views_service_proxy.dart' + as _i7; +import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i5; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakePigeonInstanceManager_0 extends _i1.SmartFake + implements _i2.PigeonInstanceManager { + _FakePigeonInstanceManager_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdDisplayContainer_1 extends _i1.SmartFake + implements _i2.AdDisplayContainer { + _FakeAdDisplayContainer_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdError_2 extends _i1.SmartFake implements _i2.AdError { + _FakeAdError_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdErrorEvent_3 extends _i1.SmartFake implements _i2.AdErrorEvent { + _FakeAdErrorEvent_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdErrorListener_4 extends _i1.SmartFake + implements _i2.AdErrorListener { + _FakeAdErrorListener_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdsLoadedListener_5 extends _i1.SmartFake + implements _i2.AdsLoadedListener { + _FakeAdsLoadedListener_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdsManager_6 extends _i1.SmartFake implements _i2.AdsManager { + _FakeAdsManager_6( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdsManagerLoadedEvent_7 extends _i1.SmartFake + implements _i2.AdsManagerLoadedEvent { + _FakeAdsManagerLoadedEvent_7( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdsLoader_8 extends _i1.SmartFake implements _i2.AdsLoader { + _FakeAdsLoader_8( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdsRequest_9 extends _i1.SmartFake implements _i2.AdsRequest { + _FakeAdsRequest_9( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeFrameLayout_10 extends _i1.SmartFake implements _i2.FrameLayout { + _FakeFrameLayout_10( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeImaSdkSettings_11 extends _i1.SmartFake + implements _i2.ImaSdkSettings { + _FakeImaSdkSettings_11( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeImaSdkFactory_12 extends _i1.SmartFake implements _i2.ImaSdkFactory { + _FakeImaSdkFactory_12( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeVideoAdPlayer_13 extends _i1.SmartFake implements _i2.VideoAdPlayer { + _FakeVideoAdPlayer_13( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeVideoAdPlayerCallback_14 extends _i1.SmartFake + implements _i2.VideoAdPlayerCallback { + _FakeVideoAdPlayerCallback_14( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeVideoView_15 extends _i1.SmartFake implements _i2.VideoView { + _FakeVideoView_15( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeOffset_16 extends _i1.SmartFake implements _i3.Offset { + _FakeOffset_16( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeSize_17 extends _i1.SmartFake implements _i3.Size { + _FakeSize_17( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeExpensiveAndroidViewController_18 extends _i1.SmartFake + implements _i4.ExpensiveAndroidViewController { + _FakeExpensiveAndroidViewController_18( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeSurfaceAndroidViewController_19 extends _i1.SmartFake + implements _i4.SurfaceAndroidViewController { + _FakeSurfaceAndroidViewController_19( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [AdDisplayContainer]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdDisplayContainer extends _i1.Mock + implements _i2.AdDisplayContainer { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdDisplayContainer pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdDisplayContainer_1( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdDisplayContainer_1( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdDisplayContainer); +} + +/// A class which mocks [AdError]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdError extends _i1.Mock implements _i2.AdError { + @override + _i2.AdErrorCode get errorCode => (super.noSuchMethod( + Invocation.getter(#errorCode), + returnValue: _i2.AdErrorCode.adsPlayerWasNotProvided, + returnValueForMissingStub: _i2.AdErrorCode.adsPlayerWasNotProvided, + ) as _i2.AdErrorCode); + + @override + int get errorCodeNumber => (super.noSuchMethod( + Invocation.getter(#errorCodeNumber), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + _i2.AdErrorType get errorType => (super.noSuchMethod( + Invocation.getter(#errorType), + returnValue: _i2.AdErrorType.load, + returnValueForMissingStub: _i2.AdErrorType.load, + ) as _i2.AdErrorType); + + @override + String get message => (super.noSuchMethod( + Invocation.getter(#message), + returnValue: _i5.dummyValue( + this, + Invocation.getter(#message), + ), + returnValueForMissingStub: _i5.dummyValue( + this, + Invocation.getter(#message), + ), + ) as String); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdError pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdError_2( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdError_2( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdError); +} + +/// A class which mocks [AdErrorEvent]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdErrorEvent extends _i1.Mock implements _i2.AdErrorEvent { + @override + _i2.AdError get error => (super.noSuchMethod( + Invocation.getter(#error), + returnValue: _FakeAdError_2( + this, + Invocation.getter(#error), + ), + returnValueForMissingStub: _FakeAdError_2( + this, + Invocation.getter(#error), + ), + ) as _i2.AdError); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdErrorEvent pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdErrorEvent_3( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdErrorEvent_3( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdErrorEvent); +} + +/// A class which mocks [AdErrorListener]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdErrorListener extends _i1.Mock implements _i2.AdErrorListener { + @override + void Function( + _i2.AdErrorListener, + _i2.AdErrorEvent, + ) get onAdError => (super.noSuchMethod( + Invocation.getter(#onAdError), + returnValue: ( + _i2.AdErrorListener pigeon_instance, + _i2.AdErrorEvent event, + ) {}, + returnValueForMissingStub: ( + _i2.AdErrorListener pigeon_instance, + _i2.AdErrorEvent event, + ) {}, + ) as void Function( + _i2.AdErrorListener, + _i2.AdErrorEvent, + )); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdErrorListener pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdErrorListener_4( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdErrorListener_4( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdErrorListener); +} + +/// A class which mocks [AdsLoadedListener]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdsLoadedListener extends _i1.Mock implements _i2.AdsLoadedListener { + @override + void Function( + _i2.AdsLoadedListener, + _i2.AdsManagerLoadedEvent, + ) get onAdsManagerLoaded => (super.noSuchMethod( + Invocation.getter(#onAdsManagerLoaded), + returnValue: ( + _i2.AdsLoadedListener pigeon_instance, + _i2.AdsManagerLoadedEvent event, + ) {}, + returnValueForMissingStub: ( + _i2.AdsLoadedListener pigeon_instance, + _i2.AdsManagerLoadedEvent event, + ) {}, + ) as void Function( + _i2.AdsLoadedListener, + _i2.AdsManagerLoadedEvent, + )); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdsLoadedListener pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdsLoadedListener_5( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdsLoadedListener_5( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdsLoadedListener); +} + +/// A class which mocks [AdsManager]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdsManager extends _i1.Mock implements _i2.AdsManager { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future discardAdBreak() => (super.noSuchMethod( + Invocation.method( + #discardAdBreak, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future pause() => (super.noSuchMethod( + Invocation.method( + #pause, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future start() => (super.noSuchMethod( + Invocation.method( + #start, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i2.AdsManager pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdsManager_6( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdsManager_6( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdsManager); + + @override + _i6.Future addAdErrorListener(_i2.AdErrorListener? errorListener) => + (super.noSuchMethod( + Invocation.method( + #addAdErrorListener, + [errorListener], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future addAdEventListener(_i2.AdEventListener? adEventListener) => + (super.noSuchMethod( + Invocation.method( + #addAdEventListener, + [adEventListener], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future destroy() => (super.noSuchMethod( + Invocation.method( + #destroy, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future init() => (super.noSuchMethod( + Invocation.method( + #init, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [AdsManagerLoadedEvent]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdsManagerLoadedEvent extends _i1.Mock + implements _i2.AdsManagerLoadedEvent { + @override + _i2.AdsManager get manager => (super.noSuchMethod( + Invocation.getter(#manager), + returnValue: _FakeAdsManager_6( + this, + Invocation.getter(#manager), + ), + returnValueForMissingStub: _FakeAdsManager_6( + this, + Invocation.getter(#manager), + ), + ) as _i2.AdsManager); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdsManagerLoadedEvent pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdsManagerLoadedEvent_7( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdsManagerLoadedEvent_7( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdsManagerLoadedEvent); +} + +/// A class which mocks [AdsLoader]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdsLoader extends _i1.Mock implements _i2.AdsLoader { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future addAdErrorListener(_i2.AdErrorListener? listener) => + (super.noSuchMethod( + Invocation.method( + #addAdErrorListener, + [listener], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future addAdsLoadedListener(_i2.AdsLoadedListener? listener) => + (super.noSuchMethod( + Invocation.method( + #addAdsLoadedListener, + [listener], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future requestAds(_i2.AdsRequest? request) => (super.noSuchMethod( + Invocation.method( + #requestAds, + [request], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i2.AdsLoader pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdsLoader_8( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdsLoader_8( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdsLoader); +} + +/// A class which mocks [AdsRequest]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdsRequest extends _i1.Mock implements _i2.AdsRequest { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future setAdTagUrl(String? adTagUrl) => (super.noSuchMethod( + Invocation.method( + #setAdTagUrl, + [adTagUrl], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future setContentProgressProvider( + _i2.ContentProgressProvider? provider) => + (super.noSuchMethod( + Invocation.method( + #setContentProgressProvider, + [provider], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i2.AdsRequest pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdsRequest_9( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdsRequest_9( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdsRequest); +} + +/// A class which mocks [FrameLayout]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockFrameLayout extends _i1.Mock implements _i2.FrameLayout { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.FrameLayout pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeFrameLayout_10( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeFrameLayout_10( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.FrameLayout); + + @override + _i6.Future addView(_i2.View? view) => (super.noSuchMethod( + Invocation.method( + #addView, + [view], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [ImaSdkFactory]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockImaSdkFactory extends _i1.Mock implements _i2.ImaSdkFactory { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future<_i2.ImaSdkSettings> createImaSdkSettings() => (super.noSuchMethod( + Invocation.method( + #createImaSdkSettings, + [], + ), + returnValue: + _i6.Future<_i2.ImaSdkSettings>.value(_FakeImaSdkSettings_11( + this, + Invocation.method( + #createImaSdkSettings, + [], + ), + )), + returnValueForMissingStub: + _i6.Future<_i2.ImaSdkSettings>.value(_FakeImaSdkSettings_11( + this, + Invocation.method( + #createImaSdkSettings, + [], + ), + )), + ) as _i6.Future<_i2.ImaSdkSettings>); + + @override + _i6.Future<_i2.AdsLoader> createAdsLoader( + _i2.ImaSdkSettings? settings, + _i2.AdDisplayContainer? container, + ) => + (super.noSuchMethod( + Invocation.method( + #createAdsLoader, + [ + settings, + container, + ], + ), + returnValue: _i6.Future<_i2.AdsLoader>.value(_FakeAdsLoader_8( + this, + Invocation.method( + #createAdsLoader, + [ + settings, + container, + ], + ), + )), + returnValueForMissingStub: + _i6.Future<_i2.AdsLoader>.value(_FakeAdsLoader_8( + this, + Invocation.method( + #createAdsLoader, + [ + settings, + container, + ], + ), + )), + ) as _i6.Future<_i2.AdsLoader>); + + @override + _i6.Future<_i2.AdsRequest> createAdsRequest() => (super.noSuchMethod( + Invocation.method( + #createAdsRequest, + [], + ), + returnValue: _i6.Future<_i2.AdsRequest>.value(_FakeAdsRequest_9( + this, + Invocation.method( + #createAdsRequest, + [], + ), + )), + returnValueForMissingStub: + _i6.Future<_i2.AdsRequest>.value(_FakeAdsRequest_9( + this, + Invocation.method( + #createAdsRequest, + [], + ), + )), + ) as _i6.Future<_i2.AdsRequest>); + + @override + _i2.ImaSdkFactory pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeImaSdkFactory_12( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeImaSdkFactory_12( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.ImaSdkFactory); +} + +/// A class which mocks [ImaSdkSettings]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockImaSdkSettings extends _i1.Mock implements _i2.ImaSdkSettings { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.ImaSdkSettings pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeImaSdkSettings_11( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeImaSdkSettings_11( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.ImaSdkSettings); +} + +/// A class which mocks [VideoAdPlayer]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockVideoAdPlayer extends _i1.Mock implements _i2.VideoAdPlayer { + @override + void Function( + _i2.VideoAdPlayer, + _i2.VideoAdPlayerCallback, + ) get addCallback => (super.noSuchMethod( + Invocation.getter(#addCallback), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.VideoAdPlayerCallback callback, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.VideoAdPlayerCallback callback, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.VideoAdPlayerCallback, + )); + + @override + void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + _i2.AdPodInfo, + ) get loadAd => (super.noSuchMethod( + Invocation.getter(#loadAd), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + _i2.AdPodInfo adPodInfo, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + _i2.AdPodInfo adPodInfo, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + _i2.AdPodInfo, + )); + + @override + void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + ) get pauseAd => (super.noSuchMethod( + Invocation.getter(#pauseAd), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + )); + + @override + void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + ) get playAd => (super.noSuchMethod( + Invocation.getter(#playAd), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + )); + + @override + void Function(_i2.VideoAdPlayer) get release => (super.noSuchMethod( + Invocation.getter(#release), + returnValue: (_i2.VideoAdPlayer pigeon_instance) {}, + returnValueForMissingStub: (_i2.VideoAdPlayer pigeon_instance) {}, + ) as void Function(_i2.VideoAdPlayer)); + + @override + void Function( + _i2.VideoAdPlayer, + _i2.VideoAdPlayerCallback, + ) get removeCallback => (super.noSuchMethod( + Invocation.getter(#removeCallback), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.VideoAdPlayerCallback callback, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.VideoAdPlayerCallback callback, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.VideoAdPlayerCallback, + )); + + @override + void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + ) get stopAd => (super.noSuchMethod( + Invocation.getter(#stopAd), + returnValue: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + returnValueForMissingStub: ( + _i2.VideoAdPlayer pigeon_instance, + _i2.AdMediaInfo adMediaInfo, + ) {}, + ) as void Function( + _i2.VideoAdPlayer, + _i2.AdMediaInfo, + )); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future setVolume(int? value) => (super.noSuchMethod( + Invocation.method( + #setVolume, + [value], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future setAdProgress(_i2.VideoProgressUpdate? progress) => + (super.noSuchMethod( + Invocation.method( + #setAdProgress, + [progress], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i2.VideoAdPlayer pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeVideoAdPlayer_13( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeVideoAdPlayer_13( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.VideoAdPlayer); +} + +/// A class which mocks [VideoAdPlayerCallback]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockVideoAdPlayerCallback extends _i1.Mock + implements _i2.VideoAdPlayerCallback { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future onAdProgress( + _i2.AdMediaInfo? adMediaInfo, + _i2.VideoProgressUpdate? videoProgressUpdate, + ) => + (super.noSuchMethod( + Invocation.method( + #onAdProgress, + [ + adMediaInfo, + videoProgressUpdate, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onBuffering(_i2.AdMediaInfo? adMediaInfo) => + (super.noSuchMethod( + Invocation.method( + #onBuffering, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onContentComplete() => (super.noSuchMethod( + Invocation.method( + #onContentComplete, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onEnded(_i2.AdMediaInfo? adMediaInfo) => (super.noSuchMethod( + Invocation.method( + #onEnded, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onError(_i2.AdMediaInfo? adMediaInfo) => (super.noSuchMethod( + Invocation.method( + #onError, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onLoaded(_i2.AdMediaInfo? adMediaInfo) => + (super.noSuchMethod( + Invocation.method( + #onLoaded, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onPause(_i2.AdMediaInfo? adMediaInfo) => (super.noSuchMethod( + Invocation.method( + #onPause, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onPlay(_i2.AdMediaInfo? adMediaInfo) => (super.noSuchMethod( + Invocation.method( + #onPlay, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onResume(_i2.AdMediaInfo? adMediaInfo) => + (super.noSuchMethod( + Invocation.method( + #onResume, + [adMediaInfo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future onVolumeChanged( + _i2.AdMediaInfo? adMediaInfo, + int? percentage, + ) => + (super.noSuchMethod( + Invocation.method( + #onVolumeChanged, + [ + adMediaInfo, + percentage, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i2.VideoAdPlayerCallback pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeVideoAdPlayerCallback_14( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeVideoAdPlayerCallback_14( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.VideoAdPlayerCallback); +} + +/// A class which mocks [VideoView]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockVideoView extends _i1.Mock implements _i2.VideoView { + @override + void Function( + _i2.VideoView, + _i2.MediaPlayer, + int, + int, + ) get onError => (super.noSuchMethod( + Invocation.getter(#onError), + returnValue: ( + _i2.VideoView pigeon_instance, + _i2.MediaPlayer player, + int what, + int extra, + ) {}, + returnValueForMissingStub: ( + _i2.VideoView pigeon_instance, + _i2.MediaPlayer player, + int what, + int extra, + ) {}, + ) as void Function( + _i2.VideoView, + _i2.MediaPlayer, + int, + int, + )); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i6.Future setVideoUri(String? uri) => (super.noSuchMethod( + Invocation.method( + #setVideoUri, + [uri], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future getCurrentPosition() => (super.noSuchMethod( + Invocation.method( + #getCurrentPosition, + [], + ), + returnValue: _i6.Future.value(0), + returnValueForMissingStub: _i6.Future.value(0), + ) as _i6.Future); + + @override + _i2.VideoView pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeVideoView_15( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeVideoView_15( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.VideoView); +} + +/// A class which mocks [SurfaceAndroidViewController]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockSurfaceAndroidViewController extends _i1.Mock + implements _i4.SurfaceAndroidViewController { + @override + bool get requiresViewComposition => (super.noSuchMethod( + Invocation.getter(#requiresViewComposition), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + int get viewId => (super.noSuchMethod( + Invocation.getter(#viewId), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + bool get awaitingCreation => (super.noSuchMethod( + Invocation.getter(#awaitingCreation), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + _i4.PointTransformer get pointTransformer => (super.noSuchMethod( + Invocation.getter(#pointTransformer), + returnValue: (_i3.Offset position) => _FakeOffset_16( + this, + Invocation.getter(#pointTransformer), + ), + returnValueForMissingStub: (_i3.Offset position) => _FakeOffset_16( + this, + Invocation.getter(#pointTransformer), + ), + ) as _i4.PointTransformer); + + @override + set pointTransformer(_i4.PointTransformer? transformer) => super.noSuchMethod( + Invocation.setter( + #pointTransformer, + transformer, + ), + returnValueForMissingStub: null, + ); + + @override + bool get isCreated => (super.noSuchMethod( + Invocation.getter(#isCreated), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + List<_i4.PlatformViewCreatedCallback> get createdCallbacks => + (super.noSuchMethod( + Invocation.getter(#createdCallbacks), + returnValue: <_i4.PlatformViewCreatedCallback>[], + returnValueForMissingStub: <_i4.PlatformViewCreatedCallback>[], + ) as List<_i4.PlatformViewCreatedCallback>); + + @override + _i6.Future setOffset(_i3.Offset? off) => (super.noSuchMethod( + Invocation.method( + #setOffset, + [off], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future create({ + _i3.Size? size, + _i3.Offset? position, + }) => + (super.noSuchMethod( + Invocation.method( + #create, + [], + { + #size: size, + #position: position, + }, + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future<_i3.Size> setSize(_i3.Size? size) => (super.noSuchMethod( + Invocation.method( + #setSize, + [size], + ), + returnValue: _i6.Future<_i3.Size>.value(_FakeSize_17( + this, + Invocation.method( + #setSize, + [size], + ), + )), + returnValueForMissingStub: _i6.Future<_i3.Size>.value(_FakeSize_17( + this, + Invocation.method( + #setSize, + [size], + ), + )), + ) as _i6.Future<_i3.Size>); + + @override + _i6.Future sendMotionEvent(_i4.AndroidMotionEvent? event) => + (super.noSuchMethod( + Invocation.method( + #sendMotionEvent, + [event], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + void addOnPlatformViewCreatedListener( + _i4.PlatformViewCreatedCallback? listener) => + super.noSuchMethod( + Invocation.method( + #addOnPlatformViewCreatedListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + void removeOnPlatformViewCreatedListener( + _i4.PlatformViewCreatedCallback? listener) => + super.noSuchMethod( + Invocation.method( + #removeOnPlatformViewCreatedListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + _i6.Future setLayoutDirection(_i3.TextDirection? layoutDirection) => + (super.noSuchMethod( + Invocation.method( + #setLayoutDirection, + [layoutDirection], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future dispatchPointerEvent(_i4.PointerEvent? event) => + (super.noSuchMethod( + Invocation.method( + #dispatchPointerEvent, + [event], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future clearFocus() => (super.noSuchMethod( + Invocation.method( + #clearFocus, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future dispose() => (super.noSuchMethod( + Invocation.method( + #dispose, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [PlatformViewsServiceProxy]. +/// +/// See the documentation for Mockito's code generation for more information. +// ignore: must_be_immutable +class MockPlatformViewsServiceProxy extends _i1.Mock + implements _i7.PlatformViewsServiceProxy { + @override + _i4.ExpensiveAndroidViewController initExpensiveAndroidView({ + required int? id, + required String? viewType, + required _i3.TextDirection? layoutDirection, + dynamic creationParams, + _i4.MessageCodec? creationParamsCodec, + _i3.VoidCallback? onFocus, + }) => + (super.noSuchMethod( + Invocation.method( + #initExpensiveAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + returnValue: _FakeExpensiveAndroidViewController_18( + this, + Invocation.method( + #initExpensiveAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + ), + returnValueForMissingStub: _FakeExpensiveAndroidViewController_18( + this, + Invocation.method( + #initExpensiveAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + ), + ) as _i4.ExpensiveAndroidViewController); + + @override + _i4.SurfaceAndroidViewController initSurfaceAndroidView({ + required int? id, + required String? viewType, + required _i3.TextDirection? layoutDirection, + dynamic creationParams, + _i4.MessageCodec? creationParamsCodec, + _i3.VoidCallback? onFocus, + }) => + (super.noSuchMethod( + Invocation.method( + #initSurfaceAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + returnValue: _FakeSurfaceAndroidViewController_19( + this, + Invocation.method( + #initSurfaceAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + ), + returnValueForMissingStub: _FakeSurfaceAndroidViewController_19( + this, + Invocation.method( + #initSurfaceAndroidView, + [], + { + #id: id, + #viewType: viewType, + #layoutDirection: layoutDirection, + #creationParams: creationParams, + #creationParamsCodec: creationParamsCodec, + #onFocus: onFocus, + }, + ), + ), + ) as _i4.SurfaceAndroidViewController); +} diff --git a/packages/interactive_media_ads/test/android/ads_manager_tests.dart b/packages/interactive_media_ads/test/android/ads_manager_tests.dart new file mode 100644 index 000000000000..b05811102cad --- /dev/null +++ b/packages/interactive_media_ads/test/android/ads_manager_tests.dart @@ -0,0 +1,136 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:interactive_media_ads/src/android/android_ads_manager.dart'; +import 'package:interactive_media_ads/src/android/android_ads_manager_delegate.dart'; +import 'package:interactive_media_ads/src/android/interactive_media_ads.g.dart' + as ima; +import 'package:interactive_media_ads/src/android/interactive_media_ads_proxy.dart'; +import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; + +import 'ads_manager_tests.mocks.dart'; + +@GenerateNiceMocks(>[ + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), + MockSpec(), +]) +void main() { + group('AndroidAdsManager', () { + test('destroy', () { + final MockAdsManager mockAdsManager = MockAdsManager(); + final AndroidAdsManager adsManager = AndroidAdsManager(mockAdsManager); + adsManager.destroy(); + + verify(mockAdsManager.destroy()); + }); + + test('init', () { + final MockAdsManager mockAdsManager = MockAdsManager(); + final AndroidAdsManager adsManager = AndroidAdsManager(mockAdsManager); + adsManager.init(AdsManagerInitParams()); + + verify(mockAdsManager.init()); + }); + + test('start', () { + final MockAdsManager mockAdsManager = MockAdsManager(); + final AndroidAdsManager adsManager = AndroidAdsManager(mockAdsManager); + adsManager.start(AdsManagerStartParams()); + + verify(mockAdsManager.start()); + }); + + test('onAdEvent', () async { + final MockAdsManager mockAdsManager = MockAdsManager(); + + late final void Function( + ima.AdEventListener, + ima.AdEvent, + ) onAdEventCallback; + + final InteractiveMediaAdsProxy proxy = InteractiveMediaAdsProxy( + newAdEventListener: ({ + required void Function( + ima.AdEventListener, + ima.AdEvent, + ) onAdEvent, + }) { + onAdEventCallback = onAdEvent; + return MockAdEventListener(); + }, + newAdErrorListener: ({required dynamic onAdError}) { + return MockAdErrorListener(); + }, + ); + + final AndroidAdsManager adsManager = AndroidAdsManager( + mockAdsManager, + proxy: proxy, + ); + await adsManager.setAdsManagerDelegate( + AndroidAdsManagerDelegate( + PlatformAdsManagerDelegateCreationParams( + onAdEvent: expectAsync1((_) {}), + ), + ), + ); + + final MockAdEvent mockAdEvent = MockAdEvent(); + when(mockAdEvent.type).thenReturn(ima.AdEventType.allAdsCompleted); + onAdEventCallback(MockAdEventListener(), mockAdEvent); + }); + + test('onAdErrorEvent', () async { + final MockAdsManager mockAdsManager = MockAdsManager(); + + late final void Function( + ima.AdErrorListener, + ima.AdErrorEvent, + ) onAdErrorCallback; + + final InteractiveMediaAdsProxy proxy = InteractiveMediaAdsProxy( + newAdEventListener: ({required dynamic onAdEvent}) { + return MockAdEventListener(); + }, + newAdErrorListener: ({ + required void Function( + ima.AdErrorListener, + ima.AdErrorEvent, + ) onAdError, + }) { + onAdErrorCallback = onAdError; + return MockAdErrorListener(); + }, + ); + + final AndroidAdsManager adsManager = AndroidAdsManager( + mockAdsManager, + proxy: proxy, + ); + await adsManager.setAdsManagerDelegate( + AndroidAdsManagerDelegate( + PlatformAdsManagerDelegateCreationParams( + onAdErrorEvent: expectAsync1((_) {}), + ), + ), + ); + + final MockAdErrorEvent mockErrorEvent = MockAdErrorEvent(); + final MockAdError mockError = MockAdError(); + when(mockError.errorType).thenReturn(ima.AdErrorType.load); + when(mockError.errorCode) + .thenReturn(ima.AdErrorCode.adsRequestNetworkError); + when(mockError.message).thenReturn('error message'); + when(mockErrorEvent.error).thenReturn(mockError); + onAdErrorCallback(MockAdErrorListener(), mockErrorEvent); + }); + }); +} diff --git a/packages/interactive_media_ads/test/android/ads_manager_tests.mocks.dart b/packages/interactive_media_ads/test/android/ads_manager_tests.mocks.dart new file mode 100644 index 000000000000..f86c6778845b --- /dev/null +++ b/packages/interactive_media_ads/test/android/ads_manager_tests.mocks.dart @@ -0,0 +1,501 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in interactive_media_ads/test/android/ads_manager_tests.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i4; + +import 'package:interactive_media_ads/src/android/interactive_media_ads.g.dart' + as _i2; +import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i3; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakePigeonInstanceManager_0 extends _i1.SmartFake + implements _i2.PigeonInstanceManager { + _FakePigeonInstanceManager_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdError_1 extends _i1.SmartFake implements _i2.AdError { + _FakeAdError_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdErrorEvent_2 extends _i1.SmartFake implements _i2.AdErrorEvent { + _FakeAdErrorEvent_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdErrorListener_3 extends _i1.SmartFake + implements _i2.AdErrorListener { + _FakeAdErrorListener_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdEvent_4 extends _i1.SmartFake implements _i2.AdEvent { + _FakeAdEvent_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdEventListener_5 extends _i1.SmartFake + implements _i2.AdEventListener { + _FakeAdEventListener_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAdsManager_6 extends _i1.SmartFake implements _i2.AdsManager { + _FakeAdsManager_6( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [AdError]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdError extends _i1.Mock implements _i2.AdError { + @override + _i2.AdErrorCode get errorCode => (super.noSuchMethod( + Invocation.getter(#errorCode), + returnValue: _i2.AdErrorCode.adsPlayerWasNotProvided, + returnValueForMissingStub: _i2.AdErrorCode.adsPlayerWasNotProvided, + ) as _i2.AdErrorCode); + + @override + int get errorCodeNumber => (super.noSuchMethod( + Invocation.getter(#errorCodeNumber), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + _i2.AdErrorType get errorType => (super.noSuchMethod( + Invocation.getter(#errorType), + returnValue: _i2.AdErrorType.load, + returnValueForMissingStub: _i2.AdErrorType.load, + ) as _i2.AdErrorType); + + @override + String get message => (super.noSuchMethod( + Invocation.getter(#message), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#message), + ), + returnValueForMissingStub: _i3.dummyValue( + this, + Invocation.getter(#message), + ), + ) as String); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdError pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdError_1( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdError_1( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdError); +} + +/// A class which mocks [AdErrorEvent]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdErrorEvent extends _i1.Mock implements _i2.AdErrorEvent { + @override + _i2.AdError get error => (super.noSuchMethod( + Invocation.getter(#error), + returnValue: _FakeAdError_1( + this, + Invocation.getter(#error), + ), + returnValueForMissingStub: _FakeAdError_1( + this, + Invocation.getter(#error), + ), + ) as _i2.AdError); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdErrorEvent pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdErrorEvent_2( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdErrorEvent_2( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdErrorEvent); +} + +/// A class which mocks [AdErrorListener]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdErrorListener extends _i1.Mock implements _i2.AdErrorListener { + @override + void Function( + _i2.AdErrorListener, + _i2.AdErrorEvent, + ) get onAdError => (super.noSuchMethod( + Invocation.getter(#onAdError), + returnValue: ( + _i2.AdErrorListener pigeon_instance, + _i2.AdErrorEvent event, + ) {}, + returnValueForMissingStub: ( + _i2.AdErrorListener pigeon_instance, + _i2.AdErrorEvent event, + ) {}, + ) as void Function( + _i2.AdErrorListener, + _i2.AdErrorEvent, + )); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdErrorListener pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdErrorListener_3( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdErrorListener_3( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdErrorListener); +} + +/// A class which mocks [AdEvent]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdEvent extends _i1.Mock implements _i2.AdEvent { + @override + _i2.AdEventType get type => (super.noSuchMethod( + Invocation.getter(#type), + returnValue: _i2.AdEventType.adBreakEnded, + returnValueForMissingStub: _i2.AdEventType.adBreakEnded, + ) as _i2.AdEventType); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdEvent pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdEvent_4( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdEvent_4( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdEvent); +} + +/// A class which mocks [AdEventListener]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdEventListener extends _i1.Mock implements _i2.AdEventListener { + @override + void Function( + _i2.AdEventListener, + _i2.AdEvent, + ) get onAdEvent => (super.noSuchMethod( + Invocation.getter(#onAdEvent), + returnValue: ( + _i2.AdEventListener pigeon_instance, + _i2.AdEvent event, + ) {}, + returnValueForMissingStub: ( + _i2.AdEventListener pigeon_instance, + _i2.AdEvent event, + ) {}, + ) as void Function( + _i2.AdEventListener, + _i2.AdEvent, + )); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i2.AdEventListener pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdEventListener_5( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdEventListener_5( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdEventListener); +} + +/// A class which mocks [AdsManager]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockAdsManager extends _i1.Mock implements _i2.AdsManager { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i4.Future discardAdBreak() => (super.noSuchMethod( + Invocation.method( + #discardAdBreak, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future pause() => (super.noSuchMethod( + Invocation.method( + #pause, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future start() => (super.noSuchMethod( + Invocation.method( + #start, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i2.AdsManager pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeAdsManager_6( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeAdsManager_6( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.AdsManager); + + @override + _i4.Future addAdErrorListener(_i2.AdErrorListener? errorListener) => + (super.noSuchMethod( + Invocation.method( + #addAdErrorListener, + [errorListener], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future addAdEventListener(_i2.AdEventListener? adEventListener) => + (super.noSuchMethod( + Invocation.method( + #addAdEventListener, + [adEventListener], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future destroy() => (super.noSuchMethod( + Invocation.method( + #destroy, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future init() => (super.noSuchMethod( + Invocation.method( + #init, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); +} diff --git a/packages/interactive_media_ads/test/version_test.dart b/packages/interactive_media_ads/test/version_test.dart new file mode 100644 index 000000000000..0bd444e995ba --- /dev/null +++ b/packages/interactive_media_ads/test/version_test.dart @@ -0,0 +1,27 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('AdsRequestProxyApi.pluginVersion matches pubspec version', () { + final String pubspecPath = '${Directory.current.path}/pubspec.yaml'; + final String pubspec = File(pubspecPath).readAsStringSync(); + final RegExp regex = RegExp(r'version:\s*(.*?) #'); + final RegExpMatch? match = regex.firstMatch(pubspec); + final String pubspecVersion = match!.group(1)!.trim(); + + final String adsRequestProxyApiPath = + '${Directory.current.path}/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt'; + final String apiFileAsString = + File(adsRequestProxyApiPath).readAsStringSync(); + + expect( + apiFileAsString, + contains('const val pluginVersion = "$pubspecVersion"'), + ); + }); +}