| 1883 | } |
| 1884 | |
| 1885 | status_t ResourceTable::addBag(const SourcePos& sourcePos, |
| 1886 | const String16& package, |
| 1887 | const String16& type, |
| 1888 | const String16& name, |
| 1889 | const String16& bagParent, |
| 1890 | const String16& bagKey, |
| 1891 | const String16& value, |
| 1892 | const Vector<StringPool::entry_style_span>* style, |
| 1893 | const ResTable_config* params, |
| 1894 | bool replace, bool isId, const int32_t format) |
| 1895 | { |
| 1896 | // Check for adding entries in other packages... for now we do |
| 1897 | // nothing. We need to do the right thing here to support skinning. |
| 1898 | uint32_t rid = mAssets->getIncludedResources() |
| 1899 | .identifierForName(name.string(), name.size(), |
| 1900 | type.string(), type.size(), |
| 1901 | package.string(), package.size()); |
| 1902 | if (rid != 0) { |
| 1903 | return NO_ERROR; |
| 1904 | } |
| 1905 | |
| 1906 | #if 0 |
| 1907 | if (name == String16("left")) { |
| 1908 | printf("Adding bag left: file=%s, line=%d, type=%s\n", |
| 1909 | sourcePos.file.striing(), sourcePos.line, String8(type).string()); |
| 1910 | } |
| 1911 | #endif |
| 1912 | sp<Entry> e = getEntry(package, type, name, sourcePos, replace, params); |
| 1913 | if (e == NULL) { |
| 1914 | return UNKNOWN_ERROR; |
| 1915 | } |
| 1916 | |
| 1917 | // If a parent is explicitly specified, set it. |
| 1918 | if (bagParent.size() > 0) { |
| 1919 | e->setParent(bagParent); |
| 1920 | } |
| 1921 | |
| 1922 | const bool first = e->getBag().indexOfKey(bagKey) < 0; |
| 1923 | status_t err = e->addToBag(sourcePos, bagKey, value, style, replace, isId, format); |
| 1924 | if (err == NO_ERROR && first) { |
| 1925 | mNumLocal++; |
| 1926 | } |
| 1927 | return err; |
| 1928 | } |
| 1929 | |
| 1930 | bool ResourceTable::hasBagOrEntry(const String16& package, |
| 1931 | const String16& type, |
no test coverage detected