Files
frameworks_base/services/Android.bp
Hai Zhang 3070d7cb82 Add services.permission java_library_static with Kotlin.
The permission and app op subsystems turned out to have a lot more
hidden references throughout the system server and it's infeasible to
define system APIs for all those references in U. So to allow
utilizing the new unified subsystem for them, we need to keep the new
subsystem in the non-updatable platform for now.

The Kotlin usage for the new subsystem was approved for the APEX
system server JAR inside Permission Mainline module, and we can
achieve the same criteria with a standalone Java library module in the
non-updatable platform, so that Kotlin is still jarjar'ed, shrunk and
only available within this module.

A caveat is that because R8 converts Java byte code to Dalvik byte
code, it can only be run when producing the final services.jar,
instead of directly when compiling this new java_library_static
module. Fortunately, services.jar has already enabled R8 shrinking
when SYSTEM_OPTIMIZE_JAVA is enabled, and when it's disabled due to
dependent JARs, we can still safely confine the shrinking within the
new module with a negated rule since no other JARs can depend on the
new code.

The BloatBuster check showed that on AAOS (with SYSTEM_OPTIMIZE_JAVA
disabled), the size of services.odex increased by 1 MB (21.3 MB ->
22.4 MB), but looking at installed-files.json from its build output,
the size of services.jar actually decreased by 2 MB (21.8 MB -> 19.4
MB). Since both of them are pinned in memory, and the new ODEX will
actually have better performance due to better optimization, it's
still a net improvement from the current situation. More details about
this is available at b/258943585#comment14.

An alternative is to create a standalone system server JAR that's also
loaded into SSCP. However, that approach is said to be causing a
slight boot time regression in b/155631167.

Bug: 182523293
Test: presubmit
Test: AyeAye BloatBuster
Test: CtsStrictJavaPackagesTestCases
Change-Id: Id35e19b941e9abbba0d039f993bbf4ec183554ab
2022-11-16 12:51:32 -08:00

262 lines
8.2 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"],
},
}
// Opt-in config for optimizing and shrinking the services target using R8.
// Enabled via `export SYSTEM_OPTIMIZE_JAVA=true`, or explicitly in Make via the
// `SOONG_CONFIG_ANDROID_SYSTEM_OPTIMIZE_JAVA` variable.
// TODO(b/196084106): Enable optimizations by default after stabilizing and
// building out retrace infrastructure.
soong_config_module_type {
name: "system_optimized_java_defaults",
module_type: "java_defaults",
config_namespace: "ANDROID",
bool_variables: ["SYSTEM_OPTIMIZE_JAVA"],
properties: ["optimize"],
}
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.
optimize: false,
shrink: true,
ignore_warnings: false,
proguard_flags_files: ["proguard.flags"],
},
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"],
},
},
},
},
}
filegroup {
name: "services-main-sources",
srcs: [
"java/**/*.java",
"java/**/package.html",
],
path: "java",
visibility: ["//visibility:private"],
}
filegroup {
name: "services-non-updatable-sources",
srcs: [
":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.contentsuggestions-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.restrictions-sources",
":services.searchui-sources",
":services.selectiontoolbar-sources",
":services.smartspace-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",
],
visibility: ["//visibility:private"],
}
java_library {
name: "Slogf",
srcs: ["core/java/com/android/server/utils/Slogf.java"],
}
// merge all required services into one jar
// ============================================================
java_library {
name: "services",
defaults: ["services_java_defaults"],
installable: true,
dex_preopt: {
app_image: true,
profile: "art-profile",
},
exclude_kotlinc_generated_files: 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.contentcapture",
"services.contentsuggestions",
"services.coverage",
"services.credentials",
"services.devicepolicy",
"services.midi",
"services.musicsearch",
"services.net",
"services.people",
"services.permission",
"services.print",
"services.profcollect",
"services.restrictions",
"services.searchui",
"services.selectiontoolbar",
"services.smartspace",
"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",
],
libs: [
"android.hidl.manager-V1.0-java",
"framework-tethering.stubs.module_lib",
"service-art.stubs.system_server",
"service-permission.stubs.system_server",
"service-sdksandbox.stubs.system_server",
],
// 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",
}
filegroup {
name: "art-profile",
srcs: ["art-profile"],
}
// API stub
// =============================================================
stubs_defaults {
name: "services-stubs-default",
installable: false,
args: " --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."],
}
droidstubs {
name: "services-non-updatable-stubs",
srcs: [":services-non-updatable-sources"],
defaults: ["services-stubs-default"],
check_api: {
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",
},
},
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",
},
],
}