1//
2// Copyright (C) 2021 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16package {
17    default_team: "trendy_team_fwk_uwb",
18    default_applicable_licenses: ["Android-Apache-2.0"],
19}
20
21java_defaults {
22    name: "service-uwb-common-defaults",
23    defaults: ["uwb-module-sdk-version-defaults"],
24    errorprone: {
25        javacflags: ["-Xep:CheckReturnValue:ERROR"],
26    },
27}
28
29filegroup {
30    name: "service-uwb-srcs",
31    srcs: [
32        "java/**/*.java",
33        ":statslog-uwb-java-gen",
34        ":uwb_config",
35    ],
36}
37
38// pre-jarjar version of service-uwb that builds against pre-jarjar version of framework-uwb
39java_library {
40    name: "service-uwb-pre-jarjar",
41    installable: false,
42    defaults: ["service-uwb-common-defaults"],
43    srcs: [":service-uwb-srcs"],
44    required: ["libuwb_uci_jni_rust"],
45    sdk_version: "system_server_current",
46
47    libs: [
48        "androidx.annotation_annotation",
49        "framework-annotations-lib",
50        "framework-configinfrastructure",
51        "framework-uwb-pre-jarjar",
52        "ServiceUwbResources",
53        "framework-statsd.stubs.module_lib",
54        "framework-wifi.stubs.module_lib",
55        "framework-bluetooth.stubs.module_lib",
56        "framework-location.stubs.module_lib",
57    ],
58
59    static_libs: [
60        "android.hardware.uwb.fira_android-V3-java",
61        "com.uwb.support.aliro",
62        "com.uwb.support.ccc",
63        "com.uwb.support.fira",
64        "com.uwb.support.generic",
65        "com.uwb.support.multichip",
66        "com.uwb.support.profile",
67        "com.uwb.support.oemextension",
68        "com.uwb.support.dltdoa",
69        "com.uwb.support.radar",
70        "guava",
71        "modules-utils-shell-command-handler",
72        "modules-utils-handlerexecutor",
73        "modules-utils-preconditions",
74        "uwb-config-proto",
75        "modules-utils-statemachine",
76        "modules-utils-build",
77        "cbor-java",
78        "bouncycastle-uwb",
79        "uwb_flags_lib",
80    ],
81
82    apex_available: [
83        "com.android.uwb",
84    ],
85}
86
87// service-uwb static library
88// ============================================================
89java_library {
90    name: "service-uwb",
91    defaults: [
92        "service-uwb-common-defaults",
93        "standalone-system-server-module-optimize-defaults",
94    ],
95    installable: true,
96    static_libs: ["service-uwb-pre-jarjar"],
97
98    // Need to include `libs` so that Soong doesn't complain about missing classes after jarjaring
99    // The below libraries are not actually needed to build since no source is compiled
100    // but they are necessary so that R8 has the right references to optimize the code.
101    // Without these, there will be missing class warnings and code may be wrongly optimized.
102    // TODO(b/242088131): remove libraries that aren't used directly
103    libs: [
104        "framework-uwb.impl",
105        "framework-statsd.stubs.module_lib",
106        "framework-wifi.stubs.module_lib",
107        "framework-bluetooth.stubs.module_lib",
108        "framework-connectivity.stubs.module_lib",
109    ],
110
111    sdk_version: "system_server_current",
112
113    jarjar_rules: ":uwb-jarjar-rules",
114    optimize: {
115        proguard_flags_files: ["proguard.flags"],
116    },
117    visibility: [
118        "//packages/modules/Uwb/apex",
119        "//packages/modules/Uwb/service/tests/uwbtests/apex",
120    ],
121    apex_available: [
122        "com.android.uwb",
123    ],
124}
125
126// Statsd auto-generated code
127// ============================================================
128genrule {
129    name: "statslog-uwb-java-gen",
130    tools: ["stats-log-api-gen"],
131    cmd: "$(location stats-log-api-gen) --java $(out) --module uwb " +
132        " --javaPackage com.android.server.uwb.proto --javaClass UwbStatsLog" +
133        " --minApiLevel 33",
134    out: ["com/android/server/uwb/proto/UwbStatsLog.java"],
135}
136