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

Commit a2783584 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Clear A2DP active device during start/stop in the native stack

Use setActiveDevice(null) during A2dpService.start() and stop()
to clear the A2DP active device both in A2dpService and the native
Bluetooth stack.
Otherwise, if A2dpService is restarted without the Bluetooth process
itself being restarted, the native Bluetooth stack might contain
stale state about the active device.

Bug: 73832547
Test: Manual - A2DP streaming, enable Location -> Bluetooth scanning,
      restart Bluetooth in Quick Settings
Change-Id: I8e001215ef052e588ddf6c53e2caf1382a70ae9b
parent f4042066
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -121,9 +121,8 @@ public class A2dpService extends ProfileService {
        mStateMachinesThread = new HandlerThread("A2dpService.StateMachines");
        mStateMachinesThread.start();

        // Step 5: Setup codec config and clear active device
        // Step 5: Setup codec config
        mA2dpCodecConfig = new A2dpCodecConfig(this, mA2dpNativeInterface);
        mActiveDevice = null;

        // Step 6: Initialize native interface
        mA2dpNativeInterface.init(mA2dpCodecConfig.codecConfigPriorities());
@@ -141,6 +140,9 @@ public class A2dpService extends ProfileService {
        // Step 8: Mark service as started
        setA2dpService(this);

        // Step 9: Clear active device
        setActiveDevice(null);

        return true;
    }

@@ -152,6 +154,9 @@ public class A2dpService extends ProfileService {
            return true;
        }

        // Step 9: Clear active device
        setActiveDevice(null);

        // Step 8: Mark service as stopped
        setA2dpService(null);

@@ -165,9 +170,8 @@ public class A2dpService extends ProfileService {
        mA2dpNativeInterface.cleanup();
        mA2dpNativeInterface = null;

        // Step 5: Clear codec config and active device
        // Step 5: Clear codec config
        mA2dpCodecConfig = null;
        mActiveDevice = null;

        // Step 4: Destroy state machines and stop handler thread
        synchronized (mStateMachines) {