summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2015-02-04 16:53:28 -0800
committercretin45 <cretin45@gmail.com>2015-02-04 16:53:28 -0800
commitb0e3ace8ca837e58dfbbc3a2422efc9ca5da2089 (patch)
treea7ceeadd3bc2cd00ae38f08d51b9a21e6ff78dcb
parent17c2db964e88e12576aaf31a1f07d24a3617dc53 (diff)
downloadpackages_apps_SetupWizard-b0e3ace8ca837e58dfbbc3a2422efc9ca5da2089.zip
packages_apps_SetupWizard-b0e3ace8ca837e58dfbbc3a2422efc9ca5da2089.tar.gz
packages_apps_SetupWizard-b0e3ace8ca837e58dfbbc3a2422efc9ca5da2089.tar.bz2
SetupWizard: Use TelephonyManager for checking/enabling mobile data
Change-Id: I6135d9a92efea56a50f5200827e0734f974c4849
-rw-r--r--src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java b/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java
index 67c90f0..46ef681 100644
--- a/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java
+++ b/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java
@@ -83,29 +83,28 @@ public class SetupWizardUtils {
}
public static boolean isMobileDataEnabled(Context context) {
- TelephonyManager tm =
- (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- if (tm.isMultiSimEnabled()) {
- int subscription = SubscriptionManager.getDefaultDataPhoneId();
- return android.provider.Settings.Global.getInt(context.getContentResolver(),
- android.provider.Settings.Global.MOBILE_DATA + subscription, 0) != 0;
- } else {
- return android.provider.Settings.Global.getInt(context.getContentResolver(),
- android.provider.Settings.Global.MOBILE_DATA, 0) != 0;
+ try {
+ TelephonyManager tm =
+ (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ return tm.getDataEnabled();
+ } catch (Exception e) {
+ return false;
}
}
public static void setMobileDataEnabled(Context context, boolean enabled) {
TelephonyManager tm =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- tm.setDataEnabled(enabled);
if (tm.isMultiSimEnabled()) {
- int subscription = SubscriptionManager.getDefaultDataPhoneId();
+ int phoneId = SubscriptionManager.getDefaultDataPhoneId();
android.provider.Settings.Global.putInt(context.getContentResolver(),
- android.provider.Settings.Global.MOBILE_DATA + subscription, enabled ? 1 : 0);
+ android.provider.Settings.Global.MOBILE_DATA + phoneId, enabled ? 1 : 0);
+ long subId = SubscriptionManager.getDefaultDataSubId();
+ tm.setDataEnabledUsingSubId(subId, enabled);
} else {
android.provider.Settings.Global.putInt(context.getContentResolver(),
android.provider.Settings.Global.MOBILE_DATA, enabled ? 1 : 0);
+ tm.setDataEnabled(enabled);
}
}