am ebd43d46: am dff83e2b: am d5970e9c: Merge "AssetManager cookies should be int32_t and not void*."
* commit 'ebd43d46ebf53005ae60af59948f8ed634f9bafb': AssetManager cookies should be int32_t and not void*.
This commit is contained in:
@@ -229,7 +229,8 @@ static jint android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject
|
|||||||
}
|
}
|
||||||
|
|
||||||
Asset* a = cookie
|
Asset* a = cookie
|
||||||
? am->openNonAsset((void*)cookie, fileName8.c_str(), (Asset::AccessMode)mode)
|
? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(),
|
||||||
|
(Asset::AccessMode)mode)
|
||||||
: am->openNonAsset(fileName8.c_str(), (Asset::AccessMode)mode);
|
: am->openNonAsset(fileName8.c_str(), (Asset::AccessMode)mode);
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
@@ -260,7 +261,7 @@ static jobject android_content_AssetManager_openNonAssetFdNative(JNIEnv* env, jo
|
|||||||
}
|
}
|
||||||
|
|
||||||
Asset* a = cookie
|
Asset* a = cookie
|
||||||
? am->openNonAsset((void*)cookie, fileName8.c_str(), Asset::ACCESS_RANDOM)
|
? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(), Asset::ACCESS_RANDOM)
|
||||||
: am->openNonAsset(fileName8.c_str(), Asset::ACCESS_RANDOM);
|
: am->openNonAsset(fileName8.c_str(), Asset::ACCESS_RANDOM);
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
@@ -435,10 +436,10 @@ static jint android_content_AssetManager_addAssetPath(JNIEnv* env, jobject clazz
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* cookie;
|
int32_t cookie;
|
||||||
bool res = am->addAssetPath(String8(path8.c_str()), &cookie);
|
bool res = am->addAssetPath(String8(path8.c_str()), &cookie);
|
||||||
|
|
||||||
return (res) ? (jint)cookie : 0;
|
return (res) ? static_cast<jint>(cookie) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean android_content_AssetManager_isUpToDate(JNIEnv* env, jobject clazz)
|
static jboolean android_content_AssetManager_isUpToDate(JNIEnv* env, jobject clazz)
|
||||||
@@ -800,7 +801,7 @@ static jstring android_content_AssetManager_getCookieName(JNIEnv* env, jobject c
|
|||||||
if (am == NULL) {
|
if (am == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
String8 name(am->getAssetPath((void*)cookie));
|
String8 name(am->getAssetPath(static_cast<int32_t>(cookie)));
|
||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
jniThrowException(env, "java/lang/IndexOutOfBoundsException", "Empty cookie name");
|
jniThrowException(env, "java/lang/IndexOutOfBoundsException", "Empty cookie name");
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1386,7 +1387,7 @@ static jint android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject
|
|||||||
}
|
}
|
||||||
|
|
||||||
Asset* a = cookie
|
Asset* a = cookie
|
||||||
? am->openNonAsset((void*)cookie, fileName8.c_str(), Asset::ACCESS_BUFFER)
|
? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(), Asset::ACCESS_BUFFER)
|
||||||
: am->openNonAsset(fileName8.c_str(), Asset::ACCESS_BUFFER);
|
: am->openNonAsset(fileName8.c_str(), Asset::ACCESS_BUFFER);
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
* then on success, *cookie is set to the value corresponding to the
|
* then on success, *cookie is set to the value corresponding to the
|
||||||
* newly-added asset source.
|
* newly-added asset source.
|
||||||
*/
|
*/
|
||||||
bool addAssetPath(const String8& path, void** cookie);
|
bool addAssetPath(const String8& path, int32_t* cookie);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convenience for adding the standard system assets. Uses the
|
* Convenience for adding the standard system assets. Uses the
|
||||||
@@ -103,17 +103,17 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Iterate over the asset paths in this manager. (Previously
|
* Iterate over the asset paths in this manager. (Previously
|
||||||
* added via addAssetPath() and addDefaultAssets().) On first call,
|
* added via addAssetPath() and addDefaultAssets().) On first call,
|
||||||
* 'cookie' must be NULL, resulting in the first cookie being returned.
|
* 'cookie' must be 0, resulting in the first cookie being returned.
|
||||||
* Each next cookie will be returned there-after, until NULL indicating
|
* Each next cookie will be returned there-after, until -1 indicating
|
||||||
* the end has been reached.
|
* the end has been reached.
|
||||||
*/
|
*/
|
||||||
void* nextAssetPath(void* cookie) const;
|
int32_t nextAssetPath(const int32_t cookie) const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return an asset path in the manager. 'which' must be between 0 and
|
* Return an asset path in the manager. 'which' must be between 0 and
|
||||||
* countAssetPaths().
|
* countAssetPaths().
|
||||||
*/
|
*/
|
||||||
String8 getAssetPath(void* cookie) const;
|
String8 getAssetPath(const int32_t cookie) const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the current locale and vendor. The locale can change during
|
* Set the current locale and vendor. The locale can change during
|
||||||
@@ -159,7 +159,7 @@ public:
|
|||||||
* Explicit non-asset file. The file explicitly named by the cookie (the
|
* Explicit non-asset file. The file explicitly named by the cookie (the
|
||||||
* resource set to look in) and fileName will be opened and returned.
|
* resource set to look in) and fileName will be opened and returned.
|
||||||
*/
|
*/
|
||||||
Asset* openNonAsset(void* cookie, const char* fileName, AccessMode mode);
|
Asset* openNonAsset(const int32_t cookie, const char* fileName, AccessMode mode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open a directory within the asset hierarchy.
|
* Open a directory within the asset hierarchy.
|
||||||
@@ -183,7 +183,7 @@ public:
|
|||||||
*
|
*
|
||||||
* To open the top-level directory, pass in "".
|
* To open the top-level directory, pass in "".
|
||||||
*/
|
*/
|
||||||
AssetDir* openNonAssetDir(void* cookie, const char* dirName);
|
AssetDir* openNonAssetDir(const int32_t cookie, const char* dirName);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the type of a file in the asset hierarchy. They will either
|
* Get the type of a file in the asset hierarchy. They will either
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ AssetManager::~AssetManager(void)
|
|||||||
delete[] mVendor;
|
delete[] mVendor;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssetManager::addAssetPath(const String8& path, void** cookie)
|
bool AssetManager::addAssetPath(const String8& path, int32_t* cookie)
|
||||||
{
|
{
|
||||||
AutoMutex _l(mLock);
|
AutoMutex _l(mLock);
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie)
|
|||||||
for (size_t i=0; i<mAssetPaths.size(); i++) {
|
for (size_t i=0; i<mAssetPaths.size(); i++) {
|
||||||
if (mAssetPaths[i].path == ap.path) {
|
if (mAssetPaths[i].path == ap.path) {
|
||||||
if (cookie) {
|
if (cookie) {
|
||||||
*cookie = (void*)(i+1);
|
*cookie = static_cast<int32_t>(i+1);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie)
|
|||||||
|
|
||||||
// new paths are always added at the end
|
// new paths are always added at the end
|
||||||
if (cookie) {
|
if (cookie) {
|
||||||
*cookie = (void*)mAssetPaths.size();
|
*cookie = static_cast<int32_t>(mAssetPaths.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// add overlay packages for /system/framework; apps are handled by the
|
// add overlay packages for /system/framework; apps are handled by the
|
||||||
@@ -395,17 +395,17 @@ bool AssetManager::addDefaultAssets()
|
|||||||
return addAssetPath(path, NULL);
|
return addAssetPath(path, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* AssetManager::nextAssetPath(void* cookie) const
|
int32_t AssetManager::nextAssetPath(const int32_t cookie) const
|
||||||
{
|
{
|
||||||
AutoMutex _l(mLock);
|
AutoMutex _l(mLock);
|
||||||
size_t next = ((size_t)cookie)+1;
|
const size_t next = static_cast<size_t>(cookie) + 1;
|
||||||
return next > mAssetPaths.size() ? NULL : (void*)next;
|
return next > mAssetPaths.size() ? -1 : next;
|
||||||
}
|
}
|
||||||
|
|
||||||
String8 AssetManager::getAssetPath(void* cookie) const
|
String8 AssetManager::getAssetPath(const int32_t cookie) const
|
||||||
{
|
{
|
||||||
AutoMutex _l(mLock);
|
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()) {
|
if (which < mAssetPaths.size()) {
|
||||||
return mAssetPaths[which].path;
|
return mAssetPaths[which].path;
|
||||||
}
|
}
|
||||||
@@ -575,15 +575,14 @@ Asset* AssetManager::openNonAsset(const char* fileName, AccessMode mode)
|
|||||||
return NULL;
|
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);
|
AutoMutex _l(mLock);
|
||||||
|
|
||||||
LOG_FATAL_IF(mAssetPaths.size() == 0, "No assets added to AssetManager");
|
LOG_FATAL_IF(mAssetPaths.size() == 0, "No assets added to AssetManager");
|
||||||
|
|
||||||
|
|
||||||
if (mCacheMode != CACHE_OFF && !mCacheValid)
|
if (mCacheMode != CACHE_OFF && !mCacheValid)
|
||||||
loadFileNameCacheLocked();
|
loadFileNameCacheLocked();
|
||||||
|
|
||||||
@@ -1206,7 +1205,7 @@ AssetDir* AssetManager::openDir(const char* dirName)
|
|||||||
*
|
*
|
||||||
* Pass in "" for the root dir.
|
* 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);
|
AutoMutex _l(mLock);
|
||||||
|
|
||||||
@@ -1225,7 +1224,7 @@ AssetDir* AssetManager::openNonAssetDir(void* cookie, const char* dirName)
|
|||||||
|
|
||||||
pMergedInfo = new SortedVector<AssetDir::FileInfo>;
|
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()) {
|
if (which < mAssetPaths.size()) {
|
||||||
const asset_path& ap = mAssetPaths.itemAt(which);
|
const asset_path& ap = mAssetPaths.itemAt(which);
|
||||||
|
|||||||
@@ -505,7 +505,7 @@ int doDump(Bundle* bundle)
|
|||||||
const char* filename = bundle->getFileSpecEntry(1);
|
const char* filename = bundle->getFileSpecEntry(1);
|
||||||
|
|
||||||
AssetManager assets;
|
AssetManager assets;
|
||||||
void* assetsCookie;
|
int32_t assetsCookie;
|
||||||
if (!assets.addAssetPath(String8(filename), &assetsCookie)) {
|
if (!assets.addAssetPath(String8(filename), &assetsCookie)) {
|
||||||
fprintf(stderr, "ERROR: dump failed because assets could not be loaded\n");
|
fprintf(stderr, "ERROR: dump failed because assets could not be loaded\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user