Introduce a set of optional Java optimization and shrinking settings for system server, based on the Soong variable added in aosp/1896612. Opting in to optimizations can be achieved with either: * Env: export SYSTEM_OPTIMIZE_JAVA=true * Make: $(call add_soong_config_var_value,ANDROID,SYSTEM_OPTIMIZE_JAVA,true) Note that the initial Proguard configuration is extremely conservative. Follow-up work will refine the rules to both allow additional shrinking while avoiding developer friction and overhead when adding services and dynamically loaded jars. As these optimiations can change the resulting stack traces, a parallel effort is working to simplify retracing of stack traces for more accurate debugging and diagnostics. Additional stabiliation and testing will occur before any effort to enable these optimizations by default for specific targets. Also note that there are no plans to enable obfuscation for any of these targets. Preliminary results: * Conservative keep rules (this CL w/ opt-in flag): * services.jar (19MB -> 15MB) * services.odex (52MB -> 54MB) (mostly from increased inlining) * Refined keep rules (follow-up CL): * services.jar (19MB -> 12MB) * services.odex (52MB -> 45MB) Bug: 203088572 Test: SYSTEM_OPTIMIZE_JAVA=true m (validate services.jar/odex change) Change-Id: I4130233310323611f63cd9bfcc0646080cf95875
243 lines
7.3 KiB
Plaintext
243 lines
7.3 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:AndroidFrameworkBinderIdentity:ERROR",
|
|
"-Xep:AndroidFrameworkCompatChange:ERROR",
|
|
// "-Xep:AndroidFrameworkUid:ERROR",
|
|
// NOTE: only enable to generate local patchfiles
|
|
// "-XepPatchChecks:refaster:frameworks/base/errorprone/refaster/EfficientXml.java.refaster",
|
|
// "-XepPatchLocation:/tmp/refaster/",
|
|
],
|
|
},
|
|
}
|
|
|
|
// 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,
|
|
optimize: true,
|
|
shrink: true,
|
|
proguard_flags_files: ["proguard.flags"],
|
|
},
|
|
// Note: Optimizations are disabled by default if unspecified in
|
|
// the java_library rule.
|
|
conditions_default: {},
|
|
},
|
|
},
|
|
}
|
|
|
|
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",
|
|
":backuplib-sources",
|
|
":services.companion-sources",
|
|
":services.contentcapture-sources",
|
|
":services.contentsuggestions-sources",
|
|
":services.coverage-sources",
|
|
":services.devicepolicy-sources",
|
|
":services.midi-sources",
|
|
":services.musicsearch-sources",
|
|
":services.net-sources",
|
|
":services.print-sources",
|
|
":services.profcollect-sources",
|
|
":services.restrictions-sources",
|
|
":services.searchui-sources",
|
|
":services.smartspace-sources",
|
|
":services.speech-sources",
|
|
":services.startop.iorap-sources",
|
|
":services.systemcaptions-sources",
|
|
":services.translation-sources",
|
|
":services.texttospeech-sources",
|
|
":services.usage-sources",
|
|
":services.usb-sources",
|
|
":services.uwb-sources",
|
|
":services.voiceinteraction-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",
|
|
},
|
|
|
|
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.devicepolicy",
|
|
"services.midi",
|
|
"services.musicsearch",
|
|
"services.net",
|
|
"services.people",
|
|
"services.print",
|
|
"services.profcollect",
|
|
"services.restrictions",
|
|
"services.searchui",
|
|
"services.smartspace",
|
|
"services.speech",
|
|
"services.startop",
|
|
"services.systemcaptions",
|
|
"services.translation",
|
|
"services.texttospeech",
|
|
"services.usage",
|
|
"services.usb",
|
|
"services.uwb",
|
|
"services.voiceinteraction",
|
|
"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",
|
|
],
|
|
|
|
// 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-package com.google.android.startop.iorap" +
|
|
" --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",
|
|
"win_sdk",
|
|
],
|
|
dir: "apistubs/android/system-server/api",
|
|
dest: "android-non-updatable.txt",
|
|
tag: ".api.txt",
|
|
},
|
|
{
|
|
targets: [
|
|
"sdk",
|
|
"win_sdk",
|
|
],
|
|
dir: "apistubs/android/system-server/api",
|
|
dest: "android-non-updatable-removed.txt",
|
|
tag: ".removed-api.txt",
|
|
},
|
|
],
|
|
}
|