Commit fa06c5b0 authored by Vasyl Gello's avatar Vasyl Gello Committed by Michael W

Return WiFi data usage for WiFi-only devices

Fixes "0B of data used" in "Data Usage" summary highlight
in Settings if Telephony is not present or turned off.
Reported-By: 's avatarL.W Reek <syphyr@gmail.com>
Refactored-By: 's avatarMichael W <baddaemon87@gmail.com>
Signed-off-by: 's avatarVasyl Gello <vasek.gello@gmail.com>

Change-Id: I9623054c2e6e70060e65e93b18a11e8fb281d5d7
parent b98c5a95
......@@ -38,6 +38,7 @@ import java.util.Date;
import java.util.Locale;
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_TX_BYTES;
import static android.telephony.TelephonyManager.SIM_STATE_READY;
......@@ -114,7 +115,24 @@ public class DataUsageController {
return rt;
}
/**
* Test if device has a Wi-Fi data radio.
*/
private boolean isWiFiSupported() {
return mConnectivityManager.isNetworkSupported(TYPE_WIFI);
}
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);
if (subscriberId == null) {
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