Files
Jihoon Kang 67bb4df230 Provide aconfig srcjars for services stub generation
Currently, flag declarations are not provided as dependencies of the
services non updatable stubs. This change modifies the dependency so
that the flag declarations are provided to the droidstubs and the
flagged apis are correctly resolved by metalava.

Test: Patch ag/35272939 and ensure that api signature file is correctly updated
Flag: EXEMPT build change
Change-Id: I47c7a839341c83096d2adb6cefdd450687018280
2025-09-04 21:57:57 +00:00

565 lines
18 KiB
Plaintext

package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "frameworks_base_license"
// to get the below license kinds:
// SPDX-license-identifier-Apache-2.0
default_applicable_licenses: ["frameworks_base_license"],
}
// Defaults for platform code that runs inside system_server
java_defaults {
name: "platform_service_defaults",
plugins: ["error_prone_android_framework"],
errorprone: {
javacflags: [
"-Xep:AndroidFrameworkCompatChange:ERROR",
// "-Xep:AndroidFrameworkUid:ERROR",
"-Xep:SelfEquals:ERROR",
"-Xep:NullTernary:ERROR",
"-Xep:TryFailThrowable:ERROR",
"-Xep:HashtableContains:ERROR",
"-Xep:FormatString:ERROR",
"-Xep:ArrayHashCode:ERROR",
"-Xep:SelfAssignment:ERROR",
"-Xep:ArrayEquals:ERROR",
"-Xep:IdentityBinaryExpression:ERROR",
// NOTE: only enable to generate local patchfiles
// "-XepPatchChecks:refaster:frameworks/base/errorprone/refaster/EfficientXml.java.refaster",
// "-XepPatchLocation:/tmp/refaster/",
],
},
lint: {
extra_check_modules: ["AndroidFrameworkLintChecker"],
},
}
// Config to control optimizing and shrinking the services target using R8.
// Set via `export SYSTEM_OPTIMIZE_JAVA=true|false`, or explicitly in Make via the
// `SOONG_CONFIG_ANDROID_SYSTEM_OPTIMIZE_JAVA` variable.
soong_config_module_type {
name: "system_optimized_java_defaults",
module_type: "java_defaults",
config_namespace: "ANDROID",
bool_variables: [
"SYSTEM_OPTIMIZE_JAVA",
"FULL_SYSTEM_OPTIMIZE_JAVA",
],
properties: [
"optimize",
"dxflags",
],
}
system_optimized_java_defaults {
name: "services_java_defaults",
soong_config_variables: {
SYSTEM_OPTIMIZE_JAVA: {
optimize: {
enabled: true,
// TODO(b/210510433): Enable optimizations after improving
// retracing infra.
// See also FULL_SYSTEM_OPTIMIZE_JAVA.
optimize: false,
shrink: true,
ignore_warnings: false,
proguard_compatibility: false,
proguard_flags_files: [
"proguard.flags",
// Ensure classes referenced in the framework-res manifest
// and implemented in system_server are kept.
":framework-res{.aapt.proguardOptionsFile}",
],
},
conditions_default: {
optimize: {
enabled: true,
optimize: false,
shrink: true,
ignore_warnings: false,
// Note that this proguard config is very conservative, only shrinking the
// permission subpackage to prune unused jarjar'ed Kotlin dependencies.
proguard_flags_files: ["proguard_permission.flags"],
},
// Explicitly configure R8 to preserve debug info, as this path should
// really only allow stripping of permission-specific code and deps.
dxflags: ["--debug"],
},
},
// Allow form factors to opt-in full system java optimization
FULL_SYSTEM_OPTIMIZE_JAVA: {
optimize: {
optimize: true,
// TODO(b/212737576): Apply this property for the SYSTEM_OPTIMIZE_JAVA case after
// resolving all downstream cyclic dependencies. For now, full optimization is
// more sensitive to downstream lib references, so it stands the most to benefit.
trace_references_from: select(soong_config_variable("ANDROID", "system_server_trace_refs"), {
any @ trace_refs: trace_refs,
default: [],
}),
},
},
},
}
filegroup {
name: "services-main-sources",
srcs: [
"java/**/*.java",
"java/**/package.html",
],
path: "java",
visibility: ["//visibility:private"],
}
filegroup {
name: "services-non-updatable-sources",
srcs: [
":incremental_aidl",
":services.core-aidl-sources",
":services.core-sources",
":services.core-sources-am-wm",
"core/java/com/android/server/am/package.html",
":services.accessibility-sources",
":services.appprediction-sources",
":services.appwidget-sources",
":services.autofill-sources",
":services.backup-sources",
":services.companion-sources",
":services.contentcapture-sources",
":services.appfunctions-sources",
":services.contentsuggestions-sources",
":services.contextualsearch-sources",
":services.coverage-sources",
":services.credentials-sources",
":services.devicepolicy-sources",
":services.midi-sources",
":services.musicsearch-sources",
":services.net-sources",
":services.permission-sources",
":services.print-sources",
":services.profcollect-sources",
":services.userrecovery-sources",
":services.restrictions-sources",
":services.searchui-sources",
":services.selectiontoolbar-sources",
":services.serial-sources",
":services.smartspace-sources",
":services.soundtrigger-sources",
":services.supervision-sources",
":services.systemcaptions-sources",
":services.translation-sources",
":services.texttospeech-sources",
":services.usage-sources",
":services.usb-sources",
":services.voiceinteraction-sources",
":services.wallpapereffectsgeneration-sources",
":services.wifi-sources",
":framework-pm-common-shared-srcs",
":framework-minus-apex-aconfig-srcjars",
],
visibility: ["//visibility:private"],
}
java_library {
name: "Slogf",
srcs: ["core/java/com/android/server/utils/Slogf.java"],
libs: [
"error_prone_annotations",
],
}
soong_config_module_type {
name: "art_profile_java_defaults",
module_type: "java_defaults",
config_namespace: "art_profile",
variables: ["services_profile_path"],
properties: ["dex_preopt"],
}
soong_config_string_variable {
name: "services_profile_path",
values: ["art_wear_profile"],
}
art_profile_java_defaults {
name: "art_profile_java_defaults",
soong_config_variables: {
services_profile_path: {
art_wear_profile: {
dex_preopt: {
app_image: true,
profile: "art-wear-profile",
},
},
conditions_default: {
dex_preopt: {
app_image: true,
profile: ":art-profile-combined",
},
},
},
},
}
// Conditionally add crashrecovery stubs library
soong_config_module_type {
name: "crashrecovery_java_defaults",
module_type: "java_defaults",
config_namespace: "ANDROID",
bool_variables: [
"release_crashrecovery_module",
],
properties: [
"libs",
],
}
crashrecovery_java_defaults {
name: "services_crashrecovery_stubs_conditionally",
soong_config_variables: {
release_crashrecovery_module: {
libs: ["service-crashrecovery.stubs.system_server"],
},
},
}
soong_config_module_type {
name: "ondeviceintelligence_module_java_defaults",
module_type: "java_defaults",
config_namespace: "ANDROID",
bool_variables: [
"release_ondevice_intelligence_module",
"release_ondevice_intelligence_platform",
],
properties: [
"libs",
"srcs",
"static_libs",
],
}
// Conditionally add ondeviceintelligence stubs library
ondeviceintelligence_module_java_defaults {
name: "ondeviceintelligence_conditionally",
soong_config_variables: {
release_ondevice_intelligence_module: {
libs: ["service-ondeviceintelligence.stubs.system_server"],
},
release_ondevice_intelligence_platform: {
srcs: [":service-ondeviceintelligence-sources-platform"],
},
},
}
// Conditionally add anomaly detector stubs library
soong_config_module_type {
name: "anomaly_detector_java_defaults",
module_type: "java_defaults",
config_namespace: "ANDROID",
bool_variables: [
"release_anomaly_detector",
],
properties: [
"libs",
],
}
anomaly_detector_java_defaults {
name: "services_anomaly_detector_stubs_conditionally",
soong_config_variables: {
release_anomaly_detector: {
libs: ["service-anomaly-detector.stubs.system_server"],
},
},
}
soong_config_module_type {
name: "system_java_library",
module_type: "java_library",
config_namespace: "system_services",
variables: ["without_hal"],
properties: ["vintf_fragment_modules"],
}
soong_config_string_variable {
name: "without_hal",
values: [
"vibrator",
"devicestate",
],
}
vintf_fragment {
name: "manifest_services_android.frameworks.location.xml",
src: "manifest_services_android.frameworks.location.xml",
}
vintf_fragment {
name: "manifest_services_android.frameworks.vibrator.xml",
src: "manifest_services_android.frameworks.vibrator.xml",
}
vintf_fragment {
name: "manifest_services_android.frameworks.devicestate.xml",
src: "manifest_services_android.frameworks.devicestate.xml",
}
// merge all required services into one intermediate jar
// ============================================================
java_library {
name: "services.impl",
defaults: [
"services_crashrecovery_stubs_conditionally",
"ondeviceintelligence_conditionally",
"services_anomaly_detector_stubs_conditionally",
],
exclude_kotlinc_generated_files: true,
optimize: {
d8_on_eng: true,
},
srcs: [":services-main-sources"],
// The convention is to name each service module 'services.$(module_name)'
static_libs: [
"services.core",
"services.accessibility",
"services.appprediction",
"services.appwidget",
"services.autofill",
"services.backup",
"services.companion",
"services.appfunctions",
"services.contentcapture",
"services.contentsuggestions",
"services.contextualsearch",
"services.coverage",
"services.credentials",
"services.devicepolicy",
"services.flags",
"services.midi",
"services.musicsearch",
"services.net",
"services.people",
"services.permission",
"services.print",
"services.profcollect",
"services.userrecovery",
"services.restrictions",
"services.searchui",
"services.selectiontoolbar",
"services.serial",
"services.smartspace",
"services.soundtrigger",
"services.supervision",
"services.systemcaptions",
"services.translation",
"services.texttospeech",
"services.usage",
"services.usb",
"services.voiceinteraction",
"services.wallpapereffectsgeneration",
"services.wifi",
"service-blobstore",
"service-jobscheduler",
"android.hidl.base-V1.0-java",
] + select(release_flag("RELEASE_MOVE_VCN_TO_MAINLINE"), {
true: [],
default: ["service-connectivity-b-platform"],
}) + select(release_flag("RELEASE_ANOMALY_DETECTOR"), {
true: ["services.signal-collectors"],
default: [],
}),
libs: [
"android.hidl.manager-V1.0-java",
"framework-tethering.stubs.module_lib",
"keepanno-annotations",
"service-art.stubs.system_server",
"service-permission.stubs.system_server",
"service-rkp.stubs.system_server",
"service-sdksandbox.stubs.system_server",
],
// Uncomment to enable output of certain warnings (deprecated, unchecked)
//javacflags: ["-Xlint"],
visibility: [
":__subpackages__",
"//frameworks/opt:__subpackages__",
],
lint: {
baseline_filename: "lint-baseline.xml",
},
}
// merge all required services into one final installable jar
// ============================================================
system_java_library {
name: "services",
defaults: [
"services_java_defaults",
"art_profile_java_defaults",
],
installable: true,
optimize: {
d8_on_eng: true,
},
exclude_kotlinc_generated_files: true,
// Note: all srcs and static_libs deps should go in services.impl.
static_libs: ["services.impl"],
soong_config_variables: {
without_hal: {
vibrator: {
vintf_fragment_modules: [
"manifest_services_android.frameworks.location.xml",
"manifest_services_android.frameworks.devicestate.xml",
],
},
devicestate: {
vintf_fragment_modules: [
"manifest_services_android.frameworks.location.xml",
"manifest_services_android.frameworks.vibrator.xml",
],
},
conditions_default: {
vintf_fragment_modules: [
"manifest_services_android.frameworks.location.xml",
"manifest_services_android.frameworks.vibrator.xml",
"manifest_services_android.frameworks.devicestate.xml",
],
},
},
},
required: [
"libukey2_jni_shared",
"core.protolog.pb",
"libusb4_policies_jni",
],
lint: {
baseline_filename: "lint-baseline.xml",
},
// Uncomment to enable output of certain warnings (deprecated, unchecked)
//javacflags: ["-Xlint"],
}
// native library
// =============================================================
cc_library_shared {
name: "libandroid_servers",
defaults: ["libservices.core-libs"],
whole_static_libs: ["libservices.core"],
}
platform_compat_config {
name: "services-platform-compat-config",
src: ":services",
}
genrule {
name: "art-profile-combined",
srcs: [
"art-profile",
"art-profile-extra",
],
out: ["art-profile-combined"],
cmd: "cat $(location art-profile) $(location art-profile-extra) > $(location art-profile-combined)",
}
// API stub
// =============================================================
soong_config_module_type_import {
from: "frameworks/base/api/Android.bp",
module_types: ["non_updatable_exportable_droidstubs"],
}
stubs_defaults {
name: "services-stubs-default",
installable: false,
flags: [
"--show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.SYSTEM_SERVER\\)",
"--hide-annotation android.annotation.Hide",
"--hide InternalClasses", // com.android.* classes are okay in this interface
// TODO: remove the --hide options below
"--hide DeprecationMismatch",
"--hide HiddenTypedefConstant",
],
visibility: ["//frameworks/base:__subpackages__"],
filter_packages: ["com.android."],
}
non_updatable_exportable_droidstubs {
name: "services-non-updatable-stubs",
srcs: [":services-non-updatable-sources"],
defaults: [
"services-stubs-default",
],
check_api: {
// Use the compatibility check properties to supply the previously released API to which
// flagged APIs can be reverted but disable the compatibility check as it is not required.
last_released: {
enabled: false,
api_file: ":android.api.combined.system-server.latest",
removed_api_file: ":android-removed.api.combined.system-server.latest",
},
current: {
api_file: "api/current.txt",
removed_api_file: "api/removed.txt",
},
api_lint: {
enabled: true,
new_since: ":android-non-updatable.api.system-server.latest",
baseline_file: "api/lint-baseline.txt",
},
},
soong_config_variables: {
release_hidden_api_exportable_stubs: {
dists: [
{
targets: ["sdk"],
dir: "apistubs/android/system-server/api",
dest: "android-non-updatable.txt",
tag: ".exportable.api.txt",
},
{
targets: ["sdk"],
dir: "apistubs/android/system-server/api",
dest: "android-non-updatable-removed.txt",
tag: ".exportable.removed-api.txt",
},
],
conditions_default: {
dists: [
{
targets: ["sdk"],
dir: "apistubs/android/system-server/api",
dest: "android-non-updatable.txt",
tag: ".api.txt",
},
{
targets: ["sdk"],
dir: "apistubs/android/system-server/api",
dest: "android-non-updatable-removed.txt",
tag: ".removed-api.txt",
},
],
},
},
},
api_surface: "system-server",
sdk_version: "module_current",
libs: [
"framework-annotations-lib",
],
}