Adam Lesinski | 2ae4a87 | 2015-11-02 16:10:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | #ifndef AAPT_LINK_MANIFESTFIXER_H |
| 18 | #define AAPT_LINK_MANIFESTFIXER_H |
| 19 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame^] | 20 | #include <string> |
| 21 | |
| 22 | #include "android-base/macros.h" |
| 23 | |
Adam Lesinski | 2ae4a87 | 2015-11-02 16:10:55 -0800 | [diff] [blame] | 24 | #include "process/IResourceTableConsumer.h" |
Adam Lesinski | 467f171 | 2015-11-16 17:35:44 -0800 | [diff] [blame] | 25 | #include "util/Maybe.h" |
Adam Lesinski | cc5609d | 2016-04-05 12:41:07 -0700 | [diff] [blame] | 26 | #include "xml/XmlActionExecutor.h" |
Adam Lesinski | 467f171 | 2015-11-16 17:35:44 -0800 | [diff] [blame] | 27 | #include "xml/XmlDom.h" |
| 28 | |
Adam Lesinski | 2ae4a87 | 2015-11-02 16:10:55 -0800 | [diff] [blame] | 29 | namespace aapt { |
| 30 | |
| 31 | struct ManifestFixerOptions { |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame^] | 32 | Maybe<std::string> min_sdk_version_default; |
| 33 | Maybe<std::string> target_sdk_version_default; |
| 34 | Maybe<std::string> rename_manifest_package; |
| 35 | Maybe<std::string> rename_instrumentation_target_package; |
| 36 | Maybe<std::string> version_name_default; |
| 37 | Maybe<std::string> version_code_default; |
Adam Lesinski | 2ae4a87 | 2015-11-02 16:10:55 -0800 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | /** |
| 41 | * Verifies that the manifest is correctly formed and inserts defaults |
| 42 | * where specified with ManifestFixerOptions. |
| 43 | */ |
Adam Lesinski | cc5609d | 2016-04-05 12:41:07 -0700 | [diff] [blame] | 44 | class ManifestFixer : public IXmlResourceConsumer { |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 45 | public: |
| 46 | explicit ManifestFixer(const ManifestFixerOptions& options) |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame^] | 47 | : options_(options) {} |
Adam Lesinski | 2ae4a87 | 2015-11-02 16:10:55 -0800 | [diff] [blame] | 48 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame^] | 49 | bool Consume(IAaptContext* context, xml::XmlResource* doc) override; |
Adam Lesinski | cc5609d | 2016-04-05 12:41:07 -0700 | [diff] [blame] | 50 | |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 51 | private: |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame^] | 52 | DISALLOW_COPY_AND_ASSIGN(ManifestFixer); |
Adam Lesinski | cc5609d | 2016-04-05 12:41:07 -0700 | [diff] [blame] | 53 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame^] | 54 | bool BuildRules(xml::XmlActionExecutor* executor, IDiagnostics* diag); |
| 55 | |
| 56 | ManifestFixerOptions options_; |
Adam Lesinski | 2ae4a87 | 2015-11-02 16:10:55 -0800 | [diff] [blame] | 57 | }; |
| 58 | |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 59 | } // namespace aapt |
Adam Lesinski | 2ae4a87 | 2015-11-02 16:10:55 -0800 | [diff] [blame] | 60 | |
| 61 | #endif /* AAPT_LINK_MANIFESTFIXER_H */ |