Merge "Refactor tetherGetStats by using stable aidl structure"

am: 335253df0f

Change-Id: Ibaefeee3e115cc04163f1b07cdba148f9e9ab3b5
This commit is contained in:
Luke Huang
2018-10-10 23:10:10 -07:00
committed by android-build-merger
4 changed files with 17 additions and 13 deletions

View File

@@ -691,6 +691,7 @@ java_defaults {
"android.hardware.radio-V1.0-java",
"android.hardware.radio-V1.3-java",
"android.hardware.usb.gadget-V1.0-java",
"netd_aidl_interface-java",
],
// Loaded with System.loadLibrary by android.view.textclassifier

View File

@@ -43,6 +43,7 @@ java_library_static {
"android.hardware.configstore-V1.0-java",
"android.hardware.contexthub-V1.0-java",
"android.hidl.manager-V1.0-java",
"netd_aidl_interface-java",
],
}

View File

@@ -57,6 +57,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.INetd;
import android.net.TetherStatsParcel;
import android.net.INetworkManagementEventObserver;
import android.net.ITetheringStatsProvider;
import android.net.InterfaceConfiguration;
@@ -1839,31 +1840,30 @@ public class NetworkManagementService extends INetworkManagementService.Stub
return new NetworkStats(SystemClock.elapsedRealtime(), 0);
}
final PersistableBundle bundle;
final TetherStatsParcel[] tetherStatsVec;
try {
bundle = mNetdService.tetherGetStats();
tetherStatsVec = mNetdService.tetherGetStats();
} catch (RemoteException | ServiceSpecificException e) {
throw new IllegalStateException("problem parsing tethering stats: ", e);
}
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(),
bundle.size());
tetherStatsVec.length);
final NetworkStats.Entry entry = new NetworkStats.Entry();
for (String iface : bundle.keySet()) {
long[] statsArray = bundle.getLongArray(iface);
for (TetherStatsParcel tetherStats : tetherStatsVec) {
try {
entry.iface = iface;
entry.iface = tetherStats.iface;
entry.uid = UID_TETHERING;
entry.set = SET_DEFAULT;
entry.tag = TAG_NONE;
entry.rxBytes = statsArray[INetd.TETHER_STATS_RX_BYTES];
entry.rxPackets = statsArray[INetd.TETHER_STATS_RX_PACKETS];
entry.txBytes = statsArray[INetd.TETHER_STATS_TX_BYTES];
entry.txPackets = statsArray[INetd.TETHER_STATS_TX_PACKETS];
entry.rxBytes = tetherStats.rxBytes;
entry.rxPackets = tetherStats.rxPackets;
entry.txBytes = tetherStats.txBytes;
entry.txPackets = tetherStats.txPackets;
stats.combineValues(entry);
} catch (ArrayIndexOutOfBoundsException e) {
throw new IllegalStateException("invalid tethering stats for " + iface, e);
throw new IllegalStateException("invalid tethering stats " + e);
}
}

View File

@@ -63,7 +63,8 @@ LOCAL_JNI_SHARED_LIBRARIES := \
libunwindstack \
libutilscallstack \
libziparchive \
libz
libz \
netd_aidl_interface-cpp
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
@@ -92,7 +93,8 @@ LOCAL_SHARED_LIBRARIES := \
liblog \
libcutils \
libnativehelper \
libnetdaidl
libnetdaidl \
netd_aidl_interface-cpp
LOCAL_STATIC_LIBRARIES := \
libpcap \