From 71d66396d2930862b41d00b98d11901f5bd5c0d0 Mon Sep 17 00:00:00 2001 From: Wayne Ma Date: Thu, 3 Mar 2022 10:15:09 +0800 Subject: [PATCH] Adding Tethering proto Bug: 153942334 Test: m, flash and boot Change-Id: I853d3a4dd914dd0c65a6c9e1749d8898da68540e --- Tethering/Android.bp | 12 +++++++ Tethering/jarjar-rules.txt | 2 ++ Tethering/proguard.flags | 6 ++++ .../tethering/metrics/stats.proto | 32 +++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 Tethering/src/com/android/networkstack/tethering/metrics/stats.proto diff --git a/Tethering/Android.bp b/Tethering/Android.bp index 41a0651534..29f6e126a5 100644 --- a/Tethering/Android.bp +++ b/Tethering/Android.bp @@ -47,6 +47,7 @@ java_defaults { "net-utils-device-common-bpf", "net-utils-device-common-netlink", "netd-client", + "tetheringstatsprotos", ], libs: [ "framework-connectivity", @@ -211,3 +212,14 @@ sdk { bootclasspath_fragments: ["com.android.tethering-bootclasspath-fragment"], systemserverclasspath_fragments: ["com.android.tethering-systemserverclasspath-fragment"], } + +java_library_static { + name: "tetheringstatsprotos", + proto: {type: "lite"}, + srcs: [ + "src/com/android/networkstack/tethering/metrics/stats.proto", + ], + static_libs: ["tetheringprotos"], + apex_available: ["com.android.tethering"], + min_sdk_version: "30", +} diff --git a/Tethering/jarjar-rules.txt b/Tethering/jarjar-rules.txt index 5de4b97b76..40eed3f4fc 100644 --- a/Tethering/jarjar-rules.txt +++ b/Tethering/jarjar-rules.txt @@ -12,3 +12,5 @@ rule com.android.net.module.util.** com.android.networkstack.tethering.util.@1 # Classes from net-utils-device-common rule com.android.net.module.util.Struct* com.android.networkstack.tethering.util.Struct@1 + +rule com.google.protobuf.** com.android.networkstack.tethering.protobuf@1 \ No newline at end of file diff --git a/Tethering/proguard.flags b/Tethering/proguard.flags index 6735317ec7..7b5ae0dfbe 100644 --- a/Tethering/proguard.flags +++ b/Tethering/proguard.flags @@ -19,3 +19,9 @@ -keepclassmembers class android.net.ip.IpServer { static final int CMD_*; } + +# The lite proto runtime uses reflection to access fields based on the names in +# the schema, keep all the fields. +-keepclassmembers class * extends com.android.networkstack.tethering.protobuf.MessageLite { + ; +} \ No newline at end of file diff --git a/Tethering/src/com/android/networkstack/tethering/metrics/stats.proto b/Tethering/src/com/android/networkstack/tethering/metrics/stats.proto new file mode 100644 index 0000000000..46a47af83a --- /dev/null +++ b/Tethering/src/com/android/networkstack/tethering/metrics/stats.proto @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto2"; +option java_multiple_files = true; + +package com.android.networkstack.tethering.metrics; + +import "frameworks/proto_logging/stats/enums/stats/connectivity/tethering.proto"; + +/** + * Logs Tethering events + */ +message NetworkTetheringReported { + optional .android.stats.connectivity.ErrorCode error_code = 1; + optional .android.stats.connectivity.DownstreamType downstream_type = 2; + optional .android.stats.connectivity.UpstreamType upstream_type = 3; + optional .android.stats.connectivity.UserType user_type = 4; +}