From f4ddd779bf7863f8f01a96d24a1e49d931621041 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 2 Jul 2016 10:07:14 +0200 Subject: [PATCH] Android N: Fixed check for international Refs #453 --- .../main/java/eu/faircode/netguard/Util.java | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/Util.java b/app/src/main/java/eu/faircode/netguard/Util.java index 94f2d4eb..f1266ea7 100644 --- a/app/src/main/java/eu/faircode/netguard/Util.java +++ b/app/src/main/java/eu/faircode/netguard/Util.java @@ -154,33 +154,7 @@ public class Util { public static boolean isInternational(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 - && hasPhoneStatePermission(context)) { - int dataSubId; - try { - dataSubId = Settings.Global.getInt(context.getContentResolver(), "multi_sim_data_call", -1); - } catch (Throwable ignored) { - dataSubId = -1; - } - if (dataSubId >= 0) { - SubscriptionManager sm = SubscriptionManager.from(context); - SubscriptionInfo si = sm.getActiveSubscriptionInfo(dataSubId); - if (si != null && si.getCountryIso() != null) - try { - Method getNetworkCountryIso = tm.getClass().getMethod("getNetworkCountryIsoForSubscription", int.class); - getNetworkCountryIso.setAccessible(true); - String networkCountryIso = (String) getNetworkCountryIso.invoke(tm, dataSubId); - Log.d(TAG, "SIM=" + si.getCountryIso() + " network=" + networkCountryIso); - return !si.getCountryIso().equals(networkCountryIso); - } catch (Throwable ex) { - Log.w(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); - sendCrashReport(ex, context); - } - } - } - - return (tm == null || tm.getSimCountryIso() == null || !tm.getSimCountryIso().equals(tm.getNetworkCountryIso())); + return (tm != null && tm.getSimCountryIso() != null && !tm.getSimCountryIso().equals(tm.getNetworkCountryIso())); } public static String getNetworkGeneration(int networkType) {