• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // Must come after all headers that specialize FromJniType() / ToJniType().
8 #include "net/net_jni_headers/AndroidTrafficStats_jni.h"
9 
10 namespace net::android::traffic_stats {
11 
12 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
13 enum TrafficStatsError {
14   // Value returned by AndroidTrafficStats APIs when a valid value is
15   // unavailable.
16   ERROR_NOT_SUPPORTED = 0,
17 };
18 
GetTotalTxBytes(int64_t * bytes)19 bool GetTotalTxBytes(int64_t* bytes) {
20   JNIEnv* env = jni_zero::AttachCurrentThread();
21   *bytes = Java_AndroidTrafficStats_getTotalTxBytes(env);
22   return *bytes != ERROR_NOT_SUPPORTED;
23 }
24 
GetTotalRxBytes(int64_t * bytes)25 bool GetTotalRxBytes(int64_t* bytes) {
26   JNIEnv* env = jni_zero::AttachCurrentThread();
27   *bytes = Java_AndroidTrafficStats_getTotalRxBytes(env);
28   return *bytes != ERROR_NOT_SUPPORTED;
29 }
30 
GetCurrentUidTxBytes(int64_t * bytes)31 bool GetCurrentUidTxBytes(int64_t* bytes) {
32   JNIEnv* env = jni_zero::AttachCurrentThread();
33   *bytes = Java_AndroidTrafficStats_getCurrentUidTxBytes(env);
34   return *bytes != ERROR_NOT_SUPPORTED;
35 }
36 
GetCurrentUidRxBytes(int64_t * bytes)37 bool GetCurrentUidRxBytes(int64_t* bytes) {
38   JNIEnv* env = jni_zero::AttachCurrentThread();
39   *bytes = Java_AndroidTrafficStats_getCurrentUidRxBytes(env);
40   return *bytes != ERROR_NOT_SUPPORTED;
41 }
42 
43 }  // namespace net::android::traffic_stats
44