diff --git a/res/layout/data_usage_header.xml b/res/layout/data_usage_header.xml
index aa2beb27431..a7b12b73237 100644
--- a/res/layout/data_usage_header.xml
+++ b/res/layout/data_usage_header.xml
@@ -45,17 +45,6 @@
android:paddingRight="@*android:dimen/preference_item_padding_side"
android:paddingTop="8dip"
android:paddingBottom="8dip"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:textAppearance="?android:attr/textAppearanceSmall" />
-
-
Background
-
- Measured by your tablet. Your carrier\'s data usage accounting may differ.
-
- Measured by your phone. Your carrier\'s data usage accounting may differ.
+
+ restricted
Disable mobile data?
@@ -3695,9 +3693,9 @@
Limiting data usage
- Your %1$s data connection will be disabled when the specified limit is reached.\n\nSince data usage is measured by your tablet, and your carrier may account for usage differently, consider using a conservative limit.
+ Your mobile data connection will be disabled when the specified limit is reached.\n\nSince data usage is measured by your tablet, and your carrier may account for usage differently, consider using a conservative limit.
- Your %1$s data connection will be disabled when the specified limit is reached.\n\nSince data usage is measured by your phone, and your carrier may account for usage differently, consider using a conservative limit.
+ Your mobile data connection will be disabled when the specified limit is reached.\n\nSince data usage is measured by your phone, and your carrier may account for usage differently, consider using a conservative limit.
Restrict background data?
@@ -3714,7 +3712,12 @@
%1$s received, %2$s sent
- %2$s: about %1$s used
+ %2$s: about %1$s used.
+
+
+ %2$s: about %1$s used, as measured by your tablet. Your carrier\'s data usage accounting may differ.
+
+ %2$s: about %1$s used, as measured by your phone. Your carrier\'s data usage accounting may differ.
Expensive networks
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index 70c0d9bacca..ae9c1cba5ff 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -1147,8 +1147,15 @@ public class DataUsageSummary extends Fragment {
final String totalPhrase = Formatter.formatFileSize(context, totalBytes);
final String rangePhrase = formatDateRange(context, start, end);
- mUsageSummary.setText(
- getString(R.string.data_usage_total_during_range, totalPhrase, rangePhrase));
+ final int summaryRes;
+ if (TAB_MOBILE.equals(mCurrentTab) || TAB_3G.equals(mCurrentApp)
+ || TAB_4G.equals(mCurrentApp)) {
+ summaryRes = R.string.data_usage_total_during_range_mobile;
+ } else {
+ summaryRes = R.string.data_usage_total_during_range;
+ }
+
+ mUsageSummary.setText(getString(summaryRes, totalPhrase, rangePhrase));
}
private final LoaderCallbacks mChartDataCallbacks = new LoaderCallbacks<
@@ -1191,13 +1198,15 @@ public class DataUsageSummary extends Fragment {
@Override
public void onLoadFinished(Loader loader, NetworkStats data) {
- mAdapter.bindStats(data);
+ final int[] restrictedAppIds = mPolicyManager.getAppsWithPolicy(
+ POLICY_REJECT_METERED_BACKGROUND);
+ mAdapter.bindStats(data, restrictedAppIds);
updateEmptyVisible();
}
@Override
public void onLoaderReset(Loader loader) {
- mAdapter.bindStats(null);
+ mAdapter.bindStats(null, new int[0]);
updateEmptyVisible();
}
@@ -1374,6 +1383,7 @@ public class DataUsageSummary extends Fragment {
public static class AppItem implements Comparable, Parcelable {
public final int appId;
+ public boolean restricted;
public SparseBooleanArray uids = new SparseBooleanArray();
public long total;
@@ -1439,7 +1449,7 @@ public class DataUsageSummary extends Fragment {
/**
* Bind the given {@link NetworkStats}, or {@code null} to clear list.
*/
- public void bindStats(NetworkStats stats) {
+ public void bindStats(NetworkStats stats, int[] restrictedAppIds) {
mItems.clear();
final AppItem systemItem = new AppItem(android.os.Process.SYSTEM_UID);
@@ -1468,6 +1478,16 @@ public class DataUsageSummary extends Fragment {
}
}
+ for (int appId : restrictedAppIds) {
+ AppItem item = knownUids.get(appId);
+ if (item == null) {
+ item = new AppItem(appId);
+ item.total = -1;
+ mItems.add(item);
+ }
+ item.restricted = true;
+ }
+
if (systemItem.total > 0) {
mItems.add(systemItem);
}
@@ -1513,7 +1533,13 @@ public class DataUsageSummary extends Fragment {
final AppItem item = mItems.get(position);
UidDetailTask.bindView(mProvider, item, convertView);
- text1.setText(Formatter.formatFileSize(context, item.total));
+ if (item.restricted && item.total <= 0) {
+ text1.setText(R.string.data_usage_app_restricted);
+ progress.setVisibility(View.GONE);
+ } else {
+ text1.setText(Formatter.formatFileSize(context, item.total));
+ progress.setVisibility(View.VISIBLE);
+ }
final int percentTotal = mLargest != 0 ? (int) (item.total * 100 / mLargest) : 0;
progress.setProgress(percentTotal);
@@ -1580,16 +1606,13 @@ public class DataUsageSummary extends Fragment {
// TODO: customize default limits based on network template
final String currentTab = parent.mCurrentTab;
if (TAB_3G.equals(currentTab)) {
- message = buildDialogMessage(res, R.string.data_usage_tab_3g);
+ message = res.getString(R.string.data_usage_limit_dialog_mobile);
limitBytes = 5 * GB_IN_BYTES;
} else if (TAB_4G.equals(currentTab)) {
- message = buildDialogMessage(res, R.string.data_usage_tab_4g);
+ message = res.getString(R.string.data_usage_limit_dialog_mobile);
limitBytes = 5 * GB_IN_BYTES;
} else if (TAB_MOBILE.equals(currentTab)) {
- message = buildDialogMessage(res, R.string.data_usage_list_mobile);
- limitBytes = 5 * GB_IN_BYTES;
- } else if (TAB_WIFI.equals(currentTab)) {
- message = buildDialogMessage(res, R.string.data_usage_tab_wifi);
+ message = res.getString(R.string.data_usage_limit_dialog_mobile);
limitBytes = 5 * GB_IN_BYTES;
} else {
throw new IllegalArgumentException("unknown current tab: " + currentTab);
@@ -1605,10 +1628,6 @@ public class DataUsageSummary extends Fragment {
dialog.show(parent.getFragmentManager(), TAG_CONFIRM_LIMIT);
}
- private static CharSequence buildDialogMessage(Resources res, int networkResId) {
- return res.getString(R.string.data_usage_limit_dialog, res.getString(networkResId));
- }
-
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
diff --git a/src/com/android/settings/net/ChartDataLoader.java b/src/com/android/settings/net/ChartDataLoader.java
index 830d00649c4..e0336b721fe 100644
--- a/src/com/android/settings/net/ChartDataLoader.java
+++ b/src/com/android/settings/net/ChartDataLoader.java
@@ -21,6 +21,7 @@ import static android.net.NetworkStats.SET_FOREGROUND;
import static android.net.NetworkStats.TAG_NONE;
import static android.net.NetworkStatsHistory.FIELD_RX_BYTES;
import static android.net.NetworkStatsHistory.FIELD_TX_BYTES;
+import static android.text.format.DateUtils.HOUR_IN_MILLIS;
import android.content.AsyncTaskLoader;
import android.content.Context;
@@ -88,9 +89,6 @@ public class ChartDataLoader extends AsyncTaskLoader {
data.network = mSession.getHistoryForNetwork(template, fields);
if (app != null) {
- data.detailDefault = null;
- data.detailForeground = null;
-
// load stats for current uid and template
final int size = app.uids.size();
for (int i = 0; i < size; i++) {
@@ -101,9 +99,15 @@ public class ChartDataLoader extends AsyncTaskLoader {
template, uid, SET_FOREGROUND, data.detailForeground);
}
- data.detail = new NetworkStatsHistory(data.detailForeground.getBucketDuration());
- data.detail.recordEntireHistory(data.detailDefault);
- data.detail.recordEntireHistory(data.detailForeground);
+ if (size > 0) {
+ data.detail = new NetworkStatsHistory(data.detailForeground.getBucketDuration());
+ data.detail.recordEntireHistory(data.detailDefault);
+ data.detail.recordEntireHistory(data.detailForeground);
+ } else {
+ data.detailDefault = new NetworkStatsHistory(HOUR_IN_MILLIS);
+ data.detailForeground = new NetworkStatsHistory(HOUR_IN_MILLIS);
+ data.detail = new NetworkStatsHistory(HOUR_IN_MILLIS);
+ }
}
return data;