diff options
-rw-r--r-- | res/layout/app_percentage_item.xml | 3 | ||||
-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 |
5 files changed, 46 insertions, 25 deletions
diff --git a/res/layout/app_percentage_item.xml b/res/layout/app_percentage_item.xml index 0c9f742..e5710e4 100644 --- a/res/layout/app_percentage_item.xml +++ b/res/layout/app_percentage_item.xml @@ -57,9 +57,12 @@ <TextView android:id="@android:id/summary" + android:layout_width="0dip" + android:layout_gravity="fill_horizontal" android:layout_columnSpan="2" android:layout_marginTop="4dip" android:visibility="gone" + android:maxLines="2" android:textAppearance="?android:attr/textAppearanceSmall" /> </GridLayout> 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 |