Merge commit 'd44c2f2c85c8720763837b89a8988b6e5cc248bf' * commit 'd44c2f2c85c8720763837b89a8988b6e5cc248bf': Migration to TrafficStats.
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
package com.android.internal.os;
|
||||
|
||||
import android.bluetooth.BluetoothHeadset;
|
||||
import android.net.TrafficStats;
|
||||
import android.os.BatteryStats;
|
||||
import android.os.NetStat;
|
||||
import android.os.Parcel;
|
||||
import android.os.ParcelFormatException;
|
||||
import android.os.Parcelable;
|
||||
@@ -1022,8 +1022,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
public void doUnplug(long batteryUptime, long batteryRealtime) {
|
||||
for (int iu = mUidStats.size() - 1; iu >= 0; iu--) {
|
||||
Uid u = mUidStats.valueAt(iu);
|
||||
u.mStartedTcpBytesReceived = NetStat.getUidRxBytes(u.mUid);
|
||||
u.mStartedTcpBytesSent = NetStat.getUidTxBytes(u.mUid);
|
||||
u.mStartedTcpBytesReceived = TrafficStats.getUidRxBytes(u.mUid);
|
||||
u.mStartedTcpBytesSent = TrafficStats.getUidTxBytes(u.mUid);
|
||||
u.mTcpBytesReceivedAtLastUnplug = u.mCurrentTcpBytesReceived;
|
||||
u.mTcpBytesSentAtLastUnplug = u.mCurrentTcpBytesSent;
|
||||
}
|
||||
@@ -1031,10 +1031,10 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mUnpluggables.get(i).unplug(batteryUptime, batteryRealtime);
|
||||
}
|
||||
// Track total mobile data
|
||||
doDataUnplug(mMobileDataRx, NetStat.getMobileRxBytes());
|
||||
doDataUnplug(mMobileDataTx, NetStat.getMobileTxBytes());
|
||||
doDataUnplug(mTotalDataRx, NetStat.getTotalRxBytes());
|
||||
doDataUnplug(mTotalDataTx, NetStat.getTotalTxBytes());
|
||||
doDataUnplug(mMobileDataRx, TrafficStats.getMobileRxBytes());
|
||||
doDataUnplug(mMobileDataTx, TrafficStats.getMobileTxBytes());
|
||||
doDataUnplug(mTotalDataRx, TrafficStats.getTotalRxBytes());
|
||||
doDataUnplug(mTotalDataTx, TrafficStats.getTotalTxBytes());
|
||||
// Track radio awake time
|
||||
mRadioDataStart = getCurrentRadioDataUptime();
|
||||
mRadioDataUptime = 0;
|
||||
@@ -1058,10 +1058,10 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
for (int i = mUnpluggables.size() - 1; i >= 0; i--) {
|
||||
mUnpluggables.get(i).plug(batteryUptime, batteryRealtime);
|
||||
}
|
||||
doDataPlug(mMobileDataRx, NetStat.getMobileRxBytes());
|
||||
doDataPlug(mMobileDataTx, NetStat.getMobileTxBytes());
|
||||
doDataPlug(mTotalDataRx, NetStat.getTotalRxBytes());
|
||||
doDataPlug(mTotalDataTx, NetStat.getTotalTxBytes());
|
||||
doDataPlug(mMobileDataRx, TrafficStats.getMobileRxBytes());
|
||||
doDataPlug(mMobileDataTx, TrafficStats.getMobileTxBytes());
|
||||
doDataPlug(mTotalDataRx, TrafficStats.getTotalRxBytes());
|
||||
doDataPlug(mTotalDataTx, TrafficStats.getTotalTxBytes());
|
||||
// Track radio awake time
|
||||
mRadioDataUptime = getRadioDataUptime();
|
||||
mRadioDataStart = -1;
|
||||
@@ -1519,7 +1519,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
|
||||
public long computeCurrentTcpBytesReceived() {
|
||||
return mCurrentTcpBytesReceived + (mStartedTcpBytesReceived >= 0
|
||||
? (NetStat.getUidRxBytes(mUid) - mStartedTcpBytesReceived) : 0);
|
||||
? (TrafficStats.getUidRxBytes(mUid) - mStartedTcpBytesReceived) : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1696,7 +1696,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
|
||||
public long computeCurrentTcpBytesSent() {
|
||||
return mCurrentTcpBytesSent + (mStartedTcpBytesSent >= 0
|
||||
? (NetStat.getUidTxBytes(mUid) - mStartedTcpBytesSent) : 0);
|
||||
? (TrafficStats.getUidTxBytes(mUid) - mStartedTcpBytesSent) : 0);
|
||||
}
|
||||
|
||||
void writeToParcelLocked(Parcel out, long batteryRealtime) {
|
||||
@@ -2919,22 +2919,22 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
|
||||
/** Only STATS_UNPLUGGED works properly */
|
||||
public long getMobileTcpBytesSent(int which) {
|
||||
return getTcpBytes(NetStat.getMobileTxBytes(), mMobileDataTx, which);
|
||||
return getTcpBytes(TrafficStats.getMobileTxBytes(), mMobileDataTx, which);
|
||||
}
|
||||
|
||||
/** Only STATS_UNPLUGGED works properly */
|
||||
public long getMobileTcpBytesReceived(int which) {
|
||||
return getTcpBytes(NetStat.getMobileRxBytes(), mMobileDataRx, which);
|
||||
return getTcpBytes(TrafficStats.getMobileRxBytes(), mMobileDataRx, which);
|
||||
}
|
||||
|
||||
/** Only STATS_UNPLUGGED works properly */
|
||||
public long getTotalTcpBytesSent(int which) {
|
||||
return getTcpBytes(NetStat.getTotalTxBytes(), mTotalDataTx, which);
|
||||
return getTcpBytes(TrafficStats.getTotalTxBytes(), mTotalDataTx, which);
|
||||
}
|
||||
|
||||
/** Only STATS_UNPLUGGED works properly */
|
||||
public long getTotalTcpBytesReceived(int which) {
|
||||
return getTcpBytes(NetStat.getTotalRxBytes(), mTotalDataRx, which);
|
||||
return getTcpBytes(TrafficStats.getTotalRxBytes(), mTotalDataRx, which);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,13 +19,14 @@ package com.google.android.net;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.net.TrafficStats;
|
||||
import android.net.http.AndroidHttpClient;
|
||||
import android.os.Build;
|
||||
import android.os.NetStat;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Checkin;
|
||||
import android.util.Config;
|
||||
import android.util.Log;
|
||||
import org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpEntityEnclosingRequest;
|
||||
import org.apache.http.HttpHost;
|
||||
@@ -45,7 +46,6 @@ import org.apache.http.impl.client.EntityEnclosingRequestWrapper;
|
||||
import org.apache.http.impl.client.RequestWrapper;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
import org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
@@ -205,8 +205,8 @@ public class GoogleHttpClient implements HttpClient {
|
||||
// to follow redirects, count each redirect as an additional round trip.
|
||||
|
||||
int uid = android.os.Process.myUid();
|
||||
long startTx = NetStat.getUidTxBytes(uid);
|
||||
long startRx = NetStat.getUidRxBytes(uid);
|
||||
long startTx = TrafficStats.getUidTxBytes(uid);
|
||||
long startRx = TrafficStats.getUidRxBytes(uid);
|
||||
|
||||
response = mClient.execute(request, context);
|
||||
HttpEntity origEntity = response == null ? null : response.getEntity();
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
|
||||
package com.google.android.net;
|
||||
|
||||
import android.os.NetStat;
|
||||
import android.net.TrafficStats;
|
||||
import android.os.SystemClock;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.EventLog;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.entity.HttpEntityWrapper;
|
||||
|
||||
@@ -45,8 +44,8 @@ public class NetworkStatsEntity extends HttpEntityWrapper {
|
||||
super.close();
|
||||
} finally {
|
||||
long processingTime = SystemClock.elapsedRealtime() - mProcessingStartTime;
|
||||
long tx = NetStat.getUidTxBytes(mUid);
|
||||
long rx = NetStat.getUidRxBytes(mUid);
|
||||
long tx = TrafficStats.getUidTxBytes(mUid);
|
||||
long rx = TrafficStats.getUidRxBytes(mUid);
|
||||
|
||||
EventLog.writeEvent(HTTP_STATS_EVENT, mUa, mResponseLatency, processingTime,
|
||||
tx - mStartTx, rx - mStartRx);
|
||||
|
||||
Reference in New Issue
Block a user