| 1819 | } |
| 1820 | |
| 1821 | status_t ResourceTable::startBag(const SourcePos& sourcePos, |
| 1822 | const String16& package, |
| 1823 | const String16& type, |
| 1824 | const String16& name, |
| 1825 | const String16& bagParent, |
| 1826 | const ResTable_config* params, |
| 1827 | bool overlay, |
| 1828 | bool replace, bool isId) |
| 1829 | { |
| 1830 | status_t result = NO_ERROR; |
| 1831 | |
| 1832 | // Check for adding entries in other packages... for now we do |
| 1833 | // nothing. We need to do the right thing here to support skinning. |
| 1834 | uint32_t rid = mAssets->getIncludedResources() |
| 1835 | .identifierForName(name.string(), name.size(), |
| 1836 | type.string(), type.size(), |
| 1837 | package.string(), package.size()); |
| 1838 | if (rid != 0) { |
| 1839 | return NO_ERROR; |
| 1840 | } |
| 1841 | |
| 1842 | #if 0 |
| 1843 | if (name == String16("left")) { |
| 1844 | printf("Adding bag left: file=%s, line=%d, type=%s\n", |
| 1845 | sourcePos.file.striing(), sourcePos.line, String8(type).string()); |
| 1846 | } |
| 1847 | #endif |
| 1848 | if (overlay && !mBundle->getAutoAddOverlay() && !hasBagOrEntry(package, type, name)) { |
| 1849 | bool canAdd = false; |
| 1850 | sp<Package> p = mPackages.valueFor(package); |
| 1851 | if (p != NULL) { |
| 1852 | sp<Type> t = p->getTypes().valueFor(type); |
| 1853 | if (t != NULL) { |
| 1854 | if (t->getCanAddEntries().indexOf(name) >= 0) { |
| 1855 | canAdd = true; |
| 1856 | } |
| 1857 | } |
| 1858 | } |
| 1859 | if (!canAdd) { |
| 1860 | sourcePos.error("Resource does not already exist in overlay at '%s'; use <add-resource> to add.\n", |
| 1861 | String8(name).string()); |
| 1862 | return UNKNOWN_ERROR; |
| 1863 | } |
| 1864 | } |
| 1865 | sp<Entry> e = getEntry(package, type, name, sourcePos, overlay, params); |
| 1866 | if (e == NULL) { |
| 1867 | return UNKNOWN_ERROR; |
| 1868 | } |
| 1869 | |
| 1870 | // If a parent is explicitly specified, set it. |
| 1871 | if (bagParent.size() > 0) { |
| 1872 | e->setParent(bagParent); |
| 1873 | } |
| 1874 | |
| 1875 | if ((result = e->makeItABag(sourcePos)) != NO_ERROR) { |
| 1876 | return result; |
| 1877 | } |
| 1878 |
no test coverage detected