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

Commit 7d0548d0 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

Fix race condition between starting of service and getting the Profile Proxy.

Incoming A2DP connections were not working.

Change-Id: I5a3322ddb39b2512495b4cd2e35593da0f605087
parent 2cd6f470
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -120,7 +120,9 @@ class BluetoothEventLoop {
                | PowerManager.ON_AFTER_RELEASE, TAG);
        mWakeLock.setReferenceCounted(false);
        initializeNativeDataNative();
    }

    /*package*/ void getProfileProxy() {
        mAdapter.getProfileProxy(mContext, mProfileServiceListener, BluetoothProfile.A2DP);
    }

+4 −0
Original line number Diff line number Diff line
@@ -319,6 +319,10 @@ public class BluetoothService extends IBluetooth.Stub {
        mEventLoop = new BluetoothEventLoop(mContext, mAdapter, this);
    }

    public synchronized void initAfterA2dpRegistration() {
        mEventLoop.getProfileProxy();
    }

    @Override
    protected void finalize() throws Throwable {
        mContext.unregisterReceiver(mReceiver);
+2 −1
Original line number Diff line number Diff line
@@ -215,6 +215,7 @@ class ServerThread extends Thread {
                bluetoothA2dp = new BluetoothA2dpService(context, bluetooth);
                ServiceManager.addService(BluetoothA2dpService.BLUETOOTH_A2DP_SERVICE,
                                          bluetoothA2dp);
                bluetooth.initAfterA2dpRegistration();

                int bluetoothOn = Settings.Secure.getInt(mContentResolver,
                    Settings.Secure.BLUETOOTH_ON, 0);