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/inmobi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## InMobi Android Mediation Adapter Changelog

#### Next Version
- Maps GMA SDK Underage consent flags to InMobi SDK age restricted method.

#### Version 11.1.0.0
- Verified compatibility with InMobi Kotlin SDK version 11.1.0.
- RewardedInterstitial support added.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,18 @@ public static void configureGlobalTargeting(Bundle extras) {

@VisibleForTesting
static void setIsAgeRestricted(InMobiSdkWrapper inMobiSdkWrapper) {
// If the COPPA value is unspecified in GMA SDK, we don't default it to either one since the
// value could have been updated before.
if (MobileAds.getRequestConfiguration().getTagForChildDirectedTreatment()
== RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE) {
RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration();
// If the COPPA or underage consent value is unspecified in GMA SDK, we don't default it to
// either one since the value could have been updated before.
if (requestConfiguration.getTagForChildDirectedTreatment()
== RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE
|| requestConfiguration.getTagForUnderAgeOfConsent()
== RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE) {
inMobiSdkWrapper.setIsAgeRestricted(true);
} else if (MobileAds.getRequestConfiguration().getTagForChildDirectedTreatment()
== RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE) {
} else if (requestConfiguration.getTagForChildDirectedTreatment()
== RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE
|| requestConfiguration.getTagForUnderAgeOfConsent()
== RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE) {
inMobiSdkWrapper.setIsAgeRestricted(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,22 @@ class InMobiAdapterUtilsTest {
@Test
fun setIsAgeRestricted_whenCOPPASet_setsAgeRestrictedTrueOnInMobiSDK() {
val inMobiSdkWrapper = mock<InMobiSdkWrapper>()
setCOPPAOnMobileAdsRequestConfiguration(
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE
setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE,
RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED,
)

InMobiAdapterUtils.setIsAgeRestricted(inMobiSdkWrapper)

verify(inMobiSdkWrapper).setIsAgeRestricted(true)
}

@Test
fun setIsAgeRestricted_whenUnderAgeConsentSet_setsAgeRestrictedTrueOnInMobiSDK() {
val inMobiSdkWrapper = mock<InMobiSdkWrapper>()
setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED,
RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE,
)

InMobiAdapterUtils.setIsAgeRestricted(inMobiSdkWrapper)
Expand All @@ -70,8 +84,22 @@ class InMobiAdapterUtilsTest {
@Test
fun setIsAgeRestricted_whenCOPPANotSet_setsAgeRestrictedFalseOnInMobiSDK() {
val inMobiSdkWrapper = mock<InMobiSdkWrapper>()
setCOPPAOnMobileAdsRequestConfiguration(
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE
setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE,
RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED,
)

InMobiAdapterUtils.setIsAgeRestricted(inMobiSdkWrapper)

verify(inMobiSdkWrapper).setIsAgeRestricted(false)
}

@Test
fun setIsAgeRestricted_whenUnderAgeConsentNotSet_setsAgeRestrictedFalseOnInMobiSDK() {
val inMobiSdkWrapper = mock<InMobiSdkWrapper>()
setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED,
RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE,
)

InMobiAdapterUtils.setIsAgeRestricted(inMobiSdkWrapper)
Expand All @@ -82,8 +110,9 @@ class InMobiAdapterUtilsTest {
@Test
fun setIsAgeRestricted_whenCOPPANotSpecified_setIsAgeRestrictedIsNeverInvoked() {
val inMobiSdkWrapper = mock<InMobiSdkWrapper>()
setCOPPAOnMobileAdsRequestConfiguration(
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED
setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED,
RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED,
)

InMobiAdapterUtils.setIsAgeRestricted(inMobiSdkWrapper)
Expand Down Expand Up @@ -241,9 +270,13 @@ class InMobiAdapterUtilsTest {
assertThat(adError).isNull()
}

private fun setCOPPAOnMobileAdsRequestConfiguration(value: Int) {
private fun setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(coppa: Int, underAgeConsent: Int) {
val requestConfiguration =
MobileAds.getRequestConfiguration().toBuilder().setTagForChildDirectedTreatment(value).build()
MobileAds.getRequestConfiguration()
.toBuilder()
.setTagForChildDirectedTreatment(coppa)
.setTagForUnderAgeOfConsent(underAgeConsent)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
}

Expand Down
Loading