summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDan Egnor <egnor@google.com>2010-04-09 12:50:11 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-04-09 12:50:11 -0700
commit2d3df559dea9ebb0ab263c2df26e8a345ed74d12 (patch)
treea4a327bdba0a5a2fc3cdb88e5828132268fb9d98 /core
parent34959e3fe87012d554af07fd6ad294b2ce3daea7 (diff)
parent4e8d8238e10d168b434dcdd2e779a9aab37f1e2c (diff)
downloadframeworks_base-2d3df559dea9ebb0ab263c2df26e8a345ed74d12.zip
frameworks_base-2d3df559dea9ebb0ab263c2df26e8a345ed74d12.tar.gz
frameworks_base-2d3df559dea9ebb0ab263c2df26e8a345ed74d12.tar.bz2
Merge "Fix sim build (sim doesn't have strl*() reliably...)" into froyo
Diffstat (limited to 'core')
-rw-r--r--core/jni/android_net_TrafficStats.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/jni/android_net_TrafficStats.cpp b/core/jni/android_net_TrafficStats.cpp
index db8fdf2..ff46bdd 100644
--- a/core/jni/android_net_TrafficStats.cpp
+++ b/core/jni/android_net_TrafficStats.cpp
@@ -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.