Skip to content

Commit 21463bf

Browse files
committed
- Version Bumped the AppLovin Flutter plugin and removed APIs that are not longer supported.
PiperOrigin-RevId: 718098871
1 parent 8ee89c4 commit 21463bf

File tree

13 files changed

+199
-366
lines changed

13 files changed

+199
-366
lines changed

packages/mediation/gma_mediation_applovin/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ android {
5050
}
5151

5252
dependencies {
53-
implementation 'com.applovin:applovin-sdk:12.6.1'
54-
implementation 'com.google.ads.mediation:applovin:12.6.1.0'
55-
implementation 'com.google.android.gms:play-services-ads:23.3.0'
53+
implementation 'com.applovin:applovin-sdk:13.0.1'
54+
implementation 'com.google.ads.mediation:applovin:13.0.1.0'
55+
implementation 'com.google.android.gms:play-services-ads:23.6.0'
5656
implementation 'androidx.core:core-ktx:1.8.0'
5757
testImplementation 'junit:junit:4.13.2'
5858
testImplementation 'androidx.test:core:1.5.0'

packages/mediation/gma_mediation_applovin/android/src/main/kotlin/io/flutter/plugins/googlemobileads/mediation/gma_mediation_applovin/AppLovinSDKApi.g.kt

Lines changed: 59 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// Autogenerated from Pigeon (v17.1.2), do not edit directly.
1+
// Autogenerated from Pigeon (v22.7.2), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
3+
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")
34

45
package io.flutter.plugins.googlemobileads.mediation.gma_mediation_applovin
56

@@ -16,125 +17,108 @@ private fun wrapResult(result: Any?): List<Any?> {
1617
}
1718

1819
private fun wrapError(exception: Throwable): List<Any?> {
19-
if (exception is FlutterError) {
20-
return listOf(
21-
exception.code,
22-
exception.message,
23-
exception.details
24-
)
20+
return if (exception is FlutterError) {
21+
listOf(exception.code, exception.message, exception.details)
2522
} else {
26-
return listOf(
23+
listOf(
2724
exception.javaClass.simpleName,
2825
exception.toString(),
29-
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)
26+
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception),
3027
)
3128
}
3229
}
3330

3431
/**
3532
* Error class for passing custom error details to Flutter via a thrown PlatformException.
33+
*
3634
* @property code The error code.
3735
* @property message The error message.
3836
* @property details The error details. Must be a datatype supported by the api codec.
3937
*/
40-
class FlutterError (
38+
class FlutterError(
4139
val code: String,
4240
override val message: String? = null,
43-
val details: Any? = null
41+
val details: Any? = null,
4442
) : Throwable()
43+
44+
private open class AppLovinSDKApiPigeonCodec : StandardMessageCodec() {
45+
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
46+
return super.readValueOfType(type, buffer)
47+
}
48+
49+
override fun writeValue(stream: ByteArrayOutputStream, value: Any?) {
50+
super.writeValue(stream, value)
51+
}
52+
}
53+
4554
/**
46-
* The generated classes set the channels to call the methods in the corresponding kotlin AppLovinSDKApi interface and swift AppLovinSDKApi protocol from the dart layer.
55+
* The generated classes set the channels to call the methods in the corresponding kotlin
56+
* AppLovinSDKApi interface and swift AppLovinSDKApi protocol from the dart layer.
4757
*
4858
* Generated interface from Pigeon that represents a handler of messages from Flutter.
4959
*/
5060
interface AppLovinSDKApi {
5161
/** Used to configure GDPR consent on the Android or iOS AppLovin SDK */
5262
fun setHasUserConsent(hasUserConsent: Boolean)
53-
/** Used to acknowledge that the user is in an age-restricted category on the Android or iOS AppLovin SDK */
54-
fun setIsAgeRestrictedUser(isAgeRestrictedUser: Boolean)
63+
5564
/** Used to opt out of the sale of personal information in AppLovin SDK. */
5665
fun setDoNotSell(doNotSell: Boolean)
57-
/** Used to initialize the Android or iOS AppLovin SDK. Can be called anytime before the adapter initialization to let AppLovin track events as soon as possible. */
58-
fun initializeSdk(sdkKey: String)
5966

6067
companion object {
6168
/** The codec used by AppLovinSDKApi. */
62-
val codec: MessageCodec<Any?> by lazy {
63-
StandardMessageCodec()
64-
}
69+
val codec: MessageCodec<Any?> by lazy { AppLovinSDKApiPigeonCodec() }
70+
6571
/** Sets up an instance of `AppLovinSDKApi` to handle messages through the `binaryMessenger`. */
66-
@Suppress("UNCHECKED_CAST")
67-
fun setUp(binaryMessenger: BinaryMessenger, api: AppLovinSDKApi?) {
72+
@JvmOverloads
73+
fun setUp(
74+
binaryMessenger: BinaryMessenger,
75+
api: AppLovinSDKApi?,
76+
messageChannelSuffix: String = "",
77+
) {
78+
val separatedMessageChannelSuffix =
79+
if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
6880
run {
69-
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.gma_mediation_applovin.AppLovinSDKApi.setHasUserConsent", codec)
81+
val channel =
82+
BasicMessageChannel<Any?>(
83+
binaryMessenger,
84+
"dev.flutter.pigeon.gma_mediation_applovin.AppLovinSDKApi.setHasUserConsent$separatedMessageChannelSuffix",
85+
codec,
86+
)
7087
if (api != null) {
7188
channel.setMessageHandler { message, reply ->
7289
val args = message as List<Any?>
7390
val hasUserConsentArg = args[0] as Boolean
74-
var wrapped: List<Any?>
75-
try {
76-
api.setHasUserConsent(hasUserConsentArg)
77-
wrapped = listOf<Any?>(null)
78-
} catch (exception: Throwable) {
79-
wrapped = wrapError(exception)
80-
}
91+
val wrapped: List<Any?> =
92+
try {
93+
api.setHasUserConsent(hasUserConsentArg)
94+
listOf(null)
95+
} catch (exception: Throwable) {
96+
wrapError(exception)
97+
}
8198
reply.reply(wrapped)
8299
}
83100
} else {
84101
channel.setMessageHandler(null)
85102
}
86103
}
87104
run {
88-
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.gma_mediation_applovin.AppLovinSDKApi.setIsAgeRestrictedUser", codec)
89-
if (api != null) {
90-
channel.setMessageHandler { message, reply ->
91-
val args = message as List<Any?>
92-
val isAgeRestrictedUserArg = args[0] as Boolean
93-
var wrapped: List<Any?>
94-
try {
95-
api.setIsAgeRestrictedUser(isAgeRestrictedUserArg)
96-
wrapped = listOf<Any?>(null)
97-
} catch (exception: Throwable) {
98-
wrapped = wrapError(exception)
99-
}
100-
reply.reply(wrapped)
101-
}
102-
} else {
103-
channel.setMessageHandler(null)
104-
}
105-
}
106-
run {
107-
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.gma_mediation_applovin.AppLovinSDKApi.setDoNotSell", codec)
105+
val channel =
106+
BasicMessageChannel<Any?>(
107+
binaryMessenger,
108+
"dev.flutter.pigeon.gma_mediation_applovin.AppLovinSDKApi.setDoNotSell$separatedMessageChannelSuffix",
109+
codec,
110+
)
108111
if (api != null) {
109112
channel.setMessageHandler { message, reply ->
110113
val args = message as List<Any?>
111114
val doNotSellArg = args[0] as Boolean
112-
var wrapped: List<Any?>
113-
try {
114-
api.setDoNotSell(doNotSellArg)
115-
wrapped = listOf<Any?>(null)
116-
} catch (exception: Throwable) {
117-
wrapped = wrapError(exception)
118-
}
119-
reply.reply(wrapped)
120-
}
121-
} else {
122-
channel.setMessageHandler(null)
123-
}
124-
}
125-
run {
126-
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.gma_mediation_applovin.AppLovinSDKApi.initializeSdk", codec)
127-
if (api != null) {
128-
channel.setMessageHandler { message, reply ->
129-
val args = message as List<Any?>
130-
val sdkKeyArg = args[0] as String
131-
var wrapped: List<Any?>
132-
try {
133-
api.initializeSdk(sdkKeyArg)
134-
wrapped = listOf<Any?>(null)
135-
} catch (exception: Throwable) {
136-
wrapped = wrapError(exception)
137-
}
115+
val wrapped: List<Any?> =
116+
try {
117+
api.setDoNotSell(doNotSellArg)
118+
listOf(null)
119+
} catch (exception: Throwable) {
120+
wrapError(exception)
121+
}
138122
reply.reply(wrapped)
139123
}
140124
} else {

packages/mediation/gma_mediation_applovin/android/src/main/kotlin/io/flutter/plugins/googlemobileads/mediation/gma_mediation_applovin/GmaMediationApplovinPlugin.kt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ package io.flutter.plugins.googlemobileads.mediation.gma_mediation_applovin
1616

1717
import android.content.Context
1818
import com.applovin.sdk.AppLovinPrivacySettings
19-
import com.applovin.sdk.AppLovinSdk
2019
import io.flutter.embedding.engine.plugins.FlutterPlugin
2120
import io.flutter.embedding.engine.plugins.activity.ActivityAware
2221
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
2322

24-
/** Links the Android dependency of the AppLovin Adapter and calls the AppLovin SDK APIs. */
25-
class GmaMediationApplovinPlugin: FlutterPlugin, ActivityAware, AppLovinSDKApi {
23+
/** Links the Android dependency of the AppLovin Adapter and calls the AppLovin SDK APIs. */
24+
class GmaMediationApplovinPlugin : FlutterPlugin, ActivityAware, AppLovinSDKApi {
2625
private lateinit var context: Context
2726

2827
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
@@ -34,22 +33,14 @@ class GmaMediationApplovinPlugin: FlutterPlugin, ActivityAware, AppLovinSDKApi {
3433
AppLovinSDKApi.setUp(binding.binaryMessenger, null)
3534
}
3635

37-
override fun setHasUserConsent(hasUserConsent: Boolean){
36+
override fun setHasUserConsent(hasUserConsent: Boolean) {
3837
AppLovinPrivacySettings.setHasUserConsent(hasUserConsent, context)
3938
}
4039

41-
override fun setIsAgeRestrictedUser(isAgeRestrictedUser: Boolean){
42-
AppLovinPrivacySettings.setIsAgeRestrictedUser(isAgeRestrictedUser, context)
43-
}
44-
4540
override fun setDoNotSell(doNotSell: Boolean) {
4641
AppLovinPrivacySettings.setDoNotSell(doNotSell, context)
4742
}
4843

49-
override fun initializeSdk(sdkKey: String) {
50-
AppLovinSdk.getInstance(sdkKey, null, context).initializeSdk()
51-
}
52-
5344
override fun onDetachedFromActivity() {}
5445

5546
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {}

packages/mediation/gma_mediation_applovin/android/src/test/kotlin/io/flutter/plugins/googlemobileads/mediation/gma_mediation_applovin/GmaMediationApplovinPluginTest.kt

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,25 @@ import android.content.Context
1818
import androidx.test.core.app.ApplicationProvider
1919
import androidx.test.ext.junit.runners.AndroidJUnit4
2020
import com.applovin.sdk.AppLovinPrivacySettings
21-
import com.applovin.sdk.AppLovinSdk
22-
import com.applovin.sdk.AppLovinSdk.getInstance
2321
import io.flutter.embedding.engine.plugins.FlutterPlugin
2422
import io.flutter.plugin.common.BinaryMessenger
2523
import org.junit.Test
2624
import org.junit.runner.RunWith
2725
import org.mockito.Mockito.mockStatic
28-
import org.mockito.kotlin.any
2926
import org.mockito.kotlin.doReturn
3027
import org.mockito.kotlin.eq
3128
import org.mockito.kotlin.mock
3229
import org.mockito.kotlin.verify
33-
import org.mockito.kotlin.whenever
3430

3531
@RunWith(AndroidJUnit4::class)
3632
internal class GmaMediationApplovinPluginTest {
3733
private val context = ApplicationProvider.getApplicationContext<Context>()
3834
private val mockBinaryMessenger = mock<BinaryMessenger>()
39-
private val mockFlutterPluginBinding = mock<FlutterPlugin.FlutterPluginBinding> {
40-
on { applicationContext } doReturn context
41-
on { binaryMessenger } doReturn mockBinaryMessenger
42-
}
35+
private val mockFlutterPluginBinding =
36+
mock<FlutterPlugin.FlutterPluginBinding> {
37+
on { applicationContext } doReturn context
38+
on { binaryMessenger } doReturn mockBinaryMessenger
39+
}
4340

4441
@Test
4542
fun setHasUserConsent_withTrueValue_invokesSetHasUserConsent() {
@@ -50,27 +47,7 @@ internal class GmaMediationApplovinPluginTest {
5047
plugin.setHasUserConsent(true)
5148

5249
mockedAppLovinPrivacySettings.verify {
53-
AppLovinPrivacySettings.setHasUserConsent(
54-
eq(true),
55-
eq(context)
56-
)
57-
}
58-
}
59-
}
60-
61-
@Test
62-
fun setIsAgeRestrictedUser_withTrueValue_invokesSetIsAgeRestrictedUser() {
63-
val plugin = GmaMediationApplovinPlugin()
64-
mockStatic(AppLovinPrivacySettings::class.java).use { mockedAppLovinPrivacySettings ->
65-
plugin.onAttachedToEngine(mockFlutterPluginBinding)
66-
67-
plugin.setIsAgeRestrictedUser(true)
68-
69-
mockedAppLovinPrivacySettings.verify {
70-
AppLovinPrivacySettings.setIsAgeRestrictedUser(
71-
eq(true),
72-
eq(context)
73-
)
50+
AppLovinPrivacySettings.setHasUserConsent(eq(true), eq(context))
7451
}
7552
}
7653
}
@@ -84,29 +61,8 @@ internal class GmaMediationApplovinPluginTest {
8461
plugin.setDoNotSell(true)
8562

8663
mockedAppLovinPrivacySettings.verify {
87-
AppLovinPrivacySettings.setDoNotSell(
88-
eq(true),
89-
eq(context)
90-
)
64+
AppLovinPrivacySettings.setDoNotSell(eq(true), eq(context))
9165
}
9266
}
9367
}
94-
95-
@Test
96-
fun initializeSdk_invokesinitializeSdk() {
97-
val plugin = GmaMediationApplovinPlugin()
98-
val mockAppLovinSdkInstance = mock<AppLovinSdk>()
99-
mockStatic(AppLovinSdk::class.java).use {
100-
plugin.onAttachedToEngine(mockFlutterPluginBinding)
101-
whenever(getInstance(eq(TEST_SDK_KEY), eq(null), eq(context))) doReturn mockAppLovinSdkInstance
102-
103-
plugin.initializeSdk(TEST_SDK_KEY)
104-
105-
verify(mockAppLovinSdkInstance).initializeSdk()
106-
}
107-
}
108-
109-
companion object {
110-
private const val TEST_SDK_KEY = "TEST_SDK_KEY"
111-
}
11268
}

packages/mediation/gma_mediation_applovin/example/ios/RunnerTests/GmaMediationApplovinPluginTests.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,57 +27,29 @@ class GmaMediationApplovinPluginTests: XCTestCase {
2727
XCTAssertEqual(appLovinSdkFake.hasUserConsent, true)
2828
}
2929

30-
func testSetIsAgeRestrictedUser() {
31-
let appLovinSdkFake = ALSdkFake()
32-
33-
GmaMediationApplovinPlugin(applovinSdk: appLovinSdkFake).setIsAgeRestrictedUser(isAgeRestrictedUser: true)
34-
35-
XCTAssertEqual(appLovinSdkFake.isAgeRestrictedUser, true)
36-
}
37-
3830
func testSetDoNotSell() {
3931
let appLovinSdkFake = ALSdkFake()
4032

4133
GmaMediationApplovinPlugin(applovinSdk: appLovinSdkFake).setDoNotSell(doNotSell: true)
4234

4335
XCTAssertEqual(appLovinSdkFake.doNotSell, true)
4436
}
45-
46-
func testInitializeSdk() {
47-
let appLovinSdkFake = ALSdkFake()
48-
49-
GmaMediationApplovinPlugin(applovinSdk: appLovinSdkFake).initializeSdk(sdkKey: "testKey")
50-
51-
XCTAssertEqual(appLovinSdkFake.initializeSdkCalls, 1)
52-
}
5337
}
5438

5539
class ALSdkFake: ALSdkProtocol {
5640
var hasUserConsent: Bool
57-
var isAgeRestrictedUser: Bool
5841
var doNotSell: Bool
59-
var initializeSdkCalls: Int
6042

6143
init() {
6244
hasUserConsent = false
63-
isAgeRestrictedUser = false
6445
doNotSell = false
65-
initializeSdkCalls = 0
6646
}
6747

6848
func setHasUserConsent(hasUserConsent: Bool) {
6949
self.hasUserConsent = hasUserConsent
7050
}
7151

72-
func setIsAgeRestrictedUser(isAgeRestrictedUser: Bool) {
73-
self.isAgeRestrictedUser = isAgeRestrictedUser
74-
}
75-
7652
func setDoNotSell(doNotSell: Bool) {
7753
self.doNotSell = doNotSell
7854
}
79-
80-
func initializeSdk(sdkKey: String) {
81-
initializeSdkCalls += 1
82-
}
8355
}

0 commit comments

Comments
 (0)