/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __APK_BUILDER_H #define __APK_BUILDER_H #include #include #include #include #include #include "ConfigDescription.h" #include "OutputSet.h" #include "ResourceFilter.h" class ApkSplit; class AaptFile; class ApkBuilder : public android::RefBase { public: explicit ApkBuilder(const sp& configFilter); /** * Tells the builder to generate a separate APK for resources that * match the configurations specified. Split APKs can not have * overlapping resources. * * NOTE: All splits should be set up before any files are added. */ android::status_t createSplitForConfigs(const std::set& configs); /** * Adds a file to be written to the final APK. It's name must not collide * with that of any files previously added. When a Split APK is being * generated, duplicates can exist as long as they are in different splits * (resources.arsc, AndroidManifest.xml). */ android::status_t addEntry(const String8& path, const android::sp& file); android::Vector >& getSplits() { return mSplits; } android::sp getBaseSplit() { return mSplits[0]; } void print() const; private: android::sp mConfigFilter; android::sp mDefaultFilter; android::Vector > mSplits; }; class ApkSplit : public OutputSet { public: android::status_t addEntry(const String8& path, const android::sp& file); const std::set& getEntries() const { return mFiles; } const std::set& getConfigs() const { return mConfigs; } bool matches(const sp& file) const { return mFilter->match(file->getGroupEntry().toParams()); } sp getResourceFilter() const { return mFilter; } const android::String8& getPrintableName() const { return mName; } const android::String8& getDirectorySafeName() const { return mDirName; } const android::String8& getPackageSafeName() const { return mPackageSafeName; } bool isBase() const { return mIsBase; } void print() const; private: friend class ApkBuilder; ApkSplit(const std::set& configs, const android::sp& filter, bool isBase=false); std::set mConfigs; const sp mFilter; const bool mIsBase; String8 mName; String8 mDirName; String8 mPackageSafeName; std::set mFiles; }; #endif // __APK_BUILDER_H