Loading include/androidfw/AssetManager.h +4 −20 Original line number Diff line number Diff line Loading @@ -136,9 +136,6 @@ public: /* * Open an asset. * * This will search through locale-specific and vendor-specific * directories and packages to find the file. * * The object returned does not depend on the AssetManager. It should * be freed by calling Asset::close(). */ Loading @@ -148,9 +145,8 @@ public: * Open a non-asset file as an asset. * * This is for opening files that are included in an asset package * but aren't assets. These sit outside the usual "locale/vendor" * path hierarchy, and will not be seen by "AssetDir" or included * in our filename cache. * but aren't assets. These sit outside the usual "assets/" * path hierarchy, and will not be seen by "AssetDir". */ Asset* openNonAsset(const char* fileName, AccessMode mode, int32_t* outCookie = NULL); Loading @@ -163,11 +159,6 @@ public: /* * Open a directory within the asset hierarchy. * * The contents of the directory are an amalgam of vendor-specific, * locale-specific, and generic assets stored loosely or in asset * packages. Depending on the cache setting and previous accesses, * this call may incur significant disk overhead. * * To open the top-level directory, pass in "". */ AssetDir* openDir(const char* dirName); Loading @@ -175,11 +166,6 @@ public: /* * Open a directory within a particular path of the asset manager. * * The contents of the directory are an amalgam of vendor-specific, * locale-specific, and generic assets stored loosely or in asset * packages. Depending on the cache setting and previous accesses, * this call may incur significant disk overhead. * * To open the top-level directory, pass in "". */ AssetDir* openNonAssetDir(const int32_t cookie, const char* dirName); Loading Loading @@ -231,8 +217,6 @@ private: Asset* openNonAssetInPathLocked(const char* fileName, AccessMode mode, const asset_path& path); String8 createPathNameLocked(const asset_path& path, const char* locale, const char* vendor); String8 createPathNameLocked(const asset_path& path, const char* rootDir); String8 createZipSourceNameLocked(const String8& zipFileName, const String8& dirName, const String8& fileName); Loading Loading @@ -306,8 +290,8 @@ private: */ class ZipSet { public: ZipSet(void); ~ZipSet(void); ZipSet() = default; ~ZipSet(); /* * Return a ZipFileRO structure for a ZipFileRO with the specified Loading libs/androidfw/AssetManager.cpp +10 −62 Original line number Diff line number Diff line Loading @@ -56,12 +56,6 @@ using namespace android; static const bool kIsDebug = false; /* * Names for default app, locale, and vendor. We might want to change * these to be an actual locale, e.g. always use en-US as the default. */ static const char* kDefaultLocale = "default"; static const char* kDefaultVendor = "default"; static const char* kAssetsRoot = "assets"; static const char* kAppZipName = NULL; //"classes.jar"; static const char* kSystemAssets = "framework/framework-res.apk"; Loading Loading @@ -370,23 +364,11 @@ void AssetManager::getConfiguration(ResTable_config* outConfig) const /* * Open an asset. * * The data could be; * - In a file on disk (assetBase + fileName). * - In a compressed file on disk (assetBase + fileName.gz). * - In a Zip archive, uncompressed or compressed. * * It can be in a number of different directories and Zip archives. * The search order is: * - [appname] * - locale + vendor * - "default" + vendor * - locale + "default" * - "default + "default" * - "common" * - (same as above) * The data could be in any asset path. Each asset path could be: * - A directory on disk. * - A Zip archive, uncompressed or compressed. * * To find a particular file, we have to try up to eight paths with * all three forms of data. * If the file is in a directory, it could have a .gz suffix, meaning it is compressed. * * We should probably reject requests for "illegal" filenames, e.g. those * with illegal characters or "../" backward relative paths. Loading Loading @@ -421,8 +403,7 @@ Asset* AssetManager::open(const char* fileName, AccessMode mode) /* * Open a non-asset file as if it were an asset. * * The "fileName" is the partial path starting from the application * name. * The "fileName" is the partial path starting from the application name. */ Asset* AssetManager::openNonAsset(const char* fileName, AccessMode mode, int32_t* outCookie) { Loading Loading @@ -488,11 +469,12 @@ FileType AssetManager::getFileType(const char* fileName) pAsset = open(fileName, Asset::ACCESS_STREAMING); delete pAsset; if (pAsset == NULL) if (pAsset == NULL) { return kFileTypeNonexistent; else } else { return kFileTypeRegular; } } bool AssetManager::appendPathToResTable(const asset_path& ap, bool appAsLib) const { // skip those ap's that correspond to system overlays Loading Loading @@ -791,18 +773,6 @@ String8 AssetManager::createZipSourceNameLocked(const String8& zipFileName, return sourceName; } /* * Create a path to a loose asset (asset-base/app/locale/vendor). */ String8 AssetManager::createPathNameLocked(const asset_path& ap, const char* locale, const char* vendor) { String8 path(ap.path); path.appendPath((locale != NULL) ? locale : kDefaultLocale); path.appendPath((vendor != NULL) ? vendor : kDefaultVendor); return path; } /* * Create a path to a loose asset (asset-base/app/rootDir). */ Loading @@ -816,15 +786,6 @@ String8 AssetManager::createPathNameLocked(const asset_path& ap, const char* roo /* * Return a pointer to one of our open Zip archives. Returns NULL if no * matching Zip file exists. * * Right now we have 2 possible Zip files (1 each in app/"common"). * * If caching is set to CACHE_OFF, to get the expected behavior we * need to reopen the Zip file on every request. That would be silly * and expensive, so instead we just check the file modification date. * * Pass in NULL values for "appName", "locale", and "vendor" if the * generics should be used. */ ZipFileRO* AssetManager::getZipFileLocked(const asset_path& ap) { Loading Loading @@ -909,14 +870,10 @@ Asset* AssetManager::openAssetFromZipLocked(const ZipFileRO* pZipFile, return pAsset; } /* * Open a directory in the asset namespace. * * An "asset directory" is simply the combination of all files in all * locations, with ".gz" stripped for loose files. With app, locale, and * vendor defined, we have 8 directories and 2 Zip archives to scan. * An "asset directory" is simply the combination of all asset paths' "assets/" directories. * * Pass in "" for the root dir. */ Loading Loading @@ -974,9 +931,7 @@ AssetDir* AssetManager::openDir(const char* dirName) /* * Open a directory in the non-asset namespace. * * An "asset directory" is simply the combination of all files in all * locations, with ".gz" stripped for loose files. With app, locale, and * vendor defined, we have 8 directories and 2 Zip archives to scan. * An "asset directory" is simply the combination of all asset paths' "assets/" directories. * * Pass in "" for the root dir. */ Loading Loading @@ -1501,13 +1456,6 @@ AssetManager::SharedZip::~SharedZip() * =========================================================================== */ /* * Constructor. */ AssetManager::ZipSet::ZipSet(void) { } /* * Destructor. Close any open archives. */ Loading Loading
include/androidfw/AssetManager.h +4 −20 Original line number Diff line number Diff line Loading @@ -136,9 +136,6 @@ public: /* * Open an asset. * * This will search through locale-specific and vendor-specific * directories and packages to find the file. * * The object returned does not depend on the AssetManager. It should * be freed by calling Asset::close(). */ Loading @@ -148,9 +145,8 @@ public: * Open a non-asset file as an asset. * * This is for opening files that are included in an asset package * but aren't assets. These sit outside the usual "locale/vendor" * path hierarchy, and will not be seen by "AssetDir" or included * in our filename cache. * but aren't assets. These sit outside the usual "assets/" * path hierarchy, and will not be seen by "AssetDir". */ Asset* openNonAsset(const char* fileName, AccessMode mode, int32_t* outCookie = NULL); Loading @@ -163,11 +159,6 @@ public: /* * Open a directory within the asset hierarchy. * * The contents of the directory are an amalgam of vendor-specific, * locale-specific, and generic assets stored loosely or in asset * packages. Depending on the cache setting and previous accesses, * this call may incur significant disk overhead. * * To open the top-level directory, pass in "". */ AssetDir* openDir(const char* dirName); Loading @@ -175,11 +166,6 @@ public: /* * Open a directory within a particular path of the asset manager. * * The contents of the directory are an amalgam of vendor-specific, * locale-specific, and generic assets stored loosely or in asset * packages. Depending on the cache setting and previous accesses, * this call may incur significant disk overhead. * * To open the top-level directory, pass in "". */ AssetDir* openNonAssetDir(const int32_t cookie, const char* dirName); Loading Loading @@ -231,8 +217,6 @@ private: Asset* openNonAssetInPathLocked(const char* fileName, AccessMode mode, const asset_path& path); String8 createPathNameLocked(const asset_path& path, const char* locale, const char* vendor); String8 createPathNameLocked(const asset_path& path, const char* rootDir); String8 createZipSourceNameLocked(const String8& zipFileName, const String8& dirName, const String8& fileName); Loading Loading @@ -306,8 +290,8 @@ private: */ class ZipSet { public: ZipSet(void); ~ZipSet(void); ZipSet() = default; ~ZipSet(); /* * Return a ZipFileRO structure for a ZipFileRO with the specified Loading
libs/androidfw/AssetManager.cpp +10 −62 Original line number Diff line number Diff line Loading @@ -56,12 +56,6 @@ using namespace android; static const bool kIsDebug = false; /* * Names for default app, locale, and vendor. We might want to change * these to be an actual locale, e.g. always use en-US as the default. */ static const char* kDefaultLocale = "default"; static const char* kDefaultVendor = "default"; static const char* kAssetsRoot = "assets"; static const char* kAppZipName = NULL; //"classes.jar"; static const char* kSystemAssets = "framework/framework-res.apk"; Loading Loading @@ -370,23 +364,11 @@ void AssetManager::getConfiguration(ResTable_config* outConfig) const /* * Open an asset. * * The data could be; * - In a file on disk (assetBase + fileName). * - In a compressed file on disk (assetBase + fileName.gz). * - In a Zip archive, uncompressed or compressed. * * It can be in a number of different directories and Zip archives. * The search order is: * - [appname] * - locale + vendor * - "default" + vendor * - locale + "default" * - "default + "default" * - "common" * - (same as above) * The data could be in any asset path. Each asset path could be: * - A directory on disk. * - A Zip archive, uncompressed or compressed. * * To find a particular file, we have to try up to eight paths with * all three forms of data. * If the file is in a directory, it could have a .gz suffix, meaning it is compressed. * * We should probably reject requests for "illegal" filenames, e.g. those * with illegal characters or "../" backward relative paths. Loading Loading @@ -421,8 +403,7 @@ Asset* AssetManager::open(const char* fileName, AccessMode mode) /* * Open a non-asset file as if it were an asset. * * The "fileName" is the partial path starting from the application * name. * The "fileName" is the partial path starting from the application name. */ Asset* AssetManager::openNonAsset(const char* fileName, AccessMode mode, int32_t* outCookie) { Loading Loading @@ -488,11 +469,12 @@ FileType AssetManager::getFileType(const char* fileName) pAsset = open(fileName, Asset::ACCESS_STREAMING); delete pAsset; if (pAsset == NULL) if (pAsset == NULL) { return kFileTypeNonexistent; else } else { return kFileTypeRegular; } } bool AssetManager::appendPathToResTable(const asset_path& ap, bool appAsLib) const { // skip those ap's that correspond to system overlays Loading Loading @@ -791,18 +773,6 @@ String8 AssetManager::createZipSourceNameLocked(const String8& zipFileName, return sourceName; } /* * Create a path to a loose asset (asset-base/app/locale/vendor). */ String8 AssetManager::createPathNameLocked(const asset_path& ap, const char* locale, const char* vendor) { String8 path(ap.path); path.appendPath((locale != NULL) ? locale : kDefaultLocale); path.appendPath((vendor != NULL) ? vendor : kDefaultVendor); return path; } /* * Create a path to a loose asset (asset-base/app/rootDir). */ Loading @@ -816,15 +786,6 @@ String8 AssetManager::createPathNameLocked(const asset_path& ap, const char* roo /* * Return a pointer to one of our open Zip archives. Returns NULL if no * matching Zip file exists. * * Right now we have 2 possible Zip files (1 each in app/"common"). * * If caching is set to CACHE_OFF, to get the expected behavior we * need to reopen the Zip file on every request. That would be silly * and expensive, so instead we just check the file modification date. * * Pass in NULL values for "appName", "locale", and "vendor" if the * generics should be used. */ ZipFileRO* AssetManager::getZipFileLocked(const asset_path& ap) { Loading Loading @@ -909,14 +870,10 @@ Asset* AssetManager::openAssetFromZipLocked(const ZipFileRO* pZipFile, return pAsset; } /* * Open a directory in the asset namespace. * * An "asset directory" is simply the combination of all files in all * locations, with ".gz" stripped for loose files. With app, locale, and * vendor defined, we have 8 directories and 2 Zip archives to scan. * An "asset directory" is simply the combination of all asset paths' "assets/" directories. * * Pass in "" for the root dir. */ Loading Loading @@ -974,9 +931,7 @@ AssetDir* AssetManager::openDir(const char* dirName) /* * Open a directory in the non-asset namespace. * * An "asset directory" is simply the combination of all files in all * locations, with ".gz" stripped for loose files. With app, locale, and * vendor defined, we have 8 directories and 2 Zip archives to scan. * An "asset directory" is simply the combination of all asset paths' "assets/" directories. * * Pass in "" for the root dir. */ Loading Loading @@ -1501,13 +1456,6 @@ AssetManager::SharedZip::~SharedZip() * =========================================================================== */ /* * Constructor. */ AssetManager::ZipSet::ZipSet(void) { } /* * Destructor. Close any open archives. */ Loading