From bbe2fdc933b265432a7958dd3382b535d25a7f8b Mon Sep 17 00:00:00 2001 From: DaVinci9196 <150454414+DaVinci9196@users.noreply.github.com> Date: Sat, 28 Sep 2024 16:57:55 +0800 Subject: [PATCH] IAP: Add support for "SKU_SERIALIZED_DOCID_LIST" (#2509) --- .../microg/vending/billing/core/IAPCore.kt | 64 +++++++++++-------- vending-app/src/main/proto/GooglePlay.proto | 5 ++ 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/vending-app/src/main/java/org/microg/vending/billing/core/IAPCore.kt b/vending-app/src/main/java/org/microg/vending/billing/core/IAPCore.kt index 1b1eb9b8ec..e845440086 100644 --- a/vending-app/src/main/java/org/microg/vending/billing/core/IAPCore.kt +++ b/vending-app/src/main/java/org/microg/vending/billing/core/IAPCore.kt @@ -47,41 +47,55 @@ class IAPCore( val multiOfferSkuDetailTemp: MutableList = mutableListOf() params.multiOfferSkuDetail.forEach { multiOfferSkuDetailTemp.add( - when (val value = it.value) { - is Boolean -> { - val multiOfferSkuDetailBuilder = MultiOfferSkuDetail.Builder() + if (it.key == "SKU_SERIALIZED_DOCID_LIST") { + val multiOfferSkuDetailBuilder = MultiOfferSkuDetail.Builder() + val skuSerializedDocIdList = SkuSerializedDocIds.Builder() + val docIdList = params.multiOfferSkuDetail["SKU_SERIALIZED_DOCID_LIST"] + if (docIdList != null) { + skuSerializedDocIdList.docIds(docIdList as List) multiOfferSkuDetailBuilder.apply { key = it.key - bv = value + skuSerializedDocIds = skuSerializedDocIdList.build() } - multiOfferSkuDetailBuilder.build() } + multiOfferSkuDetailBuilder.build() + } else { + when (val value = it.value) { + is Boolean -> { + val multiOfferSkuDetailBuilder = MultiOfferSkuDetail.Builder() + multiOfferSkuDetailBuilder.apply { + key = it.key + bv = value + } + multiOfferSkuDetailBuilder.build() + } - is Long -> { - val multiOfferSkuDetailBuilder = MultiOfferSkuDetail.Builder() - multiOfferSkuDetailBuilder.apply { - key = it.key - iv = value + is Long -> { + val multiOfferSkuDetailBuilder = MultiOfferSkuDetail.Builder() + multiOfferSkuDetailBuilder.apply { + key = it.key + iv = value + } + multiOfferSkuDetailBuilder.build() } - multiOfferSkuDetailBuilder.build() - } - is Int -> { - val multiOfferSkuDetailBuilder = MultiOfferSkuDetail.Builder() - multiOfferSkuDetailBuilder.apply { - key = it.key - iv = value.toLong() + is Int -> { + val multiOfferSkuDetailBuilder = MultiOfferSkuDetail.Builder() + multiOfferSkuDetailBuilder.apply { + key = it.key + iv = value.toLong() + } + multiOfferSkuDetailBuilder.build() } - multiOfferSkuDetailBuilder.build() - } - else -> { - val multiOfferSkuDetailBuilder = MultiOfferSkuDetail.Builder() - multiOfferSkuDetailBuilder.apply { - key = it.key - sv = value.toString() + else -> { + val multiOfferSkuDetailBuilder = MultiOfferSkuDetail.Builder() + multiOfferSkuDetailBuilder.apply { + key = it.key + sv = value.toString() + } + multiOfferSkuDetailBuilder.build() } - multiOfferSkuDetailBuilder.build() } } ) diff --git a/vending-app/src/main/proto/GooglePlay.proto b/vending-app/src/main/proto/GooglePlay.proto index 49fd299806..bc32cd1201 100644 --- a/vending-app/src/main/proto/GooglePlay.proto +++ b/vending-app/src/main/proto/GooglePlay.proto @@ -248,9 +248,14 @@ message MultiOfferSkuDetail { string sv = 2; bool bv = 3; int64 iv = 4; + SkuSerializedDocIds skuSerializedDocIds = 5; } } +message SkuSerializedDocIds { + repeated string docIds = 1; +} + message OfferSku { string unknown1 = 1; string unknown2 = 2;