From 2a6f9501f7972aa7b70b8ee7b2ff720bf6e961f0 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 24 Apr 2020 16:52:51 +0200 Subject: [PATCH] Fixed subscriptions --- app/src/main/java/eu/faircode/netguard/IAB.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/IAB.java b/app/src/main/java/eu/faircode/netguard/IAB.java index 326d9dc0..38ea4003 100644 --- a/app/src/main/java/eu/faircode/netguard/IAB.java +++ b/app/src/main/java/eu/faircode/netguard/IAB.java @@ -118,7 +118,9 @@ public class IAB implements ServiceConnection { public void updatePurchases() throws RemoteException { // Get purchases - List skus = getPurchases(); + List skus = new ArrayList<>(); + skus.addAll(getPurchases("inapp")); + skus.addAll(getPurchases("subs")); SharedPreferences prefs = context.getSharedPreferences("IAB", Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); @@ -134,13 +136,13 @@ public class IAB implements ServiceConnection { editor.apply(); } - public boolean isPurchased(String sku) throws RemoteException { - return getPurchases().contains(sku); + public boolean isPurchased(String sku, String type) throws RemoteException { + return getPurchases(type).contains(sku); } - public List getPurchases() throws RemoteException { + public List getPurchases(String type) throws RemoteException { // Get purchases - Bundle bundle = service.getPurchases(IAB_VERSION, context.getPackageName(), "inapp", null); + Bundle bundle = service.getPurchases(IAB_VERSION, context.getPackageName(), type, null); Log.i(TAG, "getPurchases"); Util.logBundle(bundle); int response = (bundle == null ? -1 : bundle.getInt("RESPONSE_CODE", -1));