@@ -11,11 +11,11 @@ import com.google.android.gms.asterism.SetAsterismConsentRequestStatus
1111import com.google.android.gms.asterism.SetAsterismConsentResponse
1212import com.google.android.gms.asterism.asterismClient
1313import com.google.android.gms.asterism.consent
14+ import com.google.android.gms.asterism.consentVersion
1415import com.google.android.gms.asterism.deviceConsentSource
1516import com.google.android.gms.asterism.deviceConsentVersion
1617import com.google.android.gms.asterism.internal.IAsterismCallbacks
1718import com.google.android.gms.asterism.isDevicePnvrFlow
18- import com.google.android.gms.asterism.rcsFlowContext
1919import com.google.android.gms.asterism.status
2020import com.google.android.gms.common.api.Status
2121import com.squareup.wire.GrpcException
@@ -29,10 +29,10 @@ import org.microg.gms.constellation.core.RpcClient
2929import org.microg.gms.constellation.core.authManager
3030import org.microg.gms.constellation.core.proto.AsterismClient
3131import org.microg.gms.constellation.core.proto.AsterismConsent
32+ import org.microg.gms.constellation.core.proto.AsterismConsent.DeviceConsentVersion
3233import org.microg.gms.constellation.core.proto.AuditToken
3334import org.microg.gms.constellation.core.proto.Consent
3435import org.microg.gms.constellation.core.proto.ConsentVersion
35- import org.microg.gms.constellation.core.proto.FlowContext
3636import org.microg.gms.constellation.core.proto.OnDemandConsent
3737import org.microg.gms.constellation.core.proto.Param
3838import org.microg.gms.constellation.core.proto.RcsConsent
@@ -62,40 +62,44 @@ suspend fun handleSetAsterismConsent(
6262 return @withContext
6363 }
6464
65- val isRcsSpecificContext = request.rcsFlowContext in listOf (
66- FlowContext .FLOW_CONTEXT_RCS_CONSENT ,
67- FlowContext .FLOW_CONTEXT_RCS_DEFAULT_ON_OUT_OF_BOX ,
68- FlowContext .FLOW_CONTEXT_RCS_SAMSUNG_UNFREEZE
69- )
70-
71- if (request.asterismClient != AsterismClient .RCS && isRcsSpecificContext) {
72- Log .e(TAG , " RCS-only flow context cannot be used with non-RCS client" )
65+ if (request.asterismClient != AsterismClient .CONSTELLATION &&
66+ request.asterismClient != AsterismClient .RCS
67+ ) {
68+ Log .e(TAG , " Invalid asterismClientValue: ${request.asterismClientValue} " )
7369 callbacks.onConsentRegistered(
7470 Status .INTERNAL_ERROR ,
7571 SetAsterismConsentResponse (request.requestCode, " " , " " )
7672 )
7773 return @withContext
7874 }
7975
80- if (request.status == SetAsterismConsentRequestStatus .ON_DEMAND ) {
81- if (request.accountName.isNullOrBlank() && request.extras?.getString(" gaia_access_token" )
82- .isNullOrBlank()
83- ) {
84- Log .e(TAG , " ODC missing accountName and no gaia_access_token in extras" )
85- callbacks.onConsentRegistered(
86- Status .INTERNAL_ERROR ,
87- SetAsterismConsentResponse (request.requestCode, " " , " " )
88- )
89- return @withContext
90- }
76+ val isRcsSpecificConsentVersion = request.consentVersion in listOf (
77+ ConsentVersion .RCS_CONSENT ,
78+ ConsentVersion .RCS_DEFAULT_ON_LEGAL_FYI ,
79+ ConsentVersion .RCS_DEFAULT_ON_OUT_OF_BOX
80+ )
81+ val hasRcsFastPath = request.asterismClient == AsterismClient .RCS &&
82+ request.consentVersion in listOf (
83+ ConsentVersion .RCS_DEFAULT_ON_LEGAL_FYI ,
84+ ConsentVersion .RCS_DEFAULT_ON_OUT_OF_BOX ,
85+ ConsentVersion .RCS_DEFAULT_ON_LEGAL_FYI_IN_SETTINGS
86+ )
87+
88+ if (request.asterismClient != AsterismClient .RCS && isRcsSpecificConsentVersion) {
89+ Log .e(TAG , " RCS-only consent version cannot be used with non-RCS client" )
90+ callbacks.onConsentRegistered(
91+ Status .INTERNAL_ERROR ,
92+ SetAsterismConsentResponse (request.requestCode, " " , " " )
93+ )
94+ return @withContext
9195 }
9296
9397 val apiParams = Param .getList(request.extras)
9498
9599 var deviceConsent: AsterismConsent ? = null
96100 var rcsConsent: RcsConsent ? = null
97101 var onDemandConsent: OnDemandConsent ? = null
98- var flowContext : FlowContext = FlowContext . FLOW_CONTEXT_UNSPECIFIED
102+ var consentVersion : ConsentVersion ? = null
99103
100104 when {
101105 request.isDevicePnvrFlow() -> {
@@ -107,6 +111,24 @@ suspend fun handleSetAsterismConsent(
107111 }
108112
109113 request.status == SetAsterismConsentRequestStatus .ON_DEMAND -> {
114+ if (
115+ request.language.isNullOrBlank() ||
116+ request.field11.isNullOrBlank() ||
117+ request.accountName.isNullOrBlank() ||
118+ request.consentVariant.isNullOrBlank() ||
119+ request.consentTrigger.isNullOrBlank()
120+ ) {
121+ Log .e(
122+ TAG ,
123+ " ODC requires language, field11, accountName, consentVariant, and consentTrigger"
124+ )
125+ callbacks.onConsentRegistered(
126+ Status .INTERNAL_ERROR ,
127+ SetAsterismConsentResponse (request.requestCode, " " , " " )
128+ )
129+ return @withContext
130+ }
131+
110132 onDemandConsent = OnDemandConsent (context, request, request.extras)
111133 if (onDemandConsent == null ) {
112134 Log .e(TAG , " ODC Flow missing required fields, aborting." )
@@ -119,36 +141,43 @@ suspend fun handleSetAsterismConsent(
119141 }
120142
121143 else -> {
122- if (request.asterismClient == AsterismClient .CONSTELLATION ) {
123- if (request.language.isNullOrBlank() || request.consentVariant.isNullOrBlank()) {
124- Log .w(
125- TAG ,
126- " CONSTELLATION client requires language and consentVariant"
127- )
128- Log .w(
129- TAG ,
130- " language=${request.language} , consentVariant=${request.consentVariant} "
131- )
144+ if (request.status == SetAsterismConsentRequestStatus .RESOURCE_TOS ||
145+ request.status == SetAsterismConsentRequestStatus .RESOURCE_TOS_FALLBACK
146+ ) {
147+ if (request.tosResourceIds?.isEmpty() != false ) {
148+ Log .w(TAG , " Resource ToS requires tosResourceIds" )
132149 callbacks.onConsentRegistered(
133150 Status .INTERNAL_ERROR ,
134151 SetAsterismConsentResponse (request.requestCode, " " , " " )
135152 )
136153 return @withContext
137154 }
155+ } else if (! hasRcsFastPath &&
156+ (request.language.isNullOrBlank() || request.field11.isNullOrBlank())
157+ ) {
158+ Log .w(TAG , " Static string ToS requires language and field11" )
159+ Log .w(
160+ TAG ,
161+ " language=${request.language} , field11=${request.field11} "
162+ )
163+ callbacks.onConsentRegistered(
164+ Status .INTERNAL_ERROR ,
165+ SetAsterismConsentResponse (request.requestCode, " " , " " )
166+ )
167+ return @withContext
138168 }
139169
140170 val rcsConsentVersion = if (request.consent == Consent .CONSENTED ) {
141171 ConsentVersion .RCS_CONSENT
142172 } else {
143- ConsentVersion .RCS_OUT_OF_BOX
173+ ConsentVersion .CONSENT_VERSION_UNSPECIFIED
144174 }
145175
146176 rcsConsent = RcsConsent (
147177 consent = request.consent,
148178 consent_version = rcsConsentVersion
149179 )
150-
151- flowContext = request.rcsFlowContext
180+ consentVersion = request.consentVersion
152181 }
153182 }
154183
@@ -173,7 +202,7 @@ suspend fun handleSetAsterismConsent(
173202 device_consent = deviceConsent,
174203 rcs_consent = rcsConsent,
175204 on_demand_consent = onDemandConsent,
176- flow_context = flowContext ,
205+ consent_version = consentVersion ? : ConsentVersion . CONSENT_VERSION_UNSPECIFIED ,
177206 api_params = apiParams,
178207 audit_record = auditRecordBytes
179208 )
@@ -193,7 +222,7 @@ suspend fun handleSetAsterismConsent(
193222 throw e
194223 }
195224
196- if (deviceConsent?.consent_version == ConsentVersion .PHONE_VERIFICATION_REACHABILITY_INTL_SMS_CALLS ) {
225+ if (deviceConsent?.consent_version == DeviceConsentVersion .PHONE_VERIFICATION_REACHABILITY_INTL_SMS_CALLS ) {
197226 ConstellationStateStore .storePnvrNotice(
198227 context,
199228 deviceConsent.consent,
0 commit comments