From 516c1eb5af060c4330c9b6a25318f20c58fddd0c Mon Sep 17 00:00:00 2001 From: KeelTrace <218190424+keeltrace@users.noreply.github.com> Date: Thu, 10 Sep 2026 13:08:15 -0700 Subject: [PATCH 1/2] fix(constellation): align automatic RCS consent request --- .../constellation/core/VerifyPhoneNumber.kt | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/play-services-constellation/core/src/main/kotlin/org/microg/gms/constellation/core/VerifyPhoneNumber.kt b/play-services-constellation/core/src/main/kotlin/org/microg/gms/constellation/core/VerifyPhoneNumber.kt index 9154d33134..4a20eff097 100644 --- a/play-services-constellation/core/src/main/kotlin/org/microg/gms/constellation/core/VerifyPhoneNumber.kt +++ b/play-services-constellation/core/src/main/kotlin/org/microg/gms/constellation/core/VerifyPhoneNumber.kt @@ -30,6 +30,7 @@ import org.microg.gms.constellation.core.proto.GetConsentResponse import org.microg.gms.constellation.core.proto.Param import org.microg.gms.constellation.core.proto.RcsConsent import org.microg.gms.constellation.core.proto.RequestHeader +import org.microg.gms.constellation.core.proto.RequestTrigger import org.microg.gms.constellation.core.proto.SetConsentRequest import org.microg.gms.constellation.core.proto.SyncRequest import org.microg.gms.constellation.core.proto.Verification @@ -50,6 +51,20 @@ private enum class ReadCallbackMode { TYPED } +internal data class RcsAutoConsentRequestSemantics( + val rcsConsentVersion: ConsentVersion, + val requestConsentVersion: ConsentVersion, + val triggerType: RequestTrigger.Type +) + +internal fun resolveRcsAutoConsentRequestSemantics( + consentType: ConsentVersion +): RcsAutoConsentRequestSemantics = RcsAutoConsentRequestSemantics( + rcsConsentVersion = ConsentVersion.RCS_CONSENT, + requestConsentVersion = consentType, + triggerType = RequestTrigger.Type.CONSENT_API_TRIGGER +) + @Suppress("DEPRECATION") suspend fun handleVerifyPhoneNumberV1( context: Context, @@ -301,14 +316,21 @@ private suspend fun runVerificationFlow( if (!consented) { Log.e(TAG, "Consent has not been set. Auto-setting consent.") val consentType = parseConsentVersion(request.extras) + val semantics = resolveRcsAutoConsentRequestSemantics(consentType) val setRequest = SetConsentRequest( - header_ = RequestHeader(context, sessionId, buildContext, "setConsent"), + header_ = RequestHeader( + context, + sessionId, + buildContext, + "setConsent", + semantics.triggerType + ), asterism_client = asterismClient, rcs_consent = RcsConsent( consent = Consent.CONSENTED, - consent_version = consentType + consent_version = semantics.rcsConsentVersion ), - consent_version = consentType, + consent_version = semantics.requestConsentVersion, api_params = Param.getList(request.extras) ) try { From d8dfdffa88e72269a5a73a657c3bf711af8143cf Mon Sep 17 00:00:00 2001 From: KeelTrace <218190424+keeltrace@users.noreply.github.com> Date: Thu, 10 Sep 2026 13:08:27 -0700 Subject: [PATCH 2/2] test(constellation): cover automatic RCS consent semantics --- .../RcsAutoConsentRequestSemanticsTest.kt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 play-services-constellation/core/src/test/kotlin/org/microg/gms/constellation/core/RcsAutoConsentRequestSemanticsTest.kt diff --git a/play-services-constellation/core/src/test/kotlin/org/microg/gms/constellation/core/RcsAutoConsentRequestSemanticsTest.kt b/play-services-constellation/core/src/test/kotlin/org/microg/gms/constellation/core/RcsAutoConsentRequestSemanticsTest.kt new file mode 100644 index 0000000000..cf25864acc --- /dev/null +++ b/play-services-constellation/core/src/test/kotlin/org/microg/gms/constellation/core/RcsAutoConsentRequestSemanticsTest.kt @@ -0,0 +1,33 @@ +package org.microg.gms.constellation.core + +import org.junit.Assert.assertEquals +import org.junit.Test +import org.microg.gms.constellation.core.proto.ConsentVersion +import org.microg.gms.constellation.core.proto.RequestTrigger + +class RcsAutoConsentRequestSemanticsTest { + @Test + fun preservesRequestedConsentVersionButUsesRcsConsentRecordVersion() { + val semantics = resolveRcsAutoConsentRequestSemantics( + ConsentVersion.RCS_DEFAULT_ON_LEGAL_FYI + ) + + assertEquals(ConsentVersion.RCS_CONSENT, semantics.rcsConsentVersion) + assertEquals( + ConsentVersion.RCS_DEFAULT_ON_LEGAL_FYI, + semantics.requestConsentVersion + ) + } + + @Test + fun usesConsentApiTrigger() { + val semantics = resolveRcsAutoConsentRequestSemantics( + ConsentVersion.RCS_DEFAULT_ON_OUT_OF_BOX + ) + + assertEquals( + RequestTrigger.Type.CONSENT_API_TRIGGER, + semantics.triggerType + ) + } +}