1// Copyright (C) 2022 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_visibility: [":__subpackages__"],
17    default_applicable_licenses: ["Android-Apache-2.0"],
18}
19
20genrule {
21    name: "statslog-ondevicepersonalization-java-gen",
22    tools: ["stats-log-api-gen"],
23    cmd: "$(location stats-log-api-gen) --java $(out) --module ondevicepersonalization" +
24        " --javaPackage com.android.ondevicepersonalization" +
25        " --javaClass OnDevicePersonalizationStatsLog",
26    out: ["com/android/ondevicepersonalization/OnDevicePersonalizationStatsLog.java"],
27}
28
29java_defaults {
30    name: "ondevicepersonalization-java-defaults",
31    lint: {
32        strict_updatability_linting: true,
33    },
34    plugins: [
35        "staledataclass-annotation-processor",
36    ],
37    // Exports needed for staledataclass-annotation-processor, see b/139342589.
38    javacflags: [
39        "-J--add-modules=jdk.compiler",
40        "-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
41        "-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
42        "-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
43        "-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
44    ],
45    min_sdk_version: "Tiramisu",
46}
47
48filegroup {
49    name: "ondevicepersonalization-sources",
50    srcs: [
51        "src/**/*.java",
52        "src/**/*.aidl",
53        "src/com/android/ondevicepersonalization/services/policyengine/**/*.kt",
54    ],
55    path: "src",
56}
57
58filegroup {
59    name: "chronicle-sources",
60    srcs: [
61        "src/com/android/libraries/**/*.kt",
62    ],
63    path: "src",
64}
65
66java_library {
67    name: "ondevicepersonalization-protos",
68    proto: {
69        type: "lite",
70    },
71    sdk_version: "system_current",
72    min_sdk_version: "Tiramisu",
73    srcs: ["src/**/*.proto"],
74    apex_available: [
75        "com.android.ondevicepersonalization",
76    ],
77}
78
79java_genrule {
80    name: "ondevicepersonalization-fbs",
81    tools: [
82        "flatc",
83        "soong_zip",
84    ],
85    host_supported: true,
86    srcs: ["src/**/*.fbs"],
87    out: ["ondevicepersonalization-fbs.srcjar"],
88    cmd: "$(location flatc) -o $(genDir) --java $(in) " +
89        "&& $(location soong_zip) -o $(out) -C $(genDir) -D $(genDir)",
90}
91
92android_app {
93    name: "OnDevicePersonalization",
94    srcs: [
95        ":ondevicepersonalization-sources",
96        ":chronicle-sources",
97        ":ondevicepersonalization-fbs",
98        ":statslog-ondevicepersonalization-java-gen",
99        ":common-ondevicepersonalization-sources",
100    ],
101    libs: [
102        "framework-adservices", // For user consent
103        "framework-annotations-lib",
104        "framework-configinfrastructure",
105        "framework-connectivity.stubs.module_lib",
106        "framework-location.stubs.module_lib",
107        "framework-ondevicepersonalization.impl",
108        "framework-statsd.stubs.module_lib", // For WW logging
109        "kotlin-annotations",
110    ],
111    static_libs: [
112        "androidx.concurrent_concurrent-futures",
113        "guava",
114        "kotlin-stdlib",
115        "kotlinx_coroutines",
116        "kotlinx-coroutines-android",
117        "ondevicepersonalization-protos",
118        "mobile_data_downloader_lib",
119        "modules-utils-build",
120        "ondevicepersonalization-plugin-lib",
121        "flatbuffers-java",
122        "apache-velocity-engine-core",
123        "owasp-java-encoder",
124        "tensorflowlite_java",
125        "tensorflow_core_proto_java_lite",
126        "adservices-shared-spe",
127    ],
128    sdk_version: "module_current",
129    min_sdk_version: "33",
130    updatable: true,
131    certificate: "platform",
132    privileged: true,
133    apex_available: ["com.android.ondevicepersonalization"],
134    defaults: [
135        "ondevicepersonalization-java-defaults",
136    ],
137    optimize: {
138        shrink_resources: true,
139        proguard_flags_files: ["src/proguard.flags"],
140    },
141}
142