1// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// 1. The "net-utils-framework-common" library is also compiled into the framework and placed on the
16//    boot classpath. It uses jarjar rules so that anything outside the framework can use this
17//    library directly.
18// 2. The "net-utils-services-common" library is for use by modules and frameworks/base/services.
19//    It does not need to be jarjared because it is not placed on the bootclasspath.
20// 3. The "net-utils-telephony-common-srcs" filegroup is for use specifically by telephony, which
21//    places many of its classes, even non-API service classes, on the boot classpath. Any file that
22//    is added to this filegroup *must* have a corresponding jarjar rule in the telephony jarjar
23//    rules file. Otherwise, it will end up on the boot classpath and other modules will not be able
24//    to provide their own copy.
25
26// Note: all filegroups here must have the right path attribute because otherwise, if they are
27// included in the bootclasspath, they could incorrectly be included in the SDK documentation even
28// though they are not in the current.txt files.
29
30package {
31    default_applicable_licenses: ["Android-Apache-2.0"],
32}
33
34java_library {
35  name: "net-utils-device-common",
36  srcs: [
37      "device/com/android/net/module/util/**/*.java",
38      // This library is used by system modules, for which the system health impact of Kotlin
39      // has not yet been evaluated. Annotations may need jarjar'ing.
40      // "src_devicecommon/**/*.kt",
41      ":framework-annotations",
42  ],
43  sdk_version: "system_current",
44  min_sdk_version: "29",
45  target_sdk_version: "30",
46  apex_available: [
47      "//apex_available:anyapex",
48      "//apex_available:platform",
49  ],
50  visibility: [
51        "//frameworks/base/packages/Tethering",
52        "//packages/modules/Connectivity:__subpackages__",
53        "//packages/modules/Connectivity/framework:__subpackages__",
54        "//frameworks/opt/net/ike",
55        "//frameworks/opt/net/wifi/service",
56        "//packages/modules/Wifi/service",
57        "//frameworks/opt/net/telephony",
58        "//packages/modules/NetworkStack:__subpackages__",
59        "//packages/modules/CaptivePortalLogin",
60        "//frameworks/libs/net/common/tests:__subpackages__",
61        "//frameworks/libs/net/common/testutils:__subpackages__",
62  ],
63  static_libs: [
64      "net-utils-framework-common",
65  ],
66  libs: [
67      "androidx.annotation_annotation",
68  ],
69}
70
71java_defaults {
72    name: "lib_mockito_extended",
73    static_libs: [
74        "mockito-target-extended-minus-junit4"
75    ],
76    jni_libs: [
77        "libdexmakerjvmtiagent",
78        "libstaticjvmtiagent",
79    ],
80}
81
82filegroup {
83    name: "net-utils-framework-common-srcs",
84    srcs: ["framework/**/*.java"],
85    path: "framework",
86    visibility: [
87        "//frameworks/base",
88        "//packages/modules/Connectivity:__subpackages__",
89        "//frameworks/base/packages/Connectivity/framework",
90    ],
91}
92
93java_library {
94    name: "net-utils-framework-common",
95    srcs: [
96        ":net-utils-framework-common-srcs",
97        // TODO: avoid including all framework annotations as they end up in library users jars
98        // and need jarjaring
99        ":framework-annotations",
100    ],
101    sdk_version: "system_current",
102    jarjar_rules: "jarjar-rules-shared.txt",
103    visibility: [
104        "//cts/tests/tests/net",
105        "//cts/tests/tests/wifi",
106        "//packages/modules/Connectivity/tests/cts/net",
107        "//frameworks/base/packages/Tethering",
108        "//packages/modules/Connectivity/Tethering",
109        "//frameworks/base/tests:__subpackages__",
110        "//frameworks/opt/net/ike",
111        "//frameworks/opt/telephony",
112        "//frameworks/base/wifi:__subpackages__",
113        "//frameworks/base/packages/Connectivity:__subpackages__",
114        "//packages/modules/Connectivity:__subpackages__",
115        "//packages/modules/NetworkStack:__subpackages__",
116        "//packages/modules/CaptivePortalLogin",
117        "//frameworks/libs/net/common/tests:__subpackages__",
118        "//frameworks/libs/net/common/device",
119        "//packages/modules/Wifi/framework/tests:__subpackages__",
120    ],
121}
122filegroup {
123    name: "net-utils-services-common-srcs",
124    srcs: [
125        "device/android/net/NetworkFactory.java",
126        "device/android/net/NetworkFactoryImpl.java",
127        "device/android/net/NetworkFactoryLegacyImpl.java",
128        "device/android/net/NetworkFactoryShim.java",
129    ],
130    visibility: [
131        "//frameworks/base/services/net",
132    ],
133}
134
135java_library {
136    name: "net-utils-services-common",
137    srcs: [
138        ":net-utils-services-common-srcs",
139        ":framework-annotations",
140    ],
141    sdk_version: "system_current",
142    min_sdk_version: "30",
143    static_libs: [
144        "modules-utils-build_system",
145    ],
146    visibility: [
147        "//frameworks/base/services/net",
148    ],
149}
150
151// Use a filegroup and not a library for telephony sources, as framework-annotations cannot be
152// included either (some annotations would be duplicated on the bootclasspath).
153filegroup {
154    name: "net-utils-telephony-common-srcs",
155    srcs: [
156        // Any class here *must* have a corresponding jarjar rule in the telephony build rules.
157        "device/android/net/NetworkFactory.java",
158        "device/android/net/NetworkFactoryImpl.java",
159        "device/android/net/NetworkFactoryLegacyImpl.java",
160        "device/android/net/NetworkFactoryShim.java",
161    ],
162    path: "device",
163    visibility: [
164        "//frameworks/opt/telephony",
165    ],
166}
167
168// Use a filegroup and not a library for wifi sources, as this needs corresponding jar-jar
169// rules on the wifi side.
170// Any class here *must* have a corresponding jarjar rule in the wifi build rules.
171filegroup {
172    name: "net-utils-framework-wifi-common-srcs",
173    srcs: [
174        "framework/com/android/net/module/util/**/*.java",
175    ],
176    path: "framework",
177    visibility: [
178        "//frameworks/base",
179    ],
180}
181
182// Use a filegroup and not a library for wifi sources, as this needs corresponding jar-jar
183// rules on the wifi side.
184// Any class here *must* have a corresponding jarjar rule in the wifi build rules.
185filegroup {
186    name: "net-utils-wifi-service-common-srcs",
187    srcs: [
188       "device/android/net/NetworkFactory.java",
189       "device/android/net/NetworkFactoryImpl.java",
190       "device/android/net/NetworkFactoryLegacyImpl.java",
191       "device/android/net/NetworkFactoryShim.java",
192    ],
193    visibility: [
194        "//frameworks/opt/net/wifi/service",
195        "//packages/modules/Wifi/service",
196    ],
197}
198