Surface tethering stats in data usage.
Bug: 5244846 Change-Id: Ib4ac03ab634278714576a66ef8d6fdbc6d15c82a
This commit is contained in:
@@ -57,9 +57,12 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@android:id/summary"
|
android:id="@android:id/summary"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_gravity="fill_horizontal"
|
||||||
android:layout_columnSpan="2"
|
android:layout_columnSpan="2"
|
||||||
android:layout_marginTop="4dip"
|
android:layout_marginTop="4dip"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
android:maxLines="2"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
|
@@ -35,6 +35,8 @@ import static android.net.NetworkTemplate.buildTemplateMobile3gLower;
|
|||||||
import static android.net.NetworkTemplate.buildTemplateMobile4g;
|
import static android.net.NetworkTemplate.buildTemplateMobile4g;
|
||||||
import static android.net.NetworkTemplate.buildTemplateMobileAll;
|
import static android.net.NetworkTemplate.buildTemplateMobileAll;
|
||||||
import static android.net.NetworkTemplate.buildTemplateWifi;
|
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_ABBREV_MONTH;
|
||||||
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
|
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
|
||||||
import static android.text.format.Time.TIMEZONE_UTC;
|
import static android.text.format.Time.TIMEZONE_UTC;
|
||||||
@@ -68,7 +70,6 @@ import android.net.NetworkPolicyManager;
|
|||||||
import android.net.NetworkStats;
|
import android.net.NetworkStats;
|
||||||
import android.net.NetworkStatsHistory;
|
import android.net.NetworkStatsHistory;
|
||||||
import android.net.NetworkTemplate;
|
import android.net.NetworkTemplate;
|
||||||
import android.net.TrafficStats;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.INetworkManagementService;
|
import android.os.INetworkManagementService;
|
||||||
@@ -1411,7 +1412,7 @@ public class DataUsageSummary extends Fragment {
|
|||||||
final int uid = entry.uid;
|
final int uid = entry.uid;
|
||||||
final boolean isApp = uid >= android.os.Process.FIRST_APPLICATION_UID
|
final boolean isApp = uid >= android.os.Process.FIRST_APPLICATION_UID
|
||||||
&& uid <= android.os.Process.LAST_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);
|
AppUsageItem item = knownUids.get(uid);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
item = new AppUsageItem(uid);
|
item = new AppUsageItem(uid);
|
||||||
|
@@ -393,4 +393,34 @@ public class Utils {
|
|||||||
list.setPadding(effectivePaddingSide, 0, effectivePaddingSide, paddingBottom);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -163,30 +163,8 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
|||||||
if (!cm.isTetheringSupported()) {
|
if (!cm.isTetheringSupported()) {
|
||||||
getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS));
|
getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS));
|
||||||
} else {
|
} 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);
|
Preference p = findPreference(KEY_TETHER_SETTINGS);
|
||||||
if (wifiAvailable && usbAvailable && bluetoothAvailable) {
|
p.setTitle(Utils.getTetheringLabel(cm));
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,11 +22,13 @@ import android.content.pm.PackageInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
import android.net.TrafficStats;
|
import android.net.TrafficStats;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
public class UidDetailProvider {
|
public class UidDetailProvider {
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@@ -71,6 +73,13 @@ public class UidDetailProvider {
|
|||||||
detail.icon = pm.getDefaultActivityIcon();
|
detail.icon = pm.getDefaultActivityIcon();
|
||||||
mUidDetailCache.put(uid, detail);
|
mUidDetailCache.put(uid, detail);
|
||||||
return 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
|
// otherwise fall back to using packagemanager labels
|
||||||
|
Reference in New Issue
Block a user