diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2013-04-14 17:58:30 +0700 |
---|---|---|
committer | Pawit Pornkitprasan <p.pawit@gmail.com> | 2013-04-14 18:06:16 +0700 |
commit | 10d7e945eb0497e6458b9ac3ab05db937724fcd8 (patch) | |
tree | 606dddac835db5aacbfb7dd6f09769fdb2e68cc8 | |
parent | 98ba3ee61ad8b391f2d339c7c283c200d2ddedd7 (diff) | |
download | packages_apps_settings-10d7e945eb0497e6458b9ac3ab05db937724fcd8.zip packages_apps_settings-10d7e945eb0497e6458b9ac3ab05db937724fcd8.tar.gz packages_apps_settings-10d7e945eb0497e6458b9ac3ab05db937724fcd8.tar.bz2 |
DataUsageSummary: fix mobile data usage display for GSM devices with no number
Some providers don't write phone number onto SIM card causing the
phone number check introduced in the partially reverted commit to fail.
Re-introduce the original check with the "or" condition.
This partially reverts commit 4c51b45355b9d6fed973f946738bf455a8b7c9ea.
Change-Id: I69a65a1a421dcdf168c3d0afeb7110cb97790034
-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)); |