Merge "Refactor tetherGetStats by using stable aidl structure"
am: 335253df0f
Change-Id: Ibaefeee3e115cc04163f1b07cdba148f9e9ab3b5
This commit is contained in:
@@ -691,6 +691,7 @@ java_defaults {
|
|||||||
"android.hardware.radio-V1.0-java",
|
"android.hardware.radio-V1.0-java",
|
||||||
"android.hardware.radio-V1.3-java",
|
"android.hardware.radio-V1.3-java",
|
||||||
"android.hardware.usb.gadget-V1.0-java",
|
"android.hardware.usb.gadget-V1.0-java",
|
||||||
|
"netd_aidl_interface-java",
|
||||||
],
|
],
|
||||||
|
|
||||||
// Loaded with System.loadLibrary by android.view.textclassifier
|
// Loaded with System.loadLibrary by android.view.textclassifier
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ java_library_static {
|
|||||||
"android.hardware.configstore-V1.0-java",
|
"android.hardware.configstore-V1.0-java",
|
||||||
"android.hardware.contexthub-V1.0-java",
|
"android.hardware.contexthub-V1.0-java",
|
||||||
"android.hidl.manager-V1.0-java",
|
"android.hidl.manager-V1.0-java",
|
||||||
|
"netd_aidl_interface-java",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.INetd;
|
import android.net.INetd;
|
||||||
|
import android.net.TetherStatsParcel;
|
||||||
import android.net.INetworkManagementEventObserver;
|
import android.net.INetworkManagementEventObserver;
|
||||||
import android.net.ITetheringStatsProvider;
|
import android.net.ITetheringStatsProvider;
|
||||||
import android.net.InterfaceConfiguration;
|
import android.net.InterfaceConfiguration;
|
||||||
@@ -1839,31 +1840,30 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
return new NetworkStats(SystemClock.elapsedRealtime(), 0);
|
return new NetworkStats(SystemClock.elapsedRealtime(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
final PersistableBundle bundle;
|
final TetherStatsParcel[] tetherStatsVec;
|
||||||
try {
|
try {
|
||||||
bundle = mNetdService.tetherGetStats();
|
tetherStatsVec = mNetdService.tetherGetStats();
|
||||||
} catch (RemoteException | ServiceSpecificException e) {
|
} catch (RemoteException | ServiceSpecificException e) {
|
||||||
throw new IllegalStateException("problem parsing tethering stats: ", e);
|
throw new IllegalStateException("problem parsing tethering stats: ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(),
|
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(),
|
||||||
bundle.size());
|
tetherStatsVec.length);
|
||||||
final NetworkStats.Entry entry = new NetworkStats.Entry();
|
final NetworkStats.Entry entry = new NetworkStats.Entry();
|
||||||
|
|
||||||
for (String iface : bundle.keySet()) {
|
for (TetherStatsParcel tetherStats : tetherStatsVec) {
|
||||||
long[] statsArray = bundle.getLongArray(iface);
|
|
||||||
try {
|
try {
|
||||||
entry.iface = iface;
|
entry.iface = tetherStats.iface;
|
||||||
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 = statsArray[INetd.TETHER_STATS_RX_BYTES];
|
entry.rxBytes = tetherStats.rxBytes;
|
||||||
entry.rxPackets = statsArray[INetd.TETHER_STATS_RX_PACKETS];
|
entry.rxPackets = tetherStats.rxPackets;
|
||||||
entry.txBytes = statsArray[INetd.TETHER_STATS_TX_BYTES];
|
entry.txBytes = tetherStats.txBytes;
|
||||||
entry.txPackets = statsArray[INetd.TETHER_STATS_TX_PACKETS];
|
entry.txPackets = tetherStats.txPackets;
|
||||||
stats.combineValues(entry);
|
stats.combineValues(entry);
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
throw new IllegalStateException("invalid tethering stats for " + iface, e);
|
throw new IllegalStateException("invalid tethering stats " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ LOCAL_JNI_SHARED_LIBRARIES := \
|
|||||||
libunwindstack \
|
libunwindstack \
|
||||||
libutilscallstack \
|
libutilscallstack \
|
||||||
libziparchive \
|
libziparchive \
|
||||||
libz
|
libz \
|
||||||
|
netd_aidl_interface-cpp
|
||||||
|
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
|
||||||
|
|
||||||
@@ -92,7 +93,8 @@ LOCAL_SHARED_LIBRARIES := \
|
|||||||
liblog \
|
liblog \
|
||||||
libcutils \
|
libcutils \
|
||||||
libnativehelper \
|
libnativehelper \
|
||||||
libnetdaidl
|
libnetdaidl \
|
||||||
|
netd_aidl_interface-cpp
|
||||||
|
|
||||||
LOCAL_STATIC_LIBRARIES := \
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
libpcap \
|
libpcap \
|
||||||
|
|||||||
Reference in New Issue
Block a user