1// Copyright (C) 2020 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_team: "trendy_team_android_permissions",
17    default_applicable_licenses: ["Android-Apache-2.0"],
18}
19
20filegroup {
21    name: "service-permission-java-sources",
22    srcs: [
23        "java/**/*.java",
24        "java/**/*.kt",
25    ],
26    path: "java",
27    visibility: ["//visibility:private"],
28}
29
30java_library {
31    name: "service-permission-proto-stream",
32    proto: {
33        type: "stream",
34        include_dirs: [
35            "external/protobuf/src",
36        ],
37    },
38    srcs: [
39        "proto/role_service.proto",
40    ],
41    installable: false,
42    min_sdk_version: "30",
43    sdk_version: "system_server_current",
44    apex_available: [
45        "com.android.permission",
46        "test_com.android.permission",
47    ],
48}
49
50java_library {
51    name: "service-permission-shared",
52    srcs: [":service-permission-shared-srcs"],
53    libs: [
54        "framework-annotations-lib",
55    ],
56    static_libs: [
57        "framework-permission-s-shared",
58    ],
59    apex_available: [
60        "com.android.permission",
61        "test_com.android.permission",
62    ],
63    installable: false,
64    min_sdk_version: "30",
65    sdk_version: "system_server_current",
66}
67
68java_sdk_library {
69    name: "service-permission",
70    defaults: [
71        "framework-system-server-module-defaults",
72        "framework-system-server-module-optimize-defaults",
73    ],
74    impl_library_visibility: [
75        "//frameworks/base/apex/permission/tests",
76        "//frameworks/base/services/tests/mockingservicestests",
77        "//frameworks/base/services/tests/PackageManagerServiceTests/server",
78        "//packages/modules/Permission/tests/apex",
79    ],
80    srcs: [
81        ":service-permission-java-sources",
82    ],
83    libs: [
84        "androidx.annotation_annotation",
85        "framework-configinfrastructure",
86        // TODO(b/177884622): Short term solution to prevent service-permission from seeing hidden
87        //  APIs in framework-permission, as we don't actually have any dependency in it.
88        //"framework-permission",
89        "framework-permission-s.impl",
90        "framework-permission-s-shared",
91        "framework-statsd.stubs.module_lib",
92        "jsr305",
93
94        // Soong fails to automatically add this dependency because all the
95        // *.kt sources are inside a filegroup.
96        "kotlin-annotations",
97        "safety-center-annotations",
98    ],
99    static_libs: [
100        "kotlin-stdlib",
101        "modules-utils-backgroundthread",
102        "modules-utils-build",
103        "modules-utils-os",
104        "role-controller",
105        "safety-center-config",
106        "safety-center-internal-data",
107        "safety-center-pending-intents",
108        "safety-center-persistence",
109        "safety-center-resources-lib",
110        "service-permission-shared",
111        "service-permission-statsd",
112        "permissioncontroller-statsd",
113        "service-permission-proto-stream",
114        "com.android.permission.flags-aconfig-java",
115    ],
116    errorprone: {
117        javacflags: ["-Xep:GuardedBy:ERROR"],
118    },
119    exclude_kotlinc_generated_files: true,
120    jarjar_rules: "jarjar-rules.txt",
121    kotlincflags: [
122        "-Werror",
123        "-Xjvm-default=all",
124        "-Xno-call-assertions",
125        "-Xno-param-assertions",
126        "-Xno-receiver-assertions",
127    ],
128    lint: {
129        baseline_filename: "lint-baseline.xml",
130    },
131    min_sdk_version: "30",
132    sdk_version: "system_server_current",
133    apex_available: [
134        "com.android.permission",
135        "test_com.android.permission",
136    ],
137    installable: true,
138    permitted_packages: [
139        "com.android.access",
140        "com.android.ecm",
141        "com.android.permission",
142        "com.android.role",
143        "com.android.safetycenter",
144    ],
145    optimize: {
146        proguard_compatibility: false, // TODO(b/215530220): remove when this is default behavior
147        proguard_flags_files: ["proguard.flags"],
148    },
149    aconfig_declarations: [
150        "android.permission.flags-aconfig",
151        "com.android.permission.flags-aconfig",
152    ],
153}
154
155genrule {
156    name: "statslog-service-permission-java-gen",
157    tools: ["stats-log-api-gen"],
158    cmd: "$(location stats-log-api-gen) --java $(out) --module permissioncontroller" +
159        " --javaPackage com.android.permission" +
160        " --javaClass PermissionStatsLog --minApiLevel 29",
161    out: ["com/android/permission/PermissionStatsLog.java"],
162}
163
164java_library {
165    name: "service-permission-statsd",
166    srcs: [
167        ":statslog-service-permission-java-gen",
168    ],
169    libs: [
170        "androidx.annotation_annotation",
171        "framework-statsd.stubs.module_lib",
172    ],
173    apex_available: [
174        "com.android.permission",
175    ],
176    min_sdk_version: "30",
177    sdk_version: "system_server_current",
178}
179