Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13b79e83 authored by Luke Huang's avatar Luke Huang
Browse files

Refactor tetherGetStats by using stable aidl structure

Use stable aidl structure instead of persistbundle

Test: runtest frameworks-net passes
Test: manual testing of tetherGetStats function works

Change-Id: I6835541d450446ba7993ac9f5b783d34229b79cb
parent afffa372
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -690,6 +690,7 @@ java_defaults {
        "android.hardware.wifi-V1.0-java-constants",
        "android.hardware.radio-V1.0-java",
        "android.hardware.usb.gadget-V1.0-java",
        "netd_aidl_interface-java",
    ],

    // Loaded with System.loadLibrary by android.view.textclassifier
+1 −0
Original line number Diff line number Diff line
@@ -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",
    ],
}

+11 −11
Original line number Diff line number Diff line
@@ -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);
                }
            }

+4 −2
Original line number Diff line number Diff line
@@ -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 \