summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/settings/DataUsageSummary.java16
-rw-r--r--src/com/android/settings/net/ChartDataLoader.java12
-rw-r--r--src/com/android/settings/net/SummaryForAllUidLoader.java11
3 files changed, 25 insertions, 14 deletions
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index 656288a83..d127204bb 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -69,11 +69,13 @@ import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.INetworkPolicyManager;
import android.net.INetworkStatsService;
+import android.net.INetworkStatsSession;
import android.net.NetworkPolicy;
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;
@@ -186,6 +188,8 @@ public class DataUsageSummary extends Fragment {
private NetworkPolicyManager mPolicyManager;
private ConnectivityManager mConnService;
+ private INetworkStatsSession mStatsSession;
+
private static final String PREF_FILE = "data_usage";
private static final String PREF_SHOW_WIFI = "show_wifi";
private static final String PREF_SHOW_ETHERNET = "show_ethernet";
@@ -285,6 +289,12 @@ public class DataUsageSummary extends Fragment {
mUidDetailProvider = new UidDetailProvider(context);
+ try {
+ mStatsSession = mStatsService.openSession();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e);
+ }
+
mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
mTabsContainer = (ViewGroup) view.findViewById(R.id.tabs_container);
mTabWidget = (TabWidget) view.findViewById(android.R.id.tabs);
@@ -533,6 +543,8 @@ public class DataUsageSummary extends Fragment {
mUidDetailProvider.clearCache();
mUidDetailProvider = null;
+
+ TrafficStats.closeQuietly(mStatsSession);
}
@Override
@@ -1139,7 +1151,7 @@ public class DataUsageSummary extends Fragment {
ChartData>() {
/** {@inheritDoc} */
public Loader<ChartData> onCreateLoader(int id, Bundle args) {
- return new ChartDataLoader(getActivity(), mStatsService, args);
+ return new ChartDataLoader(getActivity(), mStatsSession, args);
}
/** {@inheritDoc} */
@@ -1170,7 +1182,7 @@ public class DataUsageSummary extends Fragment {
NetworkStats>() {
/** {@inheritDoc} */
public Loader<NetworkStats> onCreateLoader(int id, Bundle args) {
- return new SummaryForAllUidLoader(getActivity(), mStatsService, args);
+ return new SummaryForAllUidLoader(getActivity(), mStatsSession, args);
}
/** {@inheritDoc} */
diff --git a/src/com/android/settings/net/ChartDataLoader.java b/src/com/android/settings/net/ChartDataLoader.java
index 172d37734..830d00649 100644
--- a/src/com/android/settings/net/ChartDataLoader.java
+++ b/src/com/android/settings/net/ChartDataLoader.java
@@ -24,7 +24,7 @@ import static android.net.NetworkStatsHistory.FIELD_TX_BYTES;
import android.content.AsyncTaskLoader;
import android.content.Context;
-import android.net.INetworkStatsService;
+import android.net.INetworkStatsSession;
import android.net.NetworkStatsHistory;
import android.net.NetworkTemplate;
import android.os.Bundle;
@@ -40,7 +40,7 @@ public class ChartDataLoader extends AsyncTaskLoader<ChartData> {
private static final String KEY_APP = "app";
private static final String KEY_FIELDS = "fields";
- private final INetworkStatsService mStatsService;
+ private final INetworkStatsSession mSession;
private final Bundle mArgs;
public static Bundle buildArgs(NetworkTemplate template, AppItem app) {
@@ -55,9 +55,9 @@ public class ChartDataLoader extends AsyncTaskLoader<ChartData> {
return args;
}
- public ChartDataLoader(Context context, INetworkStatsService statsService, Bundle args) {
+ public ChartDataLoader(Context context, INetworkStatsSession session, Bundle args) {
super(context);
- mStatsService = statsService;
+ mSession = session;
mArgs = args;
}
@@ -85,7 +85,7 @@ public class ChartDataLoader extends AsyncTaskLoader<ChartData> {
private ChartData loadInBackground(NetworkTemplate template, AppItem app, int fields)
throws RemoteException {
final ChartData data = new ChartData();
- data.network = mStatsService.getHistoryForNetwork(template, fields);
+ data.network = mSession.getHistoryForNetwork(template, fields);
if (app != null) {
data.detailDefault = null;
@@ -128,7 +128,7 @@ public class ChartDataLoader extends AsyncTaskLoader<ChartData> {
private NetworkStatsHistory collectHistoryForUid(
NetworkTemplate template, int uid, int set, NetworkStatsHistory existing)
throws RemoteException {
- final NetworkStatsHistory history = mStatsService.getHistoryForUid(
+ final NetworkStatsHistory history = mSession.getHistoryForUid(
template, uid, set, TAG_NONE, FIELD_RX_BYTES | FIELD_TX_BYTES);
if (existing != null) {
diff --git a/src/com/android/settings/net/SummaryForAllUidLoader.java b/src/com/android/settings/net/SummaryForAllUidLoader.java
index c01de4539..68dc79920 100644
--- a/src/com/android/settings/net/SummaryForAllUidLoader.java
+++ b/src/com/android/settings/net/SummaryForAllUidLoader.java
@@ -18,7 +18,7 @@ package com.android.settings.net;
import android.content.AsyncTaskLoader;
import android.content.Context;
-import android.net.INetworkStatsService;
+import android.net.INetworkStatsSession;
import android.net.NetworkStats;
import android.net.NetworkTemplate;
import android.os.Bundle;
@@ -29,7 +29,7 @@ public class SummaryForAllUidLoader extends AsyncTaskLoader<NetworkStats> {
private static final String KEY_START = "start";
private static final String KEY_END = "end";
- private final INetworkStatsService mStatsService;
+ private final INetworkStatsSession mSession;
private final Bundle mArgs;
public static Bundle buildArgs(NetworkTemplate template, long start, long end) {
@@ -40,10 +40,9 @@ public class SummaryForAllUidLoader extends AsyncTaskLoader<NetworkStats> {
return args;
}
- public SummaryForAllUidLoader(
- Context context, INetworkStatsService statsService, Bundle args) {
+ public SummaryForAllUidLoader(Context context, INetworkStatsSession session, Bundle args) {
super(context);
- mStatsService = statsService;
+ mSession = session;
mArgs = args;
}
@@ -60,7 +59,7 @@ public class SummaryForAllUidLoader extends AsyncTaskLoader<NetworkStats> {
final long end = mArgs.getLong(KEY_END);
try {
- return mStatsService.getSummaryForAllUid(template, start, end, false);
+ return mSession.getSummaryForAllUid(template, start, end, false);
} catch (RemoteException e) {
return null;
}