|
| 1 | +package com.google.android.gms.asterism |
| 2 | + |
| 3 | +import android.os.Bundle |
| 4 | +import android.os.Parcel |
| 5 | +import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable |
| 6 | +import com.google.android.gms.common.internal.safeparcel.SafeParcelable |
| 7 | +import com.google.android.gms.common.internal.safeparcel.SafeParcelable.Constructor |
| 8 | +import com.google.android.gms.common.internal.safeparcel.SafeParcelable.Field |
| 9 | +import com.google.android.gms.common.internal.safeparcel.SafeParcelable.Param |
| 10 | +import org.microg.gms.constellation.proto.AsterismClient |
| 11 | +import org.microg.gms.constellation.proto.Consent |
| 12 | +import org.microg.gms.constellation.proto.ConsentSource |
| 13 | +import org.microg.gms.constellation.proto.ConsentVersion |
| 14 | +import org.microg.gms.constellation.proto.FlowContext |
| 15 | + |
| 16 | +@SafeParcelable.Class |
| 17 | +data class SetAsterismConsentRequest |
| 18 | +@Constructor |
| 19 | +constructor( |
| 20 | + @JvmField @Param(1) @Field(1) val requestCode: Int, |
| 21 | + @JvmField @Param(2) @Field(2) val asterismClientValue: Int, |
| 22 | + @JvmField @Param(3) @Field(3) val flowContextValue: Int, |
| 23 | + @JvmField @Param(4) @Field(value = 4, type = "int[]") val tosResourceIds: IntArray?, |
| 24 | + @JvmField @Param(5) @Field(5) val timestamp: Long?, |
| 25 | + @JvmField @Param(6) @Field(6) val consentValue: Int, |
| 26 | + @JvmField @Param(7) @Field(7) val extras: Bundle?, |
| 27 | + @JvmField @Param(8) @Field(8) val statusValue: Int, |
| 28 | + @JvmField @Param(9) @Field(9) val tosUrl: String?, |
| 29 | + @JvmField @Param(10) @Field(10) val language: String?, |
| 30 | + @JvmField @Param(11) @Field(11) val country: String?, |
| 31 | + @JvmField @Param(12) @Field(12) val tosVersion: String?, |
| 32 | + @JvmField @Param(13) @Field(13) val tosContentTitle: String?, |
| 33 | + @JvmField @Param(14) @Field(14) val accountName: String?, |
| 34 | + @JvmField @Param(15) @Field(15) val consentVariant: String?, |
| 35 | + @JvmField @Param(16) @Field(16) val consentTrigger: String?, |
| 36 | + @JvmField @Param(17) @Field(17) val rcsFlowContextValue: Int, |
| 37 | + @JvmField @Param(18) @Field(18) val deviceConsentSourceValue: Int, |
| 38 | + @JvmField @Param(19) @Field(19) val deviceConsentVersionValue: Int, |
| 39 | +) : AbstractSafeParcelable() { |
| 40 | + enum class Status(val value: Int) { |
| 41 | + RCS_DEFAULT(0), |
| 42 | + RCS_LEGAL_FYI(1), |
| 43 | + DEVICE_PNVR(2), |
| 44 | + ON_DEMAND(3), |
| 45 | + EXPIRED(4); |
| 46 | + |
| 47 | + companion object { |
| 48 | + fun fromValue(value: Int): Status = entries.find { it.value == value } ?: EXPIRED |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + val asterismClient: AsterismClient |
| 53 | + get() = AsterismClient.fromValue(asterismClientValue) ?: AsterismClient.UNKNOWN_CLIENT |
| 54 | + |
| 55 | + val consent: Consent |
| 56 | + get() = Consent.fromValue(consentValue) ?: Consent.CONSENT_UNKNOWN |
| 57 | + |
| 58 | + val rcsFlowContext: FlowContext |
| 59 | + get() = FlowContext.fromValue(rcsFlowContextValue) ?: FlowContext.FLOW_CONTEXT_UNSPECIFIED |
| 60 | + |
| 61 | + val deviceConsentSource: ConsentSource |
| 62 | + get() = ConsentSource.fromValue(deviceConsentSourceValue) |
| 63 | + ?: ConsentSource.SOURCE_UNSPECIFIED |
| 64 | + |
| 65 | + val deviceConsentVersion: ConsentVersion |
| 66 | + get() = ConsentVersion.fromValue(deviceConsentVersionValue).let { |
| 67 | + if (it == null || it == ConsentVersion.CONSENT_VERSION_UNSPECIFIED) { |
| 68 | + ConsentVersion.PHONE_VERIFICATION_DEFAULT |
| 69 | + } else { |
| 70 | + it |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + fun isDevicePnvrFlow(): Boolean { |
| 75 | + return asterismClient == AsterismClient.CONSTELLATION && |
| 76 | + deviceConsentSourceValue > 0 && |
| 77 | + deviceConsentVersionValue > 0 |
| 78 | + } |
| 79 | + |
| 80 | + val status: Status |
| 81 | + get() = Status.fromValue(statusValue) |
| 82 | + |
| 83 | + override fun writeToParcel(out: Parcel, flags: Int) = CREATOR.writeToParcel(this, out, flags) |
| 84 | + |
| 85 | + companion object { |
| 86 | + @JvmField |
| 87 | + val CREATOR = findCreator(SetAsterismConsentRequest::class.java) |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +@SafeParcelable.Class |
| 92 | +data class SetAsterismConsentResponse |
| 93 | +@Constructor |
| 94 | +constructor( |
| 95 | + @JvmField @Param(1) @Field(1) val requestCode: Int, |
| 96 | + @JvmField @Param(2) @Field(2) val gmscoreIidToken: String?, |
| 97 | + @JvmField @Param(3) @Field(3) val fid: String? |
| 98 | +) : AbstractSafeParcelable() { |
| 99 | + |
| 100 | + override fun writeToParcel(out: Parcel, flags: Int) = CREATOR.writeToParcel(this, out, flags) |
| 101 | + |
| 102 | + companion object { |
| 103 | + @JvmField |
| 104 | + val CREATOR = findCreator(SetAsterismConsentResponse::class.java) |
| 105 | + } |
| 106 | +} |
0 commit comments