Skip to content

Commit 433390d

Browse files
Mobile Ads Developer RelationsLTPhantom
authored andcommitted
Set Age Restricted for InMobi with GMA SDK TFUA
PiperOrigin-RevId: 854339131
1 parent f807610 commit 433390d

File tree

3 files changed

+55
-14
lines changed

3 files changed

+55
-14
lines changed

ThirdPartyAdapters/inmobi/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## InMobi Android Mediation Adapter Changelog
22

3+
#### Next Version
4+
- Maps GMA SDK Underage consent flags to InMobi SDK age restricted method.
5+
36
#### Version 11.1.0.0
47
- Verified compatibility with InMobi Kotlin SDK version 11.1.0.
58
- RewardedInterstitial support added.

ThirdPartyAdapters/inmobi/inmobi/src/main/java/com/google/ads/mediation/inmobi/InMobiAdapterUtils.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,18 @@ public static void configureGlobalTargeting(Bundle extras) {
140140

141141
@VisibleForTesting
142142
static void setIsAgeRestricted(InMobiSdkWrapper inMobiSdkWrapper) {
143-
// If the COPPA value is unspecified in GMA SDK, we don't default it to either one since the
144-
// value could have been updated before.
145-
if (MobileAds.getRequestConfiguration().getTagForChildDirectedTreatment()
146-
== RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE) {
143+
RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration();
144+
// If the COPPA or underage consent value is unspecified in GMA SDK, we don't default it to
145+
// either one since the value could have been updated before.
146+
if (requestConfiguration.getTagForChildDirectedTreatment()
147+
== RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE
148+
|| requestConfiguration.getTagForUnderAgeOfConsent()
149+
== RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE) {
147150
inMobiSdkWrapper.setIsAgeRestricted(true);
148-
} else if (MobileAds.getRequestConfiguration().getTagForChildDirectedTreatment()
149-
== RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE) {
151+
} else if (requestConfiguration.getTagForChildDirectedTreatment()
152+
== RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE
153+
|| requestConfiguration.getTagForUnderAgeOfConsent()
154+
== RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE) {
150155
inMobiSdkWrapper.setIsAgeRestricted(false);
151156
}
152157
}

ThirdPartyAdapters/inmobi/inmobi/src/test/kotlin/com/google/ads/mediation/inmobi/InMobiAdapterUtilsTest.kt

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,22 @@ class InMobiAdapterUtilsTest {
5858
@Test
5959
fun setIsAgeRestricted_whenCOPPASet_setsAgeRestrictedTrueOnInMobiSDK() {
6060
val inMobiSdkWrapper = mock<InMobiSdkWrapper>()
61-
setCOPPAOnMobileAdsRequestConfiguration(
62-
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE
61+
setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(
62+
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE,
63+
RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED,
64+
)
65+
66+
InMobiAdapterUtils.setIsAgeRestricted(inMobiSdkWrapper)
67+
68+
verify(inMobiSdkWrapper).setIsAgeRestricted(true)
69+
}
70+
71+
@Test
72+
fun setIsAgeRestricted_whenUnderAgeConsentSet_setsAgeRestrictedTrueOnInMobiSDK() {
73+
val inMobiSdkWrapper = mock<InMobiSdkWrapper>()
74+
setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(
75+
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED,
76+
RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE,
6377
)
6478

6579
InMobiAdapterUtils.setIsAgeRestricted(inMobiSdkWrapper)
@@ -70,8 +84,22 @@ class InMobiAdapterUtilsTest {
7084
@Test
7185
fun setIsAgeRestricted_whenCOPPANotSet_setsAgeRestrictedFalseOnInMobiSDK() {
7286
val inMobiSdkWrapper = mock<InMobiSdkWrapper>()
73-
setCOPPAOnMobileAdsRequestConfiguration(
74-
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE
87+
setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(
88+
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE,
89+
RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED,
90+
)
91+
92+
InMobiAdapterUtils.setIsAgeRestricted(inMobiSdkWrapper)
93+
94+
verify(inMobiSdkWrapper).setIsAgeRestricted(false)
95+
}
96+
97+
@Test
98+
fun setIsAgeRestricted_whenUnderAgeConsentNotSet_setsAgeRestrictedFalseOnInMobiSDK() {
99+
val inMobiSdkWrapper = mock<InMobiSdkWrapper>()
100+
setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(
101+
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED,
102+
RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE,
75103
)
76104

77105
InMobiAdapterUtils.setIsAgeRestricted(inMobiSdkWrapper)
@@ -82,8 +110,9 @@ class InMobiAdapterUtilsTest {
82110
@Test
83111
fun setIsAgeRestricted_whenCOPPANotSpecified_setIsAgeRestrictedIsNeverInvoked() {
84112
val inMobiSdkWrapper = mock<InMobiSdkWrapper>()
85-
setCOPPAOnMobileAdsRequestConfiguration(
86-
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED
113+
setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(
114+
RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED,
115+
RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED,
87116
)
88117

89118
InMobiAdapterUtils.setIsAgeRestricted(inMobiSdkWrapper)
@@ -241,9 +270,13 @@ class InMobiAdapterUtilsTest {
241270
assertThat(adError).isNull()
242271
}
243272

244-
private fun setCOPPAOnMobileAdsRequestConfiguration(value: Int) {
273+
private fun setCOPPAAndUnderAgeOnMobileAdsRequestConfiguration(coppa: Int, underAgeConsent: Int) {
245274
val requestConfiguration =
246-
MobileAds.getRequestConfiguration().toBuilder().setTagForChildDirectedTreatment(value).build()
275+
MobileAds.getRequestConfiguration()
276+
.toBuilder()
277+
.setTagForChildDirectedTreatment(coppa)
278+
.setTagForUnderAgeOfConsent(underAgeConsent)
279+
.build()
247280
MobileAds.setRequestConfiguration(requestConfiguration)
248281
}
249282

0 commit comments

Comments
 (0)