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 17package { 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 35license { 36 name: "frameworks_base_core_res_license", 37 visibility: [":__subpackages__"], 38 license_kinds: [ 39 "SPDX-license-identifier-Apache-2.0", 40 "SPDX-license-identifier-GPL", 41 ], 42 license_text: [ 43 "NOTICE", 44 ], 45} 46 47genrule { 48 name: "remote-color-resources-compile-public", 49 tools: ["aapt2"], 50 srcs: [ 51 "remote_color_resources_res/values/public.xml", 52 ], 53 out: ["values_public.arsc.flat"], 54 cmd: "$(location aapt2) compile $(in) -o $(genDir)", 55} 56 57genrule { 58 name: "remote-color-resources-compile-colors", 59 tools: ["aapt2"], 60 srcs: [ 61 "remote_color_resources_res/values/colors.xml", 62 ], 63 out: ["values_colors.arsc.flat"], 64 cmd: "$(location aapt2) compile $(in) -o $(genDir)", 65} 66 67genrule { 68 name: "remote-color-resources-apk", 69 tools: ["aapt2"], 70 // The first input file in the list must be the manifest 71 srcs: [ 72 "RemoteThemeColorsAndroidManifest.xml", 73 ":remote-color-resources-compile-public", 74 ":remote-color-resources-compile-colors", 75 ], 76 out: ["remote-color-resources.apk"], 77 cmd: "$(location aapt2) link -o $(out) --manifest $(in)" 78} 79 80genrule { 81 name: "remote-color-resources-arsc", 82 srcs: [":remote-color-resources-apk"], 83 out: ["res/raw/remote_views_color_resources.arsc"], 84 cmd: "mkdir -p $(genDir)/remote-color-resources-arsc && " 85 + "unzip -x $(in) resources.arsc -d $(genDir)/remote-color-resources-arsc && " 86 + "mkdir -p $$(dirname $(out)) && " 87 + "mv $(genDir)/remote-color-resources-arsc/resources.arsc $(out) && " 88 + "echo 'Created $(out)'" 89} 90 91genrule { 92 name: "remote-color-resources-arsc-zip", 93 tools: ["soong_zip"], 94 srcs: [ 95 ":remote-color-resources-arsc", 96 "remote_color_resources_res/symbols.xml", 97 ], 98 out: ["remote_views_color_resources.zip"], 99 cmd: "INPUTS=($(in)) && " 100 + "RES_DIR=$$(dirname $$(dirname $${INPUTS[0]})) && " 101 + "mkdir -p $$RES_DIR/values && " 102 + "cp $${INPUTS[1]} $$RES_DIR/values && " 103 + "$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR" 104} 105 106android_app { 107 name: "framework-res", 108 sdk_version: "core_platform", 109 certificate: "platform", 110 111 srcs: [":remote-color-resources-arsc"], 112 113 // Disable dexpreopt and verify_uses_libraries check as the app 114 // contains no Java code to be dexpreopted. 115 enforce_uses_libs: false, 116 dex_preopt: { 117 enabled: false, 118 }, 119 120 // Soong special-cases framework-res to install this alongside 121 // the libraries at /system/framework/framework-res.apk. 122 123 // Generate private symbols into the com.android.internal.R class 124 // so they are not accessible to 3rd party apps. 125 aaptflags: [ 126 "--private-symbols", 127 "com.android.internal", 128 129 // Framework doesn't need versioning since it IS the platform. 130 "--no-auto-version", 131 132 // Allow overlay to add resource 133 "--auto-add-overlay", 134 ], 135 136 resource_zips: [ 137 ":remote-color-resources-arsc-zip", 138 ], 139 140 // Create package-export.apk, which other packages can use to get 141 // PRODUCT-agnostic resource data like IDs and type definitions. 142 export_package_resources: true, 143 144 dist: { 145 targets: [ 146 "simulated_device_launcher", 147 ], 148 }, 149} 150 151java_genrule { 152 name: "framework-res-package-jar", 153 srcs: [":framework-res{.export-package.apk}"], 154 out: ["framework-res-package.jar"], 155 cmd: "cp $(in) $(out)", 156} 157 158// This logic can be removed once robolectric's transition to binary resources is complete 159filegroup { 160 name: "robolectric_framework_raw_res_files", 161 srcs: [ 162 "assets/**/*", 163 "res/**/*", 164 ":remote-color-resources-arsc", 165 ], 166} 167 168// Generate a text file containing a list of permissions that non-system apps 169// are allowed to obtain. 170genrule { 171 name: "permission-list-normal", 172 out: ["permission-list-normal.txt"], 173 srcs: ["AndroidManifest.xml"], 174 cmd: "cat $(in) " + 175 // xmllint has trouble accessing attributes under the android namespace. 176 // Strip these prefixes prior to processing with xmllint. 177 " | sed -r 's/android:(name|protectionLevel)/\\1/g' " + 178 " | $(location xmllint) /dev/stdin --xpath " + 179 " '//permission[not(contains(@protectionLevel, \"signature\"))]/@name'" + 180 // The result of xmllint is name="value" pairs. Format these to just the 181 // permission name, one per-line. 182 " | sed -r 's/\\s*name=\\s*//g' | tr -d '\"'" + 183 " > $(out)", 184 tools: ["xmllint"] 185} 186