summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-05-08 11:41:47 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-05-08 11:41:47 -0700
commit672f1e2b07d985526bfd5606e6a888005fdcb70c (patch)
tree706c6cb88dc05d181e29955615dae5b25f32b8fe /core/jni
parent3a6645a1cbee11932615afda6cfca0ec91c403a5 (diff)
parent704e00ab7b62eb0a89254fbb0151a45ee4052517 (diff)
downloadframeworks_base-672f1e2b07d985526bfd5606e6a888005fdcb70c.zip
frameworks_base-672f1e2b07d985526bfd5606e6a888005fdcb70c.tar.gz
frameworks_base-672f1e2b07d985526bfd5606e6a888005fdcb70c.tar.bz2
Merge change 1192 into donut
* changes: Fix 1825581 - device restarts when using A2DP.
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_server_BluetoothA2dpService.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/core/jni/android_server_BluetoothA2dpService.cpp b/core/jni/android_server_BluetoothA2dpService.cpp
index b320c09..fe94642 100644
--- a/core/jni/android_server_BluetoothA2dpService.cpp
+++ b/core/jni/android_server_BluetoothA2dpService.cpp
@@ -45,7 +45,8 @@ static jmethodID method_onSinkPlaying;
static jmethodID method_onSinkStopped;
typedef struct {
- JNIEnv *env;
+ JavaVM *vm;
+ int envVer;
DBusConnection *conn;
jobject me; // for callbacks to java
} native_data_t;
@@ -70,7 +71,8 @@ static bool initNative(JNIEnv* env, jobject object) {
LOGE("%s: out of memory!", __FUNCTION__);
return false;
}
- nat->env = env;
+ env->GetJavaVM( &(nat->vm) );
+ nat->envVer = env->GetVersion();
nat->me = env->NewGlobalRef(object);
DBusError err;
@@ -239,8 +241,14 @@ static void onConnectSinkResult(DBusMessage *msg, void *user, void *natData) {
char *c_path = (char *)user;
DBusError err;
+ JNIEnv *env;
+
+ if (nat->vm->GetEnv((void**)&env, nat->envVer) < 0) {
+ LOGE("%s: error finding Env for our VM\n", __FUNCTION__);
+ return;
+ }
+
dbus_error_init(&err);
- JNIEnv *env = nat->env;
LOGV("... path = %s", c_path);
if (dbus_set_error_from_message(&err, msg)) {
@@ -264,8 +272,14 @@ static void onDisconnectSinkResult(DBusMessage *msg, void *user, void *natData)
char *c_path = (char *)user;
DBusError err;
+ JNIEnv *env;
+
+ if (nat->vm->GetEnv((void**)&env, nat->envVer) < 0) {
+ LOGE("%s: error finding Env for our VM\n", __FUNCTION__);
+ return;
+ }
+
dbus_error_init(&err);
- JNIEnv *env = nat->env;
LOGV("... path = %s", c_path);
if (dbus_set_error_from_message(&err, msg)) {