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

Commit 4e8d8238 authored by Dan Egnor's avatar Dan Egnor
Browse files

Fix sim build (sim doesn't have strl*() reliably...)

Just stub out the TrafficStats code for the sim.
Bug: 2578938

Change-Id: Ie555f67f581d05ee446ea29cb2223feb350c52f9
parent 78158db5
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ namespace android {

// Returns an ASCII decimal number read from the specified file, -1 on error.
static jlong readNumber(char const* filename) {
#ifdef HAVE_ANDROID_OS
    char buf[80];
    int fd = open(filename, O_RDONLY);
    if (fd < 0) {
@@ -49,6 +50,9 @@ static jlong readNumber(char const* filename) {
    close(fd);
    buf[len] = '\0';
    return atoll(buf);
#else  // Simulator
    return -1;
#endif
}

// Return the number from the first file which exists and contains data
@@ -60,6 +64,7 @@ static jlong tryBoth(char const* a, char const* b) {
// Returns the sum of numbers from the specified path under /sys/class/net/*,
// -1 if no such file exists.
static jlong readTotal(char const* suffix) {
#ifdef HAVE_ANDROID_OS
    char filename[PATH_MAX] = "/sys/class/net/";
    DIR *dir = opendir(filename);
    if (dir == NULL) {
@@ -81,6 +86,9 @@ static jlong readTotal(char const* suffix) {

    closedir(dir);
    return total;
#else  // Simulator
    return -1;
#endif
}

// Mobile stats get accessed a lot more often than total stats.