1//
2// Copyright (C) 2024 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-ranging-common-defaults",
23    defaults: ["ranging-module-sdk-version-defaults"],
24    errorprone: {
25        javacflags: ["-Xep:CheckReturnValue:ERROR"],
26    },
27}
28
29filegroup {
30    name: "service-ranging-srcs",
31    srcs: [
32        "java/**/*.java",
33    ],
34}
35
36// pre-jarjar version of service-ranging that builds against pre-jarjar version of framework-uwb
37java_library {
38    name: "service-ranging-pre-jarjar",
39    min_sdk_version: "33",
40    installable: false,
41    defaults: ["service-ranging-common-defaults"],
42    srcs: [":service-ranging-srcs"],
43    sdk_version: "system_server_current",
44
45    plugins: [
46        "auto_value_plugin",
47    ],
48    libs: [
49        "androidx.annotation_annotation",
50        "error_prone_annotations",
51        "framework-annotations-lib",
52        "framework-configinfrastructure.stubs.module_lib",
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        "guava",
61        "modules-utils-shell-command-handler",
62        "modules-utils-handlerexecutor",
63        // TODO: migrate away from auto value if possible.
64        "auto_value_annotations",
65        //"modules-utils-preconditions",
66        //"modules-utils-build",
67        "framework-ranging-pre-jarjar",
68        "androidx.annotation_annotation",
69        "androidx.concurrent_concurrent-futures",
70        "androidx.concurrent_concurrent-futures",
71        "com.uwb.fusion",
72        "ranging_rtt_backend",
73        "ranging_uwb_backend",
74        "ranging_flags_lib",
75    ],
76
77    apex_available: [
78        "com.android.uwb",
79    ],
80}
81
82// service-ranging static library
83// ============================================================
84java_library {
85    name: "service-ranging",
86    min_sdk_version: "33",
87    defaults: [
88        "service-ranging-common-defaults",
89        "standalone-system-server-module-optimize-defaults",
90    ],
91    installable: true,
92    static_libs: [
93        "service-ranging-pre-jarjar",
94        "ranging_uwb_backend",
95    ],
96
97    // Need to include `libs` so that Soong doesn't complain about missing classes after jarjaring
98    // The below libraries are not actually needed to build since no source is compiled
99    // but they are necessary so that R8 has the right references to optimize the code.
100    // Without these, there will be missing class warnings and code may be wrongly optimized.
101    // TODO(b/242088131): remove libraries that aren't used directly
102    libs: [
103        "framework-ranging.impl",
104        "framework-statsd.stubs.module_lib",
105        "framework-wifi.stubs.module_lib",
106        "framework-bluetooth.stubs.module_lib",
107        "framework-connectivity.stubs.module_lib",
108    ],
109
110    sdk_version: "system_server_current",
111
112    jarjar_rules: ":ranging-jarjar-rules",
113    //optimize: {
114    //proguard_flags_files: ["proguard.flags"],
115    //},
116    visibility: [
117        "//packages/modules/Uwb/apex",
118    ],
119    apex_available: [
120        "com.android.uwb",
121    ],
122}
123