Android N: Fixed check for international

Refs #453
This commit is contained in:
M66B 2016-07-02 10:07:14 +02:00
parent a8848ca42d
commit f4ddd779bf
1 changed files with 1 additions and 27 deletions

View File

@ -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) {