Load app usage on background thread.
Since stats service loads as needed, this may touch disk, and should run on background thread. Change-Id: I1d1d2583250314efa4d3d8f4faa9016c746c29d0
This commit is contained in:
@@ -41,6 +41,7 @@ import android.net.INetworkStatsService;
|
|||||||
import android.net.NetworkPolicy;
|
import android.net.NetworkPolicy;
|
||||||
import android.net.NetworkStats;
|
import android.net.NetworkStats;
|
||||||
import android.net.NetworkStatsHistory;
|
import android.net.NetworkStatsHistory;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
@@ -568,14 +569,25 @@ public class DataUsageSummary extends Fragment {
|
|||||||
private void updateDetailData() {
|
private void updateDetailData() {
|
||||||
if (LOGD) Log.d(TAG, "updateDetailData()");
|
if (LOGD) Log.d(TAG, "updateDetailData()");
|
||||||
|
|
||||||
|
new AsyncTask<Void, Void, NetworkStats>() {
|
||||||
|
@Override
|
||||||
|
protected NetworkStats doInBackground(Void... params) {
|
||||||
try {
|
try {
|
||||||
final long[] range = mChart.getInspectRange();
|
final long[] range = mChart.getInspectRange();
|
||||||
final NetworkStats stats = mStatsService.getSummaryForAllUid(
|
return mStatsService.getSummaryForAllUid(range[0], range[1], mTemplate);
|
||||||
range[0], range[1], mTemplate);
|
|
||||||
mAdapter.bindStats(stats);
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "problem reading stats");
|
Log.w(TAG, "problem reading stats");
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(NetworkStats stats) {
|
||||||
|
if (stats != null) {
|
||||||
|
mAdapter.bindStats(stats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getActiveSubscriberId(Context context) {
|
private static String getActiveSubscriberId(Context context) {
|
||||||
|
Reference in New Issue
Block a user