1 // Copyright 2015 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/android/traffic_stats.h" 6 7 #include "net/net_jni_headers/AndroidTrafficStats_jni.h" 8 9 namespace net::android::traffic_stats { 10 11 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net 12 enum TrafficStatsError { 13 // Value returned by AndroidTrafficStats APIs when a valid value is 14 // unavailable. 15 ERROR_NOT_SUPPORTED = 0, 16 }; 17 GetTotalTxBytes(int64_t * bytes)18bool GetTotalTxBytes(int64_t* bytes) { 19 JNIEnv* env = jni_zero::AttachCurrentThread(); 20 *bytes = Java_AndroidTrafficStats_getTotalTxBytes(env); 21 return *bytes != ERROR_NOT_SUPPORTED; 22 } 23 GetTotalRxBytes(int64_t * bytes)24bool GetTotalRxBytes(int64_t* bytes) { 25 JNIEnv* env = jni_zero::AttachCurrentThread(); 26 *bytes = Java_AndroidTrafficStats_getTotalRxBytes(env); 27 return *bytes != ERROR_NOT_SUPPORTED; 28 } 29 GetCurrentUidTxBytes(int64_t * bytes)30bool GetCurrentUidTxBytes(int64_t* bytes) { 31 JNIEnv* env = jni_zero::AttachCurrentThread(); 32 *bytes = Java_AndroidTrafficStats_getCurrentUidTxBytes(env); 33 return *bytes != ERROR_NOT_SUPPORTED; 34 } 35 GetCurrentUidRxBytes(int64_t * bytes)36bool GetCurrentUidRxBytes(int64_t* bytes) { 37 JNIEnv* env = jni_zero::AttachCurrentThread(); 38 *bytes = Java_AndroidTrafficStats_getCurrentUidRxBytes(env); 39 return *bytes != ERROR_NOT_SUPPORTED; 40 } 41 42 } // namespace net::android::traffic_stats 43