Check data sub ID

This commit is contained in:
M66B 2015-12-06 19:25:29 +01:00
parent 1702fddeeb
commit ab4078f4e6
2 changed files with 18 additions and 4 deletions

View File

@ -9,7 +9,7 @@ model {
applicationId = "eu.faircode.netguard" applicationId = "eu.faircode.netguard"
minSdkVersion.apiLevel = 21 minSdkVersion.apiLevel = 21
targetSdkVersion.apiLevel = 23 targetSdkVersion.apiLevel = 23
versionCode = 2015120601 versionCode = 2015120602
versionName = "0.50" versionName = "0.50"
archivesBaseName = "NetGuard-v$versionName-$versionCode" archivesBaseName = "NetGuard-v$versionName-$versionCode"
} }

View File

@ -124,7 +124,12 @@ public class Util {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
int dataSubId = Settings.Global.getInt(context.getContentResolver(), "multi_sim_data_call", -1); int dataSubId;
try {
dataSubId = Settings.Global.getInt(context.getContentResolver(), "multi_sim_data_call", -1);
} catch (Throwable ignored) {
dataSubId = -1;
}
if (dataSubId >= 0) { if (dataSubId >= 0) {
SubscriptionManager sm = SubscriptionManager.from(context); SubscriptionManager sm = SubscriptionManager.from(context);
SubscriptionInfo si = sm.getActiveSubscriptionInfo(dataSubId); SubscriptionInfo si = sm.getActiveSubscriptionInfo(dataSubId);
@ -406,7 +411,12 @@ public class Util {
.append(sm.getActiveSubscriptionInfoCountMax()) .append(sm.getActiveSubscriptionInfoCountMax())
.append("\r\n"); .append("\r\n");
int dataSubId = Settings.Global.getInt(context.getContentResolver(), "multi_sim_data_call", -1); int dataSubId;
try {
dataSubId = Settings.Global.getInt(context.getContentResolver(), "multi_sim_data_call", -1);
} catch (Throwable ignored) {
dataSubId = -1;
}
Method getNetworkCountryIso = null; Method getNetworkCountryIso = null;
Method getNetworkOperator = null; Method getNetworkOperator = null;
@ -443,7 +453,11 @@ public class Util {
.append(si.getDataRoaming() == SubscriptionManager.DATA_ROAMING_ENABLE ? " R" : "") .append(si.getDataRoaming() == SubscriptionManager.DATA_ROAMING_ENABLE ? " R" : "")
.append(si.getSubscriptionId() == dataSubId ? " *" : "") .append(si.getSubscriptionId() == dataSubId ? " *" : "")
.append("\r\n"); .append("\r\n");
if (getNetworkCountryIso != null && getNetworkOperator != null && getNetworkOperatorName != null && isNetworkRoaming != null) if (getNetworkCountryIso != null &&
getNetworkOperator != null &&
getNetworkOperatorName != null &&
getDataEnabled != null &&
isNetworkRoaming != null)
try { try {
sb.append("Network ") sb.append("Network ")
.append(si.getSimSlotIndex() + 1) .append(si.getSimSlotIndex() + 1)