Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2986e323 authored by Dmitry Grinberg's avatar Dmitry Grinberg Committed by Android Git Automerger
Browse files

am 536c8933: DO NOT MERGE: Fix concurrency issues with wakelock support

* commit '536c8933':
  DO NOT MERGE: Fix concurrency issues with wakelock support
parents 080b4cb8 536c8933
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -447,6 +447,9 @@ static void le_test_mode_recv_callback (bt_status_t status, uint16_t packet_coun
static void bt_wakelock_control_callback(int acquire) {
    static sp<IPowerManager> sPm = NULL;
    static sp<IBinder> sWakelock = NULL;
    static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

    pthread_mutex_lock(&mutex);

    if (sPm == NULL) {
        sp<IBinder> binder = defaultServiceManager()->checkService(String16("power"));
@@ -454,7 +457,7 @@ static void bt_wakelock_control_callback(int acquire) {

        if (sPm == NULL) {
            ALOGE("Unable to get a hold of PowerManager. Bluetooth wakelocks will not function");
            return;
            goto out;
        }
    }
    if (acquire) {
@@ -474,6 +477,8 @@ static void bt_wakelock_control_callback(int acquire) {
            sWakelock.clear();
        }
    }
out:
    pthread_mutex_unlock(&mutex);
}

bt_callbacks_t sBluetoothCallbacks = {