Merge "Fix for 512 limit in assetManager.list" into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
b8fd047311
@@ -66,16 +66,6 @@ jclass g_stringClass = NULL;
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void doThrow(JNIEnv* env, const char* exc, const char* msg = NULL)
|
|
||||||
{
|
|
||||||
jclass npeClazz;
|
|
||||||
|
|
||||||
npeClazz = env->FindClass(exc);
|
|
||||||
LOG_FATAL_IF(npeClazz == NULL, "Unable to find class %s", exc);
|
|
||||||
|
|
||||||
env->ThrowNew(npeClazz, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
STYLE_NUM_ENTRIES = 6,
|
STYLE_NUM_ENTRIES = 6,
|
||||||
STYLE_TYPE = 0,
|
STYLE_TYPE = 0,
|
||||||
@@ -131,14 +121,14 @@ static jint android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz,
|
|||||||
|
|
||||||
LOGV("openAsset in %p (Java object %p)\n", am, clazz);
|
LOGV("openAsset in %p (Java object %p)\n", am, clazz);
|
||||||
|
|
||||||
if (fileName == NULL || am == NULL) {
|
if (fileName == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "fileName");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode != Asset::ACCESS_UNKNOWN && mode != Asset::ACCESS_RANDOM
|
if (mode != Asset::ACCESS_UNKNOWN && mode != Asset::ACCESS_RANDOM
|
||||||
&& mode != Asset::ACCESS_STREAMING && mode != Asset::ACCESS_BUFFER) {
|
&& mode != Asset::ACCESS_STREAMING && mode != Asset::ACCESS_BUFFER) {
|
||||||
doThrow(env, "java/lang/IllegalArgumentException");
|
jniThrowException(env, "java/lang/IllegalArgumentException", "Bad access mode");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +136,7 @@ static jint android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz,
|
|||||||
Asset* a = am->open(fileName8, (Asset::AccessMode)mode);
|
Asset* a = am->open(fileName8, (Asset::AccessMode)mode);
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
doThrow(env, "java/io/FileNotFoundException", fileName8);
|
jniThrowException(env, "java/io/FileNotFoundException", fileName8);
|
||||||
env->ReleaseStringUTFChars(fileName, fileName8);
|
env->ReleaseStringUTFChars(fileName, fileName8);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -164,7 +154,7 @@ static jobject returnParcelFileDescriptor(JNIEnv* env, Asset* a, jlongArray outO
|
|||||||
delete a;
|
delete a;
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
doThrow(env, "java/io/FileNotFoundException",
|
jniThrowException(env, "java/io/FileNotFoundException",
|
||||||
"This file can not be opened as a file descriptor; it is probably compressed");
|
"This file can not be opened as a file descriptor; it is probably compressed");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -199,8 +189,8 @@ static jobject android_content_AssetManager_openAssetFd(JNIEnv* env, jobject cla
|
|||||||
|
|
||||||
LOGV("openAssetFd in %p (Java object %p)\n", am, clazz);
|
LOGV("openAssetFd in %p (Java object %p)\n", am, clazz);
|
||||||
|
|
||||||
if (fileName == NULL || am == NULL) {
|
if (fileName == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "fileName");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +198,7 @@ static jobject android_content_AssetManager_openAssetFd(JNIEnv* env, jobject cla
|
|||||||
Asset* a = am->open(fileName8, Asset::ACCESS_RANDOM);
|
Asset* a = am->open(fileName8, Asset::ACCESS_RANDOM);
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
doThrow(env, "java/io/FileNotFoundException", fileName8);
|
jniThrowException(env, "java/io/FileNotFoundException", fileName8);
|
||||||
env->ReleaseStringUTFChars(fileName, fileName8);
|
env->ReleaseStringUTFChars(fileName, fileName8);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -231,14 +221,14 @@ static jint android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject
|
|||||||
|
|
||||||
LOGV("openNonAssetNative in %p (Java object %p)\n", am, clazz);
|
LOGV("openNonAssetNative in %p (Java object %p)\n", am, clazz);
|
||||||
|
|
||||||
if (fileName == NULL || am == NULL) {
|
if (fileName == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "fileName");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode != Asset::ACCESS_UNKNOWN && mode != Asset::ACCESS_RANDOM
|
if (mode != Asset::ACCESS_UNKNOWN && mode != Asset::ACCESS_RANDOM
|
||||||
&& mode != Asset::ACCESS_STREAMING && mode != Asset::ACCESS_BUFFER) {
|
&& mode != Asset::ACCESS_STREAMING && mode != Asset::ACCESS_BUFFER) {
|
||||||
doThrow(env, "java/lang/IllegalArgumentException");
|
jniThrowException(env, "java/lang/IllegalArgumentException", "Bad access mode");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +238,7 @@ static jint android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject
|
|||||||
: am->openNonAsset(fileName8, (Asset::AccessMode)mode);
|
: am->openNonAsset(fileName8, (Asset::AccessMode)mode);
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
doThrow(env, "java/io/FileNotFoundException", fileName8);
|
jniThrowException(env, "java/io/FileNotFoundException", fileName8);
|
||||||
env->ReleaseStringUTFChars(fileName, fileName8);
|
env->ReleaseStringUTFChars(fileName, fileName8);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -271,8 +261,8 @@ static jobject android_content_AssetManager_openNonAssetFdNative(JNIEnv* env, jo
|
|||||||
|
|
||||||
LOGV("openNonAssetFd in %p (Java object %p)\n", am, clazz);
|
LOGV("openNonAssetFd in %p (Java object %p)\n", am, clazz);
|
||||||
|
|
||||||
if (fileName == NULL || am == NULL) {
|
if (fileName == NULL ) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "fileName");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +272,7 @@ static jobject android_content_AssetManager_openNonAssetFdNative(JNIEnv* env, jo
|
|||||||
: am->openNonAsset(fileName8, Asset::ACCESS_RANDOM);
|
: am->openNonAsset(fileName8, Asset::ACCESS_RANDOM);
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
doThrow(env, "java/io/FileNotFoundException", fileName8);
|
jniThrowException(env, "java/io/FileNotFoundException", fileName8);
|
||||||
env->ReleaseStringUTFChars(fileName, fileName8);
|
env->ReleaseStringUTFChars(fileName, fileName8);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -301,8 +291,8 @@ static jobjectArray android_content_AssetManager_list(JNIEnv* env, jobject clazz
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileName == NULL || am == NULL) {
|
if (fileName == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "fileName");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +303,7 @@ static jobjectArray android_content_AssetManager_list(JNIEnv* env, jobject clazz
|
|||||||
env->ReleaseStringUTFChars(fileName, fileName8);
|
env->ReleaseStringUTFChars(fileName, fileName8);
|
||||||
|
|
||||||
if (dir == NULL) {
|
if (dir == NULL) {
|
||||||
doThrow(env, "java/io/FileNotFoundException", fileName8);
|
jniThrowException(env, "java/io/FileNotFoundException", fileName8);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +319,6 @@ static jobjectArray android_content_AssetManager_list(JNIEnv* env, jobject clazz
|
|||||||
jobjectArray array = env->NewObjectArray(dir->getFileCount(),
|
jobjectArray array = env->NewObjectArray(dir->getFileCount(),
|
||||||
cls, NULL);
|
cls, NULL);
|
||||||
if (array == NULL) {
|
if (array == NULL) {
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
|
||||||
delete dir;
|
delete dir;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -338,11 +327,11 @@ static jobjectArray android_content_AssetManager_list(JNIEnv* env, jobject clazz
|
|||||||
const String8& name = dir->getFileName(i);
|
const String8& name = dir->getFileName(i);
|
||||||
jstring str = env->NewStringUTF(name.string());
|
jstring str = env->NewStringUTF(name.string());
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
|
||||||
delete dir;
|
delete dir;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
env->SetObjectArrayElement(array, i, str);
|
env->SetObjectArrayElement(array, i, str);
|
||||||
|
env->DeleteLocalRef(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete dir;
|
delete dir;
|
||||||
@@ -358,7 +347,7 @@ static void android_content_AssetManager_destroyAsset(JNIEnv* env, jobject clazz
|
|||||||
//printf("Destroying Asset Stream: %p\n", a);
|
//printf("Destroying Asset Stream: %p\n", a);
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "asset");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +360,7 @@ static jint android_content_AssetManager_readAssetChar(JNIEnv* env, jobject claz
|
|||||||
Asset* a = (Asset*)asset;
|
Asset* a = (Asset*)asset;
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "asset");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +376,7 @@ static jint android_content_AssetManager_readAsset(JNIEnv* env, jobject clazz,
|
|||||||
Asset* a = (Asset*)asset;
|
Asset* a = (Asset*)asset;
|
||||||
|
|
||||||
if (a == NULL || bArray == NULL) {
|
if (a == NULL || bArray == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "asset");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,7 +386,7 @@ static jint android_content_AssetManager_readAsset(JNIEnv* env, jobject clazz,
|
|||||||
|
|
||||||
jsize bLen = env->GetArrayLength(bArray);
|
jsize bLen = env->GetArrayLength(bArray);
|
||||||
if (off < 0 || off >= bLen || len < 0 || len > bLen || (off+len) > bLen) {
|
if (off < 0 || off >= bLen || len < 0 || len > bLen || (off+len) > bLen) {
|
||||||
doThrow(env, "java/lang/IndexOutOfBoundsException");
|
jniThrowException(env, "java/lang/IndexOutOfBoundsException", "");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +397,7 @@ static jint android_content_AssetManager_readAsset(JNIEnv* env, jobject clazz,
|
|||||||
if (res > 0) return res;
|
if (res > 0) return res;
|
||||||
|
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
doThrow(env, "java/io/IOException");
|
jniThrowException(env, "java/io/IOException", "");
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -420,7 +409,7 @@ static jlong android_content_AssetManager_seekAsset(JNIEnv* env, jobject clazz,
|
|||||||
Asset* a = (Asset*)asset;
|
Asset* a = (Asset*)asset;
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "asset");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,7 +423,7 @@ static jlong android_content_AssetManager_getAssetLength(JNIEnv* env, jobject cl
|
|||||||
Asset* a = (Asset*)asset;
|
Asset* a = (Asset*)asset;
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "asset");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,7 +436,7 @@ static jlong android_content_AssetManager_getAssetRemainingLength(JNIEnv* env, j
|
|||||||
Asset* a = (Asset*)asset;
|
Asset* a = (Asset*)asset;
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "asset");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +447,7 @@ static jint android_content_AssetManager_addAssetPath(JNIEnv* env, jobject clazz
|
|||||||
jstring path)
|
jstring path)
|
||||||
{
|
{
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "path");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,7 +479,7 @@ static void android_content_AssetManager_setLocale(JNIEnv* env, jobject clazz,
|
|||||||
jstring locale)
|
jstring locale)
|
||||||
{
|
{
|
||||||
if (locale == NULL) {
|
if (locale == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "locale");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,7 +514,12 @@ static jobjectArray android_content_AssetManager_getLocales(JNIEnv* env, jobject
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
env->SetObjectArrayElement(result, i, env->NewStringUTF(locales[i].string()));
|
jstring str = env->NewStringUTF(locales[i].string())
|
||||||
|
if (str == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
env->SetObjectArrayElement(result, i, str);
|
||||||
|
env->DeleteLocalRef(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -576,7 +570,7 @@ static jint android_content_AssetManager_getResourceIdentifier(JNIEnv* env, jobj
|
|||||||
jstring defPackage)
|
jstring defPackage)
|
||||||
{
|
{
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "name");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -814,14 +808,10 @@ static jstring android_content_AssetManager_getCookieName(JNIEnv* env, jobject c
|
|||||||
}
|
}
|
||||||
String8 name(am->getAssetPath((void*)cookie));
|
String8 name(am->getAssetPath((void*)cookie));
|
||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
doThrow(env, "java/lang/IndexOutOfBoundsException");
|
jniThrowException(env, "java/lang/IndexOutOfBoundsException", "Empty cookie name");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
jstring str = env->NewStringUTF(name.string());
|
jstring str = env->NewStringUTF(name.string());
|
||||||
if (str == NULL) {
|
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -889,7 +879,7 @@ static void android_content_AssetManager_dumpTheme(JNIEnv* env, jobject clazz,
|
|||||||
const ResTable& res(theme->getResTable());
|
const ResTable& res(theme->getResTable());
|
||||||
|
|
||||||
if (tag == NULL) {
|
if (tag == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "tag");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -917,8 +907,16 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla
|
|||||||
jintArray outValues,
|
jintArray outValues,
|
||||||
jintArray outIndices)
|
jintArray outIndices)
|
||||||
{
|
{
|
||||||
if (themeToken == 0 || attrs == NULL || outValues == NULL) {
|
if (themeToken == 0) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "theme token");
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
if (attrs == NULL) {
|
||||||
|
jniThrowException(env, "java/lang/NullPointerException", "attrs");
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
if (outValues == NULL) {
|
||||||
|
jniThrowException(env, "java/lang/NullPointerException", "out values");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -934,13 +932,13 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla
|
|||||||
const jsize NI = env->GetArrayLength(attrs);
|
const jsize NI = env->GetArrayLength(attrs);
|
||||||
const jsize NV = env->GetArrayLength(outValues);
|
const jsize NV = env->GetArrayLength(outValues);
|
||||||
if (NV < (NI*STYLE_NUM_ENTRIES)) {
|
if (NV < (NI*STYLE_NUM_ENTRIES)) {
|
||||||
doThrow(env, "java/lang/IndexOutOfBoundsException");
|
jniThrowException(env, "java/lang/IndexOutOfBoundsException", "out values too small");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
jint* src = (jint*)env->GetPrimitiveArrayCritical(attrs, 0);
|
jint* src = (jint*)env->GetPrimitiveArrayCritical(attrs, 0);
|
||||||
if (src == NULL) {
|
if (src == NULL) {
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
jniThrowException(env, "java/lang/OutOfMemoryError", "");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -948,7 +946,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla
|
|||||||
jint* dest = baseDest;
|
jint* dest = baseDest;
|
||||||
if (dest == NULL) {
|
if (dest == NULL) {
|
||||||
env->ReleasePrimitiveArrayCritical(attrs, src, 0);
|
env->ReleasePrimitiveArrayCritical(attrs, src, 0);
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
jniThrowException(env, "java/lang/OutOfMemoryError", "");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1152,8 +1150,16 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job
|
|||||||
jintArray outValues,
|
jintArray outValues,
|
||||||
jintArray outIndices)
|
jintArray outIndices)
|
||||||
{
|
{
|
||||||
if (xmlParserToken == 0 || attrs == NULL || outValues == NULL) {
|
if (xmlParserToken == 0) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "xmlParserToken");
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
if (attrs == NULL) {
|
||||||
|
jniThrowException(env, "java/lang/NullPointerException", "attrs");
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
if (outValues == NULL) {
|
||||||
|
jniThrowException(env, "java/lang/NullPointerException", "out values");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1169,13 +1175,13 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job
|
|||||||
const jsize NI = env->GetArrayLength(attrs);
|
const jsize NI = env->GetArrayLength(attrs);
|
||||||
const jsize NV = env->GetArrayLength(outValues);
|
const jsize NV = env->GetArrayLength(outValues);
|
||||||
if (NV < (NI*STYLE_NUM_ENTRIES)) {
|
if (NV < (NI*STYLE_NUM_ENTRIES)) {
|
||||||
doThrow(env, "java/lang/IndexOutOfBoundsException");
|
jniThrowException(env, "java/lang/IndexOutOfBoundsException", "out values too small");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
jint* src = (jint*)env->GetPrimitiveArrayCritical(attrs, 0);
|
jint* src = (jint*)env->GetPrimitiveArrayCritical(attrs, 0);
|
||||||
if (src == NULL) {
|
if (src == NULL) {
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
jniThrowException(env, "java/lang/OutOfMemoryError", "");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1183,7 +1189,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job
|
|||||||
jint* dest = baseDest;
|
jint* dest = baseDest;
|
||||||
if (dest == NULL) {
|
if (dest == NULL) {
|
||||||
env->ReleasePrimitiveArrayCritical(attrs, src, 0);
|
env->ReleasePrimitiveArrayCritical(attrs, src, 0);
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
jniThrowException(env, "java/lang/OutOfMemoryError", "");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1306,7 +1312,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz
|
|||||||
jintArray outValues)
|
jintArray outValues)
|
||||||
{
|
{
|
||||||
if (outValues == NULL) {
|
if (outValues == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "out values");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1324,7 +1330,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz
|
|||||||
jint* baseDest = (jint*)env->GetPrimitiveArrayCritical(outValues, 0);
|
jint* baseDest = (jint*)env->GetPrimitiveArrayCritical(outValues, 0);
|
||||||
jint* dest = baseDest;
|
jint* dest = baseDest;
|
||||||
if (dest == NULL) {
|
if (dest == NULL) {
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
jniThrowException(env, "java/lang/OutOfMemoryError", "");
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1399,8 +1405,8 @@ static jint android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject
|
|||||||
|
|
||||||
LOGV("openXmlAsset in %p (Java object %p)\n", am, clazz);
|
LOGV("openXmlAsset in %p (Java object %p)\n", am, clazz);
|
||||||
|
|
||||||
if (fileName == NULL || am == NULL) {
|
if (fileName == NULL) {
|
||||||
doThrow(env, "java/lang/NullPointerException");
|
jniThrowException(env, "java/lang/NullPointerException", "fileName");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1410,7 +1416,7 @@ static jint android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject
|
|||||||
: am->openNonAsset(fileName8, Asset::ACCESS_BUFFER);
|
: am->openNonAsset(fileName8, Asset::ACCESS_BUFFER);
|
||||||
|
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
doThrow(env, "java/io/FileNotFoundException", fileName8);
|
jniThrowException(env, "java/io/FileNotFoundException", fileName8);
|
||||||
env->ReleaseStringUTFChars(fileName, fileName8);
|
env->ReleaseStringUTFChars(fileName, fileName8);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1422,7 +1428,7 @@ static jint android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject
|
|||||||
delete a;
|
delete a;
|
||||||
|
|
||||||
if (err != NO_ERROR) {
|
if (err != NO_ERROR) {
|
||||||
doThrow(env, "java/io/FileNotFoundException", "Corrupt XML binary file");
|
jniThrowException(env, "java/io/FileNotFoundException", "Corrupt XML binary file");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1446,7 +1452,7 @@ static jintArray android_content_AssetManager_getArrayStringInfo(JNIEnv* env, jo
|
|||||||
|
|
||||||
jintArray array = env->NewIntArray(N * 2);
|
jintArray array = env->NewIntArray(N * 2);
|
||||||
if (array == NULL) {
|
if (array == NULL) {
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
jniThrowException(env, "java/lang/OutOfMemoryError", "");
|
||||||
res.unlockBag(startOfBag);
|
res.unlockBag(startOfBag);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1540,13 +1546,12 @@ static jobjectArray android_content_AssetManager_getArrayStringResource(JNIEnv*
|
|||||||
res.unlockBag(startOfBag);
|
res.unlockBag(startOfBag);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
env->SetObjectArrayElement(array, i, str);
|
env->SetObjectArrayElement(array, i, str);
|
||||||
|
|
||||||
// If we have a large amount of strings in our array, we might
|
// str is not NULL at that point, otherwise ExceptionCheck would have been true.
|
||||||
// overflow the local reference table of the VM.
|
// If we have a large amount of strings in our array, we might
|
||||||
if (str != NULL) {
|
// overflow the local reference table of the VM.
|
||||||
env->DeleteLocalRef(str);
|
env->DeleteLocalRef(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1571,7 +1576,7 @@ static jintArray android_content_AssetManager_getArrayIntResource(JNIEnv* env, j
|
|||||||
|
|
||||||
jintArray array = env->NewIntArray(N);
|
jintArray array = env->NewIntArray(N);
|
||||||
if (array == NULL) {
|
if (array == NULL) {
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
jniThrowException(env, "java/lang/OutOfMemoryError", "");
|
||||||
res.unlockBag(startOfBag);
|
res.unlockBag(startOfBag);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1603,7 +1608,7 @@ static void android_content_AssetManager_init(JNIEnv* env, jobject clazz)
|
|||||||
{
|
{
|
||||||
AssetManager* am = new AssetManager();
|
AssetManager* am = new AssetManager();
|
||||||
if (am == NULL) {
|
if (am == NULL) {
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
jniThrowException(env, "java/lang/OutOfMemoryError", "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1637,11 +1642,6 @@ static jobject android_content_AssetManager_getAssetAllocations(JNIEnv* env, job
|
|||||||
}
|
}
|
||||||
|
|
||||||
jstring str = env->NewStringUTF(alloc.string());
|
jstring str = env->NewStringUTF(alloc.string());
|
||||||
if (str == NULL) {
|
|
||||||
doThrow(env, "java/lang/OutOfMemoryError");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user