1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2025-01-01 12:54:07 +00:00

Prevent crash

This commit is contained in:
M66B 2017-07-06 07:50:54 +02:00
parent d02de65370
commit 13c33d7f87

View file

@ -173,31 +173,39 @@ public class IAB implements ServiceConnection {
} }
public static boolean isPurchased(String sku, Context context) { public static boolean isPurchased(String sku, Context context) {
if (Util.isDebuggable(context)) { try {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (Util.isDebuggable(context)) {
return !prefs.getBoolean("debug_iab", false); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return !prefs.getBoolean("debug_iab", false);
}
SharedPreferences prefs = context.getSharedPreferences("IAB", Context.MODE_PRIVATE);
if (ActivityPro.SKU_SUPPORT1.equals(sku) || ActivityPro.SKU_SUPPORT2.equals(sku))
return prefs.getBoolean(sku, false);
return (prefs.getBoolean(sku, false) ||
prefs.getBoolean(ActivityPro.SKU_PRO1, false) ||
prefs.getBoolean(ActivityPro.SKU_DONATION, false));
} catch (SecurityException ignored) {
return false;
} }
SharedPreferences prefs = context.getSharedPreferences("IAB", Context.MODE_PRIVATE);
if (ActivityPro.SKU_SUPPORT1.equals(sku) || ActivityPro.SKU_SUPPORT2.equals(sku))
return prefs.getBoolean(sku, false);
return (prefs.getBoolean(sku, false) ||
prefs.getBoolean(ActivityPro.SKU_PRO1, false) ||
prefs.getBoolean(ActivityPro.SKU_DONATION, false));
} }
public static boolean isPurchasedAny(Context context) { public static boolean isPurchasedAny(Context context) {
if (Util.isDebuggable(context)) { try {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (Util.isDebuggable(context)) {
return !(prefs.getBoolean("debug_iab", false) || prefs.getBoolean("debug_ads", false)); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
} return !(prefs.getBoolean("debug_iab", false) || prefs.getBoolean("debug_ads", false));
}
SharedPreferences prefs = context.getSharedPreferences("IAB", Context.MODE_PRIVATE); SharedPreferences prefs = context.getSharedPreferences("IAB", Context.MODE_PRIVATE);
for (String key : prefs.getAll().keySet()) for (String key : prefs.getAll().keySet())
if (prefs.getBoolean(key, false)) if (prefs.getBoolean(key, false))
return true; return true;
return false; return false;
} catch (SecurityException ignored) {
return false;
}
} }
public static String getResult(int responseCode) { public static String getResult(int responseCode) {