| 964 | } |
| 965 | |
| 966 | status_t XMLNode::assignResourceIds(const sp<AaptAssets>& assets, |
| 967 | const ResourceTable* table) |
| 968 | { |
| 969 | bool hasErrors = false; |
| 970 | |
| 971 | if (getType() == TYPE_ELEMENT) { |
| 972 | String16 attr("attr"); |
| 973 | const char* errorMsg; |
| 974 | const size_t N = mAttributes.size(); |
| 975 | for (size_t i=0; i<N; i++) { |
| 976 | const attribute_entry& e = mAttributes.itemAt(i); |
| 977 | if (e.ns.size() <= 0) continue; |
| 978 | bool nsIsPublic; |
| 979 | String16 pkg(getNamespaceResourcePackage(String16(assets->getPackage()), e.ns, &nsIsPublic)); |
| 980 | NOISY(printf("Elem %s %s=\"%s\": namespace(%s) %s ===> %s\n", |
| 981 | String8(getElementName()).string(), |
| 982 | String8(e.name).string(), |
| 983 | String8(e.string).string(), |
| 984 | String8(e.ns).string(), |
| 985 | (nsIsPublic) ? "public" : "private", |
| 986 | String8(pkg).string())); |
| 987 | if (pkg.size() <= 0) continue; |
| 988 | uint32_t res = table != NULL |
| 989 | ? table->getResId(e.name, &attr, &pkg, &errorMsg, nsIsPublic) |
| 990 | : assets->getIncludedResources(). |
| 991 | identifierForName(e.name.string(), e.name.size(), |
| 992 | attr.string(), attr.size(), |
| 993 | pkg.string(), pkg.size()); |
| 994 | if (res != 0) { |
| 995 | NOISY(printf("XML attribute name %s: resid=0x%08x\n", |
| 996 | String8(e.name).string(), res)); |
| 997 | setAttributeResID(i, res); |
| 998 | } else { |
| 999 | SourcePos(mFilename, getStartLineNumber()).error( |
| 1000 | "No resource identifier found for attribute '%s' in package '%s'\n", |
| 1001 | String8(e.name).string(), String8(pkg).string()); |
| 1002 | hasErrors = true; |
| 1003 | } |
| 1004 | } |
| 1005 | } |
| 1006 | const size_t N = mChildren.size(); |
| 1007 | for (size_t i=0; i<N; i++) { |
| 1008 | status_t err = mChildren.itemAt(i)->assignResourceIds(assets, table); |
| 1009 | if (err < NO_ERROR) { |
| 1010 | hasErrors = true; |
| 1011 | } |
| 1012 | } |
| 1013 | |
| 1014 | return hasErrors ? UNKNOWN_ERROR : NO_ERROR; |
| 1015 | } |
| 1016 | |
| 1017 | status_t XMLNode::flatten(const sp<AaptFile>& dest, |
| 1018 | bool stripComments, bool stripRawValues) const |
no test coverage detected