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_MANIFEST_VALIDATOR_H 18#define AAPT_MANIFEST_VALIDATOR_H 19 20#include "Logger.h" 21#include "Maybe.h" 22#include "Source.h" 23#include "StringPiece.h" 24 25#include <androidfw/ResourceTypes.h> 26 27namespace aapt { 28 29class ManifestValidator { 30public: 31 ManifestValidator(const android::ResTable& table); 32 ManifestValidator(const ManifestValidator&) = delete; 33 34 bool validate(const Source& source, android::ResXMLParser* parser); 35 36private: 37 bool validateManifest(const Source& source, android::ResXMLParser* parser); 38 39 Maybe<StringPiece16> getAttributeInlineValue(android::ResXMLParser* parser, size_t idx); 40 Maybe<StringPiece16> getAttributeValue(android::ResXMLParser* parser, size_t idx); 41 42 bool validateInlineAttribute(android::ResXMLParser* parser, size_t idx, 43 SourceLogger& logger, const StringPiece16& charSet); 44 bool validateAttribute(android::ResXMLParser* parser, size_t idx, SourceLogger& logger, 45 const StringPiece16& charSet); 46 bool validateAttributeImpl(const StringPiece16& element, const StringPiece16& attributeName, 47 const StringPiece16& attributeValue, const StringPiece16& charSet, 48 size_t lineNumber, SourceLogger& logger); 49 50 const android::ResTable& mTable; 51}; 52 53} // namespace aapt 54 55#endif // AAPT_MANIFEST_VALIDATOR_H 56