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

Commit 09cd4dfc authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

Allow a target to specify its own mobile iface name

Fixes lack of traffic indicators when the interface isn't named
"rmnet0"

Change-Id: I68247cd2765cb4fe1bfeb0ec77e0a7a71ed3df44
parent faea1156
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -253,6 +253,10 @@ ifneq ($(TARGET_RECOVERY_WRITE_MISC_PART),)
        LOCAL_CFLAGS += -DRECOVERY_WRITE_MISC_PART='$(TARGET_RECOVERY_WRITE_MISC_PART)'
endif

ifneq ($(BOARD_MOBILEDATA_INTERFACE_NAME),)
        LOCAL_CFLAGS += -DMOBILE_IFACE_NAME='$(BOARD_MOBILEDATA_INTERFACE_NAME)'
endif

include $(BUILD_SHARED_LIBRARY)

include $(call all-makefiles-under,$(LOCAL_PATH))
+16 −4
Original line number Diff line number Diff line
@@ -28,6 +28,10 @@
#include <utils/misc.h>
#include <utils/Log.h>

#ifndef MOBILE_IFACE_NAME
 #define MOBILE_IFACE_NAME "rmnet0"
#endif

namespace android {

// Returns an ASCII decimal number read from the specified file, -1 on error.
@@ -96,26 +100,34 @@ static jlong readTotal(char const* suffix) {
// each file every time (rather than caching which ones exist).

static jlong getMobileTxPackets(JNIEnv* env, jobject clazz) {
    char filename[80];
    sprintf(filename, "/sys/class/net/%s/statistics/tx_packets", MOBILE_IFACE_NAME);
    return tryBoth(
            "/sys/class/net/rmnet0/statistics/tx_packets",
            filename,
            "/sys/class/net/ppp0/statistics/tx_packets");
}

static jlong getMobileRxPackets(JNIEnv* env, jobject clazz) {
    char filename[80];
    sprintf(filename, "/sys/class/net/%s/statistics/rx_packets", MOBILE_IFACE_NAME);
    return tryBoth(
            "/sys/class/net/rmnet0/statistics/rx_packets",
            filename,
            "/sys/class/net/ppp0/statistics/rx_packets");
}

static jlong getMobileTxBytes(JNIEnv* env, jobject clazz) {
    char filename[80];
    sprintf(filename, "/sys/class/net/%s/statistics/tx_bytes", MOBILE_IFACE_NAME);
    return tryBoth(
            "/sys/class/net/rmnet0/statistics/tx_bytes",
            filename,
            "/sys/class/net/ppp0/statistics/tx_bytes");
}

static jlong getMobileRxBytes(JNIEnv* env, jobject clazz) {
    char filename[80];
    sprintf(filename, "/sys/class/net/%s/statistics/rx_bytes", MOBILE_IFACE_NAME);
    return tryBoth(
            "/sys/class/net/rmnet0/statistics/rx_bytes",
            filename,
            "/sys/class/net/ppp0/statistics/rx_bytes");
}