-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GDPR and CCPA consent APIs to Chartboost Flutter Adapter Plugin
PiperOrigin-RevId: 702353803
- Loading branch information
Showing
16 changed files
with
893 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
.../flutter/plugins/googlemobileads/mediation/gma_mediation_chartboost/ChartboostSDKApi.g.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
// Autogenerated from Pigeon (v22.6.2), do not edit directly. | ||
// See also: https://pub.dev/packages/pigeon | ||
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") | ||
|
||
package io.flutter.plugins.googlemobileads.mediation.gma_mediation_chartboost | ||
|
||
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<Any?> { | ||
return listOf(result) | ||
} | ||
|
||
private fun wrapError(exception: Throwable): List<Any?> { | ||
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) | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* 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() | ||
|
||
enum class ChartboostPrivacyStandard(val raw: Int) { | ||
GDPR(0), | ||
CCPA(1); | ||
|
||
companion object { | ||
fun ofRaw(raw: Int): ChartboostPrivacyStandard? { | ||
return values().firstOrNull { it.raw == raw } | ||
} | ||
} | ||
} | ||
private open class ChartboostSDKApiPigeonCodec : StandardMessageCodec() { | ||
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { | ||
return when (type) { | ||
129.toByte() -> { | ||
return (readValue(buffer) as Long?)?.let { | ||
ChartboostPrivacyStandard.ofRaw(it.toInt()) | ||
} | ||
} | ||
else -> super.readValueOfType(type, buffer) | ||
} | ||
} | ||
override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { | ||
when (value) { | ||
is ChartboostPrivacyStandard -> { | ||
stream.write(129) | ||
writeValue(stream, value.raw) | ||
} | ||
else -> super.writeValue(stream, value) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* The generated classes set the channels to call the methods in the | ||
* corresponding kotlin ChartboostSDKApi interface and swift ChartboostSDKApi | ||
* protocol from the dart layer. | ||
* | ||
* Generated interface from Pigeon that represents a handler of messages from Flutter. | ||
*/ | ||
interface ChartboostSDKApi { | ||
/** Used to configure GDPR consent on the Android or iOS Chartboost SDK */ | ||
fun setGDPRConsent(userConsent: Boolean) | ||
/** Used to opt out of the sale of personal information in Chartboost SDK. */ | ||
fun setCCPAConsent(userOptIn: Boolean) | ||
/** Used to clear any of the privacy data use consent above. */ | ||
fun clearDataUseConsent(privacyStandard: ChartboostPrivacyStandard) | ||
|
||
companion object { | ||
/** The codec used by ChartboostSDKApi. */ | ||
val codec: MessageCodec<Any?> by lazy { | ||
ChartboostSDKApiPigeonCodec() | ||
} | ||
/** Sets up an instance of `ChartboostSDKApi` to handle messages through the `binaryMessenger`. */ | ||
@JvmOverloads | ||
fun setUp(binaryMessenger: BinaryMessenger, api: ChartboostSDKApi?, messageChannelSuffix: String = "") { | ||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" | ||
run { | ||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.gma_mediation_chartboost.ChartboostSDKApi.setGDPRConsent$separatedMessageChannelSuffix", codec) | ||
if (api != null) { | ||
channel.setMessageHandler { message, reply -> | ||
val args = message as List<Any?> | ||
val userConsentArg = args[0] as Boolean | ||
val wrapped: List<Any?> = try { | ||
api.setGDPRConsent(userConsentArg) | ||
listOf(null) | ||
} catch (exception: Throwable) { | ||
wrapError(exception) | ||
} | ||
reply.reply(wrapped) | ||
} | ||
} else { | ||
channel.setMessageHandler(null) | ||
} | ||
} | ||
run { | ||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.gma_mediation_chartboost.ChartboostSDKApi.setCCPAConsent$separatedMessageChannelSuffix", codec) | ||
if (api != null) { | ||
channel.setMessageHandler { message, reply -> | ||
val args = message as List<Any?> | ||
val userOptInArg = args[0] as Boolean | ||
val wrapped: List<Any?> = try { | ||
api.setCCPAConsent(userOptInArg) | ||
listOf(null) | ||
} catch (exception: Throwable) { | ||
wrapError(exception) | ||
} | ||
reply.reply(wrapped) | ||
} | ||
} else { | ||
channel.setMessageHandler(null) | ||
} | ||
} | ||
run { | ||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.gma_mediation_chartboost.ChartboostSDKApi.clearDataUseConsent$separatedMessageChannelSuffix", codec) | ||
if (api != null) { | ||
channel.setMessageHandler { message, reply -> | ||
val args = message as List<Any?> | ||
val privacyStandardArg = args[0] as ChartboostPrivacyStandard | ||
val wrapped: List<Any?> = try { | ||
api.clearDataUseConsent(privacyStandardArg) | ||
listOf(null) | ||
} catch (exception: Throwable) { | ||
wrapError(exception) | ||
} | ||
reply.reply(wrapped) | ||
} | ||
} else { | ||
channel.setMessageHandler(null) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/mediation/gma_mediation_chartboost/example/ios/Flutter/Debug.xcconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" | ||
#include "Generated.xcconfig" |
1 change: 1 addition & 0 deletions
1
packages/mediation/gma_mediation_chartboost/example/ios/Flutter/Release.xcconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" | ||
#include "Generated.xcconfig" |
Oops, something went wrong.