Loading core/java/android/content/res/AssetManager.java +16 −2 Original line number Diff line number Diff line Loading @@ -610,14 +610,28 @@ public final class AssetManager implements AutoCloseable { * {@hide} */ public final int addAssetPath(String path) { return addAssetPathInternal(path, false); } /** * Add an application assets to the asset manager and loading it as shared library. * This can be either a directory or ZIP file. Not for use by applications. Returns * the cookie of the added asset, or 0 on failure. * {@hide} */ public final int addAssetPathAsSharedLibrary(String path) { return addAssetPathInternal(path, true); } private final int addAssetPathInternal(String path, boolean appAsLib) { synchronized (this) { int res = addAssetPathNative(path); int res = addAssetPathNative(path, appAsLib); makeStringBlocks(mStringBlocks); return res; } } private native final int addAssetPathNative(String path); private native final int addAssetPathNative(String path, boolean appAsLib); /** * Add a set of assets to overlay an already added set of assets. Loading core/jni/android_util_AssetManager.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -510,7 +510,7 @@ static jlong android_content_AssetManager_getAssetRemainingLength(JNIEnv* env, j } static jint android_content_AssetManager_addAssetPath(JNIEnv* env, jobject clazz, jstring path) jstring path, jboolean appAsLib) { ScopedUtfChars path8(env, path); if (path8.c_str() == NULL) { Loading @@ -523,7 +523,7 @@ static jint android_content_AssetManager_addAssetPath(JNIEnv* env, jobject clazz } int32_t cookie; bool res = am->addAssetPath(String8(path8.c_str()), &cookie); bool res = am->addAssetPath(String8(path8.c_str()), &cookie, appAsLib); return (res) ? static_cast<jint>(cookie) : 0; } Loading Loading @@ -2138,7 +2138,7 @@ static JNINativeMethod gAssetManagerMethods[] = { (void*) android_content_AssetManager_getAssetLength }, { "getAssetRemainingLength", "(J)J", (void*) android_content_AssetManager_getAssetRemainingLength }, { "addAssetPathNative", "(Ljava/lang/String;)I", { "addAssetPathNative", "(Ljava/lang/String;Z)I", (void*) android_content_AssetManager_addAssetPath }, { "addOverlayPathNative", "(Ljava/lang/String;)I", (void*) android_content_AssetManager_addOverlayPath }, Loading include/androidfw/AssetManager.h +4 −3 Original line number Diff line number Diff line Loading @@ -93,13 +93,14 @@ public: * look in multiple places for assets. It can be either a directory (for * finding assets as raw files on the disk) or a ZIP file. This newly * added asset path will be examined first when searching for assets, * before any that were previously added. * before any that were previously added, the assets are added as shared * library if appAsLib is true. * * Returns "true" on success, "false" on failure. If 'cookie' is non-NULL, * then on success, *cookie is set to the value corresponding to the * newly-added asset source. */ bool addAssetPath(const String8& path, int32_t* cookie); bool addAssetPath(const String8& path, int32_t* cookie, bool appAsLib=false); bool addOverlayPath(const String8& path, int32_t* cookie); /* Loading Loading @@ -280,7 +281,7 @@ private: const ResTable* getResTable(bool required = true) const; void setLocaleLocked(const char* locale); void updateResourceParamsLocked() const; bool appendPathToResTable(const asset_path& ap) const; bool appendPathToResTable(const asset_path& ap, bool appAsLib=false) const; Asset* openIdmapLocked(const struct asset_path& ap) const; Loading include/androidfw/ResourceTypes.h +7 −5 Original line number Diff line number Diff line Loading @@ -1505,7 +1505,7 @@ struct ResTable_lib_entry class DynamicRefTable { public: DynamicRefTable(uint8_t packageId); DynamicRefTable(uint8_t packageId, bool appAsLib); // Loads an unmapped reference table from the package. status_t load(const ResTable_lib_header* const header); Loading @@ -1530,6 +1530,7 @@ private: const uint8_t mAssignedPackageId; uint8_t mLookupTable[256]; KeyedVector<String16, uint8_t> mEntries; bool mAppAsLib; }; bool U16StringToInt(const char16_t* s, size_t len, Res_value* outValue); Loading @@ -1547,10 +1548,11 @@ public: status_t add(const void* data, size_t size, const int32_t cookie=-1, bool copyData=false); status_t add(const void* data, size_t size, const void* idmapData, size_t idmapDataSize, const int32_t cookie=-1, bool copyData=false); const int32_t cookie=-1, bool copyData=false, bool appAsLib=false); status_t add(Asset* asset, const int32_t cookie=-1, bool copyData=false); status_t add(Asset* asset, Asset* idmapAsset, const int32_t cookie=-1, bool copyData=false); status_t add(Asset* asset, Asset* idmapAsset, const int32_t cookie=-1, bool copyData=false, bool appAsLib=false); status_t add(ResTable* src); status_t addEmpty(const int32_t cookie); Loading Loading @@ -1858,7 +1860,7 @@ private: typedef Vector<Type*> TypeList; status_t addInternal(const void* data, size_t size, const void* idmapData, size_t idmapDataSize, const int32_t cookie, bool copyData); bool appAsLib, const int32_t cookie, bool copyData); ssize_t getResourcePackageIndex(uint32_t resID) const; Loading @@ -1871,7 +1873,7 @@ private: size_t nameLen, uint32_t* outTypeSpecFlags) const; status_t parsePackage( const ResTable_package* const pkg, const Header* const header); const ResTable_package* const pkg, const Header* const header, bool appAsLib); void print_value(const Package* pkg, const Res_value& value) const; Loading libs/androidfw/AssetManager.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -176,7 +176,7 @@ AssetManager::~AssetManager(void) delete[] mVendor; } bool AssetManager::addAssetPath(const String8& path, int32_t* cookie) bool AssetManager::addAssetPath(const String8& path, int32_t* cookie, bool appAsLib) { AutoMutex _l(mLock); Loading Loading @@ -238,7 +238,7 @@ bool AssetManager::addAssetPath(const String8& path, int32_t* cookie) #endif if (mResources != NULL) { appendPathToResTable(ap); appendPathToResTable(ap, appAsLib); } return true; Loading Loading @@ -610,7 +610,7 @@ FileType AssetManager::getFileType(const char* fileName) return kFileTypeRegular; } bool AssetManager::appendPathToResTable(const asset_path& ap) const { bool AssetManager::appendPathToResTable(const asset_path& ap, bool appAsLib) const { // skip those ap's that correspond to system overlays if (ap.isSystemOverlay) { return true; Loading Loading @@ -685,7 +685,7 @@ bool AssetManager::appendPathToResTable(const asset_path& ap) const { mResources->add(sharedRes); } else { ALOGV("Parsing resources for %s", ap.path.string()); mResources->add(ass, idmap, nextEntryIdx + 1, !shared); mResources->add(ass, idmap, nextEntryIdx + 1, !shared, appAsLib); } onlyEmptyResources = false; Loading Loading
core/java/android/content/res/AssetManager.java +16 −2 Original line number Diff line number Diff line Loading @@ -610,14 +610,28 @@ public final class AssetManager implements AutoCloseable { * {@hide} */ public final int addAssetPath(String path) { return addAssetPathInternal(path, false); } /** * Add an application assets to the asset manager and loading it as shared library. * This can be either a directory or ZIP file. Not for use by applications. Returns * the cookie of the added asset, or 0 on failure. * {@hide} */ public final int addAssetPathAsSharedLibrary(String path) { return addAssetPathInternal(path, true); } private final int addAssetPathInternal(String path, boolean appAsLib) { synchronized (this) { int res = addAssetPathNative(path); int res = addAssetPathNative(path, appAsLib); makeStringBlocks(mStringBlocks); return res; } } private native final int addAssetPathNative(String path); private native final int addAssetPathNative(String path, boolean appAsLib); /** * Add a set of assets to overlay an already added set of assets. Loading
core/jni/android_util_AssetManager.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -510,7 +510,7 @@ static jlong android_content_AssetManager_getAssetRemainingLength(JNIEnv* env, j } static jint android_content_AssetManager_addAssetPath(JNIEnv* env, jobject clazz, jstring path) jstring path, jboolean appAsLib) { ScopedUtfChars path8(env, path); if (path8.c_str() == NULL) { Loading @@ -523,7 +523,7 @@ static jint android_content_AssetManager_addAssetPath(JNIEnv* env, jobject clazz } int32_t cookie; bool res = am->addAssetPath(String8(path8.c_str()), &cookie); bool res = am->addAssetPath(String8(path8.c_str()), &cookie, appAsLib); return (res) ? static_cast<jint>(cookie) : 0; } Loading Loading @@ -2138,7 +2138,7 @@ static JNINativeMethod gAssetManagerMethods[] = { (void*) android_content_AssetManager_getAssetLength }, { "getAssetRemainingLength", "(J)J", (void*) android_content_AssetManager_getAssetRemainingLength }, { "addAssetPathNative", "(Ljava/lang/String;)I", { "addAssetPathNative", "(Ljava/lang/String;Z)I", (void*) android_content_AssetManager_addAssetPath }, { "addOverlayPathNative", "(Ljava/lang/String;)I", (void*) android_content_AssetManager_addOverlayPath }, Loading
include/androidfw/AssetManager.h +4 −3 Original line number Diff line number Diff line Loading @@ -93,13 +93,14 @@ public: * look in multiple places for assets. It can be either a directory (for * finding assets as raw files on the disk) or a ZIP file. This newly * added asset path will be examined first when searching for assets, * before any that were previously added. * before any that were previously added, the assets are added as shared * library if appAsLib is true. * * Returns "true" on success, "false" on failure. If 'cookie' is non-NULL, * then on success, *cookie is set to the value corresponding to the * newly-added asset source. */ bool addAssetPath(const String8& path, int32_t* cookie); bool addAssetPath(const String8& path, int32_t* cookie, bool appAsLib=false); bool addOverlayPath(const String8& path, int32_t* cookie); /* Loading Loading @@ -280,7 +281,7 @@ private: const ResTable* getResTable(bool required = true) const; void setLocaleLocked(const char* locale); void updateResourceParamsLocked() const; bool appendPathToResTable(const asset_path& ap) const; bool appendPathToResTable(const asset_path& ap, bool appAsLib=false) const; Asset* openIdmapLocked(const struct asset_path& ap) const; Loading
include/androidfw/ResourceTypes.h +7 −5 Original line number Diff line number Diff line Loading @@ -1505,7 +1505,7 @@ struct ResTable_lib_entry class DynamicRefTable { public: DynamicRefTable(uint8_t packageId); DynamicRefTable(uint8_t packageId, bool appAsLib); // Loads an unmapped reference table from the package. status_t load(const ResTable_lib_header* const header); Loading @@ -1530,6 +1530,7 @@ private: const uint8_t mAssignedPackageId; uint8_t mLookupTable[256]; KeyedVector<String16, uint8_t> mEntries; bool mAppAsLib; }; bool U16StringToInt(const char16_t* s, size_t len, Res_value* outValue); Loading @@ -1547,10 +1548,11 @@ public: status_t add(const void* data, size_t size, const int32_t cookie=-1, bool copyData=false); status_t add(const void* data, size_t size, const void* idmapData, size_t idmapDataSize, const int32_t cookie=-1, bool copyData=false); const int32_t cookie=-1, bool copyData=false, bool appAsLib=false); status_t add(Asset* asset, const int32_t cookie=-1, bool copyData=false); status_t add(Asset* asset, Asset* idmapAsset, const int32_t cookie=-1, bool copyData=false); status_t add(Asset* asset, Asset* idmapAsset, const int32_t cookie=-1, bool copyData=false, bool appAsLib=false); status_t add(ResTable* src); status_t addEmpty(const int32_t cookie); Loading Loading @@ -1858,7 +1860,7 @@ private: typedef Vector<Type*> TypeList; status_t addInternal(const void* data, size_t size, const void* idmapData, size_t idmapDataSize, const int32_t cookie, bool copyData); bool appAsLib, const int32_t cookie, bool copyData); ssize_t getResourcePackageIndex(uint32_t resID) const; Loading @@ -1871,7 +1873,7 @@ private: size_t nameLen, uint32_t* outTypeSpecFlags) const; status_t parsePackage( const ResTable_package* const pkg, const Header* const header); const ResTable_package* const pkg, const Header* const header, bool appAsLib); void print_value(const Package* pkg, const Res_value& value) const; Loading
libs/androidfw/AssetManager.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -176,7 +176,7 @@ AssetManager::~AssetManager(void) delete[] mVendor; } bool AssetManager::addAssetPath(const String8& path, int32_t* cookie) bool AssetManager::addAssetPath(const String8& path, int32_t* cookie, bool appAsLib) { AutoMutex _l(mLock); Loading Loading @@ -238,7 +238,7 @@ bool AssetManager::addAssetPath(const String8& path, int32_t* cookie) #endif if (mResources != NULL) { appendPathToResTable(ap); appendPathToResTable(ap, appAsLib); } return true; Loading Loading @@ -610,7 +610,7 @@ FileType AssetManager::getFileType(const char* fileName) return kFileTypeRegular; } bool AssetManager::appendPathToResTable(const asset_path& ap) const { bool AssetManager::appendPathToResTable(const asset_path& ap, bool appAsLib) const { // skip those ap's that correspond to system overlays if (ap.isSystemOverlay) { return true; Loading Loading @@ -685,7 +685,7 @@ bool AssetManager::appendPathToResTable(const asset_path& ap) const { mResources->add(sharedRes); } else { ALOGV("Parsing resources for %s", ap.path.string()); mResources->add(ass, idmap, nextEntryIdx + 1, !shared); mResources->add(ass, idmap, nextEntryIdx + 1, !shared, appAsLib); } onlyEmptyResources = false; Loading