Commit 1f8f597e authored by François Grisez's avatar François Grisez

Manage the case when a wake lock cannot be created

parent dd48d605
......@@ -90,10 +90,14 @@ unsigned long wake_lock_acquire(const char *tag) {
jstring tagString = (*env)->NewStringUTF(env, tag);
jobject lock = (*env)->CallObjectMethod(env, ctx.powerManager, ctx.newWakeLockID, ctx.PARTIAL_WAKE_LOCK, tagString);
(*env)->DeleteLocalRef(env, tagString);
(*env)->CallVoidMethod(env, lock, ctx.acquireID);
lock = (*env)->NewGlobalRef(env, lock);
belle_sip_message("bellesip_wake_lock_acquire(): Android wake lock acquired [ref=%p]", (void *)lock);
return (unsigned long)lock;
if(lock != NULL) {
(*env)->CallVoidMethod(env, lock, ctx.acquireID);
lock = (*env)->NewGlobalRef(env, lock);
belle_sip_message("bellesip_wake_lock_acquire(): Android wake lock acquired [ref=%p]", (void *)lock);
return (unsigned long)lock;
} else {
belle_sip_message("wake_lock_acquire(): wake lock creation failed");
}
} else {
belle_sip_error("bellesip_wake_lock_acquire(): cannot attach current thread to the JVM");
}
......@@ -104,7 +108,6 @@ unsigned long wake_lock_acquire(const char *tag) {
}
void wake_lock_release(unsigned long id) {
if(ctx.jvm != NULL && ctx.powerManager != NULL) {
if(id != 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment