diff options
author | Danny Baumann <dannybaumann@web.de> | 2013-04-15 01:29:07 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2013-04-15 01:29:07 -0700 |
commit | b2c78138c403f98824369f9f680d67c7fb359fe4 (patch) | |
tree | d4ca39b50ff9a9ca18a7f0708df812a100ab5e75 | |
parent | af3f79a1f89c07d5629929eee0ec5dcc3f52ebda (diff) | |
parent | 10d7e945eb0497e6458b9ac3ab05db937724fcd8 (diff) | |
download | packages_apps_Settings-b2c78138c403f98824369f9f680d67c7fb359fe4.zip packages_apps_Settings-b2c78138c403f98824369f9f680d67c7fb359fe4.tar.gz packages_apps_Settings-b2c78138c403f98824369f9f680d67c7fb359fe4.tar.bz2 |
Merge "DataUsageSummary: fix mobile data usage display for GSM devices with no number" into cm-10.1
-rw-r--r-- | src/com/android/settings/DataUsageSummary.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java index 1bfb585..648f9c2 100644 --- a/src/com/android/settings/DataUsageSummary.java +++ b/src/com/android/settings/DataUsageSummary.java @@ -40,6 +40,7 @@ import static android.net.TrafficStats.GB_IN_BYTES; import static android.net.TrafficStats.MB_IN_BYTES; import static android.net.TrafficStats.UID_REMOVED; import static android.net.TrafficStats.UID_TETHERING; +import static android.telephony.TelephonyManager.SIM_STATE_READY; import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH; import static android.text.format.DateUtils.FORMAT_SHOW_DATE; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; @@ -2191,7 +2192,7 @@ public class DataUsageSummary extends Fragment { } /** - * Test if device has a mobile data radio in ready state. + * Test if device has a mobile data radio with subscription in ready state. */ public static boolean hasReadyMobileRadio(Context context) { if (TEST_RADIOS) { @@ -2199,11 +2200,9 @@ public class DataUsageSummary extends Fragment { } final ConnectivityManager conn = ConnectivityManager.from(context); - final TelephonyManager tele = TelephonyManager.from(context); - // require both supported network and phone number - return conn.isNetworkSupported(TYPE_MOBILE) && - !TextUtils.isEmpty(tele.getLine1Number()); + // require both supported network and subscription + return conn.isNetworkSupported(TYPE_MOBILE) && hasSubscription(context); } /** @@ -2267,6 +2266,14 @@ public class DataUsageSummary extends Fragment { } /** + * Test if device has either a SIM card or a phone number (for SIM-less CDMA). + */ + private static boolean hasSubscription(Context context) { + final TelephonyManager tele = TelephonyManager.from(context); + return tele.getSimState() == SIM_STATE_READY || !TextUtils.isEmpty(tele.getLine1Number()); + } + + /** * Inflate a {@link Preference} style layout, adding the given {@link View} * widget into {@link android.R.id#widget_frame}. */ @@ -2320,8 +2327,7 @@ public class DataUsageSummary extends Fragment { // build combined list of all limited networks final ArrayList<CharSequence> limited = Lists.newArrayList(); - final TelephonyManager tele = TelephonyManager.from(context); - if (!TextUtils.isEmpty(tele.getLine1Number())) { + if (hasSubscription(context)) { final String subscriberId = getActiveSubscriberId(context); if (mPolicyEditor.hasLimitedPolicy(buildTemplateMobileAll(subscriberId))) { limited.add(getText(R.string.data_usage_list_mobile)); |