• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2025 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 #pragma once
18 
19 #include <memory>
20 #include <vector>
21 
22 #include "process/IResourceTableConsumer.h"
23 #include "xml/XmlDom.h"
24 
25 namespace aapt {
26 
27 // FlaggedXmlVersioner takes an XmlResource and checks if any elements have read write android
28 // flags on them. If the doc doesn't refer to any such flags the returned vector only contains
29 // the original doc.
30 //
31 // Read/write flags within xml resources files is only supported in android baklava and later. If
32 // the config resource specifies a version that is baklava or later it returns a vector containing
33 // the original XmlResource. Otherwise FlaggedXmlVersioner creates a version of the doc where all
34 // flags are assumed disabled and the config version is the same as the original doc, if specified.
35 // It also creates an XmlResource where the contents are the same as the original doc and the config
36 // version is baklava. The returned vector is composed of these two new docs.
37 class FlaggedXmlVersioner {
38  public:
39   std::vector<std::unique_ptr<xml::XmlResource>> Process(IAaptContext* context,
40                                                          xml::XmlResource* doc);
41 };
42 }  // namespace aapt