Commit d846c44f authored by sync_forks@e's avatar sync_forks@e

Merge branch 'cm-14.1' into v1-nougat

parents 92c4502e fa06c5b0
...@@ -38,6 +38,7 @@ import java.util.Date; ...@@ -38,6 +38,7 @@ import java.util.Date;
import java.util.Locale; import java.util.Locale;
import static android.net.ConnectivityManager.TYPE_MOBILE; import static android.net.ConnectivityManager.TYPE_MOBILE;
import static android.net.ConnectivityManager.TYPE_WIFI;
import static android.net.NetworkStatsHistory.FIELD_RX_BYTES; import static android.net.NetworkStatsHistory.FIELD_RX_BYTES;
import static android.net.NetworkStatsHistory.FIELD_TX_BYTES; import static android.net.NetworkStatsHistory.FIELD_TX_BYTES;
import static android.telephony.TelephonyManager.SIM_STATE_READY; import static android.telephony.TelephonyManager.SIM_STATE_READY;
...@@ -114,7 +115,24 @@ public class DataUsageController { ...@@ -114,7 +115,24 @@ public class DataUsageController {
return rt; return rt;
} }
/**
* Test if device has a Wi-Fi data radio.
*/
private boolean isWiFiSupported() {
return mConnectivityManager.isNetworkSupported(TYPE_WIFI);
}
public DataUsageInfo getDataUsageInfo() { public DataUsageInfo getDataUsageInfo() {
if (isMobileDataSupported()) {
return getMobileDataUsageInfo();
} else if (isWiFiSupported()) {
return getWifiDataUsageInfo();
}
return warn("neither mobile data nor wifi data supported");
}
public DataUsageInfo getMobileDataUsageInfo() {
final String subscriberId = getActiveSubscriberId(mContext); final String subscriberId = getActiveSubscriberId(mContext);
if (subscriberId == null) { if (subscriberId == null) {
return warn("no subscriber id"); return warn("no subscriber id");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment