summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/settings/DataUsageSummary.java20
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));