blob: f994e27e4e5b8adfd3382235eb126d96d2fd0a31 [file] [log] [blame]
Shane Farmer0a5b2012017-06-22 12:24:12 -07001/*
2 * Copyright (C) 2017 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#include "MultiApkGenerator.h"
18
19#include <algorithm>
Shane Farmer3ff44432017-09-29 11:59:25 -070020#include <regex>
Shane Farmer0a5b2012017-06-22 12:24:12 -070021#include <string>
22
Mårten Kongstad24c9aa62018-06-20 08:46:41 +020023#include "androidfw/ConfigDescription.h"
Shane Farmer0a5b2012017-06-22 12:24:12 -070024#include "androidfw/StringPiece.h"
25
26#include "LoadedApk.h"
Shane Farmer3edd4722017-09-01 14:34:22 -070027#include "ResourceUtils.h"
Shane Farmer810fd182017-09-21 14:37:44 -070028#include "ValueVisitor.h"
Shane Farmer0a5b2012017-06-22 12:24:12 -070029#include "configuration/ConfigurationParser.h"
Ryan Mitchell5fa2bb12018-07-12 11:24:51 -070030#include "cmd/Util.h"
Shane Farmer0a5b2012017-06-22 12:24:12 -070031#include "filter/AbiFilter.h"
32#include "filter/Filter.h"
Adam Lesinski46708052017-09-29 14:49:15 -070033#include "format/Archive.h"
34#include "format/binary/XmlFlattener.h"
Shane Farmerefe45392017-08-21 14:39:28 -070035#include "optimize/VersionCollapser.h"
Shane Farmer0a5b2012017-06-22 12:24:12 -070036#include "process/IResourceTableConsumer.h"
37#include "split/TableSplitter.h"
38#include "util/Files.h"
Shane Farmer3edd4722017-09-01 14:34:22 -070039#include "xml/XmlDom.h"
Shane Farmer810fd182017-09-21 14:37:44 -070040#include "xml/XmlUtil.h"
Shane Farmer0a5b2012017-06-22 12:24:12 -070041
42namespace aapt {
43
Shane Farmerefe45392017-08-21 14:39:28 -070044using ::aapt::configuration::AndroidSdk;
Shane Farmercb6c3f92017-11-27 13:19:36 -080045using ::aapt::configuration::OutputArtifact;
Shane Farmer810fd182017-09-21 14:37:44 -070046using ::aapt::xml::kSchemaAndroid;
Shane Farmer3edd4722017-09-01 14:34:22 -070047using ::aapt::xml::XmlResource;
Mårten Kongstad24c9aa62018-06-20 08:46:41 +020048using ::android::ConfigDescription;
Shane Farmer0a5b2012017-06-22 12:24:12 -070049using ::android::StringPiece;
50
Shane Farmerefe45392017-08-21 14:39:28 -070051/**
52 * Context wrapper that allows the min Android SDK value to be overridden.
53 */
54class ContextWrapper : public IAaptContext {
55 public:
56 explicit ContextWrapper(IAaptContext* context)
57 : context_(context), min_sdk_(context_->GetMinSdkVersion()) {
58 }
59
60 PackageType GetPackageType() override {
61 return context_->GetPackageType();
62 }
63
64 SymbolTable* GetExternalSymbols() override {
65 return context_->GetExternalSymbols();
66 }
67
Jeremy Meyer56f36e82022-05-20 20:35:42 +000068 android::IDiagnostics* GetDiagnostics() override {
Shane Farmer20ac0342017-11-29 16:55:05 -080069 if (source_diag_) {
70 return source_diag_.get();
71 }
Shane Farmerefe45392017-08-21 14:39:28 -070072 return context_->GetDiagnostics();
73 }
74
75 const std::string& GetCompilationPackage() override {
76 return context_->GetCompilationPackage();
77 }
78
79 uint8_t GetPackageId() override {
80 return context_->GetPackageId();
81 }
82
83 NameMangler* GetNameMangler() override {
84 return context_->GetNameMangler();
85 }
86
87 bool IsVerbose() override {
88 return context_->IsVerbose();
89 }
90
91 int GetMinSdkVersion() override {
92 return min_sdk_;
93 }
94
95 void SetMinSdkVersion(int min_sdk) {
96 min_sdk_ = min_sdk;
97 }
98
Shane Farmercb6c3f92017-11-27 13:19:36 -080099 void SetSource(const std::string& source) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000100 source_diag_ = util::make_unique<android::SourcePathDiagnostics>(android::Source{source},
101 context_->GetDiagnostics());
Shane Farmer20ac0342017-11-29 16:55:05 -0800102 }
103
Udam Sainib228df32019-06-18 16:50:34 -0700104 const std::set<std::string>& GetSplitNameDependencies() override {
105 return context_->GetSplitNameDependencies();
106 }
107
Shane Farmerefe45392017-08-21 14:39:28 -0700108 private:
109 IAaptContext* context_;
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000110 std::unique_ptr<android::SourcePathDiagnostics> source_diag_;
Shane Farmerefe45392017-08-21 14:39:28 -0700111
112 int min_sdk_ = -1;
113};
114
Shane Farmer3ff44432017-09-29 11:59:25 -0700115class SignatureFilter : public IPathFilter {
116 bool Keep(const std::string& path) override {
117 static std::regex signature_regex(R"regex(^META-INF/.*\.(RSA|DSA|EC|SF)$)regex");
118 if (std::regex_search(path, signature_regex)) {
119 return false;
120 }
121 return !(path == "META-INF/MANIFEST.MF");
122 }
123};
124
Shane Farmer0a5b2012017-06-22 12:24:12 -0700125MultiApkGenerator::MultiApkGenerator(LoadedApk* apk, IAaptContext* context)
126 : apk_(apk), context_(context) {
127}
128
Shane Farmerefe45392017-08-21 14:39:28 -0700129bool MultiApkGenerator::FromBaseApk(const MultiApkGeneratorOptions& options) {
Shane Farmer666de342017-11-29 16:07:51 -0800130 std::unordered_set<std::string> artifacts_to_keep = options.kept_artifacts;
131 std::unordered_set<std::string> filtered_artifacts;
132 std::unordered_set<std::string> kept_artifacts;
133
Shane Farmer0a5b2012017-06-22 12:24:12 -0700134 // For now, just write out the stripped APK since ABI splitting doesn't modify anything else.
Shane Farmercb6c3f92017-11-27 13:19:36 -0800135 for (const OutputArtifact& artifact : options.apk_artifacts) {
Shane Farmer0a5b2012017-06-22 12:24:12 -0700136 FilterChain filters;
Shane Farmer0a5b2012017-06-22 12:24:12 -0700137
Shane Farmer20ac0342017-11-29 16:55:05 -0800138 ContextWrapper wrapped_context{context_};
Shane Farmercb6c3f92017-11-27 13:19:36 -0800139 wrapped_context.SetSource(artifact.name);
Shane Farmer20ac0342017-11-29 16:55:05 -0800140
Shane Farmer666de342017-11-29 16:07:51 -0800141 if (!options.kept_artifacts.empty()) {
Shane Farmercb6c3f92017-11-27 13:19:36 -0800142 const auto& it = artifacts_to_keep.find(artifact.name);
Shane Farmer666de342017-11-29 16:07:51 -0800143 if (it == artifacts_to_keep.end()) {
Shane Farmercb6c3f92017-11-27 13:19:36 -0800144 filtered_artifacts.insert(artifact.name);
Shane Farmer666de342017-11-29 16:07:51 -0800145 if (context_->IsVerbose()) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000146 context_->GetDiagnostics()->Note(android::DiagMessage(artifact.name)
147 << "skipping artifact");
Shane Farmer666de342017-11-29 16:07:51 -0800148 }
149 continue;
150 } else {
151 artifacts_to_keep.erase(it);
Shane Farmercb6c3f92017-11-27 13:19:36 -0800152 kept_artifacts.insert(artifact.name);
Shane Farmer666de342017-11-29 16:07:51 -0800153 }
154 }
155
Shane Farmerefe45392017-08-21 14:39:28 -0700156 std::unique_ptr<ResourceTable> table =
Shane Farmercb6c3f92017-11-27 13:19:36 -0800157 FilterTable(context_, artifact, *apk_->GetResourceTable(), &filters);
Shane Farmerefe45392017-08-21 14:39:28 -0700158 if (!table) {
159 return false;
Shane Farmer0a5b2012017-06-22 12:24:12 -0700160 }
161
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000162 android::IDiagnostics* diag = wrapped_context.GetDiagnostics();
Shane Farmercb6c3f92017-11-27 13:19:36 -0800163
Shane Farmer3edd4722017-09-01 14:34:22 -0700164 std::unique_ptr<XmlResource> manifest;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800165 if (!UpdateManifest(artifact, &manifest, diag)) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000166 diag->Error(android::DiagMessage()
167 << "could not update AndroidManifest.xml for output artifact");
Shane Farmer810fd182017-09-21 14:37:44 -0700168 return false;
Shane Farmer3edd4722017-09-01 14:34:22 -0700169 }
170
Shane Farmerefe45392017-08-21 14:39:28 -0700171 std::string out = options.out_dir;
Shane Farmer3d66afe2017-08-24 11:04:35 -0700172 if (!file::mkdirs(out)) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000173 diag->Warn(android::DiagMessage() << "could not create out dir: " << out);
Shane Farmer3d66afe2017-08-24 11:04:35 -0700174 }
Shane Farmercb6c3f92017-11-27 13:19:36 -0800175 file::AppendPath(&out, artifact.name);
Shane Farmer0a5b2012017-06-22 12:24:12 -0700176
Shane Farmerefe45392017-08-21 14:39:28 -0700177 if (context_->IsVerbose()) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000178 diag->Note(android::DiagMessage() << "Generating split: " << out);
Shane Farmerefe45392017-08-21 14:39:28 -0700179 }
180
Shane Farmercb6c3f92017-11-27 13:19:36 -0800181 std::unique_ptr<IArchiveWriter> writer = CreateZipFileArchiveWriter(diag, out);
Shane Farmer0a5b2012017-06-22 12:24:12 -0700182
183 if (context_->IsVerbose()) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000184 diag->Note(android::DiagMessage() << "Writing output: " << out);
Shane Farmer0a5b2012017-06-22 12:24:12 -0700185 }
186
Shane Farmer3ff44432017-09-29 11:59:25 -0700187 filters.AddFilter(util::make_unique<SignatureFilter>());
Shane Farmer20ac0342017-11-29 16:55:05 -0800188 if (!apk_->WriteToArchive(&wrapped_context, table.get(), options.table_flattener_options,
189 &filters, writer.get(), manifest.get())) {
Shane Farmer0a5b2012017-06-22 12:24:12 -0700190 return false;
191 }
192 }
193
Shane Farmer666de342017-11-29 16:07:51 -0800194 // Make sure all of the requested artifacts were valid. If there are any kept artifacts left,
195 // either the config or the command line was wrong.
196 if (!artifacts_to_keep.empty()) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000197 context_->GetDiagnostics()
198 ->Error(android::DiagMessage()
199 << "The configuration and command line to filter artifacts do not match");
Shane Farmer666de342017-11-29 16:07:51 -0800200
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000201 context_->GetDiagnostics()->Error(android::DiagMessage() << kept_artifacts.size() << " kept:");
Shane Farmer666de342017-11-29 16:07:51 -0800202 for (const auto& artifact : kept_artifacts) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000203 context_->GetDiagnostics()->Error(android::DiagMessage() << " " << artifact);
Shane Farmer666de342017-11-29 16:07:51 -0800204 }
205
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000206 context_->GetDiagnostics()->Error(android::DiagMessage()
207 << filtered_artifacts.size() << " filtered:");
Shane Farmer666de342017-11-29 16:07:51 -0800208 for (const auto& artifact : filtered_artifacts) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000209 context_->GetDiagnostics()->Error(android::DiagMessage() << " " << artifact);
Shane Farmer666de342017-11-29 16:07:51 -0800210 }
211
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000212 context_->GetDiagnostics()->Error(android::DiagMessage()
213 << artifacts_to_keep.size() << " missing:");
Shane Farmer666de342017-11-29 16:07:51 -0800214 for (const auto& artifact : artifacts_to_keep) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000215 context_->GetDiagnostics()->Error(android::DiagMessage() << " " << artifact);
Shane Farmer666de342017-11-29 16:07:51 -0800216 }
217
218 return false;
219 }
220
Shane Farmer0a5b2012017-06-22 12:24:12 -0700221 return true;
222}
223
Shane Farmercb6c3f92017-11-27 13:19:36 -0800224std::unique_ptr<ResourceTable> MultiApkGenerator::FilterTable(IAaptContext* context,
225 const OutputArtifact& artifact,
226 const ResourceTable& old_table,
227 FilterChain* filters) {
Shane Farmerefe45392017-08-21 14:39:28 -0700228 TableSplitterOptions splits;
229 AxisConfigFilter axis_filter;
Shane Farmer20ac0342017-11-29 16:55:05 -0800230 ContextWrapper wrapped_context{context};
Shane Farmercb6c3f92017-11-27 13:19:36 -0800231 wrapped_context.SetSource(artifact.name);
Shane Farmerefe45392017-08-21 14:39:28 -0700232
Shane Farmercb6c3f92017-11-27 13:19:36 -0800233 if (!artifact.abis.empty()) {
234 filters->AddFilter(AbiFilter::FromAbiList(artifact.abis));
Shane Farmerefe45392017-08-21 14:39:28 -0700235 }
236
Shane Farmercb6c3f92017-11-27 13:19:36 -0800237 if (!artifact.screen_densities.empty()) {
238 for (const auto& density_config : artifact.screen_densities) {
Shane Farmerefe45392017-08-21 14:39:28 -0700239 splits.preferred_densities.push_back(density_config.density);
240 }
241 }
242
Shane Farmercb6c3f92017-11-27 13:19:36 -0800243 if (!artifact.locales.empty()) {
244 for (const auto& locale : artifact.locales) {
Shane Farmerefe45392017-08-21 14:39:28 -0700245 axis_filter.AddConfig(locale);
246 }
247 splits.config_filter = &axis_filter;
248 }
249
Shane Farmer78c43d72017-12-04 09:08:38 -0800250 if (artifact.android_sdk) {
251 wrapped_context.SetMinSdkVersion(artifact.android_sdk.value().min_sdk_version);
Shane Farmerefe45392017-08-21 14:39:28 -0700252 }
253
254 std::unique_ptr<ResourceTable> table = old_table.Clone();
255
256 VersionCollapser collapser;
Shane Farmer20ac0342017-11-29 16:55:05 -0800257 if (!collapser.Consume(&wrapped_context, table.get())) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000258 context->GetDiagnostics()->Error(android::DiagMessage()
259 << "Failed to strip versioned resources");
Shane Farmerefe45392017-08-21 14:39:28 -0700260 return {};
261 }
262
263 TableSplitter splitter{{}, splits};
264 splitter.SplitTable(table.get());
265 return table;
266}
267
Shane Farmercb6c3f92017-11-27 13:19:36 -0800268bool MultiApkGenerator::UpdateManifest(const OutputArtifact& artifact,
Shane Farmer810fd182017-09-21 14:37:44 -0700269 std::unique_ptr<XmlResource>* updated_manifest,
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000270 android::IDiagnostics* diag) {
Adam Lesinski8780eb62017-10-31 17:44:39 -0700271 const xml::XmlResource* apk_manifest = apk_->GetManifest();
272 if (apk_manifest == nullptr) {
Shane Farmer810fd182017-09-21 14:37:44 -0700273 return false;
274 }
275
Adam Lesinski8780eb62017-10-31 17:44:39 -0700276 *updated_manifest = apk_manifest->Clone();
277 XmlResource* manifest = updated_manifest->get();
278
Shane Farmer810fd182017-09-21 14:37:44 -0700279 // Make sure the first element is <manifest> with package attribute.
280 xml::Element* manifest_el = manifest->root.get();
Ryan Mitchell5fa2bb12018-07-12 11:24:51 -0700281 if (!manifest_el) {
Shane Farmer810fd182017-09-21 14:37:44 -0700282 return false;
283 }
284
285 if (!manifest_el->namespace_uri.empty() || manifest_el->name != "manifest") {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000286 diag->Error(android::DiagMessage(manifest->file.source) << "root tag must be <manifest>");
Shane Farmer810fd182017-09-21 14:37:44 -0700287 return false;
288 }
289
Ryan Mitchell5fa2bb12018-07-12 11:24:51 -0700290 // Retrieve the versionCode attribute.
291 auto version_code = manifest_el->FindAttribute(kSchemaAndroid, "versionCode");
292 if (!version_code) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000293 diag->Error(android::DiagMessage(manifest->file.source)
294 << "manifest must have a versionCode attribute");
Shane Farmer810fd182017-09-21 14:37:44 -0700295 return false;
296 }
297
Ryan Mitchell5fa2bb12018-07-12 11:24:51 -0700298 auto version_code_value = ValueCast<BinaryPrimitive>(version_code->compiled_value.get());
299 if (!version_code_value) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000300 diag->Error(android::DiagMessage(manifest->file.source) << "versionCode is invalid");
Shane Farmer810fd182017-09-21 14:37:44 -0700301 return false;
302 }
303
Ryan Mitchell5fa2bb12018-07-12 11:24:51 -0700304 // Retrieve the versionCodeMajor attribute.
305 auto version_code_major = manifest_el->FindAttribute(kSchemaAndroid, "versionCodeMajor");
306 BinaryPrimitive* version_code_major_value = nullptr;
307 if (version_code_major) {
308 version_code_major_value = ValueCast<BinaryPrimitive>(version_code_major->compiled_value.get());
309 if (!version_code_major_value) {
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000310 diag->Error(android::DiagMessage(manifest->file.source) << "versionCodeMajor is invalid");
Ryan Mitchell5fa2bb12018-07-12 11:24:51 -0700311 return false;
312 }
313 }
314
315 // Calculate and set the updated version code
316 uint64_t major = (version_code_major_value)
317 ? ((uint64_t) version_code_major_value->value.data) << 32 : 0;
318 uint64_t new_version = (major | version_code_value->value.data) + artifact.version;
319 SetLongVersionCode(manifest_el, new_version);
Shane Farmer810fd182017-09-21 14:37:44 -0700320
321 // Check to see if the minSdkVersion needs to be updated.
Shane Farmercb6c3f92017-11-27 13:19:36 -0800322 if (artifact.android_sdk) {
Shane Farmer810fd182017-09-21 14:37:44 -0700323 // TODO(safarmer): Handle the rest of the Android SDK.
Shane Farmercb6c3f92017-11-27 13:19:36 -0800324 const AndroidSdk& android_sdk = artifact.android_sdk.value();
Shane Farmer810fd182017-09-21 14:37:44 -0700325
326 if (xml::Element* uses_sdk_el = manifest_el->FindChild({}, "uses-sdk")) {
327 if (xml::Attribute* min_sdk_attr =
328 uses_sdk_el->FindAttribute(xml::kSchemaAndroid, "minSdkVersion")) {
329 // Populate with a pre-compiles attribute to we don't need to relink etc.
Shane Farmer78c43d72017-12-04 09:08:38 -0800330 const std::string& min_sdk_str = std::to_string(android_sdk.min_sdk_version);
Shane Farmer810fd182017-09-21 14:37:44 -0700331 min_sdk_attr->compiled_value = ResourceUtils::TryParseInt(min_sdk_str);
332 } else {
333 // There was no minSdkVersion. This is strange since at this point we should have been
334 // through the manifest fixer which sets the default minSdkVersion.
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000335 diag->Error(android::DiagMessage(manifest->file.source)
336 << "missing minSdkVersion from <uses-sdk>");
Shane Farmer810fd182017-09-21 14:37:44 -0700337 return false;
338 }
339 } else {
340 // No uses-sdk present. This is strange since at this point we should have been
341 // through the manifest fixer which should have added it.
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000342 diag->Error(android::DiagMessage(manifest->file.source)
343 << "missing <uses-sdk> from <manifest>");
Shane Farmer810fd182017-09-21 14:37:44 -0700344 return false;
345 }
346 }
347
Shane Farmercb6c3f92017-11-27 13:19:36 -0800348 if (!artifact.screen_densities.empty()) {
Shane Farmere1799352017-09-25 14:19:03 -0700349 xml::Element* screens_el = manifest_el->FindChild({}, "compatible-screens");
350 if (!screens_el) {
351 // create a new element.
352 std::unique_ptr<xml::Element> new_screens_el = util::make_unique<xml::Element>();
353 new_screens_el->name = "compatible-screens";
354 screens_el = new_screens_el.get();
Shane Farmerd05b9132018-02-14 15:40:35 -0800355 manifest_el->AppendChild(std::move(new_screens_el));
Shane Farmere1799352017-09-25 14:19:03 -0700356 } else {
357 // clear out the old element.
358 screens_el->GetChildElements().clear();
359 }
360
Shane Farmercb6c3f92017-11-27 13:19:36 -0800361 for (const auto& density : artifact.screen_densities) {
Shane Farmerd05b9132018-02-14 15:40:35 -0800362 AddScreens(density, screens_el);
Shane Farmere1799352017-09-25 14:19:03 -0700363 }
364 }
Shane Farmer810fd182017-09-21 14:37:44 -0700365
366 return true;
367}
368
Shane Farmerd05b9132018-02-14 15:40:35 -0800369/**
370 * Adds a screen element with both screenSize and screenDensity set. Since we only know the density
371 * we add it for all screen sizes.
372 *
373 * This requires the resource IDs for the attributes from the framework library. Since these IDs are
374 * a part of the public API (and in public.xml) we hard code the values.
375 *
376 * The excert from the framework is as follows:
377 * <public type="attr" name="screenSize" id="0x010102ca" />
378 * <public type="attr" name="screenDensity" id="0x010102cb" />
379 */
380void MultiApkGenerator::AddScreens(const ConfigDescription& config, xml::Element* parent) {
381 // Hard coded integer representation of the supported screen sizes:
382 // small = 200
383 // normal = 300
384 // large = 400
385 // xlarge = 500
386 constexpr const uint32_t kScreenSizes[4] = {200, 300, 400, 500,};
387 constexpr const uint32_t kScreenSizeResourceId = 0x010102ca;
388 constexpr const uint32_t kScreenDensityResourceId = 0x010102cb;
389
390 for (uint32_t screen_size : kScreenSizes) {
391 std::unique_ptr<xml::Element> screen = util::make_unique<xml::Element>();
392 screen->name = "screen";
393
394 xml::Attribute* size = screen->FindOrCreateAttribute(kSchemaAndroid, "screenSize");
395 size->compiled_attribute = xml::AaptAttribute(Attribute(), {kScreenSizeResourceId});
396 size->compiled_value = ResourceUtils::MakeInt(screen_size);
397
398 xml::Attribute* density = screen->FindOrCreateAttribute(kSchemaAndroid, "screenDensity");
399 density->compiled_attribute = xml::AaptAttribute(Attribute(), {kScreenDensityResourceId});
400 density->compiled_value = ResourceUtils::MakeInt(config.density);
401
402
403 parent->AppendChild(std::move(screen));
404 }
405}
406
Shane Farmer0a5b2012017-06-22 12:24:12 -0700407} // namespace aapt