diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/androidfw/AssetManager.cpp | 31 | ||||
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 28 |
2 files changed, 29 insertions, 30 deletions
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index 503c030..08328d0 100644 --- a/libs/androidfw/AssetManager.cpp +++ b/libs/androidfw/AssetManager.cpp @@ -165,7 +165,7 @@ AssetManager::~AssetManager(void) delete[] mVendor; } -bool AssetManager::addAssetPath(const String8& path, void** cookie) +bool AssetManager::addAssetPath(const String8& path, int32_t* cookie) { AutoMutex _l(mLock); @@ -192,7 +192,7 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie) for (size_t i=0; i<mAssetPaths.size(); i++) { if (mAssetPaths[i].path == ap.path) { if (cookie) { - *cookie = (void*)(i+1); + *cookie = static_cast<int32_t>(i+1); } return true; } @@ -205,7 +205,7 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie) // new paths are always added at the end if (cookie) { - *cookie = (void*)mAssetPaths.size(); + *cookie = static_cast<int32_t>(mAssetPaths.size()); } // add overlay packages for /system/framework; apps are handled by the @@ -335,7 +335,7 @@ bool AssetManager::createIdmapFileLocked(const String8& originalPath, const Stri ALOGW("failed to find resources.arsc in %s\n", ap.path.string()); goto error; } - tables[i].add(ass, (void*)1, false); + tables[i].add(ass, 1, false /* copyData */, NULL /* idMap */); } if (!getZipEntryCrcLocked(originalPath, "resources.arsc", &originalCrc)) { @@ -395,17 +395,17 @@ bool AssetManager::addDefaultAssets() return addAssetPath(path, NULL); } -void* AssetManager::nextAssetPath(void* cookie) const +int32_t AssetManager::nextAssetPath(const int32_t cookie) const { AutoMutex _l(mLock); - size_t next = ((size_t)cookie)+1; - return next > mAssetPaths.size() ? NULL : (void*)next; + const size_t next = static_cast<size_t>(cookie) + 1; + return next > mAssetPaths.size() ? -1 : next; } -String8 AssetManager::getAssetPath(void* cookie) const +String8 AssetManager::getAssetPath(const int32_t cookie) const { AutoMutex _l(mLock); - const size_t which = ((size_t)cookie)-1; + const size_t which = static_cast<size_t>(cookie) - 1; if (which < mAssetPaths.size()) { return mAssetPaths[which].path; } @@ -575,15 +575,14 @@ Asset* AssetManager::openNonAsset(const char* fileName, AccessMode mode) return NULL; } -Asset* AssetManager::openNonAsset(void* cookie, const char* fileName, AccessMode mode) +Asset* AssetManager::openNonAsset(const int32_t cookie, const char* fileName, AccessMode mode) { - const size_t which = ((size_t)cookie)-1; + const size_t which = static_cast<size_t>(cookie) - 1; AutoMutex _l(mLock); LOG_FATAL_IF(mAssetPaths.size() == 0, "No assets added to AssetManager"); - if (mCacheMode != CACHE_OFF && !mCacheValid) loadFileNameCacheLocked(); @@ -683,7 +682,7 @@ const ResTable* AssetManager::getResTable(bool required) const // can quickly copy it out for others. ALOGV("Creating shared resources for %s", ap.path.string()); sharedRes = new ResTable(); - sharedRes->add(ass, (void*)(i+1), false, idmap); + sharedRes->add(ass, i + 1, false, idmap); sharedRes = const_cast<AssetManager*>(this)-> mZipSet.setZipResourceTable(ap.path, sharedRes); } @@ -707,7 +706,7 @@ const ResTable* AssetManager::getResTable(bool required) const rt->add(sharedRes); } else { ALOGV("Parsing resources for %s", ap.path.string()); - rt->add(ass, (void*)(i+1), !shared, idmap); + rt->add(ass, i + 1, !shared, idmap); } if (!shared) { @@ -1206,7 +1205,7 @@ AssetDir* AssetManager::openDir(const char* dirName) * * Pass in "" for the root dir. */ -AssetDir* AssetManager::openNonAssetDir(void* cookie, const char* dirName) +AssetDir* AssetManager::openNonAssetDir(const int32_t cookie, const char* dirName) { AutoMutex _l(mLock); @@ -1225,7 +1224,7 @@ AssetDir* AssetManager::openNonAssetDir(void* cookie, const char* dirName) pMergedInfo = new SortedVector<AssetDir::FileInfo>; - const size_t which = ((size_t)cookie)-1; + const size_t which = static_cast<size_t>(cookie) - 1; if (which < mAssetPaths.size()) { const asset_path& ap = mAssetPaths.itemAt(which); diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 1cc3563..72d331c 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -66,9 +66,9 @@ namespace android { // size measured in sizeof(uint32_t) #define IDMAP_HEADER_SIZE (ResTable::IDMAP_HEADER_SIZE_BYTES / sizeof(uint32_t)) -static void printToLogFunc(void* cookie, const char* txt) +static void printToLogFunc(int32_t cookie, const char* txt) { - ALOGV("%s", txt); + ALOGV("[cookie=%d] %s", cookie, txt); } // Standard C isspace() is only required to look at the low byte of its input, so @@ -2461,7 +2461,7 @@ struct ResTable::Header size_t size; const uint8_t* dataEnd; size_t index; - void* cookie; + int32_t cookie; ResStringPool values; uint32_t* resourceIDMap; @@ -2860,12 +2860,12 @@ ResTable::ResTable() //ALOGI("Creating ResTable %p\n", this); } -ResTable::ResTable(const void* data, size_t size, void* cookie, bool copyData) +ResTable::ResTable(const void* data, size_t size, const int32_t cookie, bool copyData) : mError(NO_INIT) { memset(&mParams, 0, sizeof(mParams)); memset(mPackageMap, 0, sizeof(mPackageMap)); - add(data, size, cookie, copyData); + addInternal(data, size, cookie, NULL /* asset */, copyData, NULL /* idMap */); LOG_FATAL_IF(mError != NO_ERROR, "Error parsing resource table"); //ALOGI("Creating ResTable %p\n", this); } @@ -2881,13 +2881,12 @@ inline ssize_t ResTable::getResourcePackageIndex(uint32_t resID) const return ((ssize_t)mPackageMap[Res_GETPACKAGE(resID)+1])-1; } -status_t ResTable::add(const void* data, size_t size, void* cookie, bool copyData, - const void* idmap) -{ - return add(data, size, cookie, NULL, copyData, reinterpret_cast<const Asset*>(idmap)); +status_t ResTable::add(const void* data, size_t size) { + return addInternal(data, size, 0 /* cookie */, NULL /* asset */, + false /* copyData */, NULL /* idMap */); } -status_t ResTable::add(Asset* asset, void* cookie, bool copyData, const void* idmap) +status_t ResTable::add(Asset* asset, const int32_t cookie, bool copyData, const void* idmap) { const void* data = asset->getBuffer(true); if (data == NULL) { @@ -2895,7 +2894,8 @@ status_t ResTable::add(Asset* asset, void* cookie, bool copyData, const void* id return UNKNOWN_ERROR; } size_t size = (size_t)asset->getLength(); - return add(data, size, cookie, asset, copyData, reinterpret_cast<const Asset*>(idmap)); + return addInternal(data, size, cookie, asset, copyData, + reinterpret_cast<const Asset*>(idmap)); } status_t ResTable::add(ResTable* src) @@ -2922,7 +2922,7 @@ status_t ResTable::add(ResTable* src) return mError; } -status_t ResTable::add(const void* data, size_t size, void* cookie, +status_t ResTable::addInternal(const void* data, size_t size, const int32_t cookie, Asset* asset, bool copyData, const Asset* idmap) { if (!data) return NO_ERROR; @@ -2945,7 +2945,7 @@ status_t ResTable::add(const void* data, size_t size, void* cookie, const bool notDeviceEndian = htods(0xf0) != 0xf0; LOAD_TABLE_NOISY( - ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%p, asset=%p, copy=%d " + ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%d, asset=%p, copy=%d " "idmap=%p\n", data, size, cookie, asset, copyData, idmap)); if (copyData || notDeviceEndian) { @@ -4930,7 +4930,7 @@ const ResStringPool* ResTable::getTableStringBlock(size_t index) const return &mHeaders[index]->values; } -void* ResTable::getTableCookie(size_t index) const +int32_t ResTable::getTableCookie(size_t index) const { return mHeaders[index]->cookie; } |