diff options
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/Android.mk | 1 | ||||
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 2 | ||||
-rw-r--r-- | core/jni/android/graphics/Bitmap.cpp | 9 | ||||
-rw-r--r-- | core/jni/android_app_NativeActivity.cpp | 16 | ||||
-rw-r--r-- | core/jni/android_os_ParcelFileDescriptor.cpp | 151 |
5 files changed, 16 insertions, 163 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk index 1c11a9f1..d5d746a 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -63,7 +63,6 @@ LOCAL_SRC_FILES:= \ android_os_FileUtils.cpp \ android_os_MemoryFile.cpp \ android_os_MessageQueue.cpp \ - android_os_ParcelFileDescriptor.cpp \ android_os_Parcel.cpp \ android_os_SELinux.cpp \ android_os_SystemClock.cpp \ diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 6a25c9f..8472705 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -135,7 +135,6 @@ extern int register_android_text_format_Time(JNIEnv* env); extern int register_android_os_Debug(JNIEnv* env); extern int register_android_os_MessageQueue(JNIEnv* env); extern int register_android_os_Parcel(JNIEnv* env); -extern int register_android_os_ParcelFileDescriptor(JNIEnv *env); extern int register_android_os_SELinux(JNIEnv* env); extern int register_android_os_SystemProperties(JNIEnv *env); extern int register_android_os_SystemClock(JNIEnv* env); @@ -1178,7 +1177,6 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_os_FileObserver), REG_JNI(register_android_os_FileUtils), REG_JNI(register_android_os_MessageQueue), - REG_JNI(register_android_os_ParcelFileDescriptor), REG_JNI(register_android_os_SELinux), REG_JNI(register_android_os_Trace), REG_JNI(register_android_os_UEventObserver), diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index b03d12a..0ea3bf7 100644 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -222,8 +222,12 @@ static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors, }
}
- SkBitmap bitmap;
+ // ARGB_4444 is a deprecated format, convert automatically to 8888
+ if (config == SkBitmap::kARGB_4444_Config) {
+ config = SkBitmap::kARGB_8888_Config;
+ }
+ SkBitmap bitmap;
bitmap.setConfig(config, width, height);
jbyteArray buff = GraphicsJNI::allocateJavaPixelRef(env, &bitmap, NULL);
@@ -232,8 +236,7 @@ static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors, }
if (jColors != NULL) {
- GraphicsJNI::SetPixels(env, jColors, offset, stride,
- 0, 0, width, height, bitmap);
+ GraphicsJNI::SetPixels(env, jColors, offset, stride, 0, 0, width, height, bitmap);
}
return GraphicsJNI::createBitmap(env, new SkBitmap(bitmap), buff, isMutable, NULL, NULL);
diff --git a/core/jni/android_app_NativeActivity.cpp b/core/jni/android_app_NativeActivity.cpp index f768ce8..5418006 100644 --- a/core/jni/android_app_NativeActivity.cpp +++ b/core/jni/android_app_NativeActivity.cpp @@ -306,19 +306,23 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName code->internalDataPath = code->internalDataPathObj.string(); env->ReleaseStringUTFChars(internalDataDir, dirStr); - dirStr = env->GetStringUTFChars(externalDataDir, NULL); - code->externalDataPathObj = dirStr; + if (externalDataDir != NULL) { + dirStr = env->GetStringUTFChars(externalDataDir, NULL); + code->externalDataPathObj = dirStr; + env->ReleaseStringUTFChars(externalDataDir, dirStr); + } code->externalDataPath = code->externalDataPathObj.string(); - env->ReleaseStringUTFChars(externalDataDir, dirStr); code->sdkVersion = sdkVersion; code->assetManager = assetManagerForJavaObject(env, jAssetMgr); - dirStr = env->GetStringUTFChars(obbDir, NULL); - code->obbPathObj = dirStr; + if (obbDir != NULL) { + dirStr = env->GetStringUTFChars(obbDir, NULL); + code->obbPathObj = dirStr; + env->ReleaseStringUTFChars(obbDir, dirStr); + } code->obbPath = code->obbPathObj.string(); - env->ReleaseStringUTFChars(obbDir, dirStr); jbyte* rawSavedState = NULL; jsize rawSavedSize = 0; diff --git a/core/jni/android_os_ParcelFileDescriptor.cpp b/core/jni/android_os_ParcelFileDescriptor.cpp deleted file mode 100644 index 99a2d04..0000000 --- a/core/jni/android_os_ParcelFileDescriptor.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 - * - * 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. - */ - -//#define LOG_NDEBUG 0 - -#include "JNIHelp.h" - -#include <fcntl.h> -#include <sys/stat.h> -#include <stdio.h> - -#include <utils/Log.h> - -#include <android_runtime/AndroidRuntime.h> - -namespace android -{ - -static struct parcel_file_descriptor_offsets_t -{ - jfieldID mFileDescriptor; -} gParcelFileDescriptorOffsets; - -static jobject android_os_ParcelFileDescriptor_getFileDescriptorFromFd(JNIEnv* env, - jobject clazz, jint origfd) -{ - int fd = dup(origfd); - if (fd < 0) { - jniThrowException(env, "java/io/IOException", strerror(errno)); - return NULL; - } - return jniCreateFileDescriptor(env, fd); -} - -static jobject android_os_ParcelFileDescriptor_getFileDescriptorFromFdNoDup(JNIEnv* env, - jobject clazz, jint fd) -{ - return jniCreateFileDescriptor(env, fd); -} - -static void android_os_ParcelFileDescriptor_createPipeNative(JNIEnv* env, - jobject clazz, jobjectArray outFds) -{ - int fds[2]; - if (pipe(fds) < 0) { - int therr = errno; - jniThrowException(env, "java/io/IOException", strerror(therr)); - return; - } - - for (int i=0; i<2; i++) { - jobject fdObj = jniCreateFileDescriptor(env, fds[i]); - env->SetObjectArrayElement(outFds, i, fdObj); - } -} - -static jint getFd(JNIEnv* env, jobject clazz) -{ - jobject descriptor = env->GetObjectField(clazz, gParcelFileDescriptorOffsets.mFileDescriptor); - if (descriptor == NULL) return -1; - return jniGetFDFromFileDescriptor(env, descriptor); -} - -static jlong android_os_ParcelFileDescriptor_getStatSize(JNIEnv* env, - jobject clazz) -{ - jint fd = getFd(env, clazz); - if (fd < 0) { - jniThrowException(env, "java/lang/IllegalArgumentException", "bad file descriptor"); - return -1; - } - - struct stat st; - if (fstat(fd, &st) != 0) { - return -1; - } - - if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) { - return st.st_size; - } - - return -1; -} - -static jlong android_os_ParcelFileDescriptor_seekTo(JNIEnv* env, - jobject clazz, jlong pos) -{ - jint fd = getFd(env, clazz); - if (fd < 0) { - jniThrowException(env, "java/lang/IllegalArgumentException", "bad file descriptor"); - return -1; - } - - return lseek(fd, pos, SEEK_SET); -} - -static jlong android_os_ParcelFileDescriptor_getFdNative(JNIEnv* env, jobject clazz) -{ - jint fd = getFd(env, clazz); - if (fd < 0) { - jniThrowException(env, "java/lang/IllegalArgumentException", "bad file descriptor"); - return -1; - } - - return fd; -} - -static const JNINativeMethod gParcelFileDescriptorMethods[] = { - {"getFileDescriptorFromFd", "(I)Ljava/io/FileDescriptor;", - (void*)android_os_ParcelFileDescriptor_getFileDescriptorFromFd}, - {"getFileDescriptorFromFdNoDup", "(I)Ljava/io/FileDescriptor;", - (void*)android_os_ParcelFileDescriptor_getFileDescriptorFromFdNoDup}, - {"createPipeNative", "([Ljava/io/FileDescriptor;)V", - (void*)android_os_ParcelFileDescriptor_createPipeNative}, - {"getStatSize", "()J", - (void*)android_os_ParcelFileDescriptor_getStatSize}, - {"seekTo", "(J)J", - (void*)android_os_ParcelFileDescriptor_seekTo}, - {"getFdNative", "()I", - (void*)android_os_ParcelFileDescriptor_getFdNative} -}; - -const char* const kParcelFileDescriptorPathName = "android/os/ParcelFileDescriptor"; - -int register_android_os_ParcelFileDescriptor(JNIEnv* env) -{ - jclass clazz = env->FindClass(kParcelFileDescriptorPathName); - LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.ParcelFileDescriptor"); - gParcelFileDescriptorOffsets.mFileDescriptor = env->GetFieldID(clazz, "mFileDescriptor", "Ljava/io/FileDescriptor;"); - LOG_FATAL_IF(gParcelFileDescriptorOffsets.mFileDescriptor == NULL, - "Unable to find mFileDescriptor field in android.os.ParcelFileDescriptor"); - - return AndroidRuntime::registerNativeMethods( - env, kParcelFileDescriptorPathName, - gParcelFileDescriptorMethods, NELEM(gParcelFileDescriptorMethods)); -} - -} |