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

Commit 335253df authored by Luke Huang's avatar Luke Huang Committed by Gerrit Code Review
Browse files

Merge "Refactor tetherGetStats by using stable aidl structure"

parents cf117607 13b79e83
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -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
+1 −0
Original line number Original line Diff line number Diff line
@@ -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",
    ],
    ],
}
}


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


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