diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-09-18 16:17:37 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-09-18 16:17:37 -0700 |
commit | 3361663e37154b19316179e05955f05887d9ddc4 (patch) | |
tree | 6fe606c21e26cda0825a0be5c10fe374b990b38c /src | |
parent | ed9d461818780a6c38a081030a55983ea0883fa6 (diff) | |
parent | 2ae885210ef04d2533a2fc121a7f2b8770efa7e4 (diff) | |
download | packages_apps_Settings-3361663e37154b19316179e05955f05887d9ddc4.zip packages_apps_Settings-3361663e37154b19316179e05955f05887d9ddc4.tar.gz packages_apps_Settings-3361663e37154b19316179e05955f05887d9ddc4.tar.bz2 |
am 2ae88521: Merge "Surface tethering stats in data usage." into ics-factoryrom
* commit '2ae885210ef04d2533a2fc121a7f2b8770efa7e4':
Surface tethering stats in data usage.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/DataUsageSummary.java | 5 | ||||
-rw-r--r-- | src/com/android/settings/Utils.java | 30 | ||||
-rw-r--r-- | src/com/android/settings/WirelessSettings.java | 24 | ||||
-rw-r--r-- | src/com/android/settings/net/UidDetailProvider.java | 9 |
4 files changed, 43 insertions, 25 deletions
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java index bbc3606..d6c40b2 100644 --- a/src/com/android/settings/DataUsageSummary.java +++ b/src/com/android/settings/DataUsageSummary.java @@ -35,6 +35,8 @@ import static android.net.NetworkTemplate.buildTemplateMobile3gLower; import static android.net.NetworkTemplate.buildTemplateMobile4g; import static android.net.NetworkTemplate.buildTemplateMobileAll; import static android.net.NetworkTemplate.buildTemplateWifi; +import static android.net.TrafficStats.UID_REMOVED; +import static android.net.TrafficStats.UID_TETHERING; import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH; import static android.text.format.DateUtils.FORMAT_SHOW_DATE; import static android.text.format.Time.TIMEZONE_UTC; @@ -68,7 +70,6 @@ import android.net.NetworkPolicyManager; import android.net.NetworkStats; import android.net.NetworkStatsHistory; import android.net.NetworkTemplate; -import android.net.TrafficStats; import android.os.AsyncTask; import android.os.Bundle; import android.os.INetworkManagementService; @@ -1411,7 +1412,7 @@ public class DataUsageSummary extends Fragment { final int uid = entry.uid; final boolean isApp = uid >= android.os.Process.FIRST_APPLICATION_UID && uid <= android.os.Process.LAST_APPLICATION_UID; - if (isApp || uid == TrafficStats.UID_REMOVED) { + if (isApp || uid == UID_REMOVED || uid == UID_TETHERING) { AppUsageItem item = knownUids.get(uid); if (item == null) { item = new AppUsageItem(uid); diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 20a34a3..90336e2 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -393,4 +393,34 @@ public class Utils { list.setPadding(effectivePaddingSide, 0, effectivePaddingSide, paddingBottom); } } + + /** + * Return string resource that best describes combination of tethering + * options available on this device. + */ + public static int getTetheringLabel(ConnectivityManager cm) { + String[] usbRegexs = cm.getTetherableUsbRegexs(); + String[] wifiRegexs = cm.getTetherableWifiRegexs(); + String[] bluetoothRegexs = cm.getTetherableBluetoothRegexs(); + + boolean usbAvailable = usbRegexs.length != 0; + boolean wifiAvailable = wifiRegexs.length != 0; + boolean bluetoothAvailable = bluetoothRegexs.length != 0; + + if (wifiAvailable && usbAvailable && bluetoothAvailable) { + return R.string.tether_settings_title_all; + } else if (wifiAvailable && usbAvailable) { + return R.string.tether_settings_title_all; + } else if (wifiAvailable && bluetoothAvailable) { + return R.string.tether_settings_title_all; + } else if (wifiAvailable) { + return R.string.tether_settings_title_wifi; + } else if (usbAvailable && bluetoothAvailable) { + return R.string.tether_settings_title_usb_bluetooth; + } else if (usbAvailable) { + return R.string.tether_settings_title_usb; + } else { + return R.string.tether_settings_title_bluetooth; + } + } } diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java index ccbc87a..7c52413 100644 --- a/src/com/android/settings/WirelessSettings.java +++ b/src/com/android/settings/WirelessSettings.java @@ -163,30 +163,8 @@ public class WirelessSettings extends SettingsPreferenceFragment { if (!cm.isTetheringSupported()) { getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS)); } else { - String[] usbRegexs = cm.getTetherableUsbRegexs(); - String[] wifiRegexs = cm.getTetherableWifiRegexs(); - String[] bluetoothRegexs = cm.getTetherableBluetoothRegexs(); - - boolean usbAvailable = usbRegexs.length != 0; - boolean wifiAvailable = wifiRegexs.length != 0; - boolean bluetoothAvailable = bluetoothRegexs.length != 0; - Preference p = findPreference(KEY_TETHER_SETTINGS); - if (wifiAvailable && usbAvailable && bluetoothAvailable) { - p.setTitle(R.string.tether_settings_title_all); - } else if (wifiAvailable && usbAvailable) { - p.setTitle(R.string.tether_settings_title_all); - } else if (wifiAvailable && bluetoothAvailable) { - p.setTitle(R.string.tether_settings_title_all); - } else if (wifiAvailable) { - p.setTitle(R.string.tether_settings_title_wifi); - } else if (usbAvailable && bluetoothAvailable) { - p.setTitle(R.string.tether_settings_title_usb_bluetooth); - } else if (usbAvailable) { - p.setTitle(R.string.tether_settings_title_usb); - } else { - p.setTitle(R.string.tether_settings_title_bluetooth); - } + p.setTitle(Utils.getTetheringLabel(cm)); } } diff --git a/src/com/android/settings/net/UidDetailProvider.java b/src/com/android/settings/net/UidDetailProvider.java index 9eac801..0518b0b 100644 --- a/src/com/android/settings/net/UidDetailProvider.java +++ b/src/com/android/settings/net/UidDetailProvider.java @@ -22,11 +22,13 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; +import android.net.ConnectivityManager; import android.net.TrafficStats; import android.text.TextUtils; import android.util.SparseArray; import com.android.settings.R; +import com.android.settings.Utils; public class UidDetailProvider { private final Context mContext; @@ -71,6 +73,13 @@ public class UidDetailProvider { detail.icon = pm.getDefaultActivityIcon(); mUidDetailCache.put(uid, detail); return detail; + case TrafficStats.UID_TETHERING: + final ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService( + Context.CONNECTIVITY_SERVICE); + detail.label = res.getString(Utils.getTetheringLabel(cm)); + detail.icon = pm.getDefaultActivityIcon(); + mUidDetailCache.put(uid, detail); + return detail; } // otherwise fall back to using packagemanager labels |