From 06c9a2e252ff00a969f5d909355da38be6db6b34 Mon Sep 17 00:00:00 2001 From: Juan Docal <109512072+kp-juan-docal@users.noreply.github.com> Date: Thu, 23 Nov 2023 10:36:35 +0100 Subject: [PATCH] PIA-975: Update amazon public key and minor changes to coming subscription logic (#52) --- app/build.gradle | 2 +- .../main/assets/AppstoreAuthenticationKey.pem | 8 +++++++- .../android/ui/LauncherActivity.java | 10 +++++----- .../android/utils/AmazonPurchaseUtil.kt | 18 +++++++----------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index bda7e18..7cbe37b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -81,7 +81,7 @@ dependencies { implementation "androidx.databinding:databinding-runtime:3.5.3" // amazon - implementation 'com.amazon.device:amazon-appstore-sdk:3.0.2' + implementation 'com.amazon.device:amazon-appstore-sdk:3.0.4' //google def billing_version = "5.2.1" diff --git a/app/src/main/assets/AppstoreAuthenticationKey.pem b/app/src/main/assets/AppstoreAuthenticationKey.pem index 1d520f3..3b45606 100644 --- a/app/src/main/assets/AppstoreAuthenticationKey.pem +++ b/app/src/main/assets/AppstoreAuthenticationKey.pem @@ -1,3 +1,9 @@ -----BEGIN PUBLIC KEY----- - +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3/cyes3ZrgzZ9PgWOvXh +sFjbc48yQfzOyP86Tcj0FEtBi1845mjvaepi6jqoJ6N04MgjiyNuhyVGu4b9ybMe +WdiSA3npbMqK7ABz+AWFogYI+TrfnkLXrp+X0130Xw2oxJBoOrpGOimGeCfA6IWr +e6wIgKZKunbSkEx2HCaTVv+6L7iy+gqnZATqCOlH6GJ22Fq51EosX4xbqeeQRr3n +tLV7m8TRH1wRCamQfHIr5JkaQZDP1RV2BVnuqKXaI0XBKqy8Xycu6lhCvNuGWhS3 +GMZLS3gWoREpQMmWVGuhNsfLAv/CXEK6hKI3m+UCX2FWZXzYqWBNh4mQcjzlnq7v +ewIDAQAB -----END PUBLIC KEY----- diff --git a/app/src/main/java/com/privateinternetaccess/android/ui/LauncherActivity.java b/app/src/main/java/com/privateinternetaccess/android/ui/LauncherActivity.java index 6063b7a..6c9be11 100644 --- a/app/src/main/java/com/privateinternetaccess/android/ui/LauncherActivity.java +++ b/app/src/main/java/com/privateinternetaccess/android/ui/LauncherActivity.java @@ -66,6 +66,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { if (PIAApplication.isAmazon()) { PIAApplication.amazonPurchaseUtil = new AmazonPurchaseUtil(this); } + } + + @Override + protected void onResume() { + super.onResume(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!NotificationManagerCompat.from(this).areNotificationsEnabled()) { requestPermissions(new String[]{"android.permission.POST_NOTIFICATIONS"}, 0); @@ -75,11 +80,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { } } - @Override - protected void onResume() { - super.onResume(); - } - private void loadData() { loadFlags(this); if (PIAApplication.isAmazon()) { diff --git a/app/src/main/java/com/privateinternetaccess/android/utils/AmazonPurchaseUtil.kt b/app/src/main/java/com/privateinternetaccess/android/utils/AmazonPurchaseUtil.kt index 43528b0..915d399 100644 --- a/app/src/main/java/com/privateinternetaccess/android/utils/AmazonPurchaseUtil.kt +++ b/app/src/main/java/com/privateinternetaccess/android/utils/AmazonPurchaseUtil.kt @@ -2,7 +2,6 @@ package com.privateinternetaccess.android.utils import android.content.Context import androidx.lifecycle.MutableLiveData -import com.amazon.device.drm.LicensingService import com.amazon.device.iap.PurchasingListener import com.amazon.device.iap.PurchasingService import com.amazon.device.iap.model.* @@ -12,9 +11,9 @@ import com.privateinternetaccess.android.pia.model.AmazonPurchaseData class AmazonPurchaseUtil(private val context: Context) { - private val monthlyPlan = "MONTHLY" - private val yearlyPlan = "YEARLY" - private val products = hashSetOf(monthlyPlan, yearlyPlan, "PIA-M1", "PIA-Y1") + private val monthlySkuPlan = "PIA-M1" + private val yearlySkuPlan = "PIA-Y1" + private val products = setOf(monthlySkuPlan, yearlySkuPlan) val observableProducts = MutableLiveData() val observablePurchase = MutableLiveData() @@ -23,9 +22,6 @@ class AmazonPurchaseUtil(private val context: Context) { private var selectedProduct: String? = null init { - LicensingService.verifyLicense(context) { - // currently do nothing - } PurchasingService.registerListener(context, object : PurchasingListener { override fun onUserDataResponse(userData: UserDataResponse?) { // currently do nothing @@ -34,8 +30,8 @@ class AmazonPurchaseUtil(private val context: Context) { override fun onProductDataResponse(productData: ProductDataResponse?) { productData?.let { observableProducts.postValue(PricingLoadedEvent( - it.productData[monthlyPlan]!!.price, - it.productData[yearlyPlan]!!.price + it.productData[monthlySkuPlan]!!.price, + it.productData[yearlySkuPlan]!!.price )) } } @@ -62,9 +58,9 @@ class AmazonPurchaseUtil(private val context: Context) { fun selectProduct(isYearly: Boolean) { selectedProduct = if (isYearly) { - yearlyPlan + yearlySkuPlan } else { - monthlyPlan + monthlySkuPlan } }