Merge "Switch tethering stats from the unix socket to binder."
This commit is contained in:
@@ -4,7 +4,10 @@ include $(CLEAR_VARS)
|
|||||||
|
|
||||||
LOCAL_MODULE := services.core
|
LOCAL_MODULE := services.core
|
||||||
|
|
||||||
LOCAL_AIDL_INCLUDES := system/netd/server/binder
|
LOCAL_AIDL_INCLUDES := \
|
||||||
|
frameworks/native/aidl/binder \
|
||||||
|
system/netd/server/binder
|
||||||
|
|
||||||
|
|
||||||
LOCAL_SRC_FILES += \
|
LOCAL_SRC_FILES += \
|
||||||
$(call all-java-files-under,java) \
|
$(call all-java-files-under,java) \
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ import android.os.Handler;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.INetworkActivityListener;
|
import android.os.INetworkActivityListener;
|
||||||
import android.os.INetworkManagementService;
|
import android.os.INetworkManagementService;
|
||||||
|
import android.os.PersistableBundle;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteCallbackList;
|
import android.os.RemoteCallbackList;
|
||||||
@@ -1897,38 +1898,34 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
return new NetworkStats(SystemClock.elapsedRealtime(), 0);
|
return new NetworkStats(SystemClock.elapsedRealtime(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
final NativeDaemonEvent[] events;
|
final PersistableBundle bundle;
|
||||||
try {
|
try {
|
||||||
events = mConnector.executeForList("bandwidth", "gettetherstats");
|
bundle = mNetdService.tetherGetStats();
|
||||||
} catch (NativeDaemonConnectorException e) {
|
} catch (RemoteException | ServiceSpecificException e) {
|
||||||
throw e.rethrowAsParcelableException();
|
throw new IllegalStateException("problem parsing tethering stats: ", e);
|
||||||
}
|
}
|
||||||
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 1);
|
|
||||||
for (NativeDaemonEvent event : events) {
|
|
||||||
if (event.getCode() != TetheringStatsListResult) continue;
|
|
||||||
|
|
||||||
// 114 ifaceIn ifaceOut rx_bytes rx_packets tx_bytes tx_packets
|
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(),
|
||||||
final StringTokenizer tok = new StringTokenizer(event.getMessage());
|
bundle.size());
|
||||||
|
final NetworkStats.Entry entry = new NetworkStats.Entry();
|
||||||
|
|
||||||
|
for (String iface : bundle.keySet()) {
|
||||||
|
long[] statsArray = bundle.getLongArray(iface);
|
||||||
try {
|
try {
|
||||||
final String ifaceIn = tok.nextToken();
|
entry.iface = iface;
|
||||||
final String ifaceOut = tok.nextToken();
|
|
||||||
|
|
||||||
final NetworkStats.Entry entry = new NetworkStats.Entry();
|
|
||||||
entry.iface = ifaceOut;
|
|
||||||
entry.uid = UID_TETHERING;
|
entry.uid = UID_TETHERING;
|
||||||
entry.set = SET_DEFAULT;
|
entry.set = SET_DEFAULT;
|
||||||
entry.tag = TAG_NONE;
|
entry.tag = TAG_NONE;
|
||||||
entry.rxBytes = Long.parseLong(tok.nextToken());
|
entry.rxBytes = statsArray[INetd.TETHER_STATS_RX_BYTES];
|
||||||
entry.rxPackets = Long.parseLong(tok.nextToken());
|
entry.rxPackets = statsArray[INetd.TETHER_STATS_RX_PACKETS];
|
||||||
entry.txBytes = Long.parseLong(tok.nextToken());
|
entry.txBytes = statsArray[INetd.TETHER_STATS_TX_BYTES];
|
||||||
entry.txPackets = Long.parseLong(tok.nextToken());
|
entry.txPackets = statsArray[INetd.TETHER_STATS_TX_PACKETS];
|
||||||
stats.combineValues(entry);
|
stats.combineValues(entry);
|
||||||
} catch (NoSuchElementException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
throw new IllegalStateException("problem parsing tethering stats: " + event);
|
throw new IllegalStateException("invalid tethering stats for " + iface, e);
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
throw new IllegalStateException("problem parsing tethering stats: " + event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user