Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c51b453 authored by jt1134's avatar jt1134 Committed by Gerrit Code Review
Browse files

DataUsageSummary: fix mobile data usage display for sim-less devices

- Don't assume the device has a sim card. Check for a phone number
  instead. Otherwise the mobile data usage screen will not show up
  on sim-less CDMA devices.

Change-Id: Ic6e35dc209ff05e0c89dc990ad82f4ab4d3f337d
parent 8182fd42
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ 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;
@@ -2192,7 +2191,7 @@ public class DataUsageSummary extends Fragment {
    }

    /**
     * Test if device has a mobile data radio with SIM in ready state.
     * Test if device has a mobile data radio in ready state.
     */
    public static boolean hasReadyMobileRadio(Context context) {
        if (TEST_RADIOS) {
@@ -2202,8 +2201,9 @@ public class DataUsageSummary extends Fragment {
        final ConnectivityManager conn = ConnectivityManager.from(context);
        final TelephonyManager tele = TelephonyManager.from(context);

        // require both supported network and ready SIM
        return conn.isNetworkSupported(TYPE_MOBILE) && tele.getSimState() == SIM_STATE_READY;
        // require both supported network and phone number
        return conn.isNetworkSupported(TYPE_MOBILE) &&
                !TextUtils.isEmpty(tele.getLine1Number());
    }

    /**
@@ -2321,7 +2321,7 @@ public class DataUsageSummary extends Fragment {
        final ArrayList<CharSequence> limited = Lists.newArrayList();

        final TelephonyManager tele = TelephonyManager.from(context);
        if (tele.getSimState() == SIM_STATE_READY) {
        if (!TextUtils.isEmpty(tele.getLine1Number())) {
            final String subscriberId = getActiveSubscriberId(context);
            if (mPolicyEditor.hasLimitedPolicy(buildTemplateMobileAll(subscriberId))) {
                limited.add(getText(R.string.data_usage_list_mobile));