diff options
author | Jaikumar Ganesh <jaikumar@google.com> | 2009-08-24 17:11:11 -0700 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2009-08-25 12:02:34 -0700 |
commit | 6d56b530e189d7213ec77d43d3d8af97fee04179 (patch) | |
tree | fda28b02bc5998185585533f5be0664f6da9a65a /core/jni/android_server_BluetoothService.cpp | |
parent | d507ff21296b10ed57feec1200a8fe7eb09c0fc4 (diff) | |
download | frameworks_base-6d56b530e189d7213ec77d43d3d8af97fee04179.zip frameworks_base-6d56b530e189d7213ec77d43d3d8af97fee04179.tar.gz frameworks_base-6d56b530e189d7213ec77d43d3d8af97fee04179.tar.bz2 |
Add local frames for parsing properties and processing events.
We were running out of local refs when there are lots of devices.
Instead of deleting every single local ref, create a local stack frame.
This operation is inexpensive so doesn't add a high overload and keeps
the code clean instead of deleting every single local ref.
Diffstat (limited to 'core/jni/android_server_BluetoothService.cpp')
-rw-r--r-- | core/jni/android_server_BluetoothService.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/jni/android_server_BluetoothService.cpp b/core/jni/android_server_BluetoothService.cpp index 326052b..d1901b4 100644 --- a/core/jni/android_server_BluetoothService.cpp +++ b/core/jni/android_server_BluetoothService.cpp @@ -46,6 +46,7 @@ namespace android { #define BLUETOOTH_CLASS_ERROR 0xFF000000 +#define PROPERTIES_NREFS 10 #ifdef HAVE_BLUETOOTH // We initialize these variables when we load class @@ -576,11 +577,16 @@ static jobjectArray getDevicePropertiesNative(JNIEnv *env, jobject object, LOGE("DBus reply is NULL in function %s", __FUNCTION__); return NULL; } + env->PushLocalFrame(PROPERTIES_NREFS); + DBusMessageIter iter; jobjectArray str_array = NULL; if (dbus_message_iter_init(reply, &iter)) str_array = parse_remote_device_properties(env, &iter); dbus_message_unref(reply); + + env->PopLocalFrame(NULL); + return str_array; } #endif @@ -607,11 +613,15 @@ static jobjectArray getAdapterPropertiesNative(JNIEnv *env, jobject object) { LOGE("DBus reply is NULL in function %s", __FUNCTION__); return NULL; } + env->PushLocalFrame(PROPERTIES_NREFS); + DBusMessageIter iter; jobjectArray str_array = NULL; if (dbus_message_iter_init(reply, &iter)) str_array = parse_adapter_properties(env, &iter); dbus_message_unref(reply); + + env->PopLocalFrame(NULL); return str_array; } #endif |