summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp63
-rw-r--r--core/jni/android_content_res_ObbScanner.cpp2
-rw-r--r--core/jni/android_emoji_EmojiFactory.cpp2
-rw-r--r--core/jni/android_hardware_UsbDevice.cpp7
-rw-r--r--core/jni/android_net_NetUtils.cpp19
-rw-r--r--core/jni/android_net_wifi_Wifi.cpp3
-rw-r--r--core/jni/android_nio_utils.cpp9
-rw-r--r--core/jni/android_os_FileUtils.cpp27
-rw-r--r--core/jni/android_os_MemoryFile.cpp9
-rw-r--r--core/jni/android_pim_EventRecurrence.cpp6
-rw-r--r--core/jni/android_text_AndroidBidi.cpp23
-rw-r--r--core/jni/android_text_AndroidCharacter.cpp3
-rw-r--r--core/jni/android_util_EventLog.cpp3
-rw-r--r--core/jni/android_util_Process.cpp5
-rw-r--r--core/jni/com_android_internal_graphics_NativeUtils.cpp5
-rw-r--r--core/jni/com_google_android_gles_jni_EGLImpl.cpp44
-rw-r--r--media/jni/android_media_MediaRecorder.cpp6
-rw-r--r--media/jni/android_media_MediaScanner.cpp4
-rw-r--r--services/jni/com_android_server_AlarmManagerService.cpp32
19 files changed, 92 insertions, 180 deletions
diff --git a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
index 137acc6..6ce3f51 100644
--- a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
+++ b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
@@ -3,7 +3,6 @@
#define RETURN_NULL_IF_NULL(value) \
do { if (!(value)) { SkASSERT(0); return NULL; } } while (false)
-static jclass gInputStream_Clazz;
static jmethodID gInputStream_resetMethodID;
static jmethodID gInputStream_markMethodID;
static jmethodID gInputStream_availableMethodID;
@@ -19,10 +18,10 @@ public:
SkASSERT(fCapacity > 0);
fBytesRead = 0;
}
-
+
virtual bool rewind() {
JNIEnv* env = fEnv;
-
+
fBytesRead = 0;
env->CallVoidMethod(fJavaInputStream, gInputStream_resetMethodID);
@@ -34,7 +33,7 @@ public:
}
return true;
}
-
+
size_t doRead(void* buffer, size_t size) {
JNIEnv* env = fEnv;
size_t bytesRead = 0;
@@ -43,7 +42,7 @@ public:
size_t requested = size;
if (requested > fCapacity)
requested = fCapacity;
-
+
jint n = env->CallIntMethod(fJavaInputStream,
gInputStream_readMethodID, fJavaByteArray, 0, requested);
if (env->ExceptionCheck()) {
@@ -52,11 +51,11 @@ public:
SkDebugf("---- read threw an exception\n");
return 0;
}
-
+
if (n < 0) { // n == 0 should not be possible, see InputStream read() specifications.
break; // eof
}
-
+
env->GetByteArrayRegion(fJavaByteArray, 0, n,
reinterpret_cast<jbyte*>(buffer));
if (env->ExceptionCheck()) {
@@ -65,16 +64,16 @@ public:
SkDebugf("---- read:GetByteArrayRegion threw an exception\n");
return 0;
}
-
+
buffer = (void*)((char*)buffer + n);
bytesRead += n;
size -= n;
fBytesRead += n;
} while (size != 0);
-
+
return bytesRead;
}
-
+
size_t doSkip(size_t size) {
JNIEnv* env = fEnv;
@@ -92,7 +91,7 @@ public:
return (size_t)skipped;
}
-
+
size_t doSize() {
JNIEnv* env = fEnv;
jint avail = env->CallIntMethod(fJavaInputStream,
@@ -105,7 +104,7 @@ public:
}
return avail;
}
-
+
virtual size_t read(void* buffer, size_t size) {
JNIEnv* env = fEnv;
if (NULL == buffer) {
@@ -134,7 +133,7 @@ public:
}
return this->doRead(buffer, size);
}
-
+
private:
JNIEnv* fEnv;
jobject fJavaInputStream; // the caller owns this object
@@ -148,19 +147,18 @@ SkStream* CreateJavaInputStreamAdaptor(JNIEnv* env, jobject stream,
static bool gInited;
if (!gInited) {
- gInputStream_Clazz = env->FindClass("java/io/InputStream");
- RETURN_NULL_IF_NULL(gInputStream_Clazz);
- gInputStream_Clazz = (jclass)env->NewGlobalRef(gInputStream_Clazz);
+ jclass inputStream_Clazz = env->FindClass("java/io/InputStream");
+ RETURN_NULL_IF_NULL(inputStream_Clazz);
- gInputStream_resetMethodID = env->GetMethodID(gInputStream_Clazz,
+ gInputStream_resetMethodID = env->GetMethodID(inputStream_Clazz,
"reset", "()V");
- gInputStream_markMethodID = env->GetMethodID(gInputStream_Clazz,
+ gInputStream_markMethodID = env->GetMethodID(inputStream_Clazz,
"mark", "(I)V");
- gInputStream_availableMethodID = env->GetMethodID(gInputStream_Clazz,
+ gInputStream_availableMethodID = env->GetMethodID(inputStream_Clazz,
"available", "()I");
- gInputStream_readMethodID = env->GetMethodID(gInputStream_Clazz,
+ gInputStream_readMethodID = env->GetMethodID(inputStream_Clazz,
"read", "([BII)I");
- gInputStream_skipMethodID = env->GetMethodID(gInputStream_Clazz,
+ gInputStream_skipMethodID = env->GetMethodID(inputStream_Clazz,
"skip", "(J)J");
RETURN_NULL_IF_NULL(gInputStream_resetMethodID);
@@ -181,7 +179,6 @@ SkStream* CreateJavaInputStreamAdaptor(JNIEnv* env, jobject stream,
///////////////////////////////////////////////////////////////////////////////
-static jclass gOutputStream_Clazz;
static jmethodID gOutputStream_writeMethodID;
static jmethodID gOutputStream_flushMethodID;
@@ -191,11 +188,11 @@ public:
: fEnv(env), fJavaOutputStream(stream), fJavaByteArray(storage) {
fCapacity = env->GetArrayLength(storage);
}
-
+
virtual bool write(const void* buffer, size_t size) {
JNIEnv* env = fEnv;
jbyteArray storage = fJavaByteArray;
-
+
while (size > 0) {
size_t requested = size;
if (requested > fCapacity) {
@@ -210,7 +207,7 @@ public:
SkDebugf("--- write:SetByteArrayElements threw an exception\n");
return false;
}
-
+
fEnv->CallVoidMethod(fJavaOutputStream, gOutputStream_writeMethodID,
storage, 0, requested);
if (env->ExceptionCheck()) {
@@ -219,17 +216,17 @@ public:
SkDebugf("------- write threw an exception\n");
return false;
}
-
+
buffer = (void*)((char*)buffer + requested);
size -= requested;
}
return true;
}
-
+
virtual void flush() {
fEnv->CallVoidMethod(fJavaOutputStream, gOutputStream_flushMethodID);
}
-
+
private:
JNIEnv* fEnv;
jobject fJavaOutputStream; // the caller owns this object
@@ -242,14 +239,13 @@ SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream,
static bool gInited;
if (!gInited) {
- gOutputStream_Clazz = env->FindClass("java/io/OutputStream");
- RETURN_NULL_IF_NULL(gOutputStream_Clazz);
- gOutputStream_Clazz = (jclass)env->NewGlobalRef(gOutputStream_Clazz);
+ jclass outputStream_Clazz = env->FindClass("java/io/OutputStream");
+ RETURN_NULL_IF_NULL(outputStream_Clazz);
- gOutputStream_writeMethodID = env->GetMethodID(gOutputStream_Clazz,
+ gOutputStream_writeMethodID = env->GetMethodID(outputStream_Clazz,
"write", "([BII)V");
RETURN_NULL_IF_NULL(gOutputStream_writeMethodID);
- gOutputStream_flushMethodID = env->GetMethodID(gOutputStream_Clazz,
+ gOutputStream_flushMethodID = env->GetMethodID(outputStream_Clazz,
"flush", "()V");
RETURN_NULL_IF_NULL(gOutputStream_flushMethodID);
@@ -258,4 +254,3 @@ SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream,
return new SkJavaOutputStream(env, stream, storage);
}
-
diff --git a/core/jni/android_content_res_ObbScanner.cpp b/core/jni/android_content_res_ObbScanner.cpp
index 404a87d..8837538 100644
--- a/core/jni/android_content_res_ObbScanner.cpp
+++ b/core/jni/android_content_res_ObbScanner.cpp
@@ -39,7 +39,7 @@ static struct {
static void android_content_res_ObbScanner_getObbInfo(JNIEnv* env, jobject clazz, jstring file,
jobject obbInfo)
{
- const char* filePath = env->GetStringUTFChars(file, JNI_FALSE);
+ const char* filePath = env->GetStringUTFChars(file, NULL);
sp<ObbFile> obb = new ObbFile();
if (!obb->readFrom(filePath)) {
diff --git a/core/jni/android_emoji_EmojiFactory.cpp b/core/jni/android_emoji_EmojiFactory.cpp
index 1ebb36c..56859b8 100644
--- a/core/jni/android_emoji_EmojiFactory.cpp
+++ b/core/jni/android_emoji_EmojiFactory.cpp
@@ -93,8 +93,6 @@ static EmojiFactoryCaller* gCaller;
static pthread_once_t g_once = PTHREAD_ONCE_INIT;
static bool lib_emoji_factory_is_ready;
-static jclass gString_class;
-
static jclass gBitmap_class;
static jmethodID gBitmap_constructorMethodID;
diff --git a/core/jni/android_hardware_UsbDevice.cpp b/core/jni/android_hardware_UsbDevice.cpp
index c2950ea..25f901b 100644
--- a/core/jni/android_hardware_UsbDevice.cpp
+++ b/core/jni/android_hardware_UsbDevice.cpp
@@ -54,13 +54,6 @@ static JNINativeMethod method_table[] = {
int register_android_hardware_UsbDevice(JNIEnv *env)
{
- jclass clazz = env->FindClass("android/hardware/usb/UsbDevice");
- if (clazz == NULL) {
- LOGE("Can't find android/hardware/usb/UsbDevice");
- return -1;
- }
-
return AndroidRuntime::registerNativeMethods(env, "android/hardware/usb/UsbDevice",
method_table, NELEM(method_table));
}
-
diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp
index db132ec..4a0e68e 100644
--- a/core/jni/android_net_NetUtils.cpp
+++ b/core/jni/android_net_NetUtils.cpp
@@ -1,16 +1,16 @@
/*
* Copyright 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
+ * 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.
*/
@@ -225,9 +225,6 @@ static JNINativeMethod gNetworkUtilMethods[] = {
int register_android_net_NetworkUtils(JNIEnv* env)
{
- jclass netutils = env->FindClass(NETUTILS_PKG_NAME);
- LOG_FATAL_IF(netutils == NULL, "Unable to find class " NETUTILS_PKG_NAME);
-
jclass dhcpInfoInternalClass = env->FindClass("android/net/DhcpInfoInternal");
LOG_FATAL_IF(dhcpInfoInternalClass == NULL, "Unable to find class android/net/DhcpInfoInternal");
dhcpInfoInternalFieldIds.constructorId = env->GetMethodID(dhcpInfoInternalClass, "<init>", "()V");
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp
index 494dc27..2abb9ea 100644
--- a/core/jni/android_net_wifi_Wifi.cpp
+++ b/core/jni/android_net_wifi_Wifi.cpp
@@ -651,9 +651,6 @@ static JNINativeMethod gWifiMethods[] = {
int register_android_net_wifi_WifiManager(JNIEnv* env)
{
- jclass wifi = env->FindClass(WIFI_PKG_NAME);
- LOG_FATAL_IF(wifi == NULL, "Unable to find class " WIFI_PKG_NAME);
-
return AndroidRuntime::registerNativeMethods(env,
WIFI_PKG_NAME, gWifiMethods, NELEM(gWifiMethods));
}
diff --git a/core/jni/android_nio_utils.cpp b/core/jni/android_nio_utils.cpp
index 584e7a4..7cbbe12 100644
--- a/core/jni/android_nio_utils.cpp
+++ b/core/jni/android_nio_utils.cpp
@@ -32,20 +32,20 @@ void* android::nio_getPointer(JNIEnv *_env, jobject buffer, jarray *array) {
jlong pointer;
jint offset;
void *data;
-
+
pointer = _env->CallStaticLongMethod(gNioJNI.nioAccessClass,
gNioJNI.getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
return (void *) (jint) pointer;
}
-
+
*array = (jarray) _env->CallStaticObjectMethod(gNioJNI.nioAccessClass,
gNioJNI.getBaseArrayID, buffer);
offset = _env->CallStaticIntMethod(gNioJNI.nioAccessClass,
gNioJNI.getBaseArrayOffsetID, buffer);
data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
-
+
return (void *) ((char *) data + offset);
}
@@ -94,8 +94,7 @@ static jfieldID getFieldID(JNIEnv* env, jclass c, const char name[],
}
namespace android {
-
-int register_android_nio_utils(JNIEnv* env);
+
int register_android_nio_utils(JNIEnv* env) {
jclass localClass = findClass(env, "java/nio/NIOAccess");
gNioJNI.getBasePointerID = findStaticMethod(env, localClass,
diff --git a/core/jni/android_os_FileUtils.cpp b/core/jni/android_os_FileUtils.cpp
index 2b4a955..89dce89 100644
--- a/core/jni/android_os_FileUtils.cpp
+++ b/core/jni/android_os_FileUtils.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, 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
+** 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.
*/
@@ -145,7 +145,7 @@ jint android_os_FileUtils_getFatVolumeId(JNIEnv* env, jobject clazz, jstring pat
jboolean android_os_FileUtils_getFileStatus(JNIEnv* env, jobject clazz, jstring path, jobject fileStatus) {
const char* pathStr = env->GetStringUTFChars(path, NULL);
jboolean ret = false;
-
+
struct stat s;
int res = stat(pathStr, &s);
if (res == 0) {
@@ -165,9 +165,9 @@ jboolean android_os_FileUtils_getFileStatus(JNIEnv* env, jobject clazz, jstring
env->SetLongField(fileStatus, gFileStatusCtimeFieldID, s.st_ctime);
}
}
-
+
env->ReleaseStringUTFChars(path, pathStr);
-
+
return ret;
}
@@ -183,11 +183,6 @@ static const char* const kFileUtilsPathName = "android/os/FileUtils";
int register_android_os_FileUtils(JNIEnv* env)
{
- jclass clazz;
-
- clazz = env->FindClass(kFileUtilsPathName);
- LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.FileUtils");
-
jclass fileStatusClass = env->FindClass("android/os/FileUtils$FileStatus");
LOG_FATAL_IF(fileStatusClass == NULL, "Unable to find class android.os.FileUtils$FileStatus");
diff --git a/core/jni/android_os_MemoryFile.cpp b/core/jni/android_os_MemoryFile.cpp
index ee8d836..7134191 100644
--- a/core/jni/android_os_MemoryFile.cpp
+++ b/core/jni/android_os_MemoryFile.cpp
@@ -148,17 +148,10 @@ static const JNINativeMethod methods[] = {
(void*)android_os_MemoryFile_get_size}
};
-static const char* const kClassPathName = "android/os/MemoryFile";
-
int register_android_os_MemoryFile(JNIEnv* env)
{
- jclass clazz;
-
- clazz = env->FindClass(kClassPathName);
- LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.FileUtils");
-
return AndroidRuntime::registerNativeMethods(
- env, kClassPathName,
+ env, "android/os/MemoryFile",
methods, NELEM(methods));
}
diff --git a/core/jni/android_pim_EventRecurrence.cpp b/core/jni/android_pim_EventRecurrence.cpp
index 9056c90..44e898d 100644
--- a/core/jni/android_pim_EventRecurrence.cpp
+++ b/core/jni/android_pim_EventRecurrence.cpp
@@ -28,7 +28,6 @@ struct cached_array_fields_t
jfieldID count;
};
-static jclass clazz;
static jfieldID freq_field;
static jfieldID until_field;
static jfieldID count_field;
@@ -87,8 +86,7 @@ EventRecurrence_parse(JNIEnv* env, jobject This, jstring jstr)
jniThrowNullPointerException(env, "EventRecurrence.parse str parameter null");
return ;
}
- jboolean isCopy;
- const jchar* jchars = env->GetStringChars(jstr, &isCopy);
+ const jchar* jchars = env->GetStringChars(jstr, NULL);
jsize len = env->GetStringLength(jstr);
String16 str(jchars, len);
env->ReleaseStringChars(jstr, jchars);
@@ -156,7 +154,7 @@ static const char*const CLASS_NAME = "android/pim/EventRecurrence";
int register_android_pim_EventRecurrence(JNIEnv* env)
{
- clazz = env->FindClass(CLASS_NAME);
+ jclass clazz = env->FindClass(CLASS_NAME);
if (clazz == NULL) {
LOGE("Field lookup unable to find class '%s'\n", CLASS_NAME);
return -1;
diff --git a/core/jni/android_text_AndroidBidi.cpp b/core/jni/android_text_AndroidBidi.cpp
index 53028c3..d50a69f 100644
--- a/core/jni/android_text_AndroidBidi.cpp
+++ b/core/jni/android_text_AndroidBidi.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2010, 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
+** 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.
*/
@@ -24,8 +24,8 @@
#include "unicode/ubidi.h"
namespace android {
-
-static jint runBidi(JNIEnv* env, jobject obj, jint dir, jcharArray chsArray,
+
+static jint runBidi(JNIEnv* env, jobject obj, jint dir, jcharArray chsArray,
jbyteArray infoArray, int n, jboolean haveInfo)
{
// Parameters are checked on java side
@@ -63,9 +63,6 @@ static JNINativeMethod gMethods[] = {
int register_android_text_AndroidBidi(JNIEnv* env)
{
- jclass clazz = env->FindClass("android/text/AndroidBidi");
- LOG_ASSERT(clazz, "Cannot find android/text/AndroidBidi");
-
return AndroidRuntime::registerNativeMethods(env, "android/text/AndroidBidi",
gMethods, NELEM(gMethods));
}
diff --git a/core/jni/android_text_AndroidCharacter.cpp b/core/jni/android_text_AndroidCharacter.cpp
index 0d0f5fa..dacbe41 100644
--- a/core/jni/android_text_AndroidCharacter.cpp
+++ b/core/jni/android_text_AndroidCharacter.cpp
@@ -191,9 +191,6 @@ static JNINativeMethod gMethods[] = {
int register_android_text_AndroidCharacter(JNIEnv* env)
{
- jclass clazz = env->FindClass("android/text/AndroidCharacter");
- LOG_ASSERT(clazz, "Cannot find android/text/AndroidCharacter");
-
return AndroidRuntime::registerNativeMethods(env, "android/text/AndroidCharacter",
gMethods, NELEM(gMethods));
}
diff --git a/core/jni/android_util_EventLog.cpp b/core/jni/android_util_EventLog.cpp
index 91d37d3..5d51110 100644
--- a/core/jni/android_util_EventLog.cpp
+++ b/core/jni/android_util_EventLog.cpp
@@ -35,9 +35,6 @@ static jmethodID gEventInitID;
static jclass gIntegerClass;
static jfieldID gIntegerValueID;
-static jclass gListClass;
-static jfieldID gListItemsID;
-
static jclass gLongClass;
static jfieldID gLongValueID;
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index 0068de7..34f0fdc 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -915,11 +915,6 @@ const char* const kProcessPathName = "android/os/Process";
int register_android_os_Process(JNIEnv* env)
{
- jclass clazz;
-
- clazz = env->FindClass(kProcessPathName);
- LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.Process");
-
return AndroidRuntime::registerNativeMethods(
env, kProcessPathName,
methods, NELEM(methods));
diff --git a/core/jni/com_android_internal_graphics_NativeUtils.cpp b/core/jni/com_android_internal_graphics_NativeUtils.cpp
index 319946f..9cc43606 100644
--- a/core/jni/com_android_internal_graphics_NativeUtils.cpp
+++ b/core/jni/com_android_internal_graphics_NativeUtils.cpp
@@ -29,11 +29,6 @@
namespace android
{
-static jclass class_fileDescriptor;
-static jfieldID field_fileDescriptor_descriptor;
-static jmethodID method_fileDescriptor_init;
-
-
static jboolean scrollRect(JNIEnv* env, jobject graphics2D, jobject canvas, jobject rect, int dx, int dy) {
if (canvas == NULL) {
jniThrowNullPointerException(env, NULL);
diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
index 61efcf2..5f2065a 100644
--- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
@@ -29,9 +29,6 @@
namespace android {
-static jclass gDisplay_class;
-static jclass gContext_class;
-static jclass gSurface_class;
static jclass gConfig_class;
static jmethodID gConfig_ctorID;
@@ -44,21 +41,6 @@ static jfieldID gConfig_EGLConfigFieldID;
static jfieldID gSurface_SurfaceFieldID;
static jfieldID gBitmap_NativeBitmapFieldID;
-static __attribute__((noinline))
-bool hasException(JNIEnv *env) {
- if (env->ExceptionCheck() != 0) {
- env->ExceptionDescribe();
- return true;
- }
- return false;
-}
-
-static __attribute__((noinline))
-jclass make_globalref(JNIEnv* env, const char classname[]) {
- jclass c = env->FindClass(classname);
- return (jclass)env->NewGlobalRef(c);
-}
-
static inline EGLDisplay getDisplay(JNIEnv* env, jobject o) {
if (!o) return EGL_NO_DISPLAY;
return (EGLDisplay)env->GetIntField(o, gDisplay_EGLDisplayFieldID);
@@ -77,18 +59,20 @@ static inline EGLConfig getConfig(JNIEnv* env, jobject o) {
}
static void nativeClassInit(JNIEnv *_env, jclass eglImplClass)
{
- gDisplay_class = make_globalref(_env, "com/google/android/gles_jni/EGLDisplayImpl");
- gContext_class = make_globalref(_env, "com/google/android/gles_jni/EGLContextImpl");
- gSurface_class = make_globalref(_env, "com/google/android/gles_jni/EGLSurfaceImpl");
- gConfig_class = make_globalref(_env, "com/google/android/gles_jni/EGLConfigImpl");
-
- gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(I)V");
-
- gDisplay_EGLDisplayFieldID = _env->GetFieldID(gDisplay_class, "mEGLDisplay", "I");
- gContext_EGLContextFieldID = _env->GetFieldID(gContext_class, "mEGLContext", "I");
- gSurface_EGLSurfaceFieldID = _env->GetFieldID(gSurface_class, "mEGLSurface", "I");
- gSurface_NativePixelRefFieldID = _env->GetFieldID(gSurface_class, "mNativePixelRef", "I");
- gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "I");
+ jclass config_class = _env->FindClass("com/google/android/gles_jni/EGLConfigImpl");
+ gConfig_class = (jclass) _env->NewGlobalRef(config_class);
+ gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(I)V");
+ gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "I");
+
+ jclass display_class = _env->FindClass("com/google/android/gles_jni/EGLDisplayImpl");
+ gDisplay_EGLDisplayFieldID = _env->GetFieldID(display_class, "mEGLDisplay", "I");
+
+ jclass context_class = _env->FindClass("com/google/android/gles_jni/EGLContextImpl");
+ gContext_EGLContextFieldID = _env->GetFieldID(context_class, "mEGLContext", "I");
+
+ jclass surface_class = _env->FindClass("com/google/android/gles_jni/EGLSurfaceImpl");
+ gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "I");
+ gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "I");
jclass bitmap_class = _env->FindClass("android/graphics/Bitmap");
gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "I");
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index 4750b0b..2c24695 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -404,38 +404,32 @@ android_media_MediaRecorder_native_init(JNIEnv *env)
clazz = env->FindClass("android/media/MediaRecorder");
if (clazz == NULL) {
- jniThrowException(env, "java/lang/RuntimeException", "Can't find android/media/MediaRecorder");
return;
}
fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
if (fields.context == NULL) {
- jniThrowException(env, "java/lang/RuntimeException", "Can't find MediaRecorder.mNativeContext");
return;
}
fields.surface = env->GetFieldID(clazz, "mSurface", "Landroid/view/Surface;");
if (fields.surface == NULL) {
- jniThrowException(env, "java/lang/RuntimeException", "Can't find MediaRecorder.mSurface");
return;
}
jclass surface = env->FindClass("android/view/Surface");
if (surface == NULL) {
- jniThrowException(env, "java/lang/RuntimeException", "Can't find android/view/Surface");
return;
}
fields.surface_native = env->GetFieldID(surface, ANDROID_VIEW_SURFACE_JNI_ID, "I");
if (fields.surface_native == NULL) {
- jniThrowException(env, "java/lang/RuntimeException", "Can't find Surface.mSurface");
return;
}
fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative",
"(Ljava/lang/Object;IIILjava/lang/Object;)V");
if (fields.post_event == NULL) {
- jniThrowException(env, "java/lang/RuntimeException", "MediaRecorder.postEventFromNative");
return;
}
}
diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp
index 043f373..a3dd136 100644
--- a/media/jni/android_media_MediaScanner.cpp
+++ b/media/jni/android_media_MediaScanner.cpp
@@ -335,15 +335,11 @@ android_media_MediaScanner_native_init(JNIEnv *env)
LOGV("native_init");
jclass clazz = env->FindClass(kClassMediaScanner);
if (clazz == NULL) {
- const char* err = "Can't find android/media/MediaScanner";
- jniThrowException(env, kRunTimeException, err);
return;
}
fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
if (fields.context == NULL) {
- const char* err = "Can't find MediaScanner.mNativeContext";
- jniThrowException(env, kRunTimeException, err);
return;
}
}
diff --git a/services/jni/com_android_server_AlarmManagerService.cpp b/services/jni/com_android_server_AlarmManagerService.cpp
index aa8c9b3..c9a702a 100644
--- a/services/jni/com_android_server_AlarmManagerService.cpp
+++ b/services/jni/com_android_server_AlarmManagerService.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, 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
+** 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.
*/
@@ -84,7 +84,7 @@ static void android_server_AlarmManagerService_set(JNIEnv* env, jobject obj, jin
struct timespec ts;
ts.tv_sec = seconds;
ts.tv_nsec = nanoseconds;
-
+
int result = ioctl(fd, ANDROID_ALARM_SET(type), &ts);
if (result < 0)
{
@@ -97,18 +97,18 @@ static jint android_server_AlarmManagerService_waitForAlarm(JNIEnv* env, jobject
{
#ifdef HAVE_ANDROID_OS
int result = 0;
-
+
do
{
result = ioctl(fd, ANDROID_ALARM_WAIT);
} while (result < 0 && errno == EINTR);
-
+
if (result < 0)
{
LOGE("Unable to wait on alarm: %s\n", strerror(errno));
return 0;
}
-
+
return result;
#endif
}
@@ -124,14 +124,6 @@ static JNINativeMethod sMethods[] = {
int register_android_server_AlarmManagerService(JNIEnv* env)
{
- jclass clazz = env->FindClass("com/android/server/AlarmManagerService");
-
- if (clazz == NULL)
- {
- LOGE("Can't find com/android/server/AlarmManagerService");
- return -1;
- }
-
return jniRegisterNativeMethods(env, "com/android/server/AlarmManagerService",
sMethods, NELEM(sMethods));
}