blob: 48cdcd257513945a56870c2769af8db2b86d929e [file] [log] [blame]
tbansal59a1ddc2015-09-14 17:35:011// 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 Heikal58800442019-06-22 00:19:487#include "net/net_jni_headers/AndroidTrafficStats_jni.h"
tbansal59a1ddc2015-09-14 17:35:018
9namespace net {
10
11namespace android {
12
13namespace traffic_stats {
14
15// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
16enum TrafficStatsError {
17 // Value returned by AndroidTrafficStats APIs when a valid value is
18 // unavailable.
19 ERROR_NOT_SUPPORTED = 0,
20};
21
22bool GetTotalTxBytes(int64_t* bytes) {
23 JNIEnv* env = base::android::AttachCurrentThread();
24 *bytes = Java_AndroidTrafficStats_getTotalTxBytes(env);
25 return *bytes != ERROR_NOT_SUPPORTED;
26}
27
tbansal410041832015-09-28 21:19:1728bool GetTotalRxBytes(int64_t* bytes) {
29 JNIEnv* env = base::android::AttachCurrentThread();
30 *bytes = Java_AndroidTrafficStats_getTotalRxBytes(env);
31 return *bytes != ERROR_NOT_SUPPORTED;
32}
33
34bool GetCurrentUidTxBytes(int64_t* bytes) {
35 JNIEnv* env = base::android::AttachCurrentThread();
36 *bytes = Java_AndroidTrafficStats_getCurrentUidTxBytes(env);
37 return *bytes != ERROR_NOT_SUPPORTED;
38}
39
40bool GetCurrentUidRxBytes(int64_t* bytes) {
41 JNIEnv* env = base::android::AttachCurrentThread();
42 *bytes = Java_AndroidTrafficStats_getCurrentUidRxBytes(env);
43 return *bytes != ERROR_NOT_SUPPORTED;
44}
45
tbansal59a1ddc2015-09-14 17:35:0146} // namespace traffic_stats
47
48} // namespace android
49
50} // namespace net