Merge "libandroidfw: move ConfigDescription from aapt2 to libandroidfw"
This commit is contained in:
@@ -43,8 +43,10 @@ cc_library {
|
|||||||
"AssetManager2.cpp",
|
"AssetManager2.cpp",
|
||||||
"AttributeResolution.cpp",
|
"AttributeResolution.cpp",
|
||||||
"ChunkIterator.cpp",
|
"ChunkIterator.cpp",
|
||||||
|
"ConfigDescription.cpp",
|
||||||
"Idmap.cpp",
|
"Idmap.cpp",
|
||||||
"LoadedArsc.cpp",
|
"LoadedArsc.cpp",
|
||||||
|
"Locale.cpp",
|
||||||
"LocaleData.cpp",
|
"LocaleData.cpp",
|
||||||
"misc.cpp",
|
"misc.cpp",
|
||||||
"ObbFile.cpp",
|
"ObbFile.cpp",
|
||||||
@@ -135,9 +137,11 @@ cc_test {
|
|||||||
"tests/AttributeResolution_test.cpp",
|
"tests/AttributeResolution_test.cpp",
|
||||||
"tests/ByteBucketArray_test.cpp",
|
"tests/ByteBucketArray_test.cpp",
|
||||||
"tests/Config_test.cpp",
|
"tests/Config_test.cpp",
|
||||||
|
"tests/ConfigDescription_test.cpp",
|
||||||
"tests/ConfigLocale_test.cpp",
|
"tests/ConfigLocale_test.cpp",
|
||||||
"tests/Idmap_test.cpp",
|
"tests/Idmap_test.cpp",
|
||||||
"tests/LoadedArsc_test.cpp",
|
"tests/LoadedArsc_test.cpp",
|
||||||
|
"tests/Locale_test.cpp",
|
||||||
"tests/ResourceUtils_test.cpp",
|
"tests/ResourceUtils_test.cpp",
|
||||||
"tests/ResTable_test.cpp",
|
"tests/ResTable_test.cpp",
|
||||||
"tests/Split_test.cpp",
|
"tests/Split_test.cpp",
|
||||||
|
|||||||
@@ -14,22 +14,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
#include "androidfw/Locale.h"
|
||||||
|
#include "androidfw/ResourceTypes.h"
|
||||||
|
#include "androidfw/StringPiece.h"
|
||||||
|
#include "androidfw/Util.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "androidfw/ResourceTypes.h"
|
namespace android {
|
||||||
#include "androidfw/StringPiece.h"
|
|
||||||
|
|
||||||
#include "Locale.h"
|
|
||||||
#include "SdkConstants.h"
|
|
||||||
#include "util/Util.h"
|
|
||||||
|
|
||||||
using android::ResTable_config;
|
|
||||||
using android::StringPiece;
|
|
||||||
|
|
||||||
namespace aapt {
|
|
||||||
|
|
||||||
static const char* kWildcardName = "any";
|
static const char* kWildcardName = "any";
|
||||||
|
|
||||||
@@ -883,7 +877,7 @@ std::string ConfigDescription::GetBcp47LanguageTag(bool canonicalize) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string ConfigDescription::to_string() const {
|
std::string ConfigDescription::to_string() const {
|
||||||
const android::String8 str = toString();
|
const String8 str = toString();
|
||||||
return std::string(str.string(), str.size());
|
return std::string(str.string(), str.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -996,4 +990,4 @@ bool ConfigDescription::IsCompatibleWith(const ConfigDescription& o) const {
|
|||||||
return !ConflictsWith(o) && !Dominates(o) && !o.Dominates(*this);
|
return !ConflictsWith(o) && !Dominates(o) && !o.Dominates(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aapt
|
} // namespace android
|
||||||
@@ -14,7 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Locale.h"
|
#include "androidfw/Locale.h"
|
||||||
|
#include "androidfw/Util.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -22,12 +23,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "util/Util.h"
|
|
||||||
|
|
||||||
using ::android::ResTable_config;
|
using ::android::ResTable_config;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
|
|
||||||
namespace aapt {
|
namespace android {
|
||||||
|
|
||||||
void LocaleValue::set_language(const char* language_chars) {
|
void LocaleValue::set_language(const char* language_chars) {
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
@@ -258,4 +257,4 @@ void LocaleValue::WriteTo(ResTable_config* out) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aapt
|
} // namespace android
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "androidfw/Util.h"
|
#include "androidfw/Util.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "utils/ByteOrder.h"
|
#include "utils/ByteOrder.h"
|
||||||
@@ -67,5 +68,28 @@ std::string Utf16ToUtf8(const StringPiece16& utf16) {
|
|||||||
return utf8;
|
return utf8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SplitAndTransform(
|
||||||
|
const StringPiece& str, char sep, const std::function<char(char)>& f) {
|
||||||
|
std::vector<std::string> parts;
|
||||||
|
const StringPiece::const_iterator end = std::end(str);
|
||||||
|
StringPiece::const_iterator start = std::begin(str);
|
||||||
|
StringPiece::const_iterator current;
|
||||||
|
do {
|
||||||
|
current = std::find(start, end, sep);
|
||||||
|
parts.emplace_back(str.substr(start, current).to_string());
|
||||||
|
if (f) {
|
||||||
|
std::string& part = parts.back();
|
||||||
|
std::transform(part.begin(), part.end(), part.begin(), f);
|
||||||
|
}
|
||||||
|
start = current + 1;
|
||||||
|
} while (current != end);
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> SplitAndLowercase(const StringPiece& str, char sep) {
|
||||||
|
return SplitAndTransform(str, sep, ::tolower);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|||||||
@@ -14,21 +14,52 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AAPT_CONFIG_DESCRIPTION_H
|
#ifndef ANDROIDFW_CONFIG_DESCRIPTION_H
|
||||||
#define AAPT_CONFIG_DESCRIPTION_H
|
#define ANDROIDFW_CONFIG_DESCRIPTION_H
|
||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
#include "androidfw/ResourceTypes.h"
|
#include "androidfw/ResourceTypes.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
namespace aapt {
|
namespace android {
|
||||||
|
|
||||||
|
using ApiVersion = int;
|
||||||
|
|
||||||
|
enum : ApiVersion {
|
||||||
|
SDK_CUPCAKE = 3,
|
||||||
|
SDK_DONUT = 4,
|
||||||
|
SDK_ECLAIR = 5,
|
||||||
|
SDK_ECLAIR_0_1 = 6,
|
||||||
|
SDK_ECLAIR_MR1 = 7,
|
||||||
|
SDK_FROYO = 8,
|
||||||
|
SDK_GINGERBREAD = 9,
|
||||||
|
SDK_GINGERBREAD_MR1 = 10,
|
||||||
|
SDK_HONEYCOMB = 11,
|
||||||
|
SDK_HONEYCOMB_MR1 = 12,
|
||||||
|
SDK_HONEYCOMB_MR2 = 13,
|
||||||
|
SDK_ICE_CREAM_SANDWICH = 14,
|
||||||
|
SDK_ICE_CREAM_SANDWICH_MR1 = 15,
|
||||||
|
SDK_JELLY_BEAN = 16,
|
||||||
|
SDK_JELLY_BEAN_MR1 = 17,
|
||||||
|
SDK_JELLY_BEAN_MR2 = 18,
|
||||||
|
SDK_KITKAT = 19,
|
||||||
|
SDK_KITKAT_WATCH = 20,
|
||||||
|
SDK_LOLLIPOP = 21,
|
||||||
|
SDK_LOLLIPOP_MR1 = 22,
|
||||||
|
SDK_MARSHMALLOW = 23,
|
||||||
|
SDK_NOUGAT = 24,
|
||||||
|
SDK_NOUGAT_MR1 = 25,
|
||||||
|
SDK_O = 26,
|
||||||
|
SDK_O_MR1 = 27,
|
||||||
|
SDK_P = 28,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Subclass of ResTable_config that adds convenient
|
* Subclass of ResTable_config that adds convenient
|
||||||
* initialization and comparison methods.
|
* initialization and comparison methods.
|
||||||
*/
|
*/
|
||||||
struct ConfigDescription : public android::ResTable_config {
|
struct ConfigDescription : public ResTable_config {
|
||||||
/**
|
/**
|
||||||
* Returns an immutable default config.
|
* Returns an immutable default config.
|
||||||
*/
|
*/
|
||||||
@@ -180,6 +211,6 @@ inline ::std::ostream& operator<<(::std::ostream& out,
|
|||||||
return out << o.toString().string();
|
return out << o.toString().string();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aapt
|
} // namespace android
|
||||||
|
|
||||||
#endif // AAPT_CONFIG_DESCRIPTION_H
|
#endif // ANDROIDFW_CONFIG_DESCRIPTION_H
|
||||||
@@ -14,8 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AAPT_LOCALE_VALUE_H
|
#ifndef ANDROIDFW_LOCALE_VALUE_H
|
||||||
#define AAPT_LOCALE_VALUE_H
|
#define ANDROIDFW_LOCALE_VALUE_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "androidfw/ResourceTypes.h"
|
#include "androidfw/ResourceTypes.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
namespace aapt {
|
namespace android {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience class to build and parse locales.
|
* A convenience class to build and parse locales.
|
||||||
@@ -112,6 +112,6 @@ bool LocaleValue::operator>(const LocaleValue& o) const {
|
|||||||
return compare(o) > 0;
|
return compare(o) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aapt
|
} // namespace android
|
||||||
|
|
||||||
#endif // AAPT_LOCALE_VALUE_H
|
#endif // ANDROIDFW_LOCALE_VALUE_H
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
|
||||||
@@ -116,6 +117,8 @@ std::u16string Utf8ToUtf16(const StringPiece& utf8);
|
|||||||
// Converts a UTF-16 string to a UTF-8 string.
|
// Converts a UTF-16 string to a UTF-8 string.
|
||||||
std::string Utf16ToUtf8(const StringPiece16& utf16);
|
std::string Utf16ToUtf8(const StringPiece16& utf16);
|
||||||
|
|
||||||
|
std::vector<std::string> SplitAndLowercase(const android::StringPiece& str, char sep);
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
||||||
|
|||||||
@@ -14,18 +14,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
|
#include "android-base/logging.h"
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "androidfw/StringPiece.h"
|
namespace android {
|
||||||
|
|
||||||
#include "SdkConstants.h"
|
|
||||||
#include "test/Test.h"
|
|
||||||
|
|
||||||
using android::StringPiece;
|
|
||||||
|
|
||||||
namespace aapt {
|
|
||||||
|
|
||||||
static ::testing::AssertionResult TestParse(
|
static ::testing::AssertionResult TestParse(
|
||||||
const StringPiece& input, ConfigDescription* config = nullptr) {
|
const StringPiece& input, ConfigDescription* config = nullptr) {
|
||||||
@@ -140,9 +138,13 @@ TEST(ConfigDescriptionTest, ParseVrAttribute) {
|
|||||||
EXPECT_EQ(std::string("vrheadset-v26"), config.toString().string());
|
EXPECT_EQ(std::string("vrheadset-v26"), config.toString().string());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) {
|
static inline ConfigDescription ParseConfigOrDie(const android::StringPiece& str) {
|
||||||
using test::ParseConfigOrDie;
|
ConfigDescription config;
|
||||||
|
CHECK(ConfigDescription::Parse(str, &config)) << "invalid configuration: " << str;
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) {
|
||||||
EXPECT_FALSE(ParseConfigOrDie("large").ConflictsWith(ParseConfigOrDie("normal-land")));
|
EXPECT_FALSE(ParseConfigOrDie("large").ConflictsWith(ParseConfigOrDie("normal-land")));
|
||||||
EXPECT_FALSE(ParseConfigOrDie("long-hdpi").ConflictsWith(ParseConfigOrDie("xhdpi")));
|
EXPECT_FALSE(ParseConfigOrDie("long-hdpi").ConflictsWith(ParseConfigOrDie("xhdpi")));
|
||||||
EXPECT_FALSE(ParseConfigOrDie("sw600dp").ConflictsWith(ParseConfigOrDie("sw700dp")));
|
EXPECT_FALSE(ParseConfigOrDie("sw600dp").ConflictsWith(ParseConfigOrDie("sw700dp")));
|
||||||
@@ -152,4 +154,4 @@ TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) {
|
|||||||
EXPECT_FALSE(ParseConfigOrDie("600x400").ConflictsWith(ParseConfigOrDie("300x200")));
|
EXPECT_FALSE(ParseConfigOrDie("600x400").ConflictsWith(ParseConfigOrDie("300x200")));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aapt
|
} // namespace android
|
||||||
@@ -14,15 +14,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Locale.h"
|
#include "androidfw/Locale.h"
|
||||||
|
#include "androidfw/Util.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#include "util/Util.h"
|
namespace android {
|
||||||
|
|
||||||
namespace aapt {
|
|
||||||
|
|
||||||
static ::testing::AssertionResult TestLanguage(const char* input,
|
static ::testing::AssertionResult TestLanguage(const char* input,
|
||||||
const char* lang) {
|
const char* lang) {
|
||||||
@@ -93,4 +92,4 @@ TEST(ConfigDescriptionTest, ParseLanguage) {
|
|||||||
EXPECT_TRUE(TestLanguageRegion("fr-rCA", "fr", "CA"));
|
EXPECT_TRUE(TestLanguageRegion("fr-rCA", "fr", "CA"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aapt
|
} // namespace android
|
||||||
@@ -120,7 +120,6 @@ cc_library_host_static {
|
|||||||
"util/BigBuffer.cpp",
|
"util/BigBuffer.cpp",
|
||||||
"util/Files.cpp",
|
"util/Files.cpp",
|
||||||
"util/Util.cpp",
|
"util/Util.cpp",
|
||||||
"ConfigDescription.cpp",
|
|
||||||
"Debug.cpp",
|
"Debug.cpp",
|
||||||
"DominatorTree.cpp",
|
"DominatorTree.cpp",
|
||||||
"Flags.cpp",
|
"Flags.cpp",
|
||||||
@@ -130,7 +129,6 @@ cc_library_host_static {
|
|||||||
"java/ManifestClassGenerator.cpp",
|
"java/ManifestClassGenerator.cpp",
|
||||||
"java/ProguardRules.cpp",
|
"java/ProguardRules.cpp",
|
||||||
"LoadedApk.cpp",
|
"LoadedApk.cpp",
|
||||||
"Locale.cpp",
|
|
||||||
"Resource.cpp",
|
"Resource.cpp",
|
||||||
"ResourceParser.cpp",
|
"ResourceParser.cpp",
|
||||||
"ResourceTable.cpp",
|
"ResourceTable.cpp",
|
||||||
|
|||||||
@@ -19,8 +19,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "android-base/logging.h"
|
#include "android-base/logging.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
using ::android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include "test/Test.h"
|
#include "test/Test.h"
|
||||||
#include "util/Util.h"
|
#include "util/Util.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|||||||
@@ -24,10 +24,10 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
#include "utils/JenkinsHash.h"
|
#include "utils/JenkinsHash.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
@@ -171,7 +171,7 @@ struct ResourceFile {
|
|||||||
ResourceName name;
|
ResourceName name;
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
ConfigDescription config;
|
android::ConfigDescription config;
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
Type type;
|
Type type;
|
||||||
@@ -189,7 +189,7 @@ struct ResourceFile {
|
|||||||
*/
|
*/
|
||||||
struct ResourceKey {
|
struct ResourceKey {
|
||||||
ResourceName name;
|
ResourceName name;
|
||||||
ConfigDescription config;
|
android::ConfigDescription config;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator<(const ResourceKey& a, const ResourceKey& b);
|
bool operator<(const ResourceKey& a, const ResourceKey& b);
|
||||||
@@ -201,16 +201,16 @@ bool operator<(const ResourceKey& a, const ResourceKey& b);
|
|||||||
*/
|
*/
|
||||||
struct ResourceKeyRef {
|
struct ResourceKeyRef {
|
||||||
ResourceNameRef name;
|
ResourceNameRef name;
|
||||||
ConfigDescription config;
|
android::ConfigDescription config;
|
||||||
|
|
||||||
ResourceKeyRef() = default;
|
ResourceKeyRef() = default;
|
||||||
ResourceKeyRef(const ResourceNameRef& n, const ConfigDescription& c)
|
ResourceKeyRef(const ResourceNameRef& n, const android::ConfigDescription& c)
|
||||||
: name(n), config(c) {}
|
: name(n), config(c) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent taking a reference to a temporary. This is bad.
|
* Prevent taking a reference to a temporary. This is bad.
|
||||||
*/
|
*/
|
||||||
ResourceKeyRef(ResourceName&& n, const ConfigDescription& c) = delete;
|
ResourceKeyRef(ResourceName&& n, const android::ConfigDescription& c) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator<(const ResourceKeyRef& a, const ResourceKeyRef& b);
|
bool operator<(const ResourceKeyRef& a, const ResourceKeyRef& b);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
using ::aapt::ResourceUtils::StringBuilder;
|
using ::aapt::ResourceUtils::StringBuilder;
|
||||||
using ::aapt::text::Utf8Iterator;
|
using ::aapt::text::Utf8Iterator;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|||||||
@@ -20,9 +20,9 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "Diagnostics.h"
|
#include "Diagnostics.h"
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
#include "ResourceValues.h"
|
#include "ResourceValues.h"
|
||||||
@@ -53,7 +53,7 @@ struct ResourceParserOptions {
|
|||||||
class ResourceParser {
|
class ResourceParser {
|
||||||
public:
|
public:
|
||||||
ResourceParser(IDiagnostics* diag, ResourceTable* table, const Source& source,
|
ResourceParser(IDiagnostics* diag, ResourceTable* table, const Source& source,
|
||||||
const ConfigDescription& config,
|
const android::ConfigDescription& config,
|
||||||
const ResourceParserOptions& options = {});
|
const ResourceParserOptions& options = {});
|
||||||
bool Parse(xml::XmlPullParser* parser);
|
bool Parse(xml::XmlPullParser* parser);
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ class ResourceParser {
|
|||||||
IDiagnostics* diag_;
|
IDiagnostics* diag_;
|
||||||
ResourceTable* table_;
|
ResourceTable* table_;
|
||||||
Source source_;
|
Source source_;
|
||||||
ConfigDescription config_;
|
android::ConfigDescription config_;
|
||||||
ResourceParserOptions options_;
|
ResourceParserOptions options_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
using ::aapt::io::StringInputStream;
|
using ::aapt::io::StringInputStream;
|
||||||
using ::aapt::test::StrValueEq;
|
using ::aapt::test::StrValueEq;
|
||||||
using ::aapt::test::ValueEq;
|
using ::aapt::test::ValueEq;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::Res_value;
|
using ::android::Res_value;
|
||||||
using ::android::ResTable_map;
|
using ::android::ResTable_map;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
|
|
||||||
#include "android-base/logging.h"
|
#include "android-base/logging.h"
|
||||||
#include "android-base/stringprintf.h"
|
#include "android-base/stringprintf.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/ResourceTypes.h"
|
#include "androidfw/ResourceTypes.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "NameMangler.h"
|
#include "NameMangler.h"
|
||||||
#include "ResourceValues.h"
|
#include "ResourceValues.h"
|
||||||
#include "ValueVisitor.h"
|
#include "ValueVisitor.h"
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "util/Util.h"
|
#include "util/Util.h"
|
||||||
|
|
||||||
using ::aapt::text::IsValidResourceEntryName;
|
using ::aapt::text::IsValidResourceEntryName;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
using ::android::base::StringPrintf;
|
using ::android::base::StringPrintf;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#ifndef AAPT_RESOURCE_TABLE_H
|
#ifndef AAPT_RESOURCE_TABLE_H
|
||||||
#define AAPT_RESOURCE_TABLE_H
|
#define AAPT_RESOURCE_TABLE_H
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "Diagnostics.h"
|
#include "Diagnostics.h"
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
#include "ResourceValues.h"
|
#include "ResourceValues.h"
|
||||||
@@ -26,6 +25,7 @@
|
|||||||
#include "io/File.h"
|
#include "io/File.h"
|
||||||
|
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -66,7 +66,7 @@ struct Overlayable {
|
|||||||
class ResourceConfigValue {
|
class ResourceConfigValue {
|
||||||
public:
|
public:
|
||||||
// The configuration for which this value is defined.
|
// The configuration for which this value is defined.
|
||||||
const ConfigDescription config;
|
const android::ConfigDescription config;
|
||||||
|
|
||||||
// The product for which this value is defined.
|
// The product for which this value is defined.
|
||||||
const std::string product;
|
const std::string product;
|
||||||
@@ -74,7 +74,7 @@ class ResourceConfigValue {
|
|||||||
// The actual Value.
|
// The actual Value.
|
||||||
std::unique_ptr<Value> value;
|
std::unique_ptr<Value> value;
|
||||||
|
|
||||||
ResourceConfigValue(const ConfigDescription& config, const android::StringPiece& product)
|
ResourceConfigValue(const android::ConfigDescription& config, const android::StringPiece& product)
|
||||||
: config(config), product(product.to_string()) {}
|
: config(config), product(product.to_string()) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -103,14 +103,14 @@ class ResourceEntry {
|
|||||||
|
|
||||||
explicit ResourceEntry(const android::StringPiece& name) : name(name.to_string()) {}
|
explicit ResourceEntry(const android::StringPiece& name) : name(name.to_string()) {}
|
||||||
|
|
||||||
ResourceConfigValue* FindValue(const ConfigDescription& config);
|
ResourceConfigValue* FindValue(const android::ConfigDescription& config);
|
||||||
|
|
||||||
ResourceConfigValue* FindValue(const ConfigDescription& config,
|
ResourceConfigValue* FindValue(const android::ConfigDescription& config,
|
||||||
const android::StringPiece& product);
|
const android::StringPiece& product);
|
||||||
|
|
||||||
ResourceConfigValue* FindOrCreateValue(const ConfigDescription& config,
|
ResourceConfigValue* FindOrCreateValue(const android::ConfigDescription& config,
|
||||||
const android::StringPiece& product);
|
const android::StringPiece& product);
|
||||||
std::vector<ResourceConfigValue*> FindAllValues(const ConfigDescription& config);
|
std::vector<ResourceConfigValue*> FindAllValues(const android::ConfigDescription& config);
|
||||||
|
|
||||||
template <typename Func>
|
template <typename Func>
|
||||||
std::vector<ResourceConfigValue*> FindValuesIf(Func f) {
|
std::vector<ResourceConfigValue*> FindValuesIf(Func f) {
|
||||||
@@ -182,29 +182,30 @@ class ResourceTable {
|
|||||||
// When a collision of resources occurs, this method decides which value to keep.
|
// When a collision of resources occurs, this method decides which value to keep.
|
||||||
static CollisionResult ResolveValueCollision(Value* existing, Value* incoming);
|
static CollisionResult ResolveValueCollision(Value* existing, Value* incoming);
|
||||||
|
|
||||||
bool AddResource(const ResourceNameRef& name, const ConfigDescription& config,
|
bool AddResource(const ResourceNameRef& name, const android::ConfigDescription& config,
|
||||||
const android::StringPiece& product, std::unique_ptr<Value> value,
|
const android::StringPiece& product, std::unique_ptr<Value> value,
|
||||||
IDiagnostics* diag);
|
IDiagnostics* diag);
|
||||||
|
|
||||||
bool AddResourceWithId(const ResourceNameRef& name, const ResourceId& res_id,
|
bool AddResourceWithId(const ResourceNameRef& name, const ResourceId& res_id,
|
||||||
const ConfigDescription& config, const android::StringPiece& product,
|
const android::ConfigDescription& config,
|
||||||
std::unique_ptr<Value> value, IDiagnostics* diag);
|
const android::StringPiece& product, std::unique_ptr<Value> value,
|
||||||
|
IDiagnostics* diag);
|
||||||
|
|
||||||
bool AddFileReference(const ResourceNameRef& name, const ConfigDescription& config,
|
bool AddFileReference(const ResourceNameRef& name, const android::ConfigDescription& config,
|
||||||
const Source& source, const android::StringPiece& path, IDiagnostics* diag);
|
const Source& source, const android::StringPiece& path, IDiagnostics* diag);
|
||||||
|
|
||||||
bool AddFileReferenceMangled(const ResourceNameRef& name, const ConfigDescription& config,
|
bool AddFileReferenceMangled(const ResourceNameRef& name, const android::ConfigDescription& config,
|
||||||
const Source& source, const android::StringPiece& path,
|
const Source& source, const android::StringPiece& path,
|
||||||
io::IFile* file, IDiagnostics* diag);
|
io::IFile* file, IDiagnostics* diag);
|
||||||
|
|
||||||
// Same as AddResource, but doesn't verify the validity of the name. This is used
|
// Same as AddResource, but doesn't verify the validity of the name. This is used
|
||||||
// when loading resources from an existing binary resource table that may have mangled names.
|
// when loading resources from an existing binary resource table that may have mangled names.
|
||||||
bool AddResourceMangled(const ResourceNameRef& name, const ConfigDescription& config,
|
bool AddResourceMangled(const ResourceNameRef& name, const android::ConfigDescription& config,
|
||||||
const android::StringPiece& product, std::unique_ptr<Value> value,
|
const android::StringPiece& product, std::unique_ptr<Value> value,
|
||||||
IDiagnostics* diag);
|
IDiagnostics* diag);
|
||||||
|
|
||||||
bool AddResourceWithIdMangled(const ResourceNameRef& name, const ResourceId& id,
|
bool AddResourceWithIdMangled(const ResourceNameRef& name, const ResourceId& id,
|
||||||
const ConfigDescription& config,
|
const android::ConfigDescription& config,
|
||||||
const android::StringPiece& product, std::unique_ptr<Value> value,
|
const android::StringPiece& product, std::unique_ptr<Value> value,
|
||||||
IDiagnostics* diag);
|
IDiagnostics* diag);
|
||||||
|
|
||||||
@@ -277,11 +278,12 @@ class ResourceTable {
|
|||||||
IDiagnostics* diag);
|
IDiagnostics* diag);
|
||||||
|
|
||||||
bool AddResourceImpl(const ResourceNameRef& name, const ResourceId& res_id,
|
bool AddResourceImpl(const ResourceNameRef& name, const ResourceId& res_id,
|
||||||
const ConfigDescription& config, const android::StringPiece& product,
|
const android::ConfigDescription& config,
|
||||||
std::unique_ptr<Value> value, NameValidator name_validator,
|
const android::StringPiece& product, std::unique_ptr<Value> value,
|
||||||
const CollisionResolverFunc& conflict_resolver, IDiagnostics* diag);
|
NameValidator name_validator, const CollisionResolverFunc& conflict_resolver,
|
||||||
|
IDiagnostics* diag);
|
||||||
|
|
||||||
bool AddFileReferenceImpl(const ResourceNameRef& name, const ConfigDescription& config,
|
bool AddFileReferenceImpl(const ResourceNameRef& name, const android::ConfigDescription& config,
|
||||||
const Source& source, const android::StringPiece& path, io::IFile* file,
|
const Source& source, const android::StringPiece& path, io::IFile* file,
|
||||||
NameValidator name_validator, IDiagnostics* diag);
|
NameValidator name_validator, IDiagnostics* diag);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
using ::testing::Eq;
|
using ::testing::Eq;
|
||||||
using ::testing::NotNull;
|
using ::testing::NotNull;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "util/Util.h"
|
#include "util/Util.h"
|
||||||
|
|
||||||
using ::aapt::text::Utf8Iterator;
|
using ::aapt::text::Utf8Iterator;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
using ::android::StringPiece16;
|
using ::android::StringPiece16;
|
||||||
using ::android::base::StringPrintf;
|
using ::android::base::StringPrintf;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/ResourceTypes.h"
|
#include "androidfw/ResourceTypes.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
@@ -219,7 +220,8 @@ std::string BuildResourceFileName(const ResourceFile& res_file,
|
|||||||
|
|
||||||
// Parses the binary form of a resource value. `type` is used as a hint to know when a value is
|
// Parses the binary form of a resource value. `type` is used as a hint to know when a value is
|
||||||
// an ID versus a False boolean value, etc. `config` is for sorting strings in the string pool.
|
// an ID versus a False boolean value, etc. `config` is for sorting strings in the string pool.
|
||||||
std::unique_ptr<Item> ParseBinaryResValue(const ResourceType& type, const ConfigDescription& config,
|
std::unique_ptr<Item> ParseBinaryResValue(const ResourceType& type,
|
||||||
|
const android::ConfigDescription& config,
|
||||||
const android::ResStringPool& src_pool,
|
const android::ResStringPool& src_pool,
|
||||||
const android::Res_value& res_value,
|
const android::Res_value& res_value,
|
||||||
StringPool* dst_pool);
|
StringPool* dst_pool);
|
||||||
|
|||||||
@@ -24,9 +24,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "Diagnostics.h"
|
#include "Diagnostics.h"
|
||||||
#include "util/BigBuffer.h"
|
#include "util/BigBuffer.h"
|
||||||
|
|
||||||
@@ -60,12 +60,12 @@ class StringPool {
|
|||||||
kLowPriority = 0xffffffffu,
|
kLowPriority = 0xffffffffu,
|
||||||
};
|
};
|
||||||
uint32_t priority = kNormalPriority;
|
uint32_t priority = kNormalPriority;
|
||||||
ConfigDescription config;
|
android::ConfigDescription config;
|
||||||
|
|
||||||
Context() = default;
|
Context() = default;
|
||||||
Context(uint32_t p, const ConfigDescription& c) : priority(p), config(c) {}
|
Context(uint32_t p, const android::ConfigDescription& c) : priority(p), config(c) {}
|
||||||
explicit Context(uint32_t p) : priority(p) {}
|
explicit Context(uint32_t p) : priority(p) {}
|
||||||
explicit Context(const ConfigDescription& c) : priority(kNormalPriority), config(c) {
|
explicit Context(const android::ConfigDescription& c) : priority(kNormalPriority), config(c) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,11 @@
|
|||||||
#include "android-base/errors.h"
|
#include "android-base/errors.h"
|
||||||
#include "android-base/file.h"
|
#include "android-base/file.h"
|
||||||
#include "android-base/utf8.h"
|
#include "android-base/utf8.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
#include "google/protobuf/io/coded_stream.h"
|
#include "google/protobuf/io/coded_stream.h"
|
||||||
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
|
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "Diagnostics.h"
|
#include "Diagnostics.h"
|
||||||
#include "Flags.h"
|
#include "Flags.h"
|
||||||
#include "ResourceParser.h"
|
#include "ResourceParser.h"
|
||||||
@@ -50,6 +50,7 @@
|
|||||||
|
|
||||||
using ::aapt::io::FileInputStream;
|
using ::aapt::io::FileInputStream;
|
||||||
using ::aapt::text::Printer;
|
using ::aapt::text::Printer;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
using ::android::base::SystemErrorCodeToString;
|
using ::android::base::SystemErrorCodeToString;
|
||||||
using ::google::protobuf::io::CopyingOutputStreamAdaptor;
|
using ::google::protobuf::io::CopyingOutputStreamAdaptor;
|
||||||
|
|||||||
@@ -24,13 +24,13 @@
|
|||||||
#include "android-base/errors.h"
|
#include "android-base/errors.h"
|
||||||
#include "android-base/file.h"
|
#include "android-base/file.h"
|
||||||
#include "android-base/stringprintf.h"
|
#include "android-base/stringprintf.h"
|
||||||
|
#include "androidfw/Locale.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
#include "AppInfo.h"
|
#include "AppInfo.h"
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
#include "Flags.h"
|
#include "Flags.h"
|
||||||
#include "LoadedApk.h"
|
#include "LoadedApk.h"
|
||||||
#include "Locale.h"
|
|
||||||
#include "NameMangler.h"
|
#include "NameMangler.h"
|
||||||
#include "ResourceUtils.h"
|
#include "ResourceUtils.h"
|
||||||
#include "ResourceValues.h"
|
#include "ResourceValues.h"
|
||||||
@@ -68,6 +68,7 @@
|
|||||||
#include "xml/XmlDom.h"
|
#include "xml/XmlDom.h"
|
||||||
|
|
||||||
using ::aapt::io::FileInputStream;
|
using ::aapt::io::FileInputStream;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
using ::android::base::StringPrintf;
|
using ::android::base::StringPrintf;
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "android-base/file.h"
|
#include "android-base/file.h"
|
||||||
#include "android-base/stringprintf.h"
|
#include "android-base/stringprintf.h"
|
||||||
|
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/ResourceTypes.h"
|
#include "androidfw/ResourceTypes.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
|
|
||||||
using ::aapt::configuration::Abi;
|
using ::aapt::configuration::Abi;
|
||||||
using ::aapt::configuration::OutputArtifact;
|
using ::aapt::configuration::OutputArtifact;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::ResTable_config;
|
using ::android::ResTable_config;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
using ::android::base::ReadFileToString;
|
using ::android::base::ReadFileToString;
|
||||||
|
|||||||
@@ -19,15 +19,17 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "android-base/logging.h"
|
#include "android-base/logging.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
#include "androidfw/Locale.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "Locale.h"
|
|
||||||
#include "ResourceUtils.h"
|
#include "ResourceUtils.h"
|
||||||
#include "ValueVisitor.h"
|
#include "ValueVisitor.h"
|
||||||
#include "split/TableSplitter.h"
|
#include "split/TableSplitter.h"
|
||||||
#include "util/Maybe.h"
|
#include "util/Maybe.h"
|
||||||
#include "util/Util.h"
|
#include "util/Util.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
|
using ::android::LocaleValue;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "compile/Pseudolocalizer.h"
|
#include "compile/Pseudolocalizer.h"
|
||||||
#include "util/Util.h"
|
#include "util/Util.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
using ::android::StringPiece16;
|
using ::android::StringPiece16;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#include "test/Test.h"
|
#include "test/Test.h"
|
||||||
#include "util/Util.h"
|
#include "util/Util.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
TEST(PseudolocaleGeneratorTest, PseudolocalizeStyledString) {
|
TEST(PseudolocaleGeneratorTest, PseudolocalizeStyledString) {
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
#include "android-base/file.h"
|
#include "android-base/file.h"
|
||||||
#include "android-base/logging.h"
|
#include "android-base/logging.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "Diagnostics.h"
|
#include "Diagnostics.h"
|
||||||
#include "ResourceUtils.h"
|
#include "ResourceUtils.h"
|
||||||
#include "configuration/ConfigurationParser.internal.h"
|
#include "configuration/ConfigurationParser.internal.h"
|
||||||
@@ -40,6 +40,8 @@
|
|||||||
#include "xml/XmlDom.h"
|
#include "xml/XmlDom.h"
|
||||||
#include "xml/XmlUtil.h"
|
#include "xml/XmlUtil.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
#include "Diagnostics.h"
|
#include "Diagnostics.h"
|
||||||
#include "util/Maybe.h"
|
#include "util/Maybe.h"
|
||||||
|
|
||||||
@@ -109,8 +110,8 @@ struct OutputArtifact {
|
|||||||
std::string name;
|
std::string name;
|
||||||
int version;
|
int version;
|
||||||
std::vector<Abi> abis;
|
std::vector<Abi> abis;
|
||||||
std::vector<ConfigDescription> screen_densities;
|
std::vector<android::ConfigDescription> screen_densities;
|
||||||
std::vector<ConfigDescription> locales;
|
std::vector<android::ConfigDescription> locales;
|
||||||
Maybe<AndroidSdk> android_sdk;
|
Maybe<AndroidSdk> android_sdk;
|
||||||
std::vector<DeviceFeature> features;
|
std::vector<DeviceFeature> features;
|
||||||
std::vector<GlTexture> textures;
|
std::vector<GlTexture> textures;
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#ifndef AAPT2_CONFIGURATIONPARSER_INTERNAL_H
|
#ifndef AAPT2_CONFIGURATIONPARSER_INTERNAL_H
|
||||||
#define AAPT2_CONFIGURATIONPARSER_INTERNAL_H
|
#define AAPT2_CONFIGURATIONPARSER_INTERNAL_H
|
||||||
|
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
#include "configuration/ConfigurationParser.h"
|
#include "configuration/ConfigurationParser.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -148,8 +150,8 @@ struct PostProcessingConfiguration {
|
|||||||
Maybe<std::string> artifact_format;
|
Maybe<std::string> artifact_format;
|
||||||
|
|
||||||
Group<Abi> abi_groups;
|
Group<Abi> abi_groups;
|
||||||
Group<ConfigDescription> screen_density_groups;
|
Group<android::ConfigDescription> screen_density_groups;
|
||||||
Group<ConfigDescription> locale_groups;
|
Group<android::ConfigDescription> locale_groups;
|
||||||
Group<DeviceFeature> device_feature_groups;
|
Group<DeviceFeature> device_feature_groups;
|
||||||
Group<GlTexture> gl_texture_groups;
|
Group<GlTexture> gl_texture_groups;
|
||||||
Entry<AndroidSdk> android_sdks;
|
Entry<AndroidSdk> android_sdks;
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
#include "test/Test.h"
|
#include "test/Test.h"
|
||||||
#include "xml/XmlDom.h"
|
#include "xml/XmlDom.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
namespace configuration {
|
namespace configuration {
|
||||||
|
|||||||
@@ -16,9 +16,10 @@
|
|||||||
|
|
||||||
#include "filter/ConfigFilter.h"
|
#include "filter/ConfigFilter.h"
|
||||||
|
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/ResourceTypes.h"
|
#include "androidfw/ResourceTypes.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
using ::android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ class IConfigFilter {
|
|||||||
/**
|
/**
|
||||||
* Returns true if the filter matches the configuration, false otherwise.
|
* Returns true if the filter matches the configuration, false otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool Match(const ConfigDescription& config) const = 0;
|
virtual bool Match(const android::ConfigDescription& config) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,12 +46,12 @@ class IConfigFilter {
|
|||||||
*/
|
*/
|
||||||
class AxisConfigFilter : public IConfigFilter {
|
class AxisConfigFilter : public IConfigFilter {
|
||||||
public:
|
public:
|
||||||
void AddConfig(ConfigDescription config);
|
void AddConfig(android::ConfigDescription config);
|
||||||
|
|
||||||
bool Match(const ConfigDescription& config) const override;
|
bool Match(const android::ConfigDescription& config) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<std::pair<ConfigDescription, uint32_t>> configs_;
|
std::set<std::pair<android::ConfigDescription, uint32_t>> configs_;
|
||||||
uint32_t config_mask_ = 0;
|
uint32_t config_mask_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/ResourceTypes.h"
|
#include "androidfw/ResourceTypes.h"
|
||||||
|
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
@@ -54,22 +55,28 @@ class BinaryResourceParser {
|
|||||||
bool ParseType(const ResourceTablePackage* package, const android::ResChunk_header* chunk);
|
bool ParseType(const ResourceTablePackage* package, const android::ResChunk_header* chunk);
|
||||||
bool ParseLibrary(const android::ResChunk_header* chunk);
|
bool ParseLibrary(const android::ResChunk_header* chunk);
|
||||||
|
|
||||||
std::unique_ptr<Item> ParseValue(const ResourceNameRef& name, const ConfigDescription& config,
|
std::unique_ptr<Item> ParseValue(const ResourceNameRef& name,
|
||||||
|
const android::ConfigDescription& config,
|
||||||
const android::Res_value& value);
|
const android::Res_value& value);
|
||||||
|
|
||||||
std::unique_ptr<Value> ParseMapEntry(const ResourceNameRef& name, const ConfigDescription& config,
|
std::unique_ptr<Value> ParseMapEntry(const ResourceNameRef& name,
|
||||||
|
const android::ConfigDescription& config,
|
||||||
const android::ResTable_map_entry* map);
|
const android::ResTable_map_entry* map);
|
||||||
|
|
||||||
std::unique_ptr<Style> ParseStyle(const ResourceNameRef& name, const ConfigDescription& config,
|
std::unique_ptr<Style> ParseStyle(const ResourceNameRef& name,
|
||||||
|
const android::ConfigDescription& config,
|
||||||
const android::ResTable_map_entry* map);
|
const android::ResTable_map_entry* map);
|
||||||
|
|
||||||
std::unique_ptr<Attribute> ParseAttr(const ResourceNameRef& name, const ConfigDescription& config,
|
std::unique_ptr<Attribute> ParseAttr(const ResourceNameRef& name,
|
||||||
|
const android::ConfigDescription& config,
|
||||||
const android::ResTable_map_entry* map);
|
const android::ResTable_map_entry* map);
|
||||||
|
|
||||||
std::unique_ptr<Array> ParseArray(const ResourceNameRef& name, const ConfigDescription& config,
|
std::unique_ptr<Array> ParseArray(const ResourceNameRef& name,
|
||||||
|
const android::ConfigDescription& config,
|
||||||
const android::ResTable_map_entry* map);
|
const android::ResTable_map_entry* map);
|
||||||
|
|
||||||
std::unique_ptr<Plural> ParsePlural(const ResourceNameRef& name, const ConfigDescription& config,
|
std::unique_ptr<Plural> ParsePlural(const ResourceNameRef& name,
|
||||||
|
const android::ConfigDescription& config,
|
||||||
const android::ResTable_map_entry* map);
|
const android::ResTable_map_entry* map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,13 +19,15 @@
|
|||||||
#include "android-base/logging.h"
|
#include "android-base/logging.h"
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
#include "androidfw/ResourceTypes.h"
|
#include "androidfw/ResourceTypes.h"
|
||||||
|
#include "androidfw/Locale.h"
|
||||||
|
|
||||||
#include "Locale.h"
|
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
#include "ResourceUtils.h"
|
#include "ResourceUtils.h"
|
||||||
#include "ResourceValues.h"
|
#include "ResourceValues.h"
|
||||||
#include "ValueVisitor.h"
|
#include "ValueVisitor.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
|
using ::android::LocaleValue;
|
||||||
using ::android::ResStringPool;
|
using ::android::ResStringPool;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
#define AAPT_FORMAT_PROTO_PROTODESERIALIZE_H
|
#define AAPT_FORMAT_PROTO_PROTODESERIALIZE_H
|
||||||
|
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/ResourceTypes.h"
|
#include "androidfw/ResourceTypes.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "Configuration.pb.h"
|
#include "Configuration.pb.h"
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
#include "ResourceValues.h"
|
#include "ResourceValues.h"
|
||||||
@@ -34,14 +34,15 @@ namespace aapt {
|
|||||||
|
|
||||||
std::unique_ptr<Value> DeserializeValueFromPb(const pb::Value& pb_value,
|
std::unique_ptr<Value> DeserializeValueFromPb(const pb::Value& pb_value,
|
||||||
const android::ResStringPool& src_pool,
|
const android::ResStringPool& src_pool,
|
||||||
const ConfigDescription& config,
|
const android::ConfigDescription& config,
|
||||||
StringPool* value_pool, io::IFileCollection* files,
|
StringPool* value_pool, io::IFileCollection* files,
|
||||||
std::string* out_error);
|
std::string* out_error);
|
||||||
|
|
||||||
std::unique_ptr<Item> DeserializeItemFromPb(const pb::Item& pb_item,
|
std::unique_ptr<Item> DeserializeItemFromPb(const pb::Item& pb_item,
|
||||||
const android::ResStringPool& src_pool,
|
const android::ResStringPool& src_pool,
|
||||||
const ConfigDescription& config, StringPool* value_pool,
|
const android::ConfigDescription& config,
|
||||||
io::IFileCollection* files, std::string* out_error);
|
StringPool* value_pool, io::IFileCollection* files,
|
||||||
|
std::string* out_error);
|
||||||
|
|
||||||
std::unique_ptr<xml::XmlResource> DeserializeXmlResourceFromPb(const pb::XmlNode& pb_node,
|
std::unique_ptr<xml::XmlResource> DeserializeXmlResourceFromPb(const pb::XmlNode& pb_node,
|
||||||
std::string* out_error);
|
std::string* out_error);
|
||||||
@@ -49,8 +50,8 @@ std::unique_ptr<xml::XmlResource> DeserializeXmlResourceFromPb(const pb::XmlNode
|
|||||||
bool DeserializeXmlFromPb(const pb::XmlNode& pb_node, xml::Element* out_el, StringPool* value_pool,
|
bool DeserializeXmlFromPb(const pb::XmlNode& pb_node, xml::Element* out_el, StringPool* value_pool,
|
||||||
std::string* out_error);
|
std::string* out_error);
|
||||||
|
|
||||||
bool DeserializeConfigFromPb(const pb::Configuration& pb_config, ConfigDescription* out_config,
|
bool DeserializeConfigFromPb(const pb::Configuration& pb_config,
|
||||||
std::string* out_error);
|
android::ConfigDescription* out_config, std::string* out_error);
|
||||||
|
|
||||||
// Optional io::IFileCollection used to lookup references to files in the ResourceTable.
|
// Optional io::IFileCollection used to lookup references to files in the ResourceTable.
|
||||||
bool DeserializeTableFromPb(const pb::ResourceTable& pb_table, io::IFileCollection* files,
|
bool DeserializeTableFromPb(const pb::ResourceTable& pb_table, io::IFileCollection* files,
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#include "ValueVisitor.h"
|
#include "ValueVisitor.h"
|
||||||
#include "util/BigBuffer.h"
|
#include "util/BigBuffer.h"
|
||||||
|
|
||||||
|
using android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
void SerializeStringPoolToPb(const StringPool& pool, pb::StringPool* out_pb_pool, IDiagnostics* diag) {
|
void SerializeStringPoolToPb(const StringPool& pool, pb::StringPool* out_pb_pool, IDiagnostics* diag) {
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
#define AAPT_FORMAT_PROTO_PROTOSERIALIZE_H
|
#define AAPT_FORMAT_PROTO_PROTOSERIALIZE_H
|
||||||
|
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "Configuration.pb.h"
|
#include "Configuration.pb.h"
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
#include "ResourceValues.h"
|
#include "ResourceValues.h"
|
||||||
@@ -49,7 +49,7 @@ void SerializeXmlResourceToPb(const xml::XmlResource& resource, pb::XmlNode* out
|
|||||||
void SerializeStringPoolToPb(const StringPool& pool, pb::StringPool* out_pb_pool, IDiagnostics* diag);
|
void SerializeStringPoolToPb(const StringPool& pool, pb::StringPool* out_pb_pool, IDiagnostics* diag);
|
||||||
|
|
||||||
// Serializes a ConfigDescription into its protobuf representation.
|
// Serializes a ConfigDescription into its protobuf representation.
|
||||||
void SerializeConfig(const ConfigDescription& config, pb::Configuration* out_pb_config);
|
void SerializeConfig(const android::ConfigDescription& config, pb::Configuration* out_pb_config);
|
||||||
|
|
||||||
// Serializes a ResourceTable into its protobuf representation.
|
// Serializes a ResourceTable into its protobuf representation.
|
||||||
void SerializeTableToPb(const ResourceTable& table, pb::ResourceTable* out_table, IDiagnostics* diag);
|
void SerializeTableToPb(const ResourceTable& table, pb::ResourceTable* out_table, IDiagnostics* diag);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "format/proto/ProtoDeserialize.h"
|
#include "format/proto/ProtoDeserialize.h"
|
||||||
#include "test/Test.h"
|
#include "test/Test.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
using ::testing::Eq;
|
using ::testing::Eq;
|
||||||
using ::testing::IsEmpty;
|
using ::testing::IsEmpty;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "test/Test.h"
|
#include "test/Test.h"
|
||||||
|
|
||||||
using ::aapt::io::StringOutputStream;
|
using ::aapt::io::StringOutputStream;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::testing::HasSubstr;
|
using ::testing::HasSubstr;
|
||||||
using ::testing::Not;
|
using ::testing::Not;
|
||||||
|
|
||||||
|
|||||||
@@ -20,14 +20,16 @@
|
|||||||
|
|
||||||
#include "android-base/logging.h"
|
#include "android-base/logging.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
#include "SdkConstants.h"
|
#include "SdkConstants.h"
|
||||||
#include "ValueVisitor.h"
|
#include "ValueVisitor.h"
|
||||||
|
|
||||||
|
using android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
bool ShouldGenerateVersionedResource(const ResourceEntry* entry, const ConfigDescription& config,
|
bool ShouldGenerateVersionedResource(const ResourceEntry* entry,
|
||||||
|
const ConfigDescription& config,
|
||||||
const ApiVersion sdk_version_to_generate) {
|
const ApiVersion sdk_version_to_generate) {
|
||||||
// We assume the caller is trying to generate a version greater than the current configuration.
|
// We assume the caller is trying to generate a version greater than the current configuration.
|
||||||
CHECK(sdk_version_to_generate > config.sdkVersion);
|
CHECK(sdk_version_to_generate > config.sdkVersion);
|
||||||
|
|||||||
@@ -16,9 +16,11 @@
|
|||||||
|
|
||||||
#include "link/Linkers.h"
|
#include "link/Linkers.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
#include "test/Test.h"
|
#include "test/Test.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::testing::NotNull;
|
using ::testing::NotNull;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
@@ -32,7 +33,6 @@ namespace aapt {
|
|||||||
|
|
||||||
class ResourceTable;
|
class ResourceTable;
|
||||||
class ResourceEntry;
|
class ResourceEntry;
|
||||||
struct ConfigDescription;
|
|
||||||
|
|
||||||
// Defines the context in which a resource value is defined. Most resources are defined with the
|
// Defines the context in which a resource value is defined. Most resources are defined with the
|
||||||
// implicit package name of their compilation context. Understanding the package name of a resource
|
// implicit package name of their compilation context. Understanding the package name of a resource
|
||||||
@@ -43,12 +43,14 @@ struct CallSite {
|
|||||||
|
|
||||||
// Determines whether a versioned resource should be created. If a versioned resource already
|
// Determines whether a versioned resource should be created. If a versioned resource already
|
||||||
// exists, it takes precedence.
|
// exists, it takes precedence.
|
||||||
bool ShouldGenerateVersionedResource(const ResourceEntry* entry, const ConfigDescription& config,
|
bool ShouldGenerateVersionedResource(const ResourceEntry* entry,
|
||||||
|
const android::ConfigDescription& config,
|
||||||
const ApiVersion sdk_version_to_generate);
|
const ApiVersion sdk_version_to_generate);
|
||||||
|
|
||||||
// Finds the next largest ApiVersion of the config which is identical to the given config except
|
// Finds the next largest ApiVersion of the config which is identical to the given config except
|
||||||
// for sdkVersion.
|
// for sdkVersion.
|
||||||
ApiVersion FindNextApiVersionForConfig(const ResourceEntry* entry, const ConfigDescription& config);
|
ApiVersion FindNextApiVersionForConfig(const ResourceEntry* entry,
|
||||||
|
const android::ConfigDescription& config);
|
||||||
|
|
||||||
class AutoVersioner : public IResourceTableConsumer {
|
class AutoVersioner : public IResourceTableConsumer {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -14,12 +14,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "androidfw/Locale.h"
|
||||||
|
|
||||||
#include "link/NoDefaultResourceRemover.h"
|
#include "link/NoDefaultResourceRemover.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
|
|
||||||
|
using android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
static bool IsDefaultConfigRequired(const ConfigDescription& config) {
|
static bool IsDefaultConfigRequired(const ConfigDescription& config) {
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "test/Test.h"
|
#include "test/Test.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
TEST(ProductFilterTest, SelectTwoProducts) {
|
TEST(ProductFilterTest, SelectTwoProducts) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
|
|
||||||
#include "LoadedApk.h"
|
#include "LoadedApk.h"
|
||||||
@@ -43,6 +44,7 @@ using ::aapt::configuration::AndroidSdk;
|
|||||||
using ::aapt::configuration::OutputArtifact;
|
using ::aapt::configuration::OutputArtifact;
|
||||||
using ::aapt::xml::kSchemaAndroid;
|
using ::aapt::xml::kSchemaAndroid;
|
||||||
using ::aapt::xml::XmlResource;
|
using ::aapt::xml::XmlResource;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
#include "Diagnostics.h"
|
#include "Diagnostics.h"
|
||||||
#include "LoadedApk.h"
|
#include "LoadedApk.h"
|
||||||
#include "configuration/ConfigurationParser.h"
|
#include "configuration/ConfigurationParser.h"
|
||||||
@@ -66,7 +68,7 @@ class MultiApkGenerator {
|
|||||||
/**
|
/**
|
||||||
* Adds the <screen> elements to the parent node for the provided density configuration.
|
* Adds the <screen> elements to the parent node for the provided density configuration.
|
||||||
*/
|
*/
|
||||||
void AddScreens(const ConfigDescription& config, xml::Element* parent);
|
void AddScreens(const android::ConfigDescription& config, xml::Element* parent);
|
||||||
|
|
||||||
LoadedApk* apk_;
|
LoadedApk* apk_;
|
||||||
IAaptContext* context_;
|
IAaptContext* context_;
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
#include "test/Context.h"
|
#include "test/Context.h"
|
||||||
#include "test/Test.h"
|
#include "test/Test.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include "DominatorTree.h"
|
#include "DominatorTree.h"
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
|
|
||||||
|
using android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "test/Test.h"
|
#include "test/Test.h"
|
||||||
|
|
||||||
using ::aapt::test::HasValue;
|
using ::aapt::test::HasValue;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::testing::Not;
|
using ::testing::Not;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
|
|
||||||
|
using android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
template <typename Iterator, typename Pred>
|
template <typename Iterator, typename Pred>
|
||||||
|
|||||||
@@ -21,15 +21,16 @@
|
|||||||
#include "android-base/logging.h"
|
#include "android-base/logging.h"
|
||||||
#include "android-base/stringprintf.h"
|
#include "android-base/stringprintf.h"
|
||||||
#include "androidfw/AssetManager.h"
|
#include "androidfw/AssetManager.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/ResourceTypes.h"
|
#include "androidfw/ResourceTypes.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "NameMangler.h"
|
#include "NameMangler.h"
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
#include "ResourceUtils.h"
|
#include "ResourceUtils.h"
|
||||||
#include "ValueVisitor.h"
|
#include "ValueVisitor.h"
|
||||||
#include "util/Util.h"
|
#include "util/Util.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
using ::android::StringPiece16;
|
using ::android::StringPiece16;
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,13 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "android-base/logging.h"
|
#include "android-base/logging.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
#include "util/Util.h"
|
#include "util/Util.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
using ConfigClaimedMap = std::unordered_map<ResourceConfigValue*, bool>;
|
using ConfigClaimedMap = std::unordered_map<ResourceConfigValue*, bool>;
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
#include "filter/ConfigFilter.h"
|
#include "filter/ConfigFilter.h"
|
||||||
#include "process/IResourceTableConsumer.h"
|
#include "process/IResourceTableConsumer.h"
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
struct SplitConstraints {
|
struct SplitConstraints {
|
||||||
std::set<ConfigDescription> configs;
|
std::set<android::ConfigDescription> configs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TableSplitterOptions {
|
struct TableSplitterOptions {
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "test/Test.h"
|
#include "test/Test.h"
|
||||||
|
|
||||||
|
using ::android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
TEST(TableSplitterTest, NoSplitPreferredDensity) {
|
TEST(TableSplitterTest, NoSplitPreferredDensity) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ using ::aapt::configuration::AndroidSdk;
|
|||||||
using ::aapt::configuration::ConfiguredArtifact;
|
using ::aapt::configuration::ConfiguredArtifact;
|
||||||
using ::aapt::configuration::GetOrCreateGroup;
|
using ::aapt::configuration::GetOrCreateGroup;
|
||||||
using ::aapt::io::StringInputStream;
|
using ::aapt::io::StringInputStream;
|
||||||
|
using ::android::ConfigDescription;
|
||||||
using ::android::StringPiece;
|
using ::android::StringPiece;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
|
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
@@ -40,7 +41,8 @@ class ResourceTableBuilder {
|
|||||||
|
|
||||||
ResourceTableBuilder& SetPackageId(const android::StringPiece& package_name, uint8_t id);
|
ResourceTableBuilder& SetPackageId(const android::StringPiece& package_name, uint8_t id);
|
||||||
ResourceTableBuilder& AddSimple(const android::StringPiece& name, const ResourceId& id = {});
|
ResourceTableBuilder& AddSimple(const android::StringPiece& name, const ResourceId& id = {});
|
||||||
ResourceTableBuilder& AddSimple(const android::StringPiece& name, const ConfigDescription& config,
|
ResourceTableBuilder& AddSimple(const android::StringPiece& name,
|
||||||
|
const android::ConfigDescription& config,
|
||||||
const ResourceId& id = {});
|
const ResourceId& id = {});
|
||||||
ResourceTableBuilder& AddReference(const android::StringPiece& name,
|
ResourceTableBuilder& AddReference(const android::StringPiece& name,
|
||||||
const android::StringPiece& ref);
|
const android::StringPiece& ref);
|
||||||
@@ -51,7 +53,8 @@ class ResourceTableBuilder {
|
|||||||
ResourceTableBuilder& AddString(const android::StringPiece& name, const ResourceId& id,
|
ResourceTableBuilder& AddString(const android::StringPiece& name, const ResourceId& id,
|
||||||
const android::StringPiece& str);
|
const android::StringPiece& str);
|
||||||
ResourceTableBuilder& AddString(const android::StringPiece& name, const ResourceId& id,
|
ResourceTableBuilder& AddString(const android::StringPiece& name, const ResourceId& id,
|
||||||
const ConfigDescription& config, const android::StringPiece& str);
|
const android::ConfigDescription& config,
|
||||||
|
const android::StringPiece& str);
|
||||||
ResourceTableBuilder& AddFileReference(const android::StringPiece& name,
|
ResourceTableBuilder& AddFileReference(const android::StringPiece& name,
|
||||||
const android::StringPiece& path,
|
const android::StringPiece& path,
|
||||||
io::IFile* file = nullptr);
|
io::IFile* file = nullptr);
|
||||||
@@ -60,12 +63,13 @@ class ResourceTableBuilder {
|
|||||||
io::IFile* file = nullptr);
|
io::IFile* file = nullptr);
|
||||||
ResourceTableBuilder& AddFileReference(const android::StringPiece& name,
|
ResourceTableBuilder& AddFileReference(const android::StringPiece& name,
|
||||||
const android::StringPiece& path,
|
const android::StringPiece& path,
|
||||||
const ConfigDescription& config,
|
const android::ConfigDescription& config,
|
||||||
io::IFile* file = nullptr);
|
io::IFile* file = nullptr);
|
||||||
ResourceTableBuilder& AddValue(const android::StringPiece& name, std::unique_ptr<Value> value);
|
ResourceTableBuilder& AddValue(const android::StringPiece& name, std::unique_ptr<Value> value);
|
||||||
ResourceTableBuilder& AddValue(const android::StringPiece& name, const ResourceId& id,
|
ResourceTableBuilder& AddValue(const android::StringPiece& name, const ResourceId& id,
|
||||||
std::unique_ptr<Value> value);
|
std::unique_ptr<Value> value);
|
||||||
ResourceTableBuilder& AddValue(const android::StringPiece& name, const ConfigDescription& config,
|
ResourceTableBuilder& AddValue(const android::StringPiece& name,
|
||||||
|
const android::ConfigDescription& config,
|
||||||
const ResourceId& id, std::unique_ptr<Value> value);
|
const ResourceId& id, std::unique_ptr<Value> value);
|
||||||
ResourceTableBuilder& SetSymbolState(const android::StringPiece& name, const ResourceId& id,
|
ResourceTableBuilder& SetSymbolState(const android::StringPiece& name, const ResourceId& id,
|
||||||
Visibility::Level level, bool allow_new = false);
|
Visibility::Level level, bool allow_new = false);
|
||||||
@@ -163,8 +167,8 @@ class ArtifactBuilder {
|
|||||||
ArtifactBuilder& SetName(const std::string& name);
|
ArtifactBuilder& SetName(const std::string& name);
|
||||||
ArtifactBuilder& SetVersion(int version);
|
ArtifactBuilder& SetVersion(int version);
|
||||||
ArtifactBuilder& AddAbi(configuration::Abi abi);
|
ArtifactBuilder& AddAbi(configuration::Abi abi);
|
||||||
ArtifactBuilder& AddDensity(const ConfigDescription& density);
|
ArtifactBuilder& AddDensity(const android::ConfigDescription& density);
|
||||||
ArtifactBuilder& AddLocale(const ConfigDescription& locale);
|
ArtifactBuilder& AddLocale(const android::ConfigDescription& locale);
|
||||||
ArtifactBuilder& SetAndroidSdk(int min_sdk);
|
ArtifactBuilder& SetAndroidSdk(int min_sdk);
|
||||||
configuration::OutputArtifact Build();
|
configuration::OutputArtifact Build();
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "test/Common.h"
|
#include "test/Common.h"
|
||||||
|
|
||||||
|
using android::ConfigDescription;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,11 @@
|
|||||||
|
|
||||||
#include "android-base/logging.h"
|
#include "android-base/logging.h"
|
||||||
#include "android-base/macros.h"
|
#include "android-base/macros.h"
|
||||||
|
#include "androidfw/ConfigDescription.h"
|
||||||
#include "androidfw/StringPiece.h"
|
#include "androidfw/StringPiece.h"
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#include "ConfigDescription.h"
|
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
#include "ResourceTable.h"
|
#include "ResourceTable.h"
|
||||||
#include "ResourceUtils.h"
|
#include "ResourceUtils.h"
|
||||||
@@ -45,15 +45,15 @@ inline ResourceName ParseNameOrDie(const android::StringPiece& str) {
|
|||||||
return ref.ToResourceName();
|
return ref.ToResourceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ConfigDescription ParseConfigOrDie(const android::StringPiece& str) {
|
inline android::ConfigDescription ParseConfigOrDie(const android::StringPiece& str) {
|
||||||
ConfigDescription config;
|
android::ConfigDescription config;
|
||||||
CHECK(ConfigDescription::Parse(str, &config)) << "invalid configuration: " << str;
|
CHECK(android::ConfigDescription::Parse(str, &config)) << "invalid configuration: " << str;
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T = Value>
|
template <typename T = Value>
|
||||||
T* GetValueForConfigAndProduct(ResourceTable* table, const android::StringPiece& res_name,
|
T* GetValueForConfigAndProduct(ResourceTable* table, const android::StringPiece& res_name,
|
||||||
const ConfigDescription& config,
|
const android::ConfigDescription& config,
|
||||||
const android::StringPiece& product) {
|
const android::StringPiece& product) {
|
||||||
Maybe<ResourceTable::SearchResult> result = table->FindResource(ParseNameOrDie(res_name));
|
Maybe<ResourceTable::SearchResult> result = table->FindResource(ParseNameOrDie(res_name));
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -68,12 +68,12 @@ T* GetValueForConfigAndProduct(ResourceTable* table, const android::StringPiece&
|
|||||||
template <>
|
template <>
|
||||||
Value* GetValueForConfigAndProduct<Value>(ResourceTable* table,
|
Value* GetValueForConfigAndProduct<Value>(ResourceTable* table,
|
||||||
const android::StringPiece& res_name,
|
const android::StringPiece& res_name,
|
||||||
const ConfigDescription& config,
|
const android::ConfigDescription& config,
|
||||||
const android::StringPiece& product);
|
const android::StringPiece& product);
|
||||||
|
|
||||||
template <typename T = Value>
|
template <typename T = Value>
|
||||||
T* GetValueForConfig(ResourceTable* table, const android::StringPiece& res_name,
|
T* GetValueForConfig(ResourceTable* table, const android::StringPiece& res_name,
|
||||||
const ConfigDescription& config) {
|
const android::ConfigDescription& config) {
|
||||||
return GetValueForConfigAndProduct<T>(table, res_name, config, {});
|
return GetValueForConfigAndProduct<T>(table, res_name, config, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user