Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ThirdPartyAdapters/pubmatic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## PubMatic Android Mediation Adapter Changelog

#### Next Version
- Maps `AgeRestrictedTreatment` to PubMatic's COPPA API.

#### Version 5.1.2.0
- Verified compatibility with Pubmatic SDK 5.1.2.

Expand Down
2 changes: 1 addition & 1 deletion ThirdPartyAdapters/pubmatic/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
kotlinVersion = '2.1.10'
kotlinVersion = '2.3.0'
}
repositories {
google()
Expand Down
251 changes: 251 additions & 0 deletions ThirdPartyAdapters/pubmatic/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions ThirdPartyAdapters/pubmatic/pubmatic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ dependencies {
implementation 'androidx.core:core-ktx:1.13.1'
// Check for a 'useNextGenGma' flag to use the next generation GMA SDK.
if (project.hasProperty('useNextGenGma')) {
implementation 'com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk:1.0.1'
implementation 'com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk:1.1.0'
} else {
implementation 'com.google.android.gms:play-services-ads:25.2.0'
implementation 'com.google.android.gms:play-services-ads:25.3.0'
}
implementation 'com.github.bumptech.glide:glide:4.16.0'

Expand All @@ -151,7 +151,7 @@ dependencies {
testImplementation "com.google.truth:truth:1.1.5"
testImplementation 'junit:junit:4.13.2'
testImplementation "org.jacoco:org.jacoco.core:$jacocoVersion"
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.21'
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib:2.3.0'
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.1.0'
testImplementation 'org.robolectric:robolectric:4.9'
testImplementation project(':adaptertestkit')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.annotation.VisibleForTesting
import com.google.android.gms.ads.AdError
import com.google.android.gms.ads.AdFormat
import com.google.android.gms.ads.AdSize
import com.google.android.gms.ads.AgeRestrictedTreatment
import com.google.android.gms.ads.MobileAds
import com.google.android.gms.ads.RequestConfiguration
import com.google.android.gms.ads.VersionInfo
Expand Down Expand Up @@ -115,9 +116,11 @@ constructor(
val tagForChildDirectedTreatment =
MobileAds.getRequestConfiguration().tagForChildDirectedTreatment
val tagForUnderAgeOfConsent = MobileAds.getRequestConfiguration().tagForUnderAgeOfConsent
val ageRestrictedTreatment = MobileAds.getRequestConfiguration().ageRestrictedTreatment
if (
tagForChildDirectedTreatment == RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE ||
tagForUnderAgeOfConsent == RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE
tagForUnderAgeOfConsent == RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE ||
ageRestrictedTreatment == AgeRestrictedTreatment.CHILD
) {
OpenWrapSDK.setCoppa(true)
} else if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import com.google.ads.mediation.pubmatic.PubMaticMediationAdapter.Companion.SDK_
import com.google.android.gms.ads.AdError
import com.google.android.gms.ads.AdFormat
import com.google.android.gms.ads.AdSize
import com.google.android.gms.ads.AgeRestrictedTreatment
import com.google.android.gms.ads.MobileAds
import com.google.android.gms.ads.RequestConfiguration
import com.google.android.gms.ads.RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE
Expand Down Expand Up @@ -161,6 +162,14 @@ class PubMaticMediationAdapterTest {

@Before
fun setUp() {
val requestConfiguration =
RequestConfiguration.Builder()
.setTagForChildDirectedTreatment(TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED)
.setTagForUnderAgeOfConsent(TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED)
.setAgeRestrictedTreatment(AgeRestrictedTreatment.UNSPECIFIED)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)

adapter = PubMaticMediationAdapter(pubMaticSignalGenerator, pubMaticAdFactory, mediationUtils)
}

Expand Down Expand Up @@ -289,6 +298,48 @@ class PubMaticMediationAdapterTest {
}
}

@Test
fun initialize_whenAgeRestrictedTreatmentChild_setsOpenWrapCoppaTrue() {
MobileAds.setRequestConfiguration(
RequestConfiguration.Builder()
.setTagForChildDirectedTreatment(TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED)
.setTagForUnderAgeOfConsent(TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED)
.setAgeRestrictedTreatment(AgeRestrictedTreatment.CHILD)
.build()
)

mockStatic(OpenWrapSDK::class.java).use { openWrapSdk ->
adapter.initialize(
context = context,
initializationCompleteCallback = mock(),
mediationConfigurations = emptyList(),
)

openWrapSdk.verify { setCoppa(eq(true)) }
}
}

@Test
fun initialize_whenAgeRestrictedTreatmentTeen_doesNotSetOpenWrapCoppa() {
MobileAds.setRequestConfiguration(
RequestConfiguration.Builder()
.setTagForChildDirectedTreatment(TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED)
.setTagForUnderAgeOfConsent(TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED)
.setAgeRestrictedTreatment(AgeRestrictedTreatment.TEEN)
.build()
)

mockStatic(OpenWrapSDK::class.java).use { openWrapSdk ->
adapter.initialize(
context = context,
initializationCompleteCallback = mock(),
mediationConfigurations = emptyList(),
)

openWrapSdk.verify({ setCoppa(any()) }, never())
}
}

@Test
fun initialize_initializesOpenWrapSdk() {
mockStatic(OpenWrapSDK::class.java).use { openWrapSdk ->
Expand Down
Loading