1// Copyright 2018 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
15package {
16    default_applicable_licenses: ["Android-Apache-2.0"],
17}
18
19java_sdk_library {
20    name: "android.net.ipsec.ike",
21    installable: true,
22    defaults: ["framework-module-defaults"],
23
24    // ike is used as a shared library.
25    shared_library: true,
26    compile_dex: true,
27
28    aidl: {
29        local_include_dirs: ["src/java"],
30    },
31    srcs: [":ike-srcs"],
32
33    static_libs: [
34        "ike-internals",
35    ],
36
37    libs: [
38        "unsupportedappusage",
39        "framework-annotations-lib",
40        "conscrypt.module.public.api",
41        "framework-configinfrastructure",
42        "framework-connectivity.stubs.module_lib",
43        "framework-connectivity-t.stubs.module_lib",
44        "framework-statsd.stubs.module_lib",
45    ],
46    stub_only_libs: [
47        "framework-connectivity.stubs.module_lib",
48        "framework-connectivity-t.stubs.module_lib",
49    ],
50
51    api_packages: [
52        "android.net.eap",
53        "android.net.ipsec.ike",
54        "android.net.ipsec.ike.exceptions",
55        "android.net.ipsec.ike.exceptions.protocol",
56        "android.net.ipsec.ike.ike3gpp",
57    ],
58
59    hidden_api_packages: [
60        "com.android.internal.net",
61    ],
62
63    aconfig_declarations: [
64        "ipsec_aconfig_flags",
65    ],
66
67    lint: {
68        baseline_filename: "lint-baseline.xml",
69    },
70
71    // Shared filegroups of BouncyCastle and frameworks are jar-jar'ed to avoid
72    // being overwritten by the frameworks class copies.
73    jarjar_rules: "jarjar-rules-shared.txt",
74
75    hostdex: true, // for hiddenapi check
76    apex_available: [
77        "com.android.ipsec",
78        "test_com.android.ipsec",
79    ],
80
81    permitted_packages: [
82        "com.android.internal.net",
83        "android.net.ipsec.ike",
84        "android.net.eap",
85    ],
86    min_sdk_version: "30",
87}
88
89filegroup {
90    name: "ike-srcs",
91    defaults: ["framework-sources-module-defaults"],
92    srcs: [
93        ":ike-internal-srcs",
94        ":framework-ike-shared-srcs",
95        ":statslog-ike-java-gen",
96    ],
97}
98
99filegroup {
100    name: "ike-internal-srcs",
101    srcs: [
102        "src/java/**/*.java",
103    ],
104    path: "src/java/",
105}
106
107filegroup {
108    name: "ike-aes-xcbc",
109    srcs: ["src/java/**/AesXCbcImpl.java"],
110}
111
112// Provides internal classes needed to build the ike sources.
113java_library {
114    name: "ike-internals",
115    min_sdk_version: "30",
116    apex_available: [
117        "com.android.ipsec",
118        "test_com.android.ipsec",
119    ],
120    static_libs: [
121        "bouncycastle_ike_digests",
122        "modules-utils-build",
123        "modules-utils-statemachine",
124    ],
125    sdk_version: "module_current",
126}
127
128java_library {
129    name: "ike_test",
130    installable: false, // Used only for testing; never installed alone.
131    srcs: [":ike-srcs"],
132    libs: [
133        "unsupportedappusage",
134        "conscrypt.module.public.api",
135    ],
136    static_libs: ["ike-internals"],
137
138    // Shared filegroups of BouncyCastle and frameworks are jar-jar'ed to avoid
139    // being overwritten by the frameworks class copies and break code coverage
140    // reports. IKE source files are jarjared to avoid this test jar being
141    // overshadowed by the IKE jar in framework and bootclasspath which will
142    // cause compiling and runtime errors respectively.
143    jarjar_rules: "jarjar-rules-test.txt",
144}
145
146java_library {
147    name: "ike-test-utils-dependency",
148    installable: false, // Used only for building the "ike-test-utils"
149    srcs: ["src/java/**/IkeCertUtils.java"],
150    jarjar_rules: "jarjar-rules-test.txt",
151}
152
153java_library {
154    name: "ike-test-utils",
155    srcs: [
156        "src/java/**/PolicyDirection.java",
157        "tests/iketests/src/java/**/CertUtils.java",
158    ],
159    static_libs: ["ike-test-utils-dependency"],
160    libs: ["androidx.test.rules"],
161    visibility: ["//packages/modules/IPsec/tests/cts"],
162}
163
164sdk {
165    name: "ipsec-module-sdk",
166    apexes: [
167        // Adds exportable dependencies of the APEX to the sdk,
168        // e.g. *classpath_fragments.
169        "com.android.ipsec",
170    ],
171}
172
173genrule {
174    name: "statslog-ike-java-gen",
175    tools: ["stats-log-api-gen"],
176    cmd: "$(location stats-log-api-gen) --java $(out) --module ike" +
177        " --javaPackage com.android.internal.net.ipsec.ike.utils --javaClass IkeMetricsInterface",
178    out: ["com/android/internal/net/ipsec/ike/utils/IkeMetricsInterface.java"],
179}
180