tbansal | 59a1ddc | 2015-09-14 17:35:01 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 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 | |
Mohamed Heikal | 5880044 | 2019-06-22 00:19:48 | [diff] [blame] | 7 | #include "net/net_jni_headers/AndroidTrafficStats_jni.h" |
tbansal | 59a1ddc | 2015-09-14 17:35:01 | [diff] [blame] | 8 | |
| 9 | namespace net { |
| 10 | |
| 11 | namespace android { |
| 12 | |
| 13 | namespace traffic_stats { |
| 14 | |
| 15 | // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net |
| 16 | enum TrafficStatsError { |
| 17 | // Value returned by AndroidTrafficStats APIs when a valid value is |
| 18 | // unavailable. |
| 19 | ERROR_NOT_SUPPORTED = 0, |
| 20 | }; |
| 21 | |
| 22 | bool GetTotalTxBytes(int64_t* bytes) { |
| 23 | JNIEnv* env = base::android::AttachCurrentThread(); |
| 24 | *bytes = Java_AndroidTrafficStats_getTotalTxBytes(env); |
| 25 | return *bytes != ERROR_NOT_SUPPORTED; |
| 26 | } |
| 27 | |
tbansal | 41004183 | 2015-09-28 21:19:17 | [diff] [blame] | 28 | bool GetTotalRxBytes(int64_t* bytes) { |
| 29 | JNIEnv* env = base::android::AttachCurrentThread(); |
| 30 | *bytes = Java_AndroidTrafficStats_getTotalRxBytes(env); |
| 31 | return *bytes != ERROR_NOT_SUPPORTED; |
| 32 | } |
| 33 | |
| 34 | bool GetCurrentUidTxBytes(int64_t* bytes) { |
| 35 | JNIEnv* env = base::android::AttachCurrentThread(); |
| 36 | *bytes = Java_AndroidTrafficStats_getCurrentUidTxBytes(env); |
| 37 | return *bytes != ERROR_NOT_SUPPORTED; |
| 38 | } |
| 39 | |
| 40 | bool GetCurrentUidRxBytes(int64_t* bytes) { |
| 41 | JNIEnv* env = base::android::AttachCurrentThread(); |
| 42 | *bytes = Java_AndroidTrafficStats_getCurrentUidRxBytes(env); |
| 43 | return *bytes != ERROR_NOT_SUPPORTED; |
| 44 | } |
| 45 | |
tbansal | 59a1ddc | 2015-09-14 17:35:01 | [diff] [blame] | 46 | } // namespace traffic_stats |
| 47 | |
| 48 | } // namespace android |
| 49 | |
| 50 | } // namespace net |