diff options
author | Josh Guilfoyle <jasta00@gmail.com> | 2011-02-04 11:22:05 -0800 |
---|---|---|
committer | Josh Guilfoyle <jasta00@gmail.com> | 2011-02-04 14:50:32 -0800 |
commit | b6c3e53c9982ccab438a2a64bf1b0b4e9b42fdc1 (patch) | |
tree | bf55beaa3db1dbdf919e9de63b4492e00bd9ae98 /core/jni/android_util_AssetManager.cpp | |
parent | be0f217ff7fd402cc6c1e55438a1e1e53f640194 (diff) | |
download | frameworks_base-b6c3e53c9982ccab438a2a64bf1b0b4e9b42fdc1.zip frameworks_base-b6c3e53c9982ccab438a2a64bf1b0b4e9b42fdc1.tar.gz frameworks_base-b6c3e53c9982ccab438a2a64bf1b0b4e9b42fdc1.tar.bz2 |
Corrected whitespace trespasses.
Many small whitespace mistakes slipped into the framework as the themes
feature was developed. This patch reverts them to make a cleaner patch
set against android-2.3.1_r1.
Change-Id: I52223c1d572d4f013e37bebc5c11bb7b1c595eb3
Diffstat (limited to 'core/jni/android_util_AssetManager.cpp')
-rw-r--r-- | core/jni/android_util_AssetManager.cpp | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index b9ceeb7..012efd0 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -3,16 +3,16 @@ ** Copyright 2006, The Android Open Source Project ** This code has been modified. Portions copyright (C) 2010, T-Mobile USA, Inc. ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at ** -** http://www.apache.org/licenses/LICENSE-2.0 +** http://www.apache.org/licenses/LICENSE-2.0 ** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and ** limitations under the License. */ @@ -157,30 +157,30 @@ static jobject returnParcelFileDescriptor(JNIEnv* env, Asset* a, jlongArray outO off_t startOffset, length; int fd = a->openFileDescriptor(&startOffset, &length); delete a; - + if (fd < 0) { jniThrowException(env, "java/io/FileNotFoundException", "This file can not be opened as a file descriptor; it is probably compressed"); return NULL; } - + jlong* offsets = (jlong*)env->GetPrimitiveArrayCritical(outOffsets, 0); if (offsets == NULL) { close(fd); return NULL; } - + offsets[0] = startOffset; offsets[1] = length; - + env->ReleasePrimitiveArrayCritical(outOffsets, offsets, 0); - + jobject fileDesc = newFileDescriptor(env, fd); if (fileDesc == NULL) { close(fd); return NULL; } - + return newParcelFileDescriptor(env, fileDesc); } @@ -388,7 +388,7 @@ static jint android_content_AssetManager_readAsset(JNIEnv* env, jobject clazz, if (len == 0) { return 0; } - + jsize bLen = env->GetArrayLength(bArray); if (off < 0 || off >= bLen || len < 0 || len > bLen || (off+len) > bLen) { jniThrowException(env, "java/lang/IndexOutOfBoundsException", ""); @@ -547,9 +547,9 @@ static void android_content_AssetManager_setConfiguration(JNIEnv* env, jobject c ResTable_config config; memset(&config, 0, sizeof(config)); - + const char* locale8 = locale != NULL ? env->GetStringUTFChars(locale, NULL) : NULL; - + config.mcc = (uint16_t)mcc; config.mnc = (uint16_t)mnc; config.orientation = (uint8_t)orientation; @@ -565,7 +565,7 @@ static void android_content_AssetManager_setConfiguration(JNIEnv* env, jobject c config.sdkVersion = (uint16_t)sdkVersion; config.minorVersion = 0; am->setConfiguration(config, locale8); - + if (locale != NULL) env->ReleaseStringUTFChars(locale, locale8); } @@ -616,12 +616,12 @@ static jstring android_content_AssetManager_getResourceName(JNIEnv* env, jobject if (am == NULL) { return NULL; } - + ResTable::resource_name name; if (!am->getResources().getResourceName(resid, &name)) { return NULL; } - + String16 str; if (name.package != NULL) { str.setTo(name.package, name.packageLen); @@ -640,7 +640,7 @@ static jstring android_content_AssetManager_getResourceName(JNIEnv* env, jobject } str.append(name.name, name.nameLen); } - + return env->NewString((const jchar*)str.string(), str.size()); } @@ -651,16 +651,16 @@ static jstring android_content_AssetManager_getResourcePackageName(JNIEnv* env, if (am == NULL) { return NULL; } - + ResTable::resource_name name; if (!am->getResources().getResourceName(resid, &name)) { return NULL; } - + if (name.package != NULL) { return env->NewString((const jchar*)name.package, name.packageLen); } - + return NULL; } @@ -671,16 +671,16 @@ static jstring android_content_AssetManager_getResourceTypeName(JNIEnv* env, job if (am == NULL) { return NULL; } - + ResTable::resource_name name; if (!am->getResources().getResourceName(resid, &name)) { return NULL; } - + if (name.type != NULL) { return env->NewString((const jchar*)name.type, name.typeLen); } - + return NULL; } @@ -691,16 +691,16 @@ static jstring android_content_AssetManager_getResourceEntryName(JNIEnv* env, jo if (am == NULL) { return NULL; } - + ResTable::resource_name name; if (!am->getResources().getResourceName(resid, &name)) { return NULL; } - + if (name.name != NULL) { return env->NewString((const jchar*)name.name, name.nameLen); } - + return NULL; } @@ -753,10 +753,10 @@ static jint android_content_AssetManager_loadResourceBagValue(JNIEnv* env, jobje return 0; } const ResTable& res(am->getResources()); - + // Now lock down the resource object and start pulling stuff from it. res.lock(); - + ssize_t block = -1; Res_value value; @@ -777,7 +777,7 @@ static jint android_content_AssetManager_loadResourceBagValue(JNIEnv* env, jobje if (block < 0) { return block; } - + uint32_t ref = ident; if (resolve) { block = res.resolveReference(&value, block, &ref, &typeSpecFlags); @@ -888,21 +888,21 @@ static void android_content_AssetManager_dumpTheme(JNIEnv* env, jobject clazz, { ResTable::Theme* theme = (ResTable::Theme*)themeInt; const ResTable& res(theme->getResTable()); - + if (tag == NULL) { jniThrowException(env, "java/lang/NullPointerException", "tag"); return; } - + const char* tag8 = env->GetStringUTFChars(tag, NULL); const char* prefix8 = NULL; if (prefix != NULL) { prefix8 = env->GetStringUTFChars(prefix, NULL); } - + // XXX Need to use params. theme->dumpToLog(); - + if (prefix8 != NULL) { env->ReleaseStringUTFChars(prefix, prefix8); } @@ -1173,12 +1173,12 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; dest[STYLE_DENSITY] = config.density; - + if (indices != NULL && value.dataType != Res_value::TYPE_NULL) { indicesIdx++; indices[indicesIdx] = ii; } - + dest += STYLE_NUM_ENTRIES; } @@ -1212,7 +1212,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job jniThrowException(env, "java/lang/NullPointerException", "out values"); return JNI_FALSE; } - + AssetManager* am = assetManagerForJavaObject(env, clazz); if (am == NULL) { return JNI_FALSE; @@ -1221,20 +1221,20 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job ResXMLParser* xmlParser = (ResXMLParser*)xmlParserToken; ResTable_config config; Res_value value; - + const jsize NI = env->GetArrayLength(attrs); const jsize NV = env->GetArrayLength(outValues); if (NV < (NI*STYLE_NUM_ENTRIES)) { jniThrowException(env, "java/lang/IndexOutOfBoundsException", "out values too small"); return JNI_FALSE; } - + jint* src = (jint*)env->GetPrimitiveArrayCritical(attrs, 0); if (src == NULL) { jniThrowException(env, "java/lang/OutOfMemoryError", ""); return JNI_FALSE; } - + jint* baseDest = (jint*)env->GetPrimitiveArrayCritical(outValues, 0); jint* dest = baseDest; if (dest == NULL) { @@ -1242,7 +1242,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job jniThrowException(env, "java/lang/OutOfMemoryError", ""); return JNI_FALSE; } - + jint* indices = NULL; int indicesIdx = 0; if (outIndices != NULL) { @@ -1253,27 +1253,27 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job // Now lock down the resource object and start pulling stuff from it. res.lock(); - + // Retrieve the XML attributes, if requested. const jsize NX = xmlParser->getAttributeCount(); jsize ix=0; uint32_t curXmlAttr = xmlParser->getAttributeNameResID(ix); - + static const ssize_t kXmlBlock = 0x10000000; - + // Now iterate through all of the attributes that the client has requested, // filling in each with whatever data we can find. ssize_t block = 0; uint32_t typeSetFlags; for (jsize ii=0; ii<NI; ii++) { const uint32_t curIdent = (uint32_t)src[ii]; - + // Try to find a value for this attribute... value.dataType = Res_value::TYPE_NULL; value.data = 0; typeSetFlags = 0; config.density = 0; - + // Skip through XML attributes until the end or the next possible match. while (ix < NX && curIdent > curXmlAttr) { ix++; @@ -1286,7 +1286,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job ix++; curXmlAttr = xmlParser->getAttributeNameResID(ix); } - + //printf("Attribute 0x%08x: type=0x%x, data=0x%08x\n", curIdent, value.dataType, value.data); uint32_t resid = 0; if (value.dataType != Res_value::TYPE_NULL) { @@ -1302,14 +1302,14 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job #endif if (newBlock >= 0) block = newBlock; } - + // Deal with the special @null value -- it turns back to TYPE_NULL. if (value.dataType == Res_value::TYPE_REFERENCE && value.data == 0) { value.dataType = Res_value::TYPE_NULL; } - + //printf("Attribute 0x%08x: final type=0x%x, data=0x%08x\n", curIdent, value.dataType, value.data); - + // Write the final value back to Java. dest[STYLE_TYPE] = value.dataType; dest[STYLE_DATA] = value.data; @@ -1318,25 +1318,25 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; dest[STYLE_DENSITY] = config.density; - + if (indices != NULL && value.dataType != Res_value::TYPE_NULL) { indicesIdx++; indices[indicesIdx] = ii; } - + dest += STYLE_NUM_ENTRIES; } - + res.unlock(); - + if (indices != NULL) { indices[0] = indicesIdx; env->ReleasePrimitiveArrayCritical(outIndices, indices, 0); } - + env->ReleasePrimitiveArrayCritical(outValues, baseDest, 0); env->ReleasePrimitiveArrayCritical(attrs, src, 0); - + return JNI_TRUE; } @@ -1348,12 +1348,12 @@ static jint android_content_AssetManager_getArraySize(JNIEnv* env, jobject clazz return NULL; } const ResTable& res(am->getResources()); - + res.lock(); const ResTable::bag_entry* defStyleEnt = NULL; ssize_t bagOff = res.getBagLocked(id, &defStyleEnt); res.unlock(); - + return bagOff; } @@ -1365,7 +1365,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz jniThrowException(env, "java/lang/NullPointerException", "out values"); return JNI_FALSE; } - + AssetManager* am = assetManagerForJavaObject(env, clazz); if (am == NULL) { return JNI_FALSE; @@ -1374,25 +1374,25 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz ResTable_config config; Res_value value; ssize_t block; - + const jsize NV = env->GetArrayLength(outValues); - + jint* baseDest = (jint*)env->GetPrimitiveArrayCritical(outValues, 0); jint* dest = baseDest; if (dest == NULL) { jniThrowException(env, "java/lang/OutOfMemoryError", ""); return JNI_FALSE; } - + // Now lock down the resource object and start pulling stuff from it. res.lock(); - + const ResTable::bag_entry* arrayEnt = NULL; uint32_t arrayTypeSetFlags = 0; ssize_t bagOff = res.getBagLocked(id, &arrayEnt, &arrayTypeSetFlags); const ResTable::bag_entry* endArrayEnt = arrayEnt + (bagOff >= 0 ? bagOff : 0); - + int i = 0; uint32_t typeSetFlags; while (i < NV && arrayEnt < endArrayEnt) { @@ -1400,7 +1400,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz typeSetFlags = arrayTypeSetFlags; config.density = 0; value = arrayEnt->map.value; - + uint32_t resid = 0; if (value.dataType != Res_value::TYPE_NULL) { // Take care of resolving the found resource to its final value. @@ -1459,13 +1459,13 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz i+= STYLE_NUM_ENTRIES; arrayEnt++; } - + i /= STYLE_NUM_ENTRIES; - + res.unlock(); - + env->ReleasePrimitiveArrayCritical(outValues, baseDest, 0); - + return i; } @@ -1538,7 +1538,7 @@ static jintArray android_content_AssetManager_getArrayStringInfo(JNIEnv* env, jo jint stringIndex = -1; jint stringBlock = 0; value = bag->map.value; - + // Take care of resolving the found resource to its final value. stringBlock = res.resolveReference(&value, bag->stringBlock, NULL); if (value.dataType == Res_value::TYPE_STRING) { @@ -1660,7 +1660,7 @@ static jintArray android_content_AssetManager_getArrayIntResource(JNIEnv* env, j const ResTable::bag_entry* bag = startOfBag; for (size_t i=0; ((ssize_t)i)<N; i++, bag++) { value = bag->map.value; - + // Take care of resolving the found resource to its final value. ssize_t block = res.resolveReference(&value, bag->stringBlock, NULL); #if THROW_ON_BAD_ID @@ -1729,15 +1729,15 @@ static jint android_content_AssetManager_splitThemePackage(JNIEnv* env, jobject const char* drmProtectedAssetFileName8 = env->GetStringUTFChars(javaString, NULL); ZipEntry *assetEntry = srcZip->getEntryByName(drmProtectedAssetFileName8); if (assetEntry == NULL) { - result = 1; + result = 1; LOGV("Invalid asset entry %s\n", drmProtectedAssetFileName8); } else { - status_t loc_result = dstZip->add(srcZip, assetEntry, 0, NULL); + status_t loc_result = dstZip->add(srcZip, assetEntry, 0, NULL); if (loc_result != NO_ERROR) { LOGV("error copying zip entry %s\n", drmProtectedAssetFileName8); result = result | 2; } else { - loc_result = srcZip->remove(assetEntry); + loc_result = srcZip->remove(assetEntry); if (loc_result != NO_ERROR) { LOGV("error removing zip entry %s\n", drmProtectedAssetFileName8); result = result | 4; |