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

Commit 8af9af99 authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

Fix calling method on the stopped service

Since the callback was scheduled on the main loop, the service can be
stopped after that and before the callback is called. We should check
if the service is still running before we execute the scheduled callback
logic.

Bug: 298898621
Test: atest BluetoothInstrumentationTests
Change-Id: Id7c9fa75758a13aea93d2d235feb99bfc4cda85c
parent 7f7d8d59
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1253,6 +1253,11 @@ public class A2dpService extends ProfileService {
    }

    void connectionStateChanged(BluetoothDevice device, int fromState, int toState) {
        if (!isAvailable()) {
            Log.w(TAG, "connectionStateChanged: service is not available");
            return;
        }

        if ((device == null) || (fromState == toState)) {
            return;
        }
+5 −0
Original line number Diff line number Diff line
@@ -677,6 +677,11 @@ public class BassClientService extends ProfileService {

    synchronized void connectionStateChanged(BluetoothDevice device, int fromState,
                                             int toState) {
        if (!isAvailable()) {
            Log.w(TAG, "connectionStateChanged: service is not available");
            return;
        }

        if ((device == null) || (fromState == toState)) {
            Log.e(TAG, "connectionStateChanged: unexpected invocation. device=" + device
                    + " fromState=" + fromState + " toState=" + toState);
+5 −0
Original line number Diff line number Diff line
@@ -1022,6 +1022,11 @@ public class CsipSetCoordinatorService extends ProfileService {

    @VisibleForTesting
    synchronized void connectionStateChanged(BluetoothDevice device, int fromState, int toState) {
        if (!isAvailable()) {
            Log.w(TAG, "connectionStateChanged: service is not available");
            return;
        }

        if ((device == null) || (fromState == toState)) {
            Log.e(TAG,
                    "connectionStateChanged: unexpected invocation. device=" + device
+5 −0
Original line number Diff line number Diff line
@@ -1078,6 +1078,11 @@ public class VolumeControlService extends ProfileService {
    @VisibleForTesting
    synchronized void connectionStateChanged(BluetoothDevice device, int fromState,
                                             int toState) {
        if (!isAvailable()) {
            Log.w(TAG, "connectionStateChanged: service is not available");
            return;
        }

        if ((device == null) || (fromState == toState)) {
            Log.e(TAG, "connectionStateChanged: unexpected invocation. device=" + device
                    + " fromState=" + fromState + " toState=" + toState);