am 2d3df559: Merge "Fix sim build (sim doesn\'t have strl*() reliably...)" into froyo
Merge commit '2d3df559dea9ebb0ab263c2df26e8a345ed74d12' into froyo-plus-aosp * commit '2d3df559dea9ebb0ab263c2df26e8a345ed74d12': Fix sim build (sim doesn't have strl*() reliably...)
This commit is contained in:
@@ -32,6 +32,7 @@ namespace android {
|
|||||||
|
|
||||||
// Returns an ASCII decimal number read from the specified file, -1 on error.
|
// Returns an ASCII decimal number read from the specified file, -1 on error.
|
||||||
static jlong readNumber(char const* filename) {
|
static jlong readNumber(char const* filename) {
|
||||||
|
#ifdef HAVE_ANDROID_OS
|
||||||
char buf[80];
|
char buf[80];
|
||||||
int fd = open(filename, O_RDONLY);
|
int fd = open(filename, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
@@ -49,6 +50,9 @@ static jlong readNumber(char const* filename) {
|
|||||||
close(fd);
|
close(fd);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
return atoll(buf);
|
return atoll(buf);
|
||||||
|
#else // Simulator
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the number from the first file which exists and contains data
|
// 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/*,
|
// Returns the sum of numbers from the specified path under /sys/class/net/*,
|
||||||
// -1 if no such file exists.
|
// -1 if no such file exists.
|
||||||
static jlong readTotal(char const* suffix) {
|
static jlong readTotal(char const* suffix) {
|
||||||
|
#ifdef HAVE_ANDROID_OS
|
||||||
char filename[PATH_MAX] = "/sys/class/net/";
|
char filename[PATH_MAX] = "/sys/class/net/";
|
||||||
DIR *dir = opendir(filename);
|
DIR *dir = opendir(filename);
|
||||||
if (dir == NULL) {
|
if (dir == NULL) {
|
||||||
@@ -81,6 +86,9 @@ static jlong readTotal(char const* suffix) {
|
|||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return total;
|
return total;
|
||||||
|
#else // Simulator
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mobile stats get accessed a lot more often than total stats.
|
// Mobile stats get accessed a lot more often than total stats.
|
||||||
|
|||||||
Reference in New Issue
Block a user