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    ],
41    license_text: [
42        "NOTICE",
43    ],
44}
45
46genrule {
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
56genrule {
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
66genrule {
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
79genrule {
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
90genrule {
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
105android_app {
106    name: "framework-res",
107    sdk_version: "core_platform",
108    certificate: "platform",
109
110    srcs: [
111        ":remote-color-resources-arsc",
112    ],
113
114    // Disable dexpreopt and verify_uses_libraries check as the app
115    // contains no Java code to be dexpreopted.
116    enforce_uses_libs: false,
117    dex_preopt: {
118        enabled: false,
119    },
120
121    // Soong special-cases framework-res to install this alongside
122    // the libraries at /system/framework/framework-res.apk.
123
124    // Generate private symbols into the com.android.internal.R class
125    // so they are not accessible to 3rd party apps.
126    aaptflags: [
127        "--private-symbols",
128        "com.android.internal",
129
130        // Framework doesn't need versioning since it IS the platform.
131        "--no-auto-version",
132
133        // Allow overlay to add resource
134        "--auto-add-overlay",
135
136        // Framework resources benefit tremendously from enabling sparse encoding, saving tens
137        // of MBs in size and RAM use.
138        "--enable-sparse-encoding",
139    ],
140
141    resource_zips: [
142        ":remote-color-resources-arsc-zip",
143    ],
144
145    // Create package-export.apk, which other packages can use to get
146    // PRODUCT-agnostic resource data like IDs and type definitions.
147    export_package_resources: true,
148
149    dist: {
150        targets: [
151            "simulated_device_launcher",
152        ],
153    },
154}
155
156java_genrule {
157    name: "framework-res-package-jar",
158    srcs: [":framework-res{.export-package.apk}"],
159    out: ["framework-res-package.jar"],
160    cmd: "cp $(in) $(out)",
161}
162
163// Generate a text file containing a list of permissions that non-system apps
164// are allowed to obtain.
165genrule {
166    name: "permission-list-normal",
167    out: ["permission-list-normal.txt"],
168    srcs: ["AndroidManifest.xml"],
169    cmd: "cat $(in) " +
170        // xmllint has trouble accessing attributes under the android namespace.
171        // Strip these prefixes prior to processing with xmllint.
172        " | sed -r 's/android:(name|protectionLevel)/\\1/g' " +
173        " | $(location xmllint) /dev/stdin --xpath " +
174        " '//permission[not(contains(@protectionLevel, \"signature\"))]/@name'" +
175        // The result of xmllint is name="value" pairs. Format these to just the
176        // permission name, one per-line.
177        " | sed -r 's/\\s*name=\\s*//g' | tr -d '\"'" +
178        " > $(out)",
179    tools: ["xmllint"],
180}
181
182filegroup {
183    name: "frameworks-base-core-AndroidManifest.xml",
184    srcs: ["AndroidManifest.xml"],
185    visibility: [
186        "//frameworks/base",
187        "//frameworks/base/api",
188    ],
189}
190