MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / addIncludedResources

Method addIncludedResources

tools/aapt/ResourceTable.cpp:1693–1754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1691}
1692
1693status_t ResourceTable::addIncludedResources(Bundle* bundle, const sp<AaptAssets>& assets)
1694{
1695 status_t err = assets->buildIncludedResources(bundle);
1696 if (err != NO_ERROR) {
1697 return err;
1698 }
1699
1700 // For future reference to included resources.
1701 mAssets = assets;
1702
1703 const ResTable& incl = assets->getIncludedResources();
1704
1705 // Retrieve all the packages.
1706 const size_t N = incl.getBasePackageCount();
1707 for (size_t phase=0; phase<2; phase++) {
1708 for (size_t i=0; i<N; i++) {
1709 String16 name(incl.getBasePackageName(i));
1710 uint32_t id = incl.getBasePackageId(i);
1711 // First time through: only add base packages (id
1712 // is not 0); second time through add the other
1713 // packages.
1714 if (phase != 0) {
1715 if (id != 0) {
1716 // Skip base packages -- already one.
1717 id = 0;
1718 } else {
1719 // Assign a dynamic id.
1720 id = mNextPackageId;
1721 }
1722 } else if (id != 0) {
1723 if (id == 127) {
1724 if (mHaveAppPackage) {
1725 fprintf(stderr, "Included resources have two application packages!\n");
1726 return UNKNOWN_ERROR;
1727 }
1728 mHaveAppPackage = true;
1729 }
1730 if (mNextPackageId > id) {
1731 fprintf(stderr, "Included base package ID %d already in use!\n", id);
1732 return UNKNOWN_ERROR;
1733 }
1734 }
1735 if (id != 0) {
1736 NOISY(printf("Including package %s with ID=%d\n",
1737 String8(name).string(), id));
1738 sp<Package> p = new Package(name, id);
1739 mPackages.add(name, p);
1740 mOrderedPackages.add(p);
1741
1742 if (id >= mNextPackageId) {
1743 mNextPackageId = id+1;
1744 }
1745 }
1746 }
1747 }
1748
1749 // Every resource table always has one first entry, the bag attributes.
1750 const SourcePos unknown(String8("????"), 0);

Callers

nothing calls this directly

Calls 8

getTypeFunction · 0.85
stringMethod · 0.80
String16Class · 0.70
addMethod · 0.65
getBasePackageCountMethod · 0.45
getBasePackageNameMethod · 0.45
getBasePackageIdMethod · 0.45

Tested by

no test coverage detected