Skip to content

Commit

Permalink
PIA-975: Update amazon public key and minor changes to coming subscri…
Browse files Browse the repository at this point in the history
…ption logic (#52)
  • Loading branch information
kp-juan-docal authored Nov 23, 2023
1 parent 9393c12 commit 06c9a2e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/assets/AppstoreAuthenticationKey.pem
Original file line number Diff line number Diff line change
@@ -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-----
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -75,11 +80,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}
}

@Override
protected void onResume() {
super.onResume();
}

private void loadData() {
loadFlags(this);
if (PIAApplication.isAmazon()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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<PricingLoadedEvent?>()
val observablePurchase = MutableLiveData<PurchaseResponse?>()
Expand All @@ -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
Expand All @@ -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
))
}
}
Expand All @@ -62,9 +58,9 @@ class AmazonPurchaseUtil(private val context: Context) {

fun selectProduct(isYearly: Boolean) {
selectedProduct = if (isYearly) {
yearlyPlan
yearlySkuPlan
} else {
monthlyPlan
monthlySkuPlan
}
}

Expand Down

0 comments on commit 06c9a2e

Please sign in to comment.