Merge "Search all packages for a given type string when looking up resources by name" into lmp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
aeef612f20
@ -4175,57 +4175,61 @@ nope:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ssize_t ti = group->findType16(type, typeLen);
|
const size_t packageCount = group->packages.size();
|
||||||
if (ti < 0) {
|
for (size_t pi = 0; pi < packageCount; pi++) {
|
||||||
TABLE_NOISY(printf("Type not found in package %s\n", String8(group->name).string()));
|
ssize_t ti = group->packages[pi]->typeStrings.indexOfString(type, typeLen);
|
||||||
continue;
|
if (ti < 0) {
|
||||||
}
|
|
||||||
|
|
||||||
const TypeList& typeList = group->types[ti];
|
|
||||||
if (typeList.isEmpty()) {
|
|
||||||
TABLE_NOISY(printf("Expected type structure not found in package %s for index %d\n",
|
|
||||||
String8(group->name).string(), ti));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t typeCount = typeList.size();
|
|
||||||
for (size_t i = 0; i < typeCount; i++) {
|
|
||||||
const Type* t = typeList[i];
|
|
||||||
const ssize_t ei = t->package->keyStrings.indexOfString(name, nameLen);
|
|
||||||
if (ei < 0) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t configCount = t->configs.size();
|
ti += group->packages[pi]->typeIdOffset;
|
||||||
for (size_t j = 0; j < configCount; j++) {
|
|
||||||
const TypeVariant tv(t->configs[j]);
|
|
||||||
for (TypeVariant::iterator iter = tv.beginEntries();
|
|
||||||
iter != tv.endEntries();
|
|
||||||
iter++) {
|
|
||||||
const ResTable_entry* entry = *iter;
|
|
||||||
if (entry == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dtohl(entry->key.index) == (size_t) ei) {
|
const TypeList& typeList = group->types[ti];
|
||||||
uint32_t resId = Res_MAKEID(group->id - 1, ti, iter.index());
|
if (typeList.isEmpty()) {
|
||||||
if (outTypeSpecFlags) {
|
TABLE_NOISY(printf("Expected type structure not found in package %s for index %d\n",
|
||||||
Entry result;
|
String8(group->name).string(), ti));
|
||||||
if (getEntry(group, ti, iter.index(), NULL, &result) != NO_ERROR) {
|
continue;
|
||||||
ALOGW("Failed to find spec flags for %s:%s/%s (0x%08x)",
|
}
|
||||||
String8(group->name).string(),
|
|
||||||
String8(String16(type, typeLen)).string(),
|
|
||||||
String8(String16(name, nameLen)).string(),
|
|
||||||
resId);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*outTypeSpecFlags = result.specFlags;
|
|
||||||
|
|
||||||
if (fakePublic) {
|
const size_t typeCount = typeList.size();
|
||||||
*outTypeSpecFlags |= ResTable_typeSpec::SPEC_PUBLIC;
|
for (size_t i = 0; i < typeCount; i++) {
|
||||||
}
|
const Type* t = typeList[i];
|
||||||
|
const ssize_t ei = t->package->keyStrings.indexOfString(name, nameLen);
|
||||||
|
if (ei < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t configCount = t->configs.size();
|
||||||
|
for (size_t j = 0; j < configCount; j++) {
|
||||||
|
const TypeVariant tv(t->configs[j]);
|
||||||
|
for (TypeVariant::iterator iter = tv.beginEntries();
|
||||||
|
iter != tv.endEntries();
|
||||||
|
iter++) {
|
||||||
|
const ResTable_entry* entry = *iter;
|
||||||
|
if (entry == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dtohl(entry->key.index) == (size_t) ei) {
|
||||||
|
uint32_t resId = Res_MAKEID(group->id - 1, ti, iter.index());
|
||||||
|
if (outTypeSpecFlags) {
|
||||||
|
Entry result;
|
||||||
|
if (getEntry(group, ti, iter.index(), NULL, &result) != NO_ERROR) {
|
||||||
|
ALOGW("Failed to find spec flags for %s:%s/%s (0x%08x)",
|
||||||
|
String8(group->name).string(),
|
||||||
|
String8(String16(type, typeLen)).string(),
|
||||||
|
String8(String16(name, nameLen)).string(),
|
||||||
|
resId);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*outTypeSpecFlags = result.specFlags;
|
||||||
|
|
||||||
|
if (fakePublic) {
|
||||||
|
*outTypeSpecFlags |= ResTable_typeSpec::SPEC_PUBLIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resId;
|
||||||
}
|
}
|
||||||
return resId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ TEST(SplitFeatureTest, TestNewResourceIsAccessible) {
|
|||||||
EXPECT_EQ(Res_value::TYPE_STRING, val.dataType);
|
EXPECT_EQ(Res_value::TYPE_STRING, val.dataType);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SplitFeatureTest, TestNewResourceIsAccessibleByName) {
|
TEST(SplitFeatureTest, TestNewResourceNameHasCorrectName) {
|
||||||
ResTable table;
|
ResTable table;
|
||||||
ASSERT_EQ(NO_ERROR, table.add(basic_arsc, basic_arsc_len));
|
ASSERT_EQ(NO_ERROR, table.add(basic_arsc, basic_arsc_len));
|
||||||
|
|
||||||
@ -200,4 +200,17 @@ TEST(SplitFeatureTest, TestNewResourceIsAccessibleByName) {
|
|||||||
String16(name.name, name.nameLen));
|
String16(name.name, name.nameLen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(SplitFeatureTest, TestNewResourceIsAccessibleByName) {
|
||||||
|
ResTable table;
|
||||||
|
ASSERT_EQ(NO_ERROR, table.add(basic_arsc, basic_arsc_len));
|
||||||
|
ASSERT_EQ(NO_ERROR, table.add(feature_arsc, feature_arsc_len));
|
||||||
|
|
||||||
|
const String16 name("test3");
|
||||||
|
const String16 type("string");
|
||||||
|
const String16 package("com.android.test.basic");
|
||||||
|
ASSERT_EQ(base::R::string::test3, table.identifierForName(name.string(), name.size(),
|
||||||
|
type.string(), type.size(),
|
||||||
|
package.string(), package.size()));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Reference in New Issue
Block a user