Loading src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public class AppDataUsagePreferenceController extends AppInfoPreferenceControlle } private static NetworkTemplate getTemplate(Context context) { if (DataUsageList.hasReadyMobileRadio(context)) { if (DataUsageUtils.hasReadyMobileRadio(context)) { return NetworkTemplate.buildTemplateMobileWildcard(); } if (DataUsageUtils.hasWifiRadio(context)) { Loading src/com/android/settings/datausage/DataUsageList.java +0 −57 Original line number Diff line number Diff line Loading @@ -479,63 +479,6 @@ public class DataUsageList extends DataUsageBaseFragment { return Math.max(largest, item.total); } /** * Test if device has a mobile data radio with SIM in ready state. */ public static boolean hasReadyMobileRadio(Context context) { if (DataUsageUtils.TEST_RADIOS) { return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile"); } final ConnectivityManager conn = ConnectivityManager.from(context); final TelephonyManager tele = TelephonyManager.from(context); final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(context).getActiveSubscriptionInfoList(); // No activated Subscriptions if (subInfoList == null) { if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subInfoList=null"); return false; } // require both supported network and ready SIM boolean isReady = true; for (SubscriptionInfo subInfo : subInfoList) { isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY; if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo); } boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio:" + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady); } return retVal; } /* * TODO: consider adding to TelephonyManager or SubscriptionManager. */ public static boolean hasReadyMobileRadio(Context context, int subId) { if (DataUsageUtils.TEST_RADIOS) { return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile"); } final ConnectivityManager conn = ConnectivityManager.from(context); final TelephonyManager tele = TelephonyManager.from(context); final int slotId = SubscriptionManager.getSlotIndex(subId); final boolean isReady = tele.getSimState(slotId) == SIM_STATE_READY; boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio: subId=" + subId + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady); } return retVal; } private OnItemSelectedListener mCycleListener = new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Loading src/com/android/settings/datausage/DataUsageListV2.java +0 −57 Original line number Diff line number Diff line Loading @@ -483,63 +483,6 @@ public class DataUsageListV2 extends DataUsageBaseFragment { return Math.max(largest, item.total); } /** * Test if device has a mobile data radio with SIM in ready state. */ public static boolean hasReadyMobileRadio(Context context) { if (DataUsageUtils.TEST_RADIOS) { return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile"); } final ConnectivityManager conn = ConnectivityManager.from(context); final TelephonyManager tele = TelephonyManager.from(context); final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(context).getActiveSubscriptionInfoList(); // No activated Subscriptions if (subInfoList == null) { if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subInfoList=null"); return false; } // require both supported network and ready SIM boolean isReady = true; for (SubscriptionInfo subInfo : subInfoList) { isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY; if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo); } boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio:" + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady); } return retVal; } /* * TODO: consider adding to TelephonyManager or SubscriptionManager. */ public static boolean hasReadyMobileRadio(Context context, int subId) { if (DataUsageUtils.TEST_RADIOS) { return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile"); } final ConnectivityManager conn = ConnectivityManager.from(context); final TelephonyManager tele = TelephonyManager.from(context); final int slotId = SubscriptionManager.getSlotIndex(subId); final boolean isReady = tele.getSimState(slotId) == SIM_STATE_READY; boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio: subId=" + subId + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady); } return retVal; } private OnItemSelectedListener mCycleListener = new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Loading src/com/android/settings/datausage/DataUsageUtils.java +41 −0 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ package com.android.settings.datausage; import static android.net.ConnectivityManager.TYPE_MOBILE; import static android.net.ConnectivityManager.TYPE_WIFI; import static android.telephony.TelephonyManager.SIM_STATE_READY; import android.content.Context; import android.net.ConnectivityManager; Loading @@ -31,6 +33,7 @@ import android.telephony.TelephonyManager; import android.text.BidiFormatter; import android.text.format.Formatter; import android.text.format.Formatter.BytesResult; import android.util.Log; import java.util.List; Loading @@ -40,7 +43,9 @@ import java.util.List; public final class DataUsageUtils { static final boolean TEST_RADIOS = false; static final String TEST_RADIOS_PROP = "test.radios"; private static final boolean LOGD = false; private static final String ETHERNET = "ethernet"; private static final String TAG = "DataUsageUtils"; private DataUsageUtils() { } Loading Loading @@ -98,6 +103,42 @@ public final class DataUsageUtils { .isNetworkSupported(ConnectivityManager.TYPE_MOBILE); } /** * Test if device has a mobile data radio with SIM in ready state. */ public static boolean hasReadyMobileRadio(Context context) { if (DataUsageUtils.TEST_RADIOS) { return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile"); } final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(context).getActiveSubscriptionInfoList(); // No activated Subscriptions if (subInfoList == null) { if (LOGD) { Log.d(TAG, "hasReadyMobileRadio: subInfoList=null"); } return false; } final TelephonyManager tele = TelephonyManager.from(context); // require both supported network and ready SIM boolean isReady = true; for (SubscriptionInfo subInfo : subInfoList) { isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo); } } final ConnectivityManager conn = ConnectivityManager.from(context); final boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio:" + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady); } return retVal; } /** * Whether device has a Wi-Fi data radio. */ Loading Loading
src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public class AppDataUsagePreferenceController extends AppInfoPreferenceControlle } private static NetworkTemplate getTemplate(Context context) { if (DataUsageList.hasReadyMobileRadio(context)) { if (DataUsageUtils.hasReadyMobileRadio(context)) { return NetworkTemplate.buildTemplateMobileWildcard(); } if (DataUsageUtils.hasWifiRadio(context)) { Loading
src/com/android/settings/datausage/DataUsageList.java +0 −57 Original line number Diff line number Diff line Loading @@ -479,63 +479,6 @@ public class DataUsageList extends DataUsageBaseFragment { return Math.max(largest, item.total); } /** * Test if device has a mobile data radio with SIM in ready state. */ public static boolean hasReadyMobileRadio(Context context) { if (DataUsageUtils.TEST_RADIOS) { return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile"); } final ConnectivityManager conn = ConnectivityManager.from(context); final TelephonyManager tele = TelephonyManager.from(context); final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(context).getActiveSubscriptionInfoList(); // No activated Subscriptions if (subInfoList == null) { if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subInfoList=null"); return false; } // require both supported network and ready SIM boolean isReady = true; for (SubscriptionInfo subInfo : subInfoList) { isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY; if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo); } boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio:" + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady); } return retVal; } /* * TODO: consider adding to TelephonyManager or SubscriptionManager. */ public static boolean hasReadyMobileRadio(Context context, int subId) { if (DataUsageUtils.TEST_RADIOS) { return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile"); } final ConnectivityManager conn = ConnectivityManager.from(context); final TelephonyManager tele = TelephonyManager.from(context); final int slotId = SubscriptionManager.getSlotIndex(subId); final boolean isReady = tele.getSimState(slotId) == SIM_STATE_READY; boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio: subId=" + subId + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady); } return retVal; } private OnItemSelectedListener mCycleListener = new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Loading
src/com/android/settings/datausage/DataUsageListV2.java +0 −57 Original line number Diff line number Diff line Loading @@ -483,63 +483,6 @@ public class DataUsageListV2 extends DataUsageBaseFragment { return Math.max(largest, item.total); } /** * Test if device has a mobile data radio with SIM in ready state. */ public static boolean hasReadyMobileRadio(Context context) { if (DataUsageUtils.TEST_RADIOS) { return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile"); } final ConnectivityManager conn = ConnectivityManager.from(context); final TelephonyManager tele = TelephonyManager.from(context); final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(context).getActiveSubscriptionInfoList(); // No activated Subscriptions if (subInfoList == null) { if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subInfoList=null"); return false; } // require both supported network and ready SIM boolean isReady = true; for (SubscriptionInfo subInfo : subInfoList) { isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY; if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo); } boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio:" + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady); } return retVal; } /* * TODO: consider adding to TelephonyManager or SubscriptionManager. */ public static boolean hasReadyMobileRadio(Context context, int subId) { if (DataUsageUtils.TEST_RADIOS) { return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile"); } final ConnectivityManager conn = ConnectivityManager.from(context); final TelephonyManager tele = TelephonyManager.from(context); final int slotId = SubscriptionManager.getSlotIndex(subId); final boolean isReady = tele.getSimState(slotId) == SIM_STATE_READY; boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio: subId=" + subId + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady); } return retVal; } private OnItemSelectedListener mCycleListener = new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Loading
src/com/android/settings/datausage/DataUsageUtils.java +41 −0 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ package com.android.settings.datausage; import static android.net.ConnectivityManager.TYPE_MOBILE; import static android.net.ConnectivityManager.TYPE_WIFI; import static android.telephony.TelephonyManager.SIM_STATE_READY; import android.content.Context; import android.net.ConnectivityManager; Loading @@ -31,6 +33,7 @@ import android.telephony.TelephonyManager; import android.text.BidiFormatter; import android.text.format.Formatter; import android.text.format.Formatter.BytesResult; import android.util.Log; import java.util.List; Loading @@ -40,7 +43,9 @@ import java.util.List; public final class DataUsageUtils { static final boolean TEST_RADIOS = false; static final String TEST_RADIOS_PROP = "test.radios"; private static final boolean LOGD = false; private static final String ETHERNET = "ethernet"; private static final String TAG = "DataUsageUtils"; private DataUsageUtils() { } Loading Loading @@ -98,6 +103,42 @@ public final class DataUsageUtils { .isNetworkSupported(ConnectivityManager.TYPE_MOBILE); } /** * Test if device has a mobile data radio with SIM in ready state. */ public static boolean hasReadyMobileRadio(Context context) { if (DataUsageUtils.TEST_RADIOS) { return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile"); } final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(context).getActiveSubscriptionInfoList(); // No activated Subscriptions if (subInfoList == null) { if (LOGD) { Log.d(TAG, "hasReadyMobileRadio: subInfoList=null"); } return false; } final TelephonyManager tele = TelephonyManager.from(context); // require both supported network and ready SIM boolean isReady = true; for (SubscriptionInfo subInfo : subInfoList) { isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo); } } final ConnectivityManager conn = ConnectivityManager.from(context); final boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady; if (LOGD) { Log.d(TAG, "hasReadyMobileRadio:" + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady); } return retVal; } /** * Whether device has a Wi-Fi data radio. */ Loading