| 1 |
// |
| 2 |
// Copyright (C) 2008 The Android Open Source Project |
| 3 |
// |
| 4 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
// you may not use this file except in compliance with the License. |
| 6 |
// You may obtain a copy of the License at |
| 7 |
// |
| 8 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
// |
| 10 |
// Unless required by applicable law or agreed to in writing, software |
| 11 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
// See the License for the specific language governing permissions and |
| 14 |
// limitations under the License. |
| 15 |
// |
| 16 |
|
| 17 |
package { |
| 18 |
default_applicable_licenses: ["frameworks_base_core_res_license"], |
| 19 |
} |
| 20 |
|
| 21 |
// Added automatically by a large-scale-change that took the approach of |
| 22 |
// 'apply every license found to every target'. While this makes sure we respect |
| 23 |
// every license restriction, it may not be entirely correct. |
| 24 |
// |
| 25 |
// e.g. GPL in an MIT project might only apply to the contrib/ directory. |
| 26 |
// |
| 27 |
// Please consider splitting the single license below into multiple licenses, |
| 28 |
// taking care not to lose any license_kind information, and overriding the |
| 29 |
// default license using the 'licenses: [...]' property on targets as needed. |
| 30 |
// |
| 31 |
// For unused files, consider creating a 'fileGroup' with "//visibility:private" |
| 32 |
// to attach the license to, and including a comment whether the files may be |
| 33 |
// used in the current project. |
| 34 |
// See: http://go/android-license-faq |
| 35 |
license { |
| 36 |
name: "frameworks_base_core_res_license", |
| 37 |
visibility: [":__subpackages__"], |
| 38 |
license_kinds: [ |
| 39 |
"SPDX-license-identifier-Apache-2.0", |
| 40 |
], |
| 41 |
license_text: [ |
| 42 |
"NOTICE", |
| 43 |
], |
| 44 |
} |
| 45 |
|
| 46 |
genrule { |
| 47 |
name: "remote-color-resources-compile-public", |
| 48 |
tools: ["aapt2"], |
| 49 |
srcs: [ |
| 50 |
"remote_color_resources_res/values/public.xml", |
| 51 |
], |
| 52 |
out: ["values_public.arsc.flat"], |
| 53 |
cmd: "$(location aapt2) compile $(in) -o $(genDir)", |
| 54 |
} |
| 55 |
|
| 56 |
genrule { |
| 57 |
name: "remote-color-resources-compile-colors", |
| 58 |
tools: ["aapt2"], |
| 59 |
srcs: [ |
| 60 |
"remote_color_resources_res/values/colors.xml", |
| 61 |
], |
| 62 |
out: ["values_colors.arsc.flat"], |
| 63 |
cmd: "$(location aapt2) compile $(in) -o $(genDir)", |
| 64 |
} |
| 65 |
|
| 66 |
genrule { |
| 67 |
name: "remote-color-resources-apk", |
| 68 |
tools: ["aapt2"], |
| 69 |
// The first input file in the list must be the manifest |
| 70 |
srcs: [ |
| 71 |
"RemoteThemeColorsAndroidManifest.xml", |
| 72 |
":remote-color-resources-compile-public", |
| 73 |
":remote-color-resources-compile-colors", |
| 74 |
], |
| 75 |
out: ["remote-color-resources.apk"], |
| 76 |
cmd: "$(location aapt2) link -o $(out) --manifest $(in)", |
| 77 |
} |
| 78 |
|
| 79 |
genrule { |
| 80 |
name: "remote-color-resources-arsc", |
| 81 |
srcs: [":remote-color-resources-apk"], |
| 82 |
out: ["res/raw/remote_views_color_resources.arsc"], |
| 83 |
cmd: "mkdir -p $(genDir)/remote-color-resources-arsc && " + |
| 84 |
"unzip -x $(in) resources.arsc -d $(genDir)/remote-color-resources-arsc && " + |
| 85 |
"mkdir -p $$(dirname $(out)) && " + |
| 86 |
"mv $(genDir)/remote-color-resources-arsc/resources.arsc $(out) && " + |
| 87 |
"echo 'Created $(out)'", |
| 88 |
} |
| 89 |
|
| 90 |
genrule { |
| 91 |
name: "remote-color-resources-arsc-zip", |
| 92 |
tools: ["soong_zip"], |
| 93 |
srcs: [ |
| 94 |
":remote-color-resources-arsc", |
| 95 |
"remote_color_resources_res/symbols.xml", |
| 96 |
], |
| 97 |
out: ["remote_views_color_resources.zip"], |
| 98 |
cmd: "INPUTS=($(in)) && " + |
| 99 |
"RES_DIR=$$(dirname $$(dirname $${INPUTS[0]})) && " + |
| 100 |
"mkdir -p $$RES_DIR/values && " + |
| 101 |
"cp $${INPUTS[1]} $$RES_DIR/values && " + |
| 102 |
"$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR", |
| 103 |
} |
| 104 |
|
| 105 |
android_app { |
| 106 |
name: "framework-res", |
| 107 |
sdk_version: "core_platform", |
| 108 |
certificate: "platform", |
| 109 |
|
| 110 |
srcs: [":remote-color-resources-arsc"], |
| 111 |
|
| 112 |
// Disable dexpreopt and verify_uses_libraries check as the app |
| 113 |
// contains no Java code to be dexpreopted. |
| 114 |
enforce_uses_libs: false, |
| 115 |
dex_preopt: { |
| 116 |
enabled: false, |
| 117 |
}, |
| 118 |
|
| 119 |
// Soong special-cases framework-res to install this alongside |
| 120 |
// the libraries at /system/framework/framework-res.apk. |
| 121 |
|
| 122 |
// Generate private symbols into the com.android.internal.R class |
| 123 |
// so they are not accessible to 3rd party apps. |
| 124 |
aaptflags: [ |
| 125 |
"--private-symbols", |
| 126 |
"com.android.internal", |
| 127 |
|
| 128 |
// Framework doesn't need versioning since it IS the platform. |
| 129 |
"--no-auto-version", |
| 130 |
|
| 131 |
// Allow overlay to add resource |
| 132 |
"--auto-add-overlay", |
| 133 |
|
| 134 |
// Framework resources benefit tremendously from enabling sparse encoding, saving tens |
| 135 |
// of MBs in size and RAM use. |
| 136 |
"--enable-sparse-encoding", |
| 137 |
], |
| 138 |
|
| 139 |
resource_zips: [ |
| 140 |
":remote-color-resources-arsc-zip", |
| 141 |
], |
| 142 |
|
| 143 |
// Create package-export.apk, which other packages can use to get |
| 144 |
// PRODUCT-agnostic resource data like IDs and type definitions. |
| 145 |
export_package_resources: true, |
| 146 |
|
| 147 |
dist: { |
| 148 |
targets: [ |
| 149 |
"simulated_device_launcher", |
| 150 |
], |
| 151 |
}, |
| 152 |
} |
| 153 |
|
| 154 |
java_genrule { |
| 155 |
name: "framework-res-package-jar", |
| 156 |
srcs: [":framework-res{.export-package.apk}"], |
| 157 |
out: ["framework-res-package.jar"], |
| 158 |
cmd: "cp $(in) $(out)", |
| 159 |
} |
| 160 |
|
| 161 |
// Generate a text file containing a list of permissions that non-system apps |
| 162 |
// are allowed to obtain. |
| 163 |
genrule { |
| 164 |
name: "permission-list-normal", |
| 165 |
out: ["permission-list-normal.txt"], |
| 166 |
srcs: ["AndroidManifest.xml"], |
| 167 |
cmd: "cat $(in) " + |
| 168 |
// xmllint has trouble accessing attributes under the android namespace. |
| 169 |
// Strip these prefixes prior to processing with xmllint. |
| 170 |
" | sed -r 's/android:(name|protectionLevel)/\\1/g' " + |
| 171 |
" | $(location xmllint) /dev/stdin --xpath " + |
| 172 |
" '//permission[not(contains(@protectionLevel, \"signature\"))]/@name'" + |
| 173 |
// The result of xmllint is name="value" pairs. Format these to just the |
| 174 |
// permission name, one per-line. |
| 175 |
" | sed -r 's/\\s*name=\\s*//g' | tr -d '\"'" + |
| 176 |
" > $(out)", |
| 177 |
tools: ["xmllint"], |
| 178 |
} |
| 179 |
|
| 180 |
filegroup { |
| 181 |
name: "frameworks-base-core-AndroidManifest.xml", |
| 182 |
srcs: ["AndroidManifest.xml"], |
| 183 |
visibility: [ |
| 184 |
"//frameworks/base", |
| 185 |
"//frameworks/base/api", |
| 186 |
], |
| 187 |
} |